40#ifdef SOPLEX_WITH_BOOST
41#include <boost/version.hpp>
47int main(
int argc,
char* argv[]);
55 " --readbas=<basfile> read starting basis from file\n"
56 " --writebas=<basfile> write terminal basis to file\n"
57 " --writefile=<lpfile> write LP to file in LP or MPS format depending on extension\n"
58 " --writedual=<lpfile> write the dual LP to a file in LP or MPS formal depending on extension\n"
59 " --<type>:<name>=<val> change parameter value using syntax of settings file entries\n"
60 " --loadset=<setfile> load parameters from settings file (overruled by command line parameters)\n"
61 " --saveset=<setfile> save parameters to settings file\n"
62 " --diffset=<setfile> save modified parameters to settings file\n"
63 " --extsol=<value> external solution for soplex to use for validation\n"
65 "limits and tolerances:\n"
66 " -t<s> set time limit to <s> seconds\n"
67 " -i<n> set iteration limit to <n>\n"
68 " -f<eps> set primal feasibility tolerance to <eps>\n"
69 " -o<eps> set dual feasibility (optimality) tolerance to <eps>\n"
70 " -l<eps> set validation tolerance to <eps>\n"
72 "algorithmic settings (* indicates default):\n"
73 " --readmode=<value> choose reading mode for <lpfile> (0* - floating-point, 1 - rational)\n"
74 " --solvemode=<value> choose solving mode (0 - floating-point solve, 1* - auto, 2 - exact rational solve)\n"
75 " --arithmetic=<value> choose base arithmetic type (0 - double, 1 - quadprecision, 2 - higher multiprecision)\n"
76#ifdef SOPLEX_WITH_MPFR
77 " --precision=<value> choose precision for multiprecision solve (only active when arithmetic=2 minimal value = 50)\n"
79#ifdef SOPLEX_WITH_CPPMPF
80 " --precision=<value> choose precision for multiprecision solve (only active when arithmetic=2, possible values 50,100,200, compile with mpfr for arbitrary precision)\n"
82 " -s<value> choose simplifier/presolver (0 - off, 1* - internal, 2*- PaPILO)\n"
83 " -g<value> choose scaling (0 - off, 1 - uni-equilibrium, 2* - bi-equilibrium, 3 - geometric, 4 - iterated geometric, 5 - least squares, 6 - geometric-equilibrium)\n"
84 " -p<value> choose pricing (0* - auto, 1 - dantzig, 2 - parmult, 3 - devex, 4 - quicksteep, 5 - steep)\n"
85 " -r<value> choose ratio tester (0 - textbook, 1 - harris, 2 - fast, 3* - boundflipping)\n"
88 " -v<level> set verbosity to <level> (0 - error, 3 - normal, 5 - high)\n"
89 " -x=<solfile> print primal solution to file (or just -x to print to terminal)\n"
90 " -y=<solfile> print dual multipliers to file (or just -y to print to terminal)\n"
91 " -X=<solfile> print primal solution in rational numbers to file (or just -X to print to terminal)\n"
92 " -Y=<solfile> print dual multipliers in rational numbers to file (or just -Y to print to terminal)\n"
93 " -q display detailed statistics\n"
94 " -c perform final check of optimal solution in original problem\n"
98 std::cerr <<
"missing input file\n\n";
100 std::cerr <<
"invalid option \"" << argv[idx] <<
"\"\n\n";
102 std::cerr <<
"usage: " << argv[0] <<
" " <<
"[options] <lpfile>\n"
103#ifdef SOPLEX_WITH_ZLIB
104 <<
" <lpfile> linear program as .mps[.gz] or .lp[.gz] file\n\n"
106 <<
" <lpfile> linear program as .mps or .lp file\n\n"
113void freeStrings(
char*& s1,
char*& s2,
char*& s3,
char*& s4,
char*& s5)
159 if(
soplex.getBoundViolation(boundviol, sumviol) &&
soplex.getRowViolation(rowviol, sumviol))
162 R maxviol = boundviol > rowviol ? boundviol : rowviol;
164 soplex.spxout <<
"Primal solution " << (feasible ?
"feasible" :
"infeasible")
165 <<
" in original problem (max. violation = " << std::scientific << maxviol
166 << std::setprecision(8) << std::fixed <<
").\n");
184 if(
soplex.getRedCostViolation(redcostviol, sumviol) &&
soplex.getDualViolation(dualviol, sumviol))
187 R maxviol = redcostviol > dualviol ? redcostviol : dualviol;
189 soplex.spxout <<
"Dual solution " << (feasible ?
"feasible" :
"infeasible")
190 <<
" in original problem (max. violation = " << std::scientific << maxviol
191 << std::setprecision(8) << std::fixed <<
").\n"
216 if(
soplex.getBoundViolationRational(boundviol, sumviol)
217 &&
soplex.getRowViolationRational(rowviol, sumviol))
220 Rational maxviol = boundviol > rowviol ? boundviol : rowviol;
222 soplex.spxout <<
"Primal solution " << (feasible ?
"feasible" :
"infeasible") <<
223 " in original problem (max. violation = " << maxviol <<
").\n"
242 if(
soplex.getRedCostViolationRational(redcostviol, sumviol)
243 &&
soplex.getDualViolationRational(dualviol, sumviol))
246 Rational maxviol = redcostviol > dualviol ? redcostviol : dualviol;
248 soplex.spxout <<
"Dual solution " << (feasible ?
"feasible" :
"infeasible") <<
249 " in original problem (max. violation = " << maxviol <<
").\n"
285 bool real =
true,
bool rational =
false,
bool append =
false)
289 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
290 printwidth = printprec + 10;
291 std::ofstream outfile;
294 outfile.open(filename, std::ios::app);
296 outfile.open(filename);
302 if(
soplex.getPrimalRay(primal))
304 outfile <<
"\nPrimal ray (name, value):\n";
306 for(
int i = 0; i <
soplex.numCols(); ++i)
308 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
310 outfile << colnames[i] <<
"\t"
311 << std::setw(printwidth) << std::setprecision(printprec)
312 << primal[i] << std::endl;
316 outfile <<
"All other entries are zero (within "
317 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
318 << std::setprecision(8) << std::fixed
319 <<
")." << std::endl;
321 else if(
soplex.isPrimalFeasible() &&
soplex.getPrimal(primal))
324 outfile <<
"\nPrimal solution (name, value):\n";
326 for(
int i = 0; i <
soplex.numCols(); ++i)
328 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
330 outfile << colnames[i] <<
"\t"
331 << std::setw(printwidth) << std::setprecision(printprec)
332 << primal[i] << std::endl;
337 outfile <<
"All other variables are zero (within "
338 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
339 << std::setprecision(8) << std::fixed
340 <<
"). Solution has " << nNonzeros <<
" nonzero entries." << std::endl;
343 outfile <<
"No primal information available.\n";
350 if(
soplex.getPrimalRayRational(primal))
352 outfile <<
"\nPrimal ray (name, value):\n";
354 for(
int i = 0; i <
soplex.numCols(); ++i)
358 outfile << colnames[i] <<
"\t"
359 << std::setw(printwidth) << std::setprecision(printprec)
360 << primal[i] << std::endl;
364 outfile <<
"All other entries are zero." << std::endl;
367 if(
soplex.isPrimalFeasible() &&
soplex.getPrimalRational(primal))
370 outfile <<
"\nPrimal solution (name, value):\n";
372 for(
int i = 0; i <
soplex.numColsRational(); ++i)
376 outfile << colnames[i] <<
"\t" << primal[i] << std::endl;
381 outfile <<
"All other variables are zero. Solution has "
382 << nNonzeros <<
" nonzero entries." << std::endl;
385 outfile <<
"No primal (rational) solution available.\n";
393 bool real =
true,
bool rational =
false,
bool append =
false)
397 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
398 printwidth = printprec + 10;
400 std::ofstream outfile;
403 outfile.open(filename, std::ios::app);
405 outfile.open(filename);
411 if(
soplex.getDualFarkas(dual))
413 outfile <<
"\nDual ray (name, value):\n";
415 for(
int i = 0; i <
soplex.numRows(); ++i)
417 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
419 outfile << rownames[i] <<
"\t"
420 << std::setw(printwidth) << std::setprecision(printprec)
421 << dual[i] << std::endl;
425 outfile <<
"All other entries are zero (within "
426 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
427 << std::setprecision(8) << std::fixed <<
")." << std::endl;
429 else if(
soplex.isDualFeasible() &&
soplex.getDual(dual))
431 outfile <<
"\nDual solution (name, value):\n";
433 for(
int i = 0; i <
soplex.numRows(); ++i)
435 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
437 outfile << rownames[i] <<
"\t"
438 << std::setw(printwidth) << std::setprecision(printprec)
439 << dual[i] << std::endl;
443 outfile <<
"All other dual values are zero (within "
444 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
445 << std::setprecision(8) << std::fixed <<
")." << std::endl;
449 if(
soplex.getRedCost(redcost))
451 outfile <<
"\nReduced costs (name, value):\n";
453 for(
int i = 0; i <
soplex.numCols(); ++i)
455 if(isNotZero(redcost[i],
soplex.tolerances()->epsilon()))
457 outfile << colnames[i] <<
"\t"
458 << std::setw(printwidth) << std::setprecision(printprec)
459 << redcost[i] << std::endl;
463 outfile <<
"All other reduced costs are zero (within "
464 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
465 << std::setprecision(8) << std::fixed <<
")." << std::endl;
469 outfile <<
"No dual information available.\n";
476 if(
soplex.getDualFarkasRational(dual))
478 outfile <<
"\nDual ray (name, value):\n";
480 for(
int i = 0; i <
soplex.numRows(); ++i)
484 outfile << rownames[i] <<
"\t"
485 << std::setw(printwidth)
486 << std::setprecision(printprec)
487 << dual[i] << std::endl;
491 outfile <<
"All other entries are zero." << std::endl;
494 if(
soplex.isDualFeasible() &&
soplex.getDualRational(dual))
496 outfile <<
"\nDual solution (name, value):\n";
498 for(
int i = 0; i <
soplex.numRowsRational(); ++i)
501 outfile << rownames[i] <<
"\t" << dual[i] << std::endl;
504 outfile <<
"All other dual values are zero." << std::endl;
508 if(
soplex.getRedCostRational(redcost))
510 outfile <<
"\nReduced costs (name, value):\n";
512 for(
int i = 0; i <
soplex.numCols(); ++i)
515 outfile << colnames[i] <<
"\t" << redcost[i] << std::endl;
518 outfile <<
"All other reduced costs are zero." << std::endl;
522 outfile <<
"No dual (rational) solution available.\n";
529 bool real =
true,
bool rational =
false)
533 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
534 printwidth = printprec + 10;
540 if(
soplex.getPrimalRay(primal))
544 for(
int i = 0; i <
soplex.numCols(); ++i)
546 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
549 << std::setw(printwidth) << std::setprecision(printprec)
550 << primal[i] << std::endl;)
555 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
556 << std::setprecision(8) << std::fixed
557 <<
")." << std::endl;)
559 else if(
soplex.isPrimalFeasible() &&
soplex.getPrimal(primal))
564 for(
int i = 0; i <
soplex.numCols(); ++i)
566 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
569 << std::setw(printwidth) << std::setprecision(printprec)
570 << primal[i] << std::endl;)
576 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
577 << std::setprecision(8) << std::fixed
578 <<
"). Solution has " << nNonzeros <<
" nonzero entries." << std::endl;)
588 if(
soplex.getPrimalRayRational(primal))
592 for(
int i = 0; i <
soplex.numCols(); ++i)
597 << std::setw(printwidth) << std::setprecision(printprec)
598 << primal[i] << std::endl;)
605 if(
soplex.isPrimalFeasible() &&
soplex.getPrimalRational(primal))
610 for(
int i = 0; i <
soplex.numColsRational(); ++i)
620 << nNonzeros <<
" nonzero entries." << std::endl;)
631 bool real =
true,
bool rational =
false)
635 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
636 printwidth = printprec + 10;
642 if(
soplex.getDualFarkas(dual))
646 for(
int i = 0; i <
soplex.numRows(); ++i)
648 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
651 << std::setw(printwidth) << std::setprecision(printprec)
652 << dual[i] << std::endl;)
657 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
658 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
660 else if(
soplex.isDualFeasible() &&
soplex.getDual(dual))
664 for(
int i = 0; i <
soplex.numRows(); ++i)
666 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
669 << std::setw(printwidth) << std::setprecision(printprec)
670 << dual[i] << std::endl;)
675 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
676 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
680 if(
soplex.getRedCost(redcost))
684 for(
int i = 0; i <
soplex.numCols(); ++i)
686 if(isNotZero(redcost[i],
soplex.tolerances()->epsilon()))
689 << std::setw(printwidth) << std::setprecision(printprec)
690 << redcost[i] << std::endl;)
695 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
696 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
707 if(
soplex.getDualFarkasRational(dual))
711 for(
int i = 0; i <
soplex.numRows(); ++i)
716 << std::setw(printwidth)
717 << std::setprecision(printprec)
718 << dual[i] << std::endl;)
725 if(
soplex.isDualFeasible() &&
soplex.getDualRational(dual))
729 for(
int i = 0; i <
soplex.numRowsRational(); ++i)
739 if(
soplex.getRedCostRational(redcost))
743 for(
int i = 0; i <
soplex.numCols(); ++i)
763 Timer* readingTime =
nullptr;
767 const char* lpfilename =
nullptr;
768 char* readbasname =
nullptr;
769 char* writebasname =
nullptr;
770 char* writefilename =
nullptr;
771 char* writedualfilename =
nullptr;
772 char* loadsetname =
nullptr;
773 char* savesetname =
nullptr;
774 char* diffsetname =
nullptr;
775 bool printPrimal =
false;
776 bool printPrimalRational =
false;
777 bool printDual =
false;
778 bool printDualRational =
false;
779 bool displayStatistics =
false;
780 bool checkSol =
false;
782 char* primalSolName =
nullptr;
783 char* dualSolName =
nullptr;
786 char* primalSolNameRational =
nullptr;
787 char* dualSolNameRational =
nullptr;
797 readingTime = TimerFactory::createTimer(Timer::USER_TIME);
805 validation =
nullptr;
818 for(optidx = 1; optidx < argc; optidx++)
820 char* option = argv[optidx];
825 lpfilename = argv[optidx];
833 || (option[2] ==
'\0' && strchr(
"xyXYqc", option[1]) ==
nullptr)
834 || (option[3] ==
'\0' && strchr(
"xyXY", option[1]) !=
nullptr))
838 goto TERMINATE_FREESTRINGS;
848 if(strncmp(option,
"readbas=", 8) == 0)
850 if(readbasname ==
nullptr)
852 char* filename = &option[8];
853 readbasname =
new char[strlen(filename) + 1];
854 spxSnprintf(readbasname, strlen(filename) + 1,
"%s", filename);
858 else if(strncmp(option,
"writebas=", 9) == 0)
860 if(writebasname ==
nullptr)
862 char* filename = &option[9];
863 writebasname =
new char[strlen(filename) + 1];
864 spxSnprintf(writebasname, strlen(filename) + 1,
"%s", filename);
868 else if(strncmp(option,
"writefile=", 10) == 0)
870 if(writefilename ==
nullptr)
872 char* filename = &option[10];
873 writefilename =
new char[strlen(filename) + 1];
874 spxSnprintf(writefilename, strlen(filename) + 1,
"%s", filename);
878 else if(strncmp(option,
"writedual=", 10) == 0)
880 if(writedualfilename ==
nullptr)
882 char* dualfilename = &option[10];
883 writedualfilename =
new char[strlen(dualfilename) + 1];
884 spxSnprintf(writedualfilename, strlen(dualfilename) + 1,
"%s", dualfilename);
888 else if(strncmp(option,
"loadset=", 8) == 0)
890 if(loadsetname ==
nullptr)
892 char* filename = &option[8];
893 loadsetname =
new char[strlen(filename) + 1];
894 spxSnprintf(loadsetname, strlen(filename) + 1,
"%s", filename);
896 if(!
soplex->loadSettingsFile(loadsetname))
900 goto TERMINATE_FREESTRINGS;
910 else if(strncmp(option,
"saveset=", 8) == 0)
912 if(savesetname ==
nullptr)
914 char* filename = &option[8];
915 savesetname =
new char[strlen(filename) + 1];
916 spxSnprintf(savesetname, strlen(filename) + 1,
"%s", filename);
920 else if(strncmp(option,
"diffset=", 8) == 0)
922 if(diffsetname ==
nullptr)
924 char* filename = &option[8];
925 diffsetname =
new char[strlen(filename) + 1];
926 spxSnprintf(diffsetname, strlen(filename) + 1,
"%s", filename);
930 else if(strncmp(option,
"readmode=", 9) == 0)
932 if(!
soplex->setIntParam(
soplex->READMODE, option[9] -
'0'))
936 goto TERMINATE_FREESTRINGS;
940 else if(strncmp(option,
"solvemode=", 10) == 0)
942 if(!
soplex->setIntParam(
soplex->SOLVEMODE, option[10] -
'0'))
946 goto TERMINATE_FREESTRINGS;
957 else if(strncmp(option,
"extsol=", 7) == 0)
959 char* input = &option[7];
965 goto TERMINATE_FREESTRINGS;
969 else if(strncmp(option,
"arithmetic=", 11) == 0)
974 else if(strncmp(option,
"precision=", 10) == 0)
979 else if(!
soplex->parseSettingsString(option))
983 goto TERMINATE_FREESTRINGS;
992 if(!
soplex->setRealParam(
soplex->TIMELIMIT, atoi(&option[2])))
996 goto TERMINATE_FREESTRINGS;
1004 if(!
soplex->setIntParam(
soplex->ITERLIMIT, atoi(&option[2])))
1008 goto TERMINATE_FREESTRINGS;
1016 if(!
soplex->setRealParam(
soplex->FEASTOL, atof(&option[2])))
1020 goto TERMINATE_FREESTRINGS;
1028 if(!
soplex->setRealParam(
soplex->OPTTOL, atof(&option[2])))
1032 goto TERMINATE_FREESTRINGS;
1044 goto TERMINATE_FREESTRINGS;
1052 if(!
soplex->setIntParam(
soplex->SIMPLIFIER, option[2] -
'0'))
1056 goto TERMINATE_FREESTRINGS;
1064 if(!
soplex->setIntParam(
soplex->SCALER, option[2] -
'0'))
1068 goto TERMINATE_FREESTRINGS;
1076 if(!
soplex->setIntParam(
soplex->PRICER, option[2] -
'0'))
1080 goto TERMINATE_FREESTRINGS;
1088 if(!
soplex->setIntParam(
soplex->RATIOTESTER, option[2] -
'0'))
1092 goto TERMINATE_FREESTRINGS;
1100 if(!
soplex->setIntParam(
soplex->VERBOSITY, option[2] -
'0'))
1104 goto TERMINATE_FREESTRINGS;
1113 if(strncmp(option,
"-x=", 3) == 0)
1115 if(primalSolName ==
nullptr)
1117 char* filename = &option[3];
1118 primalSolName =
new char[strlen(filename) + 1];
1119 spxSnprintf(primalSolName, strlen(filename) + 1,
"%s", filename);
1127 printPrimalRational =
true;
1129 if(strncmp(option,
"-X=", 3) == 0)
1131 if(primalSolNameRational ==
nullptr)
1133 char* filename = &option[3];
1134 primalSolNameRational =
new char[strlen(filename) + 1];
1135 spxSnprintf(primalSolNameRational, strlen(filename) + 1,
"%s", filename);
1145 if(strncmp(option,
"-y=", 3) == 0)
1147 if(dualSolName ==
nullptr)
1149 char* filename = &option[3];
1150 dualSolName =
new char[strlen(filename) + 1];
1151 spxSnprintf(dualSolName, strlen(filename) + 1,
"%s", filename);
1159 printDualRational =
true;
1161 if(strncmp(option,
"-Y=", 3) == 0)
1163 if(dualSolNameRational ==
nullptr)
1165 char* filename = &option[3];
1166 dualSolNameRational =
new char[strlen(filename) + 1];
1167 spxSnprintf(dualSolNameRational, strlen(filename) + 1,
"%s", filename);
1175 displayStatistics =
true;
1186 if(!
soplex->saveSettingsFile(
nullptr,
false))
1198 goto TERMINATE_FREESTRINGS;
1206 if(lpfilename ==
nullptr && savesetname ==
nullptr && diffsetname ==
nullptr)
1210 goto TERMINATE_FREESTRINGS;
1217 "Error: manual synchronization is invalid on command line. Change parameter int:syncmode.\n");
1219 goto TERMINATE_FREESTRINGS;
1223 if(savesetname !=
nullptr)
1229 if(!
soplex->saveSettingsFile(savesetname,
false))
1231 SPX_MSG_ERROR(std::cerr <<
"Error writing parameters to file <" << savesetname <<
">\n");
1235 if(diffsetname !=
nullptr)
1238 diffsetname <<
"> . . .\n");
1240 if(!
soplex->saveSettingsFile(diffsetname,
true))
1242 SPX_MSG_ERROR(std::cerr <<
"Error writing modified parameters to file <" << diffsetname <<
">\n");
1247 if(lpfilename ==
nullptr)
1249 if(loadsetname !=
nullptr || savesetname !=
nullptr || diffsetname !=
nullptr)
1254 goto TERMINATE_FREESTRINGS;
1258 readingTime->
start();
1270 << (
soplex->intParam(
soplex->READMODE) ==
soplex->READMODE_REAL ?
"(real)" :
"(rational)")
1271 <<
" LP file <" << lpfilename <<
"> . . .\n");
1273 if(!
soplex->readFile(lpfilename, &rownames, &colnames))
1275 SPX_MSG_ERROR(std::cerr <<
"Error while reading file <" << lpfilename <<
">.\n");
1277 goto TERMINATE_FREESTRINGS;
1281 if(writefilename !=
nullptr)
1283 if(!
soplex->writeFile(writefilename, &rownames, &colnames))
1285 SPX_MSG_ERROR(std::cerr <<
"Error while writing file <" << writefilename <<
">.\n\n");
1287 goto TERMINATE_FREESTRINGS;
1297 if(writedualfilename !=
nullptr)
1299 if(!
soplex->writeDualFileReal(writedualfilename, &rownames, &colnames))
1301 SPX_MSG_ERROR(std::cerr <<
"Error while writing dual file <" << writedualfilename <<
">.\n\n");
1303 goto TERMINATE_FREESTRINGS;
1313 if(readbasname !=
nullptr)
1318 if(!
soplex->readBasisFile(readbasname, &rownames, &colnames))
1320 SPX_MSG_ERROR(std::cerr <<
"Error while reading file <" << readbasname <<
">.\n");
1322 goto TERMINATE_FREESTRINGS;
1326 readingTime->
stop();
1329 std::streamsize prec =
soplex->spxout.precision();
1330 soplex->spxout <<
"Reading took "
1331 << std::fixed << std::setprecision(2) << readingTime->
time()
1332 << std::scientific << std::setprecision(
int(prec))
1333 <<
" seconds.\n\n");
1336 <<
soplex->numCols() <<
" columns and " <<
soplex->numNonzeros() <<
" nonzeros.\n\n");
1342 if(primalSolName ==
nullptr && primalSolNameRational ==
nullptr)
1346 if(primalSolName !=
nullptr)
1352 if(primalSolNameRational !=
nullptr)
1354 append = primalSolName !=
nullptr && strcmp(primalSolName, primalSolNameRational) == 0;
1359 if(dualSolName ==
nullptr && dualSolNameRational ==
nullptr)
1363 if(dualSolName !=
nullptr)
1365 append = primalSolName !=
nullptr && strcmp(dualSolName, primalSolName) == 0;
1366 append = append || (primalSolNameRational !=
nullptr
1367 && strcmp(dualSolName, primalSolNameRational) == 0);
1372 if(dualSolNameRational !=
nullptr)
1374 append = (primalSolName !=
nullptr && strcmp(dualSolNameRational, primalSolName) == 0);
1375 append = append || (primalSolNameRational !=
nullptr
1376 && strcmp(dualSolNameRational, primalSolNameRational) == 0);
1377 append = append || (dualSolName !=
nullptr && strcmp(dualSolNameRational, dualSolName) == 0);
1382 checkSolution<R>(*
soplex);
1384 if(displayStatistics)
1387 soplex->printStatistics(
soplex->spxout.getStream(SPxOut::VERB_INFO1));
1394 if(writebasname !=
nullptr)
1399 "No basis information available. Could not write file <" << writebasname <<
">\n\n");
1401 else if(!
soplex->writeBasisFile(writebasname, &rownames, &colnames))
1403 SPX_MSG_ERROR(std::cerr <<
"Error while writing file <" << writebasname <<
">.\n\n");
1405 goto TERMINATE_FREESTRINGS;
1419 goto TERMINATE_FREESTRINGS;
1422TERMINATE_FREESTRINGS:
1423 freeStrings(readbasname, writebasname, loadsetname, savesetname, diffsetname);
1424 freeStrings(primalSolName, dualSolName, primalSolName, primalSolName, primalSolName);
1437 if(
nullptr != validation)
1443 if(
nullptr != readingTime)
1468 for(optidx = 1; optidx < argc; optidx++)
1470 char* option = argv[optidx];
1473 if(option[0] !=
'-')
1479 if(option[1] ==
'\0'
1480 || (option[2] ==
'\0' && strchr(
"xyXYqc", option[1]) ==
nullptr)
1481 || (option[3] ==
'\0' && strchr(
"xyXY", option[1]) !=
nullptr))
1490 option = &option[2];
1494 if(strncmp(option,
"arithmetic=", 11) == 0)
1496 if(option[11] ==
'1')
1498#ifndef SOPLEX_WITH_FLOAT128
1500 "Cannot set arithmetic type to quadprecision - Soplex compiled without quadprecision support\n";)
1507 else if(option[11] ==
'2')
1509#ifndef SOPLEX_WITH_BOOST
1511 "Cannot set arithmetic type to multiprecision - Soplex compiled without boost\n";)
1525 else if(strncmp(option,
"precision=", 10) == 0)
1527 precision = atoi(option + 10);
1528#ifndef SOPLEX_WITH_BOOST
1529 SPX_MSG_ERROR(std::cerr <<
"Setting precision to non-default value without Boost has no effect\n";)
1540 if(precision != 0 && arithmetic != 2)
1543 "Setting precision to non-default value without enabling multiprecision solve has no effect\n";)
1549 runSoPlex<Real>(argc, argv);
1552#ifdef SOPLEX_WITH_BOOST
1553#ifdef SOPLEX_WITH_FLOAT128
1556#if BOOST_VERSION < 107000
1557 std::cerr <<
"Error: Boost version too old." << std:: endl <<
1558 "In order to use the quadprecision feature of SoPlex," <<
1559 " Boost Version 1.70.0 or higher is required." << std::endl << \
1560 "Included Boost version is " << BOOST_VERSION / 100000 <<
"."
1561 << BOOST_VERSION / 100 % 1000 <<
"."
1562 << BOOST_VERSION % 100
1565 using namespace boost::multiprecision;
1566 using Quad = boost::multiprecision::float128;
1567 runSoPlex<Quad>(argc, argv);
1573 using namespace boost::multiprecision;
1575#if BOOST_VERSION < 107000
1576 std::cerr <<
"Error: Boost version too old." << std:: endl <<
1577 "In order to use the multiprecision feature of SoPlex," <<
1578 " Boost Version 1.70.0 or higher is required." << std::endl << \
1579 "Included Boost version is " << BOOST_VERSION / 100000 <<
"."
1580 << BOOST_VERSION / 100 % 1000 <<
"."
1581 << BOOST_VERSION % 100
1584#ifdef SOPLEX_WITH_MPFR
1590 using multiprecision = number<mpfr_float_backend<0>, et_off>;
1591 multiprecision::default_precision(precision);
1592 runSoPlex<multiprecision>(argc, argv);
1595#ifdef SOPLEX_WITH_CPPMPF
1599 using multiprecision1 = number<cpp_dec_float<50>, et_off>;
1600 using multiprecision2 = number<cpp_dec_float<100>, et_off>;
1601 using multiprecision3 = number<cpp_dec_float<200>, et_off>;
1604 runSoPlex<multiprecision1>(argc, argv);
1605 else if(precision <= 100)
1606 runSoPlex<multiprecision2>(argc, argv);
1608 runSoPlex<multiprecision3>(argc, argv);
1617 std::cerr <<
"Wrong value for the arithmetic mode\n";
virtual const std::string & what() const
returns exception message
Wrapper for the system time query methods.
virtual Real time() const =0
virtual void start()=0
start timer, resume accounting user, system and real time.
virtual Real stop()=0
stop timer, return accounted user time.
bool updateValidationTolerance(const std::string &tolerance)
updates the tolerance used for validation
bool validate
should the soplex solution be validated?
bool updateExternalSolution(const std::string &solution)
updates the external solution used for validation
~Validation()
default destructor
void validateSolveReal(SoPlexBase< R > &soplex)
validates the soplex solution using the external solution
Everything should be within this namespace.
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
void spx_free(T &p)
Release memory.
void spx_alloc(T &p, size_t n=1)
Allocate memory.
Preconfigured SoPlex LP solver.
int main(int argc, char *argv[])
runs SoPlexBase command line
static void printUsage(const char *const argv[], int idx)
static void writePrimalSolution(SoPlexBase< R > &soplex, const char *filename, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false, bool append=false)
static void printDualSolution(SoPlexBase< R > &soplex, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false)
int runSoPlex(int argc, char *argv[])
static void checkSolutionRational(SoPlexBase< R > &soplex)
performs external feasibility check with rational type
void checkSolution(SoPlexBase< R > &soplex)
performs external feasibility check according to check mode
static void writeDualSolution(SoPlexBase< R > &soplex, const char *filename, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false, bool append=false)
static void freeStrings(char *&s1, char *&s2, char *&s3, char *&s4, char *&s5)
static void checkSolutionReal(SoPlexBase< R > &soplex)
performs external feasibility check with real type
static void printPrimalSolution(SoPlexBase< R > &soplex, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false)
#define SPX_MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::VERB_ERROR.
#define SPX_MSG_WARNING(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::VERB_WARNING.
#define SPX_MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::VERB_INFO1.
Validation object for soplex solutions.