Commit d786dcb8 authored by Simon de Givry's avatar Simon de Givry Committed by Thomas Schiex
Browse files

[option] -trws with no parameter will assume 0.00001 accuracy

parent 9f121c5b
// Cmake generated version
#define Toulbar_VERSION "1.0.0-121-g4a5cff9-master-tainted (1540891863)"
#define Toulbar_VERSION "1.0.0-123-g75f2763-master-tainted (1540908133)"
......@@ -2844,7 +2844,7 @@ void WCSP::propagateTRWS()
if (ToulBar2::uai)
cout << "TRW-S dual bound: " << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Cost2ADCost(getLb() + ebound) << std::setprecision(DECIMAL_POINT) << " energy: " << -(Cost2LogProb(getLb() + ebound) + ToulBar2::markov_log) << " -- primal bound: " << std::setprecision(ToulBar2::decimalPoint) << Cost2ADCost(bestUb) << std::setprecision(DECIMAL_POINT) << " energy: " << -(Cost2LogProb(bestUb) + ToulBar2::markov_log) << " (+" << (100 * change) << "%) (accuracy: " << (100.0 * (bestUb - ebound - getLb()) / (bestUb + 1)) << "%) (iter:" << nIteration << ")" << endl;
else
cout << "TRW-S bounds: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dglb << ", " << Dgub << std::setprecision(DECIMAL_POINT) << "[ (+" << (100 * change) << "%) (accuracy: " << (100.0 * (bestUb - ebound - getLb()) / (bestUb + 1)) << "%) (iter:" << nIteration << ")" << endl;
cout << "TRW-S bounds: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dglb << ", " << Dgub << std::setprecision(DECIMAL_POINT) << "] (+" << (100 * change) << "%) (accuracy: " << (100.0 * (bestUb - ebound - getLb()) / (bestUb + 1)) << "%) (iter:" << nIteration << ")" << endl;
}
previousEbound = ebound;
}
......
......@@ -780,7 +780,7 @@ void Solver::showGap(Cost newLb, Cost newUb)
if (ToulBar2::verbose >= 0 && newgap < oldgap) {
Double Dglb = (ToulBar2::costMultiplier >= 0 ? wcsp->Cost2ADCost(globalLowerBound) : wcsp->Cost2ADCost(globalUpperBound));
Double Dgub = (ToulBar2::costMultiplier >= 0 ? wcsp->Cost2ADCost(globalUpperBound) : wcsp->Cost2ADCost(globalLowerBound));
cout << "Optimality gap: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dglb << ", " << Dgub << "[ " << std::setprecision(DECIMAL_POINT) << (100. * (Dgub - Dglb)) / max(fabsl(Dglb), fabsl(Dgub)) << " % (" << nbBacktracks << " backtracks, " << nbNodes << " nodes)" << endl;
cout << "Optimality gap: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dglb << ", " << Dgub << "] " << std::setprecision(DECIMAL_POINT) << (100. * (Dgub - Dglb)) / max(fabsl(Dglb), fabsl(Dgub)) << " % (" << nbBacktracks << " backtracks, " << nbNodes << " nodes)" << endl;
}
}
}
......@@ -1600,7 +1600,7 @@ Cost Solver::preprocessing(Cost initialUpperBound)
if (ToulBar2::verbose >= 0) {
Double Dlb = wcsp->getDLb();
Double Dub = wcsp->getDUb();
cout << "Initial lower and upper bounds: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dlb << ", " << Dub << "[ " << std::setprecision(DECIMAL_POINT) << (100.0 * (Dub - Dlb)) / max(fabsl(Dlb), fabsl(Dub)) << "%" << endl;
cout << "Initial lower and upper bounds: [" << std::fixed << std::setprecision(ToulBar2::decimalPoint) << Dlb << ", " << Dub << "] " << std::setprecision(DECIMAL_POINT) << (100.0 * (Dub - Dlb)) / max(fabsl(Dlb), fabsl(Dub)) << "%" << endl;
}
initGap(wcsp->getLb(), wcsp->getUb());
......
......@@ -361,7 +361,7 @@ CSimpleOpt::SOption g_rgOptions[] = {
{ OPT_costMultiplier, (char*)"-C", SO_REQ_SEP },
{ OPT_deltaUb, (char*)"-agap", SO_REQ_SEP },
{ NO_OPT_trws, (char*)"-trws:", SO_NONE },
{ OPT_trwsAccuracy, (char*)"-trws", SO_REQ_SEP },
{ OPT_trwsAccuracy, (char*)"-trws", SO_OPT },
{ OPT_trwsAccuracy, (char*)"--trws-accuracy", SO_REQ_SEP },
{ OPT_trwsOrder, (char*)"--trws-order", SO_NONE },
{ NO_OPT_trwsOrder, (char*)"--trws-order:", SO_NONE },
......@@ -1416,11 +1416,17 @@ int _tmain(int argc, TCHAR* argv[])
}
if (args.OptionId() == OPT_trwsAccuracy) {
double co = atof(args.OptionArg());
if (co >= 0.)
ToulBar2::trwsAccuracy = co;
else
ToulBar2::trwsAccuracy = -1.;
if (args.OptionArg() == NULL) {
ToulBar2::trwsAccuracy = 0.00001;
} else {
double co = atof(args.OptionArg());
if (co >= 0.)
ToulBar2::trwsAccuracy = co;
else
ToulBar2::trwsAccuracy = -1.;
}
} else if (args.OptionId() == NO_OPT_trws) {
ToulBar2::trwsAccuracy = -1.;
}
if (args.OptionId() == OPT_trwsOrder) {
ToulBar2::trwsOrder = true;
......@@ -1436,9 +1442,6 @@ int _tmain(int argc, TCHAR* argv[])
if (args.OptionId() == OPT_trwsNIterComputeUb) {
ToulBar2::trwsNIterComputeUb = atol(args.OptionArg());
}
if (args.OptionId() == NO_OPT_trws) {
ToulBar2::trwsAccuracy = -1.;
}
// elimination of functional variables
if (args.OptionId() == OPT_preprocessFunctional) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment