44int main(
int argc,
char* argv[]);
52 " --version print version and compiler information\n"
53 " --readbas=<basfile> read starting basis from file\n"
54 " --writebas=<basfile> write terminal basis to file\n"
55 " --writefile=<lpfile> write LP to file in LP or MPS format depending on extension\n"
56 " --writedual=<lpfile> write the dual LP to a file in LP or MPS formal depending on extension\n"
57 " --<type>:<name>=<val> change parameter value using syntax of settings file entries\n"
58 " --loadset=<setfile> load parameters from settings file (overruled by command line parameters)\n"
59 " --saveset=<setfile> save parameters to settings file\n"
60 " --diffset=<setfile> save modified parameters to settings file\n"
61 " --extsol=<value> external solution for soplex to use for validation\n"
63 "limits and tolerances:\n"
64 " -t<s> set time limit to <s> seconds\n"
65 " -i<n> set iteration limit to <n>\n"
66 " -f<eps> set primal feasibility tolerance to <eps>\n"
67 " -o<eps> set dual feasibility (optimality) tolerance to <eps>\n"
68 " -l<eps> set validation tolerance to <eps>\n"
70 "algorithmic settings (* indicates default):\n"
71 " --readmode=<value> choose reading mode for <lpfile> (0* - floating-point, 1 - rational)\n"
72 " --solvemode=<value> choose solving mode (0 - floating-point solve, 1* - auto, 2 - exact rational solve)\n"
73 " --arithmetic=<value> choose base arithmetic type (0 - double, 1 - quadprecision, 2 - higher multiprecision)\n"
74#ifdef SOPLEX_WITH_MPFR
75 " --precision=<value> choose precision for multiprecision solve (only active when arithmetic=2 minimal value = 50)\n"
77#ifdef SOPLEX_WITH_CPPMPF
78 " --precision=<value> choose precision for multiprecision solve (only active when arithmetic=2, possible values 50,100,200, compile with mpfr for arbitrary precision)\n"
80 " -s<value> choose simplifier/presolver (0 - off, 1* - internal, 2*- PaPILO)\n"
81 " -g<value> choose scaling (0 - off, 1 - uni-equilibrium, 2* - bi-equilibrium, 3 - geometric, 4 - iterated geometric, 5 - least squares, 6 - geometric-equilibrium)\n"
82 " -p<value> choose pricing (0* - auto, 1 - dantzig, 2 - parmult, 3 - devex, 4 - quicksteep, 5 - steep)\n"
83 " -r<value> choose ratio tester (0 - textbook, 1 - harris, 2 - fast, 3* - boundflipping)\n"
86 " -v<level> set verbosity to <level> (0 - error, 3 - normal, 5 - high)\n"
87 " -x=<solfile> print primal solution to file (or just -x to print to terminal)\n"
88 " -y=<solfile> print dual multipliers to file (or just -y to print to terminal)\n"
89 " -X=<solfile> print primal solution in rational numbers to file (or just -X to print to terminal)\n"
90 " -Y=<solfile> print dual multipliers in rational numbers to file (or just -Y to print to terminal)\n"
91 " -q display detailed statistics\n"
92 " -c perform final check of optimal solution in original problem\n"
96 std::cerr <<
"missing input file\n\n";
98 std::cerr <<
"invalid option \"" << argv[idx] <<
"\"\n\n";
100 std::cerr <<
"usage: " << argv[0] <<
" " <<
"[options] <lpfile>\n"
101#ifdef SOPLEX_WITH_ZLIB
102 <<
" <lpfile> linear program as .mps[.gz] or .lp[.gz] file\n\n"
104 <<
" <lpfile> linear program as .mps or .lp file\n\n"
111void freeStrings(
char*& s1,
char*& s2,
char*& s3,
char*& s4,
char*& s5)
157 if(
soplex.getBoundViolation(boundviol, sumviol) &&
soplex.getRowViolation(rowviol, sumviol))
160 R maxviol = boundviol > rowviol ? boundviol : rowviol;
162 soplex.spxout <<
"Primal solution " << (feasible ?
"feasible" :
"infeasible")
163 <<
" in original problem (max. violation = " << std::scientific << maxviol
164 << std::setprecision(8) << std::fixed <<
").\n");
182 if(
soplex.getRedCostViolation(redcostviol, sumviol) &&
soplex.getDualViolation(dualviol, sumviol))
185 R maxviol = redcostviol > dualviol ? redcostviol : dualviol;
187 soplex.spxout <<
"Dual solution " << (feasible ?
"feasible" :
"infeasible")
188 <<
" in original problem (max. violation = " << std::scientific << maxviol
189 << std::setprecision(8) << std::fixed <<
").\n"
214 if(
soplex.getBoundViolationRational(boundviol, sumviol)
215 &&
soplex.getRowViolationRational(rowviol, sumviol))
218 Rational maxviol = boundviol > rowviol ? boundviol : rowviol;
220 soplex.spxout <<
"Primal solution " << (feasible ?
"feasible" :
"infeasible") <<
221 " in original problem (max. violation = " << maxviol <<
").\n"
240 if(
soplex.getRedCostViolationRational(redcostviol, sumviol)
241 &&
soplex.getDualViolationRational(dualviol, sumviol))
244 Rational maxviol = redcostviol > dualviol ? redcostviol : dualviol;
246 soplex.spxout <<
"Dual solution " << (feasible ?
"feasible" :
"infeasible") <<
247 " in original problem (max. violation = " << maxviol <<
").\n"
283 bool real =
true,
bool rational =
false,
bool append =
false)
287 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
288 printwidth = printprec + 10;
289 std::ofstream outfile;
292 outfile.open(filename, std::ios::app);
294 outfile.open(filename);
300 if(
soplex.getPrimalRay(primal))
302 outfile <<
"\nPrimal ray (name, value):\n";
304 for(
int i = 0; i <
soplex.numCols(); ++i)
306 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
308 outfile << colnames[i] <<
"\t"
309 << std::setw(printwidth) << std::setprecision(printprec)
310 << primal[i] << std::endl;
314 outfile <<
"All other entries are zero (within "
315 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
316 << std::setprecision(8) << std::fixed
317 <<
")." << std::endl;
319 else if(
soplex.isPrimalFeasible() &&
soplex.getPrimal(primal))
322 outfile <<
"\nPrimal solution (name, value):\n";
324 for(
int i = 0; i <
soplex.numCols(); ++i)
326 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
328 outfile << colnames[i] <<
"\t"
329 << std::setw(printwidth) << std::setprecision(printprec)
330 << primal[i] << std::endl;
335 outfile <<
"All other variables are zero (within "
336 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
337 << std::setprecision(8) << std::fixed
338 <<
"). Solution has " << nNonzeros <<
" nonzero entries." << std::endl;
341 outfile <<
"No primal information available.\n";
348 if(
soplex.getPrimalRayRational(primal))
350 outfile <<
"\nPrimal ray (name, value):\n";
352 for(
int i = 0; i <
soplex.numCols(); ++i)
356 outfile << colnames[i] <<
"\t"
357 << std::setw(printwidth) << std::setprecision(printprec)
358 << primal[i] << std::endl;
362 outfile <<
"All other entries are zero." << std::endl;
365 if(
soplex.isPrimalFeasible() &&
soplex.getPrimalRational(primal))
368 outfile <<
"\nPrimal solution (name, value):\n";
370 for(
int i = 0; i <
soplex.numColsRational(); ++i)
374 outfile << colnames[i] <<
"\t" << primal[i] << std::endl;
379 outfile <<
"All other variables are zero. Solution has "
380 << nNonzeros <<
" nonzero entries." << std::endl;
383 outfile <<
"No primal (rational) solution available.\n";
391 bool real =
true,
bool rational =
false,
bool append =
false)
395 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
396 printwidth = printprec + 10;
398 std::ofstream outfile;
401 outfile.open(filename, std::ios::app);
403 outfile.open(filename);
409 if(
soplex.getDualFarkas(dual))
411 outfile <<
"\nDual ray (name, value):\n";
413 for(
int i = 0; i <
soplex.numRows(); ++i)
415 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
417 outfile << rownames[i] <<
"\t"
418 << std::setw(printwidth) << std::setprecision(printprec)
419 << dual[i] << std::endl;
423 outfile <<
"All other entries are zero (within "
424 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
425 << std::setprecision(8) << std::fixed <<
")." << std::endl;
427 else if(
soplex.isDualFeasible() &&
soplex.getDual(dual))
429 outfile <<
"\nDual solution (name, value):\n";
431 for(
int i = 0; i <
soplex.numRows(); ++i)
433 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
435 outfile << rownames[i] <<
"\t"
436 << std::setw(printwidth) << std::setprecision(printprec)
437 << dual[i] << std::endl;
441 outfile <<
"All other dual values are zero (within "
442 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
443 << std::setprecision(8) << std::fixed <<
")." << std::endl;
447 if(
soplex.getRedCost(redcost))
449 outfile <<
"\nReduced costs (name, value):\n";
451 for(
int i = 0; i <
soplex.numCols(); ++i)
453 if(isNotZero(redcost[i],
soplex.tolerances()->epsilon()))
455 outfile << colnames[i] <<
"\t"
456 << std::setw(printwidth) << std::setprecision(printprec)
457 << redcost[i] << std::endl;
461 outfile <<
"All other reduced costs are zero (within "
462 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
463 << std::setprecision(8) << std::fixed <<
")." << std::endl;
467 outfile <<
"No dual information available.\n";
474 if(
soplex.getDualFarkasRational(dual))
476 outfile <<
"\nDual ray (name, value):\n";
478 for(
int i = 0; i <
soplex.numRows(); ++i)
482 outfile << rownames[i] <<
"\t"
483 << std::setw(printwidth)
484 << std::setprecision(printprec)
485 << dual[i] << std::endl;
489 outfile <<
"All other entries are zero." << std::endl;
492 if(
soplex.isDualFeasible() &&
soplex.getDualRational(dual))
494 outfile <<
"\nDual solution (name, value):\n";
496 for(
int i = 0; i <
soplex.numRowsRational(); ++i)
499 outfile << rownames[i] <<
"\t" << dual[i] << std::endl;
502 outfile <<
"All other dual values are zero." << std::endl;
506 if(
soplex.getRedCostRational(redcost))
508 outfile <<
"\nReduced costs (name, value):\n";
510 for(
int i = 0; i <
soplex.numCols(); ++i)
513 outfile << colnames[i] <<
"\t" << redcost[i] << std::endl;
516 outfile <<
"All other reduced costs are zero." << std::endl;
520 outfile <<
"No dual (rational) solution available.\n";
527 bool real =
true,
bool rational =
false)
531 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
532 printwidth = printprec + 10;
538 if(
soplex.getPrimalRay(primal))
542 for(
int i = 0; i <
soplex.numCols(); ++i)
544 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
547 << std::setw(printwidth) << std::setprecision(printprec)
548 << primal[i] << std::endl;)
553 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
554 << std::setprecision(8) << std::fixed
555 <<
")." << std::endl;)
557 else if(
soplex.isPrimalFeasible() &&
soplex.getPrimal(primal))
562 for(
int i = 0; i <
soplex.numCols(); ++i)
564 if(isNotZero(primal[i],
soplex.tolerances()->epsilon()))
567 << std::setw(printwidth) << std::setprecision(printprec)
568 << primal[i] << std::endl;)
574 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
575 << std::setprecision(8) << std::fixed
576 <<
"). Solution has " << nNonzeros <<
" nonzero entries." << std::endl;)
586 if(
soplex.getPrimalRayRational(primal))
590 for(
int i = 0; i <
soplex.numCols(); ++i)
595 << std::setw(printwidth) << std::setprecision(printprec)
596 << primal[i] << std::endl;)
603 if(
soplex.isPrimalFeasible() &&
soplex.getPrimalRational(primal))
608 for(
int i = 0; i <
soplex.numColsRational(); ++i)
618 << nNonzeros <<
" nonzero entries." << std::endl;)
629 bool real =
true,
bool rational =
false)
633 printprec = (int) - log10(
Real(
soplex.tolerances()->epsilon()));
634 printwidth = printprec + 10;
640 if(
soplex.getDualFarkas(dual))
644 for(
int i = 0; i <
soplex.numRows(); ++i)
646 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
649 << std::setw(printwidth) << std::setprecision(printprec)
650 << dual[i] << std::endl;)
655 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
656 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
658 else if(
soplex.isDualFeasible() &&
soplex.getDual(dual))
662 for(
int i = 0; i <
soplex.numRows(); ++i)
664 if(isNotZero(dual[i],
soplex.tolerances()->epsilon()))
667 << std::setw(printwidth) << std::setprecision(printprec)
668 << dual[i] << std::endl;)
673 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
674 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
678 if(
soplex.getRedCost(redcost))
682 for(
int i = 0; i <
soplex.numCols(); ++i)
684 if(isNotZero(redcost[i],
soplex.tolerances()->epsilon()))
687 << std::setw(printwidth) << std::setprecision(printprec)
688 << redcost[i] << std::endl;)
693 << std::setprecision(1) << std::scientific <<
soplex.tolerances()->epsilon()
694 << std::setprecision(8) << std::fixed <<
")." << std::endl;)
705 if(
soplex.getDualFarkasRational(dual))
709 for(
int i = 0; i <
soplex.numRows(); ++i)
714 << std::setw(printwidth)
715 << std::setprecision(printprec)
716 << dual[i] << std::endl;)
723 if(
soplex.isDualFeasible() &&
soplex.getDualRational(dual))
727 for(
int i = 0; i <
soplex.numRowsRational(); ++i)
737 if(
soplex.getRedCostRational(redcost))
741 for(
int i = 0; i <
soplex.numCols(); ++i)
761 Timer* readingTime =
nullptr;
765 const char* lpfilename =
nullptr;
766 char* readbasname =
nullptr;
767 char* writebasname =
nullptr;
768 char* writefilename =
nullptr;
769 char* writedualfilename =
nullptr;
770 char* loadsetname =
nullptr;
771 char* savesetname =
nullptr;
772 char* diffsetname =
nullptr;
773 bool printPrimal =
false;
774 bool printPrimalRational =
false;
775 bool printDual =
false;
776 bool printDualRational =
false;
777 bool displayStatistics =
false;
778 bool checkSol =
false;
780 char* primalSolName =
nullptr;
781 char* dualSolName =
nullptr;
784 char* primalSolNameRational =
nullptr;
785 char* dualSolNameRational =
nullptr;
795 readingTime = TimerFactory::createTimer(Timer::USER_TIME);
803 soplex->printExternalCodes();
806 validation =
nullptr;
819 for(optidx = 1; optidx < argc; optidx++)
821 char* option = argv[optidx];
826 lpfilename = argv[optidx];
834 || (option[2] ==
'\0' && strchr(
"xyXYqc", option[1]) ==
nullptr)
835 || (option[3] ==
'\0' && strchr(
"xyXY", option[1]) !=
nullptr))
839 goto TERMINATE_FREESTRINGS;
849 if(strncmp(option,
"version", 7) == 0)
853#if defined(__INTEL_COMPILER)
855#elif defined(__clang__)
857 __clang_minor__ <<
"." << __clang_patchlevel__ << std::endl);
858#elif defined(_MSC_VER)
861#elif defined(__GNUC__)
862#if defined(__GNUC_PATCHLEVEL__)
864 << __GNUC_PATCHLEVEL__ << std::endl);
874 goto TERMINATE_FREESTRINGS;
877 else if(strncmp(option,
"readbas=", 8) == 0)
879 if(readbasname ==
nullptr)
881 char* filename = &option[8];
882 readbasname =
new char[strlen(filename) + 1];
883 spxSnprintf(readbasname, strlen(filename) + 1,
"%s", filename);
887 else if(strncmp(option,
"writebas=", 9) == 0)
889 if(writebasname ==
nullptr)
891 char* filename = &option[9];
892 writebasname =
new char[strlen(filename) + 1];
893 spxSnprintf(writebasname, strlen(filename) + 1,
"%s", filename);
897 else if(strncmp(option,
"writefile=", 10) == 0)
899 if(writefilename ==
nullptr)
901 char* filename = &option[10];
902 writefilename =
new char[strlen(filename) + 1];
903 spxSnprintf(writefilename, strlen(filename) + 1,
"%s", filename);
907 else if(strncmp(option,
"writedual=", 10) == 0)
909 if(writedualfilename ==
nullptr)
911 char* dualfilename = &option[10];
912 writedualfilename =
new char[strlen(dualfilename) + 1];
913 spxSnprintf(writedualfilename, strlen(dualfilename) + 1,
"%s", dualfilename);
917 else if(strncmp(option,
"loadset=", 8) == 0)
919 if(loadsetname ==
nullptr)
921 char* filename = &option[8];
922 loadsetname =
new char[strlen(filename) + 1];
923 spxSnprintf(loadsetname, strlen(filename) + 1,
"%s", filename);
925 if(!
soplex->loadSettingsFile(loadsetname))
929 goto TERMINATE_FREESTRINGS;
939 else if(strncmp(option,
"saveset=", 8) == 0)
941 if(savesetname ==
nullptr)
943 char* filename = &option[8];
944 savesetname =
new char[strlen(filename) + 1];
945 spxSnprintf(savesetname, strlen(filename) + 1,
"%s", filename);
949 else if(strncmp(option,
"diffset=", 8) == 0)
951 if(diffsetname ==
nullptr)
953 char* filename = &option[8];
954 diffsetname =
new char[strlen(filename) + 1];
955 spxSnprintf(diffsetname, strlen(filename) + 1,
"%s", filename);
959 else if(strncmp(option,
"readmode=", 9) == 0)
961 if(!
soplex->setIntParam(
soplex->READMODE, option[9] -
'0'))
965 goto TERMINATE_FREESTRINGS;
969 else if(strncmp(option,
"solvemode=", 10) == 0)
971 if(!
soplex->setIntParam(
soplex->SOLVEMODE, option[10] -
'0'))
975 goto TERMINATE_FREESTRINGS;
986 else if(strncmp(option,
"extsol=", 7) == 0)
988 char* input = &option[7];
994 goto TERMINATE_FREESTRINGS;
998 else if(strncmp(option,
"arithmetic=", 11) == 0)
1003 else if(strncmp(option,
"precision=", 10) == 0)
1008 else if(!
soplex->parseSettingsString(option))
1012 goto TERMINATE_FREESTRINGS;
1021 if(!
soplex->setRealParam(
soplex->TIMELIMIT, atoi(&option[2])))
1025 goto TERMINATE_FREESTRINGS;
1033 if(!
soplex->setIntParam(
soplex->ITERLIMIT, atoi(&option[2])))
1037 goto TERMINATE_FREESTRINGS;
1045 if(!
soplex->setRealParam(
soplex->FEASTOL, atof(&option[2])))
1049 goto TERMINATE_FREESTRINGS;
1057 if(!
soplex->setRealParam(
soplex->OPTTOL, atof(&option[2])))
1061 goto TERMINATE_FREESTRINGS;
1073 goto TERMINATE_FREESTRINGS;
1081 if(!
soplex->setIntParam(
soplex->SIMPLIFIER, option[2] -
'0'))
1085 goto TERMINATE_FREESTRINGS;
1093 if(!
soplex->setIntParam(
soplex->SCALER, option[2] -
'0'))
1097 goto TERMINATE_FREESTRINGS;
1105 if(!
soplex->setIntParam(
soplex->PRICER, option[2] -
'0'))
1109 goto TERMINATE_FREESTRINGS;
1117 if(!
soplex->setIntParam(
soplex->RATIOTESTER, option[2] -
'0'))
1121 goto TERMINATE_FREESTRINGS;
1129 if(!
soplex->setIntParam(
soplex->VERBOSITY, option[2] -
'0'))
1133 goto TERMINATE_FREESTRINGS;
1142 if(strncmp(option,
"-x=", 3) == 0)
1144 if(primalSolName ==
nullptr)
1146 char* filename = &option[3];
1147 primalSolName =
new char[strlen(filename) + 1];
1148 spxSnprintf(primalSolName, strlen(filename) + 1,
"%s", filename);
1156 printPrimalRational =
true;
1158 if(strncmp(option,
"-X=", 3) == 0)
1160 if(primalSolNameRational ==
nullptr)
1162 char* filename = &option[3];
1163 primalSolNameRational =
new char[strlen(filename) + 1];
1164 spxSnprintf(primalSolNameRational, strlen(filename) + 1,
"%s", filename);
1174 if(strncmp(option,
"-y=", 3) == 0)
1176 if(dualSolName ==
nullptr)
1178 char* filename = &option[3];
1179 dualSolName =
new char[strlen(filename) + 1];
1180 spxSnprintf(dualSolName, strlen(filename) + 1,
"%s", filename);
1188 printDualRational =
true;
1190 if(strncmp(option,
"-Y=", 3) == 0)
1192 if(dualSolNameRational ==
nullptr)
1194 char* filename = &option[3];
1195 dualSolNameRational =
new char[strlen(filename) + 1];
1196 spxSnprintf(dualSolNameRational, strlen(filename) + 1,
"%s", filename);
1204 displayStatistics =
true;
1215 if(!
soplex->saveSettingsFile(
nullptr,
false))
1227 goto TERMINATE_FREESTRINGS;
1235 if(lpfilename ==
nullptr && savesetname ==
nullptr && diffsetname ==
nullptr)
1239 goto TERMINATE_FREESTRINGS;
1246 "Error: manual synchronization is invalid on command line. Change parameter int:syncmode.\n");
1248 goto TERMINATE_FREESTRINGS;
1252 if(savesetname !=
nullptr)
1258 if(!
soplex->saveSettingsFile(savesetname,
false))
1260 SPX_MSG_ERROR(std::cerr <<
"Error writing parameters to file <" << savesetname <<
">\n");
1264 if(diffsetname !=
nullptr)
1267 diffsetname <<
"> . . .\n");
1269 if(!
soplex->saveSettingsFile(diffsetname,
true))
1271 SPX_MSG_ERROR(std::cerr <<
"Error writing modified parameters to file <" << diffsetname <<
">\n");
1276 if(lpfilename ==
nullptr)
1278 if(loadsetname !=
nullptr || savesetname !=
nullptr || diffsetname !=
nullptr)
1283 goto TERMINATE_FREESTRINGS;
1287 readingTime->
start();
1299 << (
soplex->intParam(
soplex->READMODE) ==
soplex->READMODE_REAL ?
"(real)" :
"(rational)")
1300 <<
" LP file <" << lpfilename <<
"> . . .\n");
1302 if(!
soplex->readFile(lpfilename, &rownames, &colnames))
1304 SPX_MSG_ERROR(std::cerr <<
"Error while reading file <" << lpfilename <<
">.\n");
1306 goto TERMINATE_FREESTRINGS;
1310 if(writefilename !=
nullptr)
1312 if(!
soplex->writeFile(writefilename, &rownames, &colnames))
1314 SPX_MSG_ERROR(std::cerr <<
"Error while writing file <" << writefilename <<
">.\n\n");
1316 goto TERMINATE_FREESTRINGS;
1326 if(writedualfilename !=
nullptr)
1328 if(!
soplex->writeDualFileReal(writedualfilename, &rownames, &colnames))
1330 SPX_MSG_ERROR(std::cerr <<
"Error while writing dual file <" << writedualfilename <<
">.\n\n");
1332 goto TERMINATE_FREESTRINGS;
1342 if(readbasname !=
nullptr)
1347 if(!
soplex->readBasisFile(readbasname, &rownames, &colnames))
1349 SPX_MSG_ERROR(std::cerr <<
"Error while reading file <" << readbasname <<
">.\n");
1351 goto TERMINATE_FREESTRINGS;
1355 readingTime->
stop();
1358 std::streamsize prec =
soplex->spxout.precision();
1359 soplex->spxout <<
"Reading took "
1360 << std::fixed << std::setprecision(2) << readingTime->
time()
1361 << std::scientific << std::setprecision(
int(prec))
1362 <<
" seconds.\n\n");
1365 <<
soplex->numCols() <<
" columns and " <<
soplex->numNonzeros() <<
" nonzeros.\n\n");
1371 if(primalSolName ==
nullptr && primalSolNameRational ==
nullptr)
1375 if(primalSolName !=
nullptr)
1381 if(primalSolNameRational !=
nullptr)
1383 append = primalSolName !=
nullptr && strcmp(primalSolName, primalSolNameRational) == 0;
1388 if(dualSolName ==
nullptr && dualSolNameRational ==
nullptr)
1392 if(dualSolName !=
nullptr)
1394 append = primalSolName !=
nullptr && strcmp(dualSolName, primalSolName) == 0;
1395 append = append || (primalSolNameRational !=
nullptr
1396 && strcmp(dualSolName, primalSolNameRational) == 0);
1401 if(dualSolNameRational !=
nullptr)
1403 append = (primalSolName !=
nullptr && strcmp(dualSolNameRational, primalSolName) == 0);
1404 append = append || (primalSolNameRational !=
nullptr
1405 && strcmp(dualSolNameRational, primalSolNameRational) == 0);
1406 append = append || (dualSolName !=
nullptr && strcmp(dualSolNameRational, dualSolName) == 0);
1411 checkSolution<R>(*
soplex);
1413 if(displayStatistics)
1416 soplex->printStatistics(
soplex->spxout.getStream(SPxOut::VERB_INFO1));
1423 if(writebasname !=
nullptr)
1428 "No basis information available. Could not write file <" << writebasname <<
">\n\n");
1430 else if(!
soplex->writeBasisFile(writebasname, &rownames, &colnames))
1432 SPX_MSG_ERROR(std::cerr <<
"Error while writing file <" << writebasname <<
">.\n\n");
1434 goto TERMINATE_FREESTRINGS;
1448 goto TERMINATE_FREESTRINGS;
1451TERMINATE_FREESTRINGS:
1452 freeStrings(readbasname, writebasname, loadsetname, savesetname, diffsetname);
1453 freeStrings(primalSolName, dualSolName, primalSolName, primalSolName, primalSolName);
1466 if(
nullptr != validation)
1472 if(
nullptr != readingTime)
1489 for(optidx = 1; optidx < argc; optidx++)
1491 char* option = argv[optidx];
1494 if(option[0] !=
'-')
1500 if(option[1] ==
'\0'
1501 || (option[2] ==
'\0' && strchr(
"xyXYqc", option[1]) ==
nullptr)
1502 || (option[3] ==
'\0' && strchr(
"xyXY", option[1]) !=
nullptr))
1512 option = &option[2];
1516 if(strncmp(option,
"arithmetic=", 11) == 0)
1518 if(option[11] ==
'1')
1520#ifndef SOPLEX_WITH_FLOAT128
1522 "Cannot set arithmetic type to quadprecision - Soplex compiled without quadprecision support\n";)
1529 else if(option[11] ==
'2')
1531#ifndef SOPLEX_WITH_BOOST
1533 "Cannot set arithmetic type to multiprecision - Soplex compiled without boost\n";)
1547 else if(strncmp(option,
"precision=", 10) == 0)
1549 precision = atoi(option + 10);
1550#ifndef SOPLEX_WITH_BOOST
1551 SPX_MSG_ERROR(std::cerr <<
"Setting precision to non-default value without Boost has no effect\n";)
1562 if(precision != 0 && arithmetic != 2)
1565 "Setting precision to non-default value without enabling multiprecision solve has no effect\n";)
1571 runSoPlex<Real>(argc, argv);
1574#ifdef SOPLEX_WITH_BOOST
1575#ifdef SOPLEX_WITH_FLOAT128
1578#if BOOST_VERSION < 107000
1579 std::cerr <<
"Error: Boost version too old." << std:: endl <<
1580 "In order to use the quadprecision feature of SoPlex," <<
1581 " Boost Version 1.70.0 or higher is required." << std::endl << \
1582 "Included Boost version is " << BOOST_VERSION / 100000 <<
"."
1583 << BOOST_VERSION / 100 % 1000 <<
"."
1584 << BOOST_VERSION % 100
1587 using namespace boost::multiprecision;
1588 using Quad = boost::multiprecision::float128;
1589 runSoPlex<Quad>(argc, argv);
1595 using namespace boost::multiprecision;
1597#if BOOST_VERSION < 107000
1598 std::cerr <<
"Error: Boost version too old." << std:: endl <<
1599 "In order to use the multiprecision feature of SoPlex," <<
1600 " Boost Version 1.70.0 or higher is required." << std::endl << \
1601 "Included Boost version is " << BOOST_VERSION / 100000 <<
"."
1602 << BOOST_VERSION / 100 % 1000 <<
"."
1603 << BOOST_VERSION % 100
1606#ifdef SOPLEX_WITH_MPFR
1612 using multiprecision = number<mpfr_float_backend<0>, et_off>;
1613 multiprecision::default_precision(precision);
1614 runSoPlex<multiprecision>(argc, argv);
1617#ifdef SOPLEX_WITH_CPPMPF
1621 using multiprecision1 = number<cpp_dec_float<50>, et_off>;
1622 using multiprecision2 = number<cpp_dec_float<100>, et_off>;
1623 using multiprecision3 = number<cpp_dec_float<200>, et_off>;
1626 runSoPlex<multiprecision1>(argc, argv);
1627 else if(precision <= 100)
1628 runSoPlex<multiprecision2>(argc, argv);
1630 runSoPlex<multiprecision3>(argc, argv);
1639 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.