Scippy

SoPlex

Sequential object-oriented simPlex

soplexmain.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file soplexmain.cpp
17  * @brief Command line interface of SoPlex LP solver
18  */
19 
20 #ifndef SOPLEX_LEGACY
21 #include <assert.h>
22 #include <math.h>
23 #include <string.h>
24 
25 #include <iostream>
26 #include <iomanip>
27 #include <fstream>
28 
29 #include "soplex.h"
30 #include "spxgithash.h"
31 #include "timerfactory.h"
32 
33 #include "validation.h"
34 
35 #ifdef SOPLEX_WITH_EGLIB
36 extern "C" {
37 #include "EGlib.h"
38 }
39 #else
40 #define EGlpNumStart() {}
41 #define EGlpNumClear() {}
42 #endif
43 
44 using namespace soplex;
45 
46 // function prototype
47 int main(int argc, char* argv[]);
48 
49 // prints usage and command line options
50 static
51 void printUsage(const char* const argv[], int idx)
52 {
53  const char* usage =
54  "general options:\n"
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"
64  "\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"
71  "\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 - force iterative refinement)\n"
75  " -s<value> choose simplifier/presolver (0 - off, 1* - auto)\n"
76  " -g<value> choose scaling (0 - off, 1 - uni-equilibrium, 2* - bi-equilibrium, 3 - geometric, 4 - iterated geometric, 5 - least squares, 6 - geometric-equilibrium)\n"
77  " -p<value> choose pricing (0* - auto, 1 - dantzig, 2 - parmult, 3 - devex, 4 - quicksteep, 5 - steep)\n"
78  " -r<value> choose ratio tester (0 - textbook, 1 - harris, 2 - fast, 3* - boundflipping)\n"
79  "\n"
80  "display options:\n"
81  " -v<level> set verbosity to <level> (0 - error, 3 - normal, 5 - high)\n"
82  " -x print primal solution\n"
83  " -y print dual multipliers\n"
84  " -X print primal solution in rational numbers\n"
85  " -Y print dual multipliers in rational numbers\n"
86  " -q display detailed statistics\n"
87  " -c perform final check of optimal solution in original problem\n"
88  "\n";
89 
90  if( idx <= 0 )
91  std::cerr << "missing input file\n\n";
92  else
93  std::cerr << "invalid option \"" << argv[idx] << "\"\n\n";
94 
95  std::cerr << "usage: " << argv[0] << " " << "[options] <lpfile>\n"
96 #ifdef SOPLEX_WITH_ZLIB
97  << " <lpfile> linear program as .mps[.gz] or .lp[.gz] file\n\n"
98 #else
99  << " <lpfile> linear program as .mps or .lp file\n\n"
100 #endif
101  << usage;
102 }
103 
104 // cleans up C strings
105 static
106 void freeStrings(char*& s1, char*& s2, char*& s3, char*& s4, char*& s5)
107 {
108  if( s1 != 0 )
109  {
110  delete [] s1;
111  s1 = 0;
112  }
113  if( s2 != 0 )
114  {
115  delete [] s2;
116  s2 = 0;
117  }
118  if( s3 != 0 )
119  {
120  delete [] s3;
121  s3 = 0;
122  }
123  if( s4 != 0 )
124  {
125  delete [] s4;
126  s4 = 0;
127  }
128  if( s5 != 0 )
129  {
130  delete [] s5;
131  s5 = 0;
132  }
133 }
134 
135 /// performs external feasibility check with real type
136 ///@todo implement external check; currently we use the internal methods for convenience
137 static
139 {
140  if( soplex.hasPrimal() )
141  {
142  Real boundviol;
143  Real rowviol;
144  Real sumviol;
145 
146  if( soplex.getBoundViolationReal(boundviol, sumviol) && soplex.getRowViolationReal(rowviol, sumviol) )
147  {
148  MSG_INFO1( soplex.spxout,
149  Real maxviol = boundviol > rowviol ? boundviol : rowviol;
150  bool feasible = (maxviol <= soplex.realParam(SoPlex::FEASTOL));
151  soplex.spxout << "Primal solution " << (feasible ? "feasible" : "infeasible")
152  << " in original problem (max. violation = " << std::scientific << maxviol
153  << std::setprecision(8) << std::fixed << ").\n"
154  );
155  }
156  else
157  {
158  MSG_INFO1( soplex.spxout, soplex.spxout << "Could not check primal solution.\n" );
159  }
160  }
161  else
162  {
163  MSG_INFO1( soplex.spxout, soplex.spxout << "No primal solution available.\n" );
164  }
165 
166  if( soplex.hasDual() )
167  {
168  Real redcostviol;
169  Real dualviol;
170  Real sumviol;
171 
172  if( soplex.getRedCostViolationReal(redcostviol, sumviol) && soplex.getDualViolationReal(dualviol, sumviol) )
173  {
174  MSG_INFO1( soplex.spxout,
175  Real maxviol = redcostviol > dualviol ? redcostviol : dualviol;
176  bool feasible = (maxviol <= soplex.realParam(SoPlex::OPTTOL));
177  soplex.spxout << "Dual solution " << (feasible ? "feasible" : "infeasible")
178  << " in original problem (max. violation = " << std::scientific << maxviol
179  << std::setprecision(8) << std::fixed << ").\n"
180  );
181  }
182  else
183  {
184  MSG_INFO1( soplex.spxout, soplex.spxout << "Could not check dual solution.\n" );
185  }
186  }
187  else
188  {
189  MSG_INFO1( soplex.spxout, soplex.spxout << "No dual solution available.\n" );
190  }
191 }
192 
193 /// performs external feasibility check with rational type
194 ///@todo implement external check; currently we use the internal methods for convenience
195 static
197 {
198  if( soplex.hasPrimal() )
199  {
200  Rational boundviol;
201  Rational rowviol;
202  Rational sumviol;
203 
204  if( soplex.getBoundViolationRational(boundviol, sumviol) && soplex.getRowViolationRational(rowviol, sumviol) )
205  {
206  MSG_INFO1( soplex.spxout,
207  Rational maxviol = boundviol > rowviol ? boundviol : rowviol;
208  bool feasible = (maxviol <= soplex.realParam(SoPlex::FEASTOL));
209  soplex.spxout << "Primal solution " << (feasible ? "feasible" : "infeasible") << " in original problem (max. violation = " << rationalToString(maxviol) << ").\n"
210  );
211  }
212  else
213  {
214  MSG_INFO1( soplex.spxout, soplex.spxout << "Could not check primal solution.\n" );
215  }
216  }
217  else
218  {
219  MSG_INFO1( soplex.spxout, soplex.spxout << "No primal solution available.\n" );
220  }
221 
222  if( soplex.hasDual() )
223  {
224  Rational redcostviol;
225  Rational dualviol;
226  Rational sumviol;
227 
228  if( soplex.getRedCostViolationRational(redcostviol, sumviol) && soplex.getDualViolationRational(dualviol, sumviol) )
229  {
230  MSG_INFO1( soplex.spxout,
231  Rational maxviol = redcostviol > dualviol ? redcostviol : dualviol;
232  bool feasible = (maxviol <= soplex.realParam(SoPlex::OPTTOL));
233  soplex.spxout << "Dual solution " << (feasible ? "feasible" : "infeasible") << " in original problem (max. violation = " << rationalToString(maxviol) << ").\n"
234  );
235  }
236  else
237  {
238  MSG_INFO1( soplex.spxout, soplex.spxout << "Could not check dual solution.\n" );
239  }
240  }
241  else
242  {
243  MSG_INFO1( soplex.spxout, soplex.spxout << "No dual solution available.\n" );
244  }
245 }
246 
247 /// performs external feasibility check according to check mode
248 static
250 {
254  {
255  checkSolutionRational(soplex);
256  }
257  else
258  {
259  checkSolutionReal(soplex);
260  }
261 
262  MSG_INFO1( soplex.spxout, soplex.spxout << "\n" );
263 }
264 
265 static
266 void printPrimalSolution(SoPlex& soplex, NameSet& colnames, NameSet& rownames, bool real = true, bool rational = false)
267 {
268  int printprec;
269  int printwidth;
270  printprec = (int) -log10(double(Param::epsilon()));
271  printwidth = printprec + 10;
272 
273  if( real )
274  {
275  DVector primal(soplex.numColsReal());
276  if( soplex.getPrimalRayReal(primal) )
277  {
278  MSG_INFO1( soplex.spxout, soplex.spxout << "\nPrimal ray (name, value):\n"; )
279  for( int i = 0; i < soplex.numColsReal(); ++i )
280  {
281  if ( isNotZero( primal[i] ) )
282  {
283  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t"
284  << std::setw(printwidth) << std::setprecision(printprec)
285  << primal[i] << std::endl; )
286  }
287  }
288  MSG_INFO1( soplex.spxout, soplex.spxout << "All other entries are zero (within "
289  << std::setprecision(1) << std::scientific << Param::epsilon()
290  << std::setprecision(8) << std::fixed
291  << ")." << std::endl; )
292  }
293  else if( soplex.isPrimalFeasible() && soplex.getPrimalReal(primal) )
294  {
295  int nNonzeros = 0;
296  MSG_INFO1( soplex.spxout, soplex.spxout << "\nPrimal solution (name, value):\n"; )
297  for( int i = 0; i < soplex.numColsReal(); ++i )
298  {
299  if ( isNotZero( primal[i] ) )
300  {
301  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t"
302  << std::setw(printwidth) << std::setprecision(printprec)
303  << primal[i] << std::endl; )
304  ++nNonzeros;
305  }
306  }
307  MSG_INFO1( soplex.spxout, soplex.spxout << "All other variables are zero (within "
308  << std::setprecision(1) << std::scientific << Param::epsilon()
309  << std::setprecision(8) << std::fixed
310  << "). Solution has " << nNonzeros << " nonzero entries." << std::endl; )
311  }
312  else
313  MSG_INFO1( soplex.spxout, soplex.spxout << "No primal information available.\n")
314  }
315  if( rational )
316  {
317  DVectorRational primal(soplex.numColsReal());
318 
319  if( soplex.getPrimalRayRational(primal) )
320  {
321  MSG_INFO1( soplex.spxout, soplex.spxout << "\nPrimal ray (name, value):\n"; )
322  for( int i = 0; i < soplex.numColsReal(); ++i )
323  {
324  if( primal[i] != (Rational) 0 )
325  {
326  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t"
327  << std::setw(printwidth) << std::setprecision(printprec)
328  << primal[i] << std::endl; )
329  }
330  }
331  MSG_INFO1( soplex.spxout, soplex.spxout << "All other entries are zero." << std::endl; )
332  }
333 
334  if( soplex.isPrimalFeasible() && soplex.getPrimalRational(primal) )
335  {
336  int nNonzeros = 0;
337  MSG_INFO1( soplex.spxout, soplex.spxout << "\nPrimal solution (name, value):\n"; )
338  for( int i = 0; i < soplex.numColsRational(); ++i )
339  {
340  if ( primal[i] != (Rational) 0 )
341  {
342  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t" << primal[i] << std::endl; )
343  ++nNonzeros;
344  }
345  }
346  MSG_INFO1( soplex.spxout, soplex.spxout << "All other variables are zero. Solution has "
347  << nNonzeros << " nonzero entries." << std::endl; )
348  }
349  else
350  MSG_INFO1( soplex.spxout, soplex.spxout << "No primal (rational) solution available.\n")
351 
352  }
353 }
354 
355 static
356 void printDualSolution(SoPlex& soplex, NameSet& colnames, NameSet& rownames, bool real = true, bool rational = false)
357 {
358  int printprec;
359  int printwidth;
360  printprec = (int) -log10(double(Param::epsilon()));
361  printwidth = printprec + 10;
362 
363  if( real )
364  {
365  DVector dual(soplex.numRowsReal());
366  if( soplex.getDualFarkasReal(dual) )
367  {
368  MSG_INFO1( soplex.spxout, soplex.spxout << "\nDual ray (name, value):\n"; )
369  for( int i = 0; i < soplex.numRowsReal(); ++i )
370  {
371  if ( isNotZero( dual[i] ) )
372  {
373  MSG_INFO1( soplex.spxout, soplex.spxout << rownames[i] << "\t"
374  << std::setw(printwidth) << std::setprecision(printprec)
375  << dual[i] << std::endl; )
376  }
377  }
378  MSG_INFO1( soplex.spxout, soplex.spxout << "All other entries are zero (within "
379  << std::setprecision(1) << std::scientific << Param::epsilon()
380  << std::setprecision(8) << std::fixed << ")." << std::endl; )
381  }
382  else if( soplex.isDualFeasible() && soplex.getDualReal(dual) )
383  {
384  MSG_INFO1( soplex.spxout, soplex.spxout << "\nDual solution (name, value):\n"; )
385  for( int i = 0; i < soplex.numRowsReal(); ++i )
386  {
387  if ( isNotZero( dual[i] ) )
388  {
389  MSG_INFO1( soplex.spxout, soplex.spxout << rownames[i] << "\t"
390  << std::setw(printwidth) << std::setprecision(printprec)
391  << dual[i] << std::endl; )
392  }
393  }
394  MSG_INFO1( soplex.spxout, soplex.spxout << "All other dual values are zero (within "
395  << std::setprecision(1) << std::scientific << Param::epsilon()
396  << std::setprecision(8) << std::fixed << ")." << std::endl; )
397 
398  DVector redcost(soplex.numColsReal());
399  if( soplex.getRedCostReal(redcost) )
400  {
401  MSG_INFO1( soplex.spxout, soplex.spxout << "\nReduced costs (name, value):\n"; )
402  for( int i = 0; i < soplex.numColsReal(); ++i )
403  {
404  if ( isNotZero( redcost[i] ) )
405  {
406  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t"
407  << std::setw(printwidth) << std::setprecision(printprec)
408  << redcost[i] << std::endl; )
409  }
410  }
411  MSG_INFO1( soplex.spxout, soplex.spxout << "All other reduced costs are zero (within "
412  << std::setprecision(1) << std::scientific << Param::epsilon()
413  << std::setprecision(8) << std::fixed << ")." << std::endl; )
414  }
415  }
416  else
417  MSG_INFO1( soplex.spxout, soplex.spxout << "No dual information available.\n")
418  }
419 
420  if( rational )
421  {
422  DVectorRational dual(soplex.numRowsReal());
423  if( soplex.getDualFarkasRational(dual) )
424  {
425  MSG_INFO1( soplex.spxout, soplex.spxout << "\nDual ray (name, value):\n"; )
426  for( int i = 0; i < soplex.numRowsReal(); ++i )
427  {
428  if( dual[i] != (Rational) 0 )
429  {
430  MSG_INFO1( soplex.spxout, soplex.spxout << rownames[i] << "\t"
431  << std::setw(printwidth)
432  << std::setprecision(printprec)
433  << dual[i] << std::endl; )
434  }
435  }
436  MSG_INFO1( soplex.spxout, soplex.spxout << "All other entries are zero." << std::endl; )
437  }
438  if( soplex.isDualFeasible() && soplex.getDualRational(dual) )
439  {
440  MSG_INFO1( soplex.spxout, soplex.spxout << "\nDual solution (name, value):\n"; )
441  for( int i = 0; i < soplex.numRowsRational(); ++i )
442  {
443  if ( dual[i] != (Rational) 0 )
444  MSG_INFO1( soplex.spxout, soplex.spxout << rownames[i] << "\t" << dual[i] << std::endl; )
445  }
446  MSG_INFO1( soplex.spxout, soplex.spxout << "All other dual values are zero." << std::endl; )
447 
448  DVectorRational redcost(soplex.numColsReal());
449  if( soplex.getRedCostRational(redcost) )
450  {
451  MSG_INFO1( soplex.spxout, soplex.spxout << "\nReduced costs (name, value):\n"; )
452  for( int i = 0; i < soplex.numColsReal(); ++i )
453  {
454  if ( redcost[i] != (Rational) 0 )
455  MSG_INFO1( soplex.spxout, soplex.spxout << colnames[i] << "\t" << redcost[i] << std::endl; )
456  }
457  MSG_INFO1( soplex.spxout, soplex.spxout << "All other reduced costs are zero." << std::endl; )
458  }
459  }
460  else
461  MSG_INFO1( soplex.spxout, soplex.spxout << "No dual (rational) solution available.\n")
462  }
463 }
464 
465 
466 
467 /// runs SoPlex command line
468 int main(int argc, char* argv[])
469 {
470  ///@todo the EGlib version info should be printed after the SoPlex version info
471  // initialize EGlib's GMP memory management before any rational numbers are created
472  EGlpNumStart();
473 
474  SoPlex* soplex = 0;
475 
476  Timer* readingTime = 0;
477  Validation* validation = 0;
478  int optidx;
479 
480  const char* lpfilename = 0;
481  char* readbasname = 0;
482  char* writebasname = 0;
483  char* writefilename = 0;
484  char* writedualfilename = 0;
485  char* loadsetname = 0;
486  char* savesetname = 0;
487  char* diffsetname = 0;
488  bool printPrimal = false;
489  bool printPrimalRational = false;
490  bool printDual = false;
491  bool printDualRational = false;
492  bool displayStatistics = false;
493  bool checkSol = false;
494 
495  int returnValue = 0;
496 
497  try
498  {
499  NameSet rownames;
500  NameSet colnames;
501 
502  // create default timer (CPU time)
504  soplex = 0;
505  spx_alloc(soplex);
506  new (soplex) SoPlex();
507 
508  soplex->printVersion();
509  MSG_INFO1( soplex->spxout, soplex->spxout << SOPLEX_COPYRIGHT << std::endl << std::endl );
510 
511  validation = 0;
512  spx_alloc(validation);
513  new (validation) Validation();
514 
515  // no options were given
516  if( argc <= 1 )
517  {
518  printUsage(argv, 0);
519  returnValue = 1;
520  goto TERMINATE;
521  }
522 
523  // read arguments from command line
524  for( optidx = 1; optidx < argc; optidx++ )
525  {
526  char* option = argv[optidx];
527 
528  // we reached <lpfile>
529  if( option[0] != '-' )
530  {
531  lpfilename = argv[optidx];
532  continue;
533  }
534 
535  // option string must start with '-', must contain at least two characters, and exactly two characters if and
536  // only if it is -x, -y, -q, or -c
537  if( option[0] != '-' || option[1] == '\0'
538  || ((option[2] == '\0') != (option[1] == 'x' || option[1] == 'X' || option[1] == 'y' || option[1] == 'Y' || option[1] == 'q' || option[1] == 'c')) )
539  {
540  printUsage(argv, optidx);
541  returnValue = 1;
542  goto TERMINATE_FREESTRINGS;
543  }
544 
545  switch( option[1] )
546  {
547  case '-' :
548  {
549  option = &option[2];
550 
551  // --readbas=<basfile> : read starting basis from file
552  if( strncmp(option, "readbas=", 8) == 0 )
553  {
554  if( readbasname == 0 )
555  {
556  char* filename = &option[8];
557  readbasname = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
558  }
559  }
560  // --writebas=<basfile> : write terminal basis to file
561  else if( strncmp(option, "writebas=", 9) == 0 )
562  {
563  if( writebasname == 0 )
564  {
565  char* filename = &option[9];
566  writebasname = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
567  }
568  }
569  // --writefile=<lpfile> : write LP to file
570  else if( strncmp(option, "writefile=", 10) == 0 )
571  {
572  if( writefilename == 0 )
573  {
574  char* filename = &option[10];
575  writefilename = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
576  }
577  }
578  // --writedual=<lpfile> : write dual LP to a file
579  else if( strncmp(option, "writedual=", 10) == 0 )
580  {
581  if( writedualfilename == 0 )
582  {
583  char* dualfilename = &option[10];
584  writedualfilename = strncpy(new char[strlen(dualfilename) + 1], dualfilename, strlen(dualfilename) + 1);
585  }
586  }
587  // --loadset=<setfile> : load parameters from settings file
588  else if( strncmp(option, "loadset=", 8) == 0 )
589  {
590  if( loadsetname == 0 )
591  {
592  char* filename = &option[8];
593  loadsetname = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
594  if( !soplex->loadSettingsFile(loadsetname) )
595  {
596  printUsage(argv, optidx);
597  returnValue = 1;
598  goto TERMINATE_FREESTRINGS;
599  }
600  else
601  {
602  // we need to start parsing again because some command line parameters might have been overwritten
603  optidx = 0;
604  }
605  }
606  }
607  // --saveset=<setfile> : save parameters to settings file
608  else if( strncmp(option, "saveset=", 8) == 0 )
609  {
610  if( savesetname == 0 )
611  {
612  char* filename = &option[8];
613  savesetname = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
614  }
615  }
616  // --diffset=<setfile> : save modified parameters to settings file
617  else if( strncmp(option, "diffset=", 8) == 0 )
618  {
619  if( diffsetname == 0 )
620  {
621  char* filename = &option[8];
622  diffsetname = strncpy(new char[strlen(filename) + 1], filename, strlen(filename) + 1);
623  }
624  }
625  // --readmode=<value> : choose reading mode for <lpfile> (0* - floating-point, 1 - rational)
626  else if( strncmp(option, "readmode=", 9) == 0 )
627  {
628  if( !soplex->setIntParam(SoPlex::READMODE, option[9] - '0') )
629  {
630  printUsage(argv, optidx);
631  returnValue = 1;
632  goto TERMINATE_FREESTRINGS;
633  }
634  }
635  // --solvemode=<value> : choose solving mode (0* - floating-point solve, 1 - auto, 2 - force iterative refinement)
636  else if( strncmp(option, "solvemode=", 10) == 0 )
637  {
638  if( !soplex->setIntParam(SoPlex::SOLVEMODE, option[10] - '0') )
639  {
640  printUsage(argv, optidx);
641  returnValue = 1;
642  goto TERMINATE_FREESTRINGS;
643  }
644  // if the LP is parsed rationally and might be solved rationally, we choose automatic syncmode such that
645  // the rational LP is kept after reading
648  {
650  }
651  }
652  // --extsol=<value> : external solution for soplex to use for validation
653  else if( strncmp(option, "extsol=", 7) == 0 )
654  {
655  char* input = &option[7];
656  if( !validation->updateExternalSolution(input) )
657  {
658  printUsage(argv, optidx);
659  returnValue = 1;
660  goto TERMINATE_FREESTRINGS;
661  }
662  }
663  // --<type>:<name>=<val> : change parameter value using syntax of settings file entries
664  else if( !soplex->parseSettingsString(option) )
665  {
666  printUsage(argv, optidx);
667  returnValue = 1;
668  goto TERMINATE_FREESTRINGS;
669  }
670  break;
671  }
672 
673  case 't' :
674  // -t<s> : set time limit to <s> seconds
675  if( !soplex->setRealParam(SoPlex::TIMELIMIT, atoi(&option[2])) )
676  {
677  printUsage(argv, optidx);
678  returnValue = 1;
679  goto TERMINATE_FREESTRINGS;
680  }
681  break;
682 
683  case 'i' :
684  // -i<n> : set iteration limit to <n>
685  if( !soplex->setIntParam(SoPlex::ITERLIMIT, atoi(&option[2])) )
686  {
687  printUsage(argv, optidx);
688  returnValue = 1;
689  goto TERMINATE_FREESTRINGS;
690  }
691  break;
692 
693  case 'f' :
694  // -f<eps> : set primal feasibility tolerance to <eps>
695  if( !soplex->setRealParam(SoPlex::FEASTOL, atof(&option[2])) )
696  {
697  printUsage(argv, optidx);
698  returnValue = 1;
699  goto TERMINATE_FREESTRINGS;
700  }
701  break;
702 
703  case 'o' :
704  // -o<eps> : set dual feasibility (optimality) tolerance to <eps>
705  if( !soplex->setRealParam(SoPlex::OPTTOL, atof(&option[2])) )
706  {
707  printUsage(argv, optidx);
708  returnValue = 1;
709  goto TERMINATE_FREESTRINGS;
710  }
711  break;
712 
713  case 'l' :
714  // l<eps> : set validation tolerance to <eps>
715  if( !validation->updateValidationTolerance(&option[2]) )
716  {
717  printUsage(argv, optidx);
718  returnValue = 1;
719  goto TERMINATE_FREESTRINGS;
720  }
721  break;
722 
723  case 's' :
724  // -s<value> : choose simplifier/presolver (0 - off, 1* - auto)
725  if( !soplex->setIntParam(SoPlex::SIMPLIFIER, option[2] - '0') )
726  {
727  printUsage(argv, optidx);
728  returnValue = 1;
729  goto TERMINATE_FREESTRINGS;
730  }
731  break;
732 
733  case 'g' :
734  // -g<value> : choose scaling (0 - off, 1 - uni-equilibrium, 2* - bi-equilibrium, 3 - geometric, 4 - iterated geometric, 5 - least squares, 6 - geometric-equilibrium)
735  if( !soplex->setIntParam(SoPlex::SCALER, option[2] - '0') )
736  {
737  printUsage(argv, optidx);
738  returnValue = 1;
739  goto TERMINATE_FREESTRINGS;
740  }
741  break;
742 
743  case 'p' :
744  // -p<value> : choose pricing (0* - auto, 1 - dantzig, 2 - parmult, 3 - devex, 4 - quicksteep, 5 - steep)
745  if( !soplex->setIntParam(SoPlex::PRICER, option[2] - '0') )
746  {
747  printUsage(argv, optidx);
748  returnValue = 1;
749  goto TERMINATE_FREESTRINGS;
750  }
751  break;
752 
753  case 'r' :
754  // -r<value> : choose ratio tester (0 - textbook, 1 - harris, 2* - fast, 3 - boundflipping)
755  if( !soplex->setIntParam(SoPlex::RATIOTESTER, option[2] - '0') )
756  {
757  printUsage(argv, optidx);
758  returnValue = 1;
759  goto TERMINATE_FREESTRINGS;
760  }
761  break;
762 
763  case 'v' :
764  // -v<level> : set verbosity to <level> (0 - error, 3 - normal, 5 - high)
765  if( !soplex->setIntParam(SoPlex::VERBOSITY, option[2] - '0') )
766  {
767  printUsage(argv, optidx);
768  returnValue = 1;
769  goto TERMINATE_FREESTRINGS;
770  }
771  break;
772 
773  case 'x' :
774  // -x : print primal solution
775  printPrimal = true;
776  break;
777 
778  case 'X' :
779  // -X : print primal solution with rationals
780  printPrimalRational = true;
781  break;
782 
783  case 'y' :
784  // -y : print dual multipliers
785  printDual = true;
786  break;
787 
788  case 'Y' :
789  // -Y : print dual multipliers with rationals
790  printDualRational = true;
791  break;
792 
793  case 'q' :
794  // -q : display detailed statistics
795  displayStatistics = true;
796  break;
797 
798  case 'c' :
799  // -c : perform final check of optimal solution in original problem
800  checkSol = true;
801  break;
802 
803  case 'h' :
804  // -h : display all parameters
805  if( !soplex->saveSettingsFile(0, false) )
806  {
807  MSG_ERROR( std::cerr << "Error printing parameters\n" );
808  }
809  break;
810 
811  //lint -fallthrough
812  default :
813  {
814  printUsage(argv, optidx);
815  returnValue = 1;
816  goto TERMINATE_FREESTRINGS;
817  }
818  }
819  }
820 
821  MSG_INFO1( soplex->spxout, soplex->printUserSettings(); )
822 
823  // no LP file was given and no settings files are written
824  if( lpfilename == 0 && savesetname == 0 && diffsetname == 0 )
825  {
826  printUsage(argv, 0);
827  returnValue = 1;
828  goto TERMINATE_FREESTRINGS;
829  }
830 
831  // ensure that syncmode is not manual
833  {
834  MSG_ERROR( std::cerr << "Error: manual synchronization is invalid on command line. Change parameter int:syncmode.\n" );
835  returnValue = 1;
836  goto TERMINATE_FREESTRINGS;
837  }
838 
839  // save settings files
840  if( savesetname != 0 )
841  {
842  MSG_INFO1( soplex->spxout, soplex->spxout << "Saving parameters to settings file <" << savesetname << "> . . .\n" );
843  if( !soplex->saveSettingsFile(savesetname, false) )
844  {
845  MSG_ERROR( std::cerr << "Error writing parameters to file <" << savesetname << ">\n" );
846  }
847  }
848  if( diffsetname != 0 )
849  {
850  MSG_INFO1( soplex->spxout, soplex->spxout << "Saving modified parameters to settings file <" << diffsetname << "> . . .\n" );
851  if( !soplex->saveSettingsFile(diffsetname, true) )
852  {
853  MSG_ERROR( std::cerr << "Error writing modified parameters to file <" << diffsetname << ">\n" );
854  }
855  }
856 
857  // no LP file given: exit after saving settings
858  if( lpfilename == 0 )
859  {
860  if( loadsetname != 0 || savesetname != 0 || diffsetname != 0 )
861  {
862  MSG_INFO1( soplex->spxout, soplex->spxout << "\n" );
863  }
864  goto TERMINATE_FREESTRINGS;
865  }
866 
867  // measure time for reading LP file and basis file
868  readingTime->start();
869 
870  // if the LP is parsed rationally and might be solved rationally, we choose automatic syncmode such that
871  // the rational LP is kept after reading
874  {
876  }
877 
878  // read LP from input file
879  MSG_INFO1( soplex->spxout, soplex->spxout << "Reading "
880  << (soplex->intParam(SoPlex::READMODE) == SoPlex::READMODE_REAL ? "(real)" : "(rational)")
881  << " LP file <" << lpfilename << "> . . .\n" );
882 
883  if( !soplex->readFile(lpfilename, &rownames, &colnames) )
884  {
885  MSG_ERROR( std::cerr << "Error while reading file <" << lpfilename << ">.\n" );
886  returnValue = 1;
887  goto TERMINATE_FREESTRINGS;
888  }
889 
890  // write LP if specified
891  if( writefilename != 0 )
892  {
893  if( !soplex->writeFileReal(writefilename, &rownames, &colnames) )
894  {
895  MSG_ERROR( std::cerr << "Error while writing file <" << writefilename << ">.\n\n" );
896  returnValue = 1;
897  goto TERMINATE_FREESTRINGS;
898  }
899  else
900  {
901  MSG_INFO1( soplex->spxout, soplex->spxout << "Written LP to file <" << writefilename << ">.\n\n" );
902  }
903  }
904 
905  // write dual LP if specified
906  if( writedualfilename != 0 )
907  {
908  if( !soplex->writeDualFileReal(writedualfilename, &rownames, &colnames) )
909  {
910  MSG_ERROR( std::cerr << "Error while writing dual file <" << writedualfilename << ">.\n\n" );
911  returnValue = 1;
912  goto TERMINATE_FREESTRINGS;
913  }
914  else
915  {
916  MSG_INFO1( soplex->spxout, soplex->spxout << "Written dual LP to file <" << writedualfilename << ">.\n\n" );
917  }
918  }
919 
920  // read basis file if specified
921  if( readbasname != 0 )
922  {
923  MSG_INFO1( soplex->spxout, soplex->spxout << "Reading basis file <" << readbasname << "> . . . " );
924  if( !soplex->readBasisFile(readbasname, &rownames, &colnames) )
925  {
926  MSG_ERROR( std::cerr << "Error while reading file <" << readbasname << ">.\n" );
927  returnValue = 1;
928  goto TERMINATE_FREESTRINGS;
929  }
930  }
931 
932  readingTime->stop();
933 
934  MSG_INFO1( soplex->spxout,
935  std::streamsize prec = soplex->spxout.precision();
936  soplex->spxout << "Reading took "
937  << std::fixed << std::setprecision(2) << readingTime->time()
938  << std::scientific << std::setprecision(int(prec))
939  << " seconds.\n\n" );
940 
941  MSG_INFO1( soplex->spxout, soplex->spxout << "LP has " << soplex->numRowsReal() << " rows "
942  << soplex->numColsReal() << " columns and " << soplex->numNonzerosReal() << " nonzeros.\n\n" );
943 
944  // solve the LP
945  soplex->optimize();
946 
947  // print solution, check solution, and display statistics
948  printPrimalSolution(*soplex, colnames, rownames, printPrimal, printPrimalRational);
949  printDualSolution(*soplex, colnames, rownames, printDual, printDualRational);
950 
951  if( checkSol )
952  checkSolution(*soplex);
953 
954  if( displayStatistics )
955  {
956  MSG_INFO1( soplex->spxout, soplex->spxout << "Statistics\n==========\n\n" );
957  soplex->printStatistics(soplex->spxout.getStream(SPxOut::INFO1));
958  }
959 
960  if(validation->validate)
961  validation->validateSolveReal(*soplex);
962 
963  // write basis file if specified
964  if( writebasname != 0 )
965  {
966  if( !soplex->hasBasis() )
967  {
968  MSG_WARNING( soplex->spxout, soplex->spxout << "No basis information available. Could not write file <" << writebasname << ">\n\n" );
969  }
970  else if( !soplex->writeBasisFile(writebasname, &rownames, &colnames) )
971  {
972  MSG_ERROR( std::cerr << "Error while writing file <" << writebasname << ">.\n\n" );
973  returnValue = 1;
974  goto TERMINATE_FREESTRINGS;
975  }
976  else
977  {
978  MSG_INFO1( soplex->spxout, soplex->spxout << "Written basis information to file <" << writebasname << ">.\n\n" );
979  }
980  }
981  }
982  catch( const SPxException& x )
983  {
984  MSG_ERROR( std::cerr << "Exception caught: " << x.what() << "\n" );
985  returnValue = 1;
986  goto TERMINATE_FREESTRINGS;
987  }
988 
989  TERMINATE_FREESTRINGS:
990  freeStrings(readbasname, writebasname, loadsetname, savesetname, diffsetname);
991 
992  TERMINATE:
993  // because EGlpNumClear() calls mpq_clear() for all mpq_t variables, we need to destroy all objects of class Rational
994  // beforehand; hence all Rational objects and all data that uses Rational objects must be allocated dynamically via
995  // spx_alloc() and freed here; disabling the list memory is crucial
996  if( 0 != soplex )
997  {
998  soplex->~SoPlex();
999  spx_free(soplex);
1000  }
1001  if( 0 != validation )
1002  {
1003  validation->~Validation();
1004  spx_free(validation);
1005  }
1007  EGlpNumClear();
1008  if( 0 != readingTime )
1009  {
1010  readingTime->~Timer();
1011  spx_free(readingTime);
1012  }
1013 
1014  return returnValue;
1015 }
1016 #else
1017 #include <assert.h>
1018 #include <math.h>
1019 #include <string.h>
1020 #include <iostream>
1021 #include <iomanip>
1022 #include <fstream>
1023 
1024 #include "spxdefines.h"
1025 #include "soplex.h"
1026 #include "spxsolver.h"
1027 
1028 #include "timer.h"
1029 #include "spxgithash.h"
1030 #include "spxpricer.h"
1031 #include "spxdantzigpr.h"
1032 #include "spxparmultpr.h"
1033 #include "spxdevexpr.h"
1034 #include "spxhybridpr.h"
1035 #include "spxsteeppr.h"
1036 #include "spxsteepexpr.h"
1037 #include "spxweightpr.h"
1038 #include "spxratiotester.h"
1039 #include "spxharrisrt.h"
1040 #include "spxdefaultrt.h"
1041 #include "spxfastrt.h"
1042 #include "spxboundflippingrt.h"
1043 #include "spxsimplifier.h"
1044 #include "spxmainsm.h"
1045 #include "spxscaler.h"
1046 #include "spxequilisc.h"
1047 #include "spxleastsqsc.h"
1048 #include "spxgeometsc.h"
1049 #include "spxsumst.h"
1050 #include "spxweightst.h"
1051 #include "spxvectorst.h"
1052 #include "slufactor.h"
1053 #include "spxout.h"
1054 
1055 using namespace soplex;
1056 
1057 
1058 //------------------------------------------------------------------------
1059 // for simplicity: store whether we are in check mode:
1060 static bool checkMode = false;
1061 //------------------------------------------------------------------------
1062 
1063 
1064 //------------------------------------------------------------------------
1065 // class MySoPlex
1066 //------------------------------------------------------------------------
1067 
1068 /** LP solver class for the command line. */
1069 class MySoPlex : public SoPlex
1070 {
1071 public:
1072  /// default constructor
1073  MySoPlex( SPxOut& outstream,
1076  : SoPlex(outstream, p_type, p_rep)
1077  {}
1078  //------------------------------------------------------------------------
1079  /// virtual destructor
1080  virtual ~MySoPlex()
1081  {}
1082  //------------------------------------------------------------------------
1083  void displayQuality() const
1084  {
1085  Real maxviol;
1086  Real sumviol;
1087 
1088  if ( checkMode )
1089  {
1090  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP05 Violations (max/sum)" << std::endl; )
1091 
1092  m_solver.qualConstraintViolation(maxviol, sumviol);
1093 
1094  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP06 Constraints :"
1095  << std::setw(16) << maxviol << " "
1096  << std::setw(16) << sumviol << std::endl; )
1097 
1098  qualConstraintViolation(maxviol, sumviol);
1099 
1100  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP07 (unscaled) :"
1101  << std::setw(16) << maxviol << " "
1102  << std::setw(16) << sumviol << std::endl; )
1103 
1104  m_solver.qualBoundViolation(maxviol, sumviol);
1105 
1106  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP08 Bounds :"
1107  << std::setw(16) << maxviol << " "
1108  << std::setw(16) << sumviol << std::endl; )
1109 
1110  qualBoundViolation(maxviol, sumviol);
1111 
1112  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP09 (unscaled) :"
1113  << std::setw(16) << maxviol << " "
1114  << std::setw(16) << sumviol << std::endl; )
1115 
1116  if (!m_vanished)
1117  {
1118  m_solver.qualSlackViolation(maxviol, sumviol);
1119 
1120  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP10 Slacks :"
1121  << std::setw(16) << maxviol << " "
1122  << std::setw(16) << sumviol << std::endl; )
1123 
1124  m_solver.qualRedCostViolation(maxviol, sumviol);
1125 
1126  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP11 Reduced costs :"
1127  << std::setw(16) << maxviol << " "
1128  << std::setw(16) << sumviol << std::endl; )
1129 #if 0
1130  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP12 Proven dual bound:"
1131  << std::setw(20)
1132  << std::setprecision(20)
1133  << m_solver.provedDualbound() << std::endl; )
1134 #endif
1135  }
1136  }
1137  else
1138  {
1139  MSG_INFO1( (*spxout), (*spxout) << "Violations (max/sum)" << std::endl; )
1140 
1141  m_solver.qualConstraintViolation(maxviol, sumviol);
1142 
1143  MSG_INFO1( (*spxout), (*spxout) << "Constraints :"
1144  << std::setw(16) << maxviol << " "
1145  << std::setw(16) << sumviol << std::endl; )
1146 
1147  qualConstraintViolation(maxviol, sumviol);
1148 
1149  MSG_INFO1( (*spxout), (*spxout) << " (unscaled) :"
1150  << std::setw(16) << maxviol << " "
1151  << std::setw(16) << sumviol << std::endl; )
1152 
1153  m_solver.qualBoundViolation(maxviol, sumviol);
1154 
1155  MSG_INFO1( (*spxout), (*spxout) << "Bounds :"
1156  << std::setw(16) << maxviol << " "
1157  << std::setw(16) << sumviol << std::endl; )
1158 
1159  qualBoundViolation(maxviol, sumviol);
1160 
1161  MSG_INFO1( (*spxout), (*spxout) << " (unscaled) :"
1162  << std::setw(16) << maxviol << " "
1163  << std::setw(16) << sumviol << std::endl; )
1164 
1165  if (!m_vanished)
1166  {
1167  m_solver.qualSlackViolation(maxviol, sumviol);
1168 
1169  MSG_INFO1( (*spxout), (*spxout) << "Slacks :"
1170  << std::setw(16) << maxviol << " "
1171  << std::setw(16) << sumviol << std::endl; )
1172 
1173  m_solver.qualRedCostViolation(maxviol, sumviol);
1174 
1175  MSG_INFO1( (*spxout), (*spxout) << "Reduced costs :"
1176  << std::setw(16) << maxviol << " "
1177  << std::setw(16) << sumviol << std::endl; )
1178 #if 0
1179  MSG_INFO1( (*spxout), (*spxout) << "Proven dual bound:"
1180  << std::setw(20)
1181  << std::setprecision(20)
1182  << m_solver.provedDualbound() << std::endl; )
1183 #endif
1184  }
1185  }
1186  }
1187  //------------------------------------------------------------------------
1188  void displayInfeasibility() const
1189  {
1190  assert(m_solver.status() == SPxSolver::INFEASIBLE);
1191 
1192 #if 0
1193  if ( checkMode )
1194  {
1195  if( m_solver.isProvenInfeasible() )
1196  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP13 Infeasibility is proven." << std::endl; )
1197  else
1198  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP13 Infeasibility could not be proven!" << std::endl; )
1199  }
1200  else
1201  {
1202  if ( m_solver.isProvenInfeasible() )
1203  {
1204  MSG_INFO1( (*spxout), (*spxout) << "Infeasibility is proven." << std::endl; )
1205  }
1206  else
1207  {
1208  MSG_INFO1( (*spxout), (*spxout) << "Infeasibility could not be proven!" << std::endl; )
1209  }
1210  }
1211 #endif
1212  }
1213 };
1214 
1215 
1216 //------------------------------------------------------------------------
1217 // Helpers
1218 //------------------------------------------------------------------------
1219 
1220 static
1221 void print_version_info()
1222 {
1223  const char* banner1 =
1224  "************************************************************************\n"
1225  "* *\n"
1226  "* SoPlex --- the Sequential object-oriented simPlex. *\n"
1227  ;
1228 
1229  const char* banner2 =
1230  "* *\n"
1231  "* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum *\n"
1232  "* fuer Informationstechnik Berlin *\n"
1233  "* *\n"
1234  "* SoPlex is distributed under the terms of the ZIB Academic Licence. *\n"
1235  "* You should have received a copy of the ZIB Academic License *\n"
1236  "* along with SoPlex; If not email to soplex@zib.de. *\n"
1237  "* *\n"
1238  "************************************************************************\n"
1239  ;
1240 
1241  if( !checkMode )
1242  std::cout << banner1;
1243 
1244 #if (SOPLEX_SUBVERSION > 0)
1245  if( !checkMode )
1246  std::cout << "* Version ";
1247  else
1248  std::cout << "SoPlex version ";
1249  std::cout << SOPLEX_VERSION/100 << "."
1250  << (SOPLEX_VERSION % 100)/10 << "."
1251  << SOPLEX_VERSION % 10 << "."
1253  << " - Githash "
1254  << std::setw(13) << std::setiosflags(std::ios::left) << getGitHash();
1255  if( !checkMode )
1256  std::cout << " *\n" << banner2 << std::endl;
1257  else
1258  std::cout << "\n";
1259 #else
1260  if( !checkMode )
1261  std::cout << "* Release ";
1262  else
1263  std::cout << "SoPlex release ";
1264  std::cout << SOPLEX_VERSION/100 << "."
1265  << (SOPLEX_VERSION % 100)/10 << "."
1266  << SOPLEX_VERSION % 10
1267  << " - Githash "
1268  << std::setw(13) << std::setiosflags(std::ios::left) << getGitHash();
1269  if( !checkMode )
1270  std::cout << " *\n" << banner2 << std::endl;
1271  else
1272  std::cout << "\n";
1273 #endif
1274 
1275  /// The following code block is tests and shows compilation parameters.
1276  std::cout << "[NDEBUG:"
1277 #ifdef NDEBUG
1278  << "YES"
1279 #else
1280  << "NO"
1281 #endif
1282  << "]";
1283 
1284  std::cout << "[WITH_WARNINGS:"
1285 #ifdef WITH_WARNINGS
1286  << "YES"
1287 #else
1288  << "NO"
1289 #endif
1290  << "]";
1291 
1292  std::cout << "[ENABLE_ADDITIONAL_CHECKS:"
1293 #ifdef ENABLE_ADDITIONAL_CHECKS
1294  << "YES"
1295 #else
1296  << "NO"
1297 #endif
1298  << "]";
1299 
1300  std::cout << "[ENABLE_CONSISTENCY_CHECKS:"
1301 #ifdef ENABLE_CONSISTENCY_CHECKS
1302  << "YES"
1303 #else
1304  << "NO"
1305 #endif
1306  << "]";
1307 
1308  std::cout << "[SOPLEX_WITH_GMP:"
1309 #ifdef SOPLEX_WITH_GMP
1310  << "YES"
1311 #else
1312  << "NO"
1313 #endif
1314  << "]" << std::endl;
1315 
1316  std::cout << std::endl;
1317 }
1318 
1319 #if 0
1320 static
1321 void print_short_version_info()
1322 {
1323  const char* banner1 =
1324  "************************************************************************\n"
1325  "* SoPlex --- the Sequential object-oriented simPlex. ";
1326  const char* banner2 =
1327  "* Copyright (C) 1996-2017 Konrad-Zuse-Zentrum *\n"
1328  "* fuer Informationstechnik Berlin *\n"
1329  "************************************************************************\n";
1330 
1331  std::cout << banner1;
1332 #if (SOPLEX_SUBVERSION > 0)
1333  std::cout << "Version "
1334  << SOPLEX_VERSION/100 << "."
1335  << (SOPLEX_VERSION % 100)/10 << "."
1336  << SOPLEX_VERSION % 10 << "."
1338  << " *\n";
1339 #else
1340  std::cout << "Release "
1341  << SOPLEX_VERSION/100 << "."
1342  << (SOPLEX_VERSION % 100)/10 << "."
1343  << SOPLEX_VERSION % 10
1344  << " *\n";
1345 #endif
1346  std::cout << banner2 << std::endl;
1347 }
1348 #endif
1349 
1350 //------------------------------------------------------------------------
1351 static
1352 void print_usage_and_exit( const char* const argv[] )
1353 {
1354  const char* usage =
1355  "[options] LPfile [Basfile]\n\n"
1356  " LPfile can be either in MPS or LPF format\n\n"
1357  "options: (*) indicates default\n"
1358  " (!) indicates experimental features which may give wrong results\n"
1359  " -e select entering algorithm (default is leaving)\n"
1360  " -r select row wise representation (default is column)\n"
1361  " -i select Eta-update (default is Forest-Tomlin)\n"
1362  " -x output solution vector\n"
1363  " -y output dual multipliers\n"
1364  " -q display solution quality\n"
1365  " -br read file with starting basis from Basfile\n"
1366  " -bw write file with optimal basis to Basfile\n"
1367  " -l set time limit in seconds\n"
1368  " -L set iteration limit\n"
1369  " -f set primal feasibility tolerance\n"
1370  " -o set optimality, i.e., dual feasibility tolerance\n"
1371  " -d set primal and dual feasibility tolerance to same value\n"
1372  " -zz set general zero tolerance\n"
1373  " -zf set factorization zero tolerance\n"
1374  " -zu set update zero tolerance\n"
1375  " -v set verbosity Level: from 0 (ERROR) to 5 (INFO3), default 3 (INFO1)\n"
1376  " -V show program version\n"
1377  " -C check mode (for check scripts)\n"
1378  " -h show this help\n\n"
1379  "Simplifier: Scaler: Starter: Pricer: Ratiotester:\n"
1380  " -s0 none -g0 none -c0 none* -p0 Textbook -t0 Textbook\n"
1381  " -s1 Main* -g1 uni-Equi -c1 Weight -p1 ParMult -t1 Harris\n"
1382  " -g2 bi-Equi* -c2 Sum -p2 Devex -t2 Fast\n"
1383  " -g3 Geo1 -c3 Vector -p3 Hybrid! -t3 Bound Flipping*\n"
1384  " -g4 Geo8 -p4 Steep*\n"
1385  " -p5 Weight\n"
1386  " -p6 SteepExactSetup\n"
1387  ;
1388 
1389  std::cerr << "usage: " << argv[0] << " " << usage << std::endl;
1390  exit(0);
1391 }
1392 
1393 //------------------------------------------------------------------------
1394 static
1395 void check_parameter(const char param, const char* const argv[])
1396 {
1397  if (param == '\0')
1398  print_usage_and_exit( argv );
1399 }
1400 
1401 //------------------------------------------------------------------------
1402 static
1403 void print_algorithm_parameters(
1404  MySoPlex& work,
1405  const SPxSolver::Representation representation,
1406  const SLUFactor::UpdateType update
1407  )
1408 {
1409  if ( checkMode )
1410  {
1411  MSG_INFO1( (*work.spxout), (*work.spxout)
1412  << "IEXAMP12 Feastol = "
1413  << std::setw(16) << work.feastol() << std::endl
1414  << "IEXAMP52 Opttol = "
1415  << std::setw(16) << work.opttol() << std::endl
1416  << "IEXAMP13 Epsilon Zero = "
1417  << std::setw(16) << Param::epsilon() << std::endl
1418  << "IEXAMP37 Epsilon Factor = "
1419  << std::setw(16) << Param::epsilonFactorization() << std::endl
1420  << "IEXAMP38 Epsilon Update = "
1421  << std::setw(16) << Param::epsilonUpdate() << std::endl
1422  << "IEXAMP14 "
1423  << (work.type() == SPxSolver::ENTER ? "Entering" : "Leaving")
1424  << " algorithm" << std::endl
1425  << "IEXAMP15 "
1426  << (representation == SPxSolver::ROW ? "Row" : "Column")
1427  << " representation" << std::endl
1428  << "IEXAMP16 "
1429  << (update == SLUFactor::ETA ? "Eta" : "Forest-Tomlin")
1430  << " update" << std::endl; )
1431  }
1432  else
1433  {
1434  MSG_INFO1( (*work.spxout), (*work.spxout)
1435  << "SoPlex parameters: " << std::endl
1436  << "Feastol = "
1437  << std::setw(16) << work.feastol() << std::endl
1438  << "Opttol = "
1439  << std::setw(16) << work.opttol() << std::endl
1440  << "Epsilon Zero = "
1441  << std::setw(16) << Param::epsilon() << std::endl
1442  << "Epsilon Factor = "
1443  << std::setw(16) << Param::epsilonFactorization() << std::endl
1444  << "Epsilon Update = "
1445  << std::setw(16) << Param::epsilonUpdate() << std::endl
1446  << std::endl
1447  << "algorithm = " << (work.type() == SPxSolver::ENTER ? "Entering" : "Leaving")
1448  << std::endl
1449  << "representation = " << (representation == SPxSolver::ROW ? "Row" : "Column")
1450  << std::endl
1451  << "update = " << (update == SLUFactor::ETA ? "Eta" : "Forest-Tomlin")
1452  << std::endl; )
1453  }
1454 }
1455 
1456 //------------------------------------------------------------------------
1457 static
1458 SPxPricer* get_pricer(const int pricing, SPxOut* spxout)
1459 {
1460  SPxPricer* pricer = 0;
1461  switch(pricing)
1462  {
1463  case 6 :
1464  pricer = new SPxSteepExPR;
1465  break;
1466  case 5 :
1467  pricer = new SPxWeightPR;
1468  break;
1469  case 4 :
1470  pricer = new SPxSteepPR;
1471  break;
1472  case 3 :
1473  pricer = new SPxHybridPR;
1474  break;
1475  case 2 :
1476  pricer = new SPxDevexPR;
1477  break;
1478  case 1 :
1479  pricer = new SPxParMultPR;
1480  break;
1481  case 0 :
1482  /*FALLTHROUGH*/
1483  default :
1484  pricer = new SPxDantzigPR;
1485  break;
1486  }
1487 
1488  assert(pricer != 0);
1489  if ( checkMode )
1490 #ifdef PARTIAL_PRICING
1491  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP17 " << pricer->getName() << " pricing"
1492  << " (partial, size = " << MAX_PRICING_CANDIDATES << ")"
1493  << std::endl; )
1494 #else
1495  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP17 " << pricer->getName() << " pricing"
1496  << std::endl; )
1497 #endif
1498  else
1499 #ifdef PARTIAL_PRICING
1500  MSG_INFO1( (*spxout), (*spxout) << "pricing = " << pricer->getName()
1501  << " (partial, size = " << MAX_PRICING_CANDIDATES << ")"
1502  << std::endl; )
1503 #else
1504  MSG_INFO1( (*spxout), (*spxout) << "pricing = " << pricer->getName()
1505  << std::endl; )
1506 #endif
1507  return pricer;
1508 }
1509 
1510 //------------------------------------------------------------------------
1511 static
1512 SPxRatioTester* get_ratio_tester(const int ratiotest, SPxOut* spxout)
1513 {
1514  SPxRatioTester* ratiotester = 0;
1515  switch(ratiotest)
1516  {
1517  case 3 :
1518  ratiotester = new SPxBoundFlippingRT;
1519  break;
1520  case 2 :
1521  ratiotester = new SPxFastRT;
1522  break;
1523  case 1 :
1524  ratiotester = new SPxHarrisRT;
1525  break;
1526  case 0 :
1527  /*FALLTHROUGH*/
1528  default:
1529  ratiotester = new SPxDefaultRT;
1530  break;
1531  }
1532 
1533  assert(ratiotester != 0);
1534  if ( checkMode )
1535  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP18 " << ratiotester->getName() << " ratiotest" << std::endl; )
1536  else
1537  MSG_INFO1( (*spxout), (*spxout) << "ratiotest = " << ratiotester->getName() << std::endl; )
1538  return ratiotester;
1539 }
1540 
1541 //------------------------------------------------------------------------
1542 static
1543 void get_scalers(
1544  SPxScaler*& postscaler,
1545  const int scaling,
1546  SPxOut* spxout
1547  )
1548 {
1549 
1550  switch(scaling)
1551  {
1552  case 4:
1553  postscaler = new SPxGeometSC(8);
1554  break;
1555  case 3:
1556  postscaler = new SPxGeometSC(1);
1557  break;
1558  case 2 :
1559  postscaler = new SPxEquiliSC(true);
1560  break;
1561  case 1 :
1562  postscaler = new SPxEquiliSC(false);
1563  break;
1564  case 0 :
1565  /*FALLTHROUGH*/
1566  default :
1567  postscaler = 0;
1568  break;
1569  }
1570 
1571  if ( checkMode )
1572  {
1573  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP19 "
1574  << ((postscaler != 0) ? postscaler->getName() : "no")
1575  << " scaling" << std::endl; )
1576  }
1577  else
1578  {
1579  MSG_INFO1( (*spxout), (*spxout) << "scaling = "
1580  << ((postscaler != 0) ? postscaler->getName() : "no")
1581  << std::endl; )
1582  }
1583 }
1584 
1585 //------------------------------------------------------------------------
1586 static
1587 SPxSimplifier* get_simplifier(const int simplifying, SPxOut* spxout)
1588 {
1589  SPxSimplifier* simplifier = 0;
1590  switch(simplifying)
1591  {
1592  case 1 :
1593  simplifier = new SPxMainSM;
1594  break;
1595  case 0 :
1596  /*FALLTHROUGH*/
1597  default :
1598  assert(simplifier == 0);
1599  break;
1600  }
1601 
1602  if ( checkMode )
1603  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP20 " << ((simplifier == 0) ? "no" : simplifier->getName()) << " simplifier" << std::endl; )
1604  else
1605  MSG_INFO1( (*spxout), (*spxout) << "simplifier = " << ((simplifier == 0) ? "no" : simplifier->getName()) << std::endl; )
1606  return simplifier;
1607 }
1608 
1609 //------------------------------------------------------------------------
1610 static
1611 SPxStarter* get_starter(const int starting, SPxOut* spxout)
1612 {
1613  SPxStarter* starter = 0;
1614  switch(starting)
1615  {
1616  case 3 :
1617  starter = new SPxVectorST;
1618  break;
1619  case 2 :
1620  starter = new SPxSumST;
1621  break;
1622  case 1 :
1623  starter = new SPxWeightST;
1624  break;
1625  case 0 :
1626  /*FALLTHROUGH*/
1627  default :
1628  break;
1629  }
1630 
1631  if ( checkMode )
1632  MSG_INFO1( (*spxout), (*spxout) << "IEXAMP21 " << ((starter == 0) ? "no" : starter->getName()) << " starter" << std::endl; )
1633  else
1634  MSG_INFO1( (*spxout), (*spxout) << "starter = " << ((starter == 0) ? "no" : starter->getName()) << std::endl; )
1635 
1636  return starter;
1637 }
1638 
1639 //------------------------------------------------------------------------
1640 #ifdef SEND_ALL_OUTPUT_TO_FILES
1641 static
1642 void redirect_output(
1643  std::ostream& myerrstream,
1644  std::ostream& myinfostream
1645  )
1646 {
1647  myerrstream .setf( std::ios::scientific | std::ios::showpoint );
1648  myinfostream.setf( std::ios::scientific | std::ios::showpoint );
1649  spxout.setStream( SPxOut::ERROR, myerrstream );
1650  spxout.setStream( SPxOut::WARNING, myerrstream );
1651  spxout.setStream( SPxOut::INFO1, myinfostream );
1652  spxout.setStream( SPxOut::INFO2, myinfostream );
1653  spxout.setStream( SPxOut::INFO3, myinfostream );
1654  spxout.setStream( SPxOut::DEBUG, myinfostream );
1655 }
1656 #endif
1657 //------------------------------------------------------------------------
1658 static
1659 void read_input_file(
1660  MySoPlex& work,
1661  const char* filename,
1662  NameSet& rownames,
1663  NameSet& colnames)
1664 {
1665  if ( checkMode )
1666  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP22 loading LP file " << filename << std::endl; )
1667  else
1668  MSG_INFO1( (*work.spxout), (*work.spxout) << "\nLoading LP file " << filename << std::endl; )
1669 
1670  UserTimer timer;
1671  timer.start();
1672 
1673  if ( ! work.readFile(filename, &rownames, &colnames, 0) )
1674  {
1675  if ( checkMode )
1676  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP23 error while reading file \"" << filename << "\"" << std::endl; )
1677  else
1678  MSG_INFO1( (*work.spxout), (*work.spxout) << "error while reading file \"" << filename << "\"" << std::endl; )
1679  exit(1);
1680  }
1681  assert(work.isConsistent());
1682 
1683  timer.stop();
1684 
1685  if ( checkMode )
1686  {
1687  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP24 LP has "
1688  << work.nRows() << " rows "
1689  << work.nCols() << " columns "
1690  << work.nNzos() << " nonzeros"
1691  << std::endl; )
1692 
1693  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP41 LP reading time: " << timer.time() << std::endl; )
1694  }
1695  else
1696  {
1697  MSG_INFO1( (*work.spxout), (*work.spxout) << "LP has "
1698  << work.nRows() << " rows "
1699  << work.nCols() << " columns "
1700  << work.nNzos() << " nonzeros"
1701  << std::endl; )
1702 
1703  MSG_INFO1( (*work.spxout),
1704  std::streamsize prec = (*work.spxout).precision();
1705  (*work.spxout) << "LP reading time: " << std::fixed << std::setprecision(2) << timer.time();
1706  (*work.spxout) << std::scientific << std::setprecision(int(prec)) << std::endl; )
1707  }
1708 }
1709 
1710 //------------------------------------------------------------------------
1711 static
1712 void read_basis_file(
1713  MySoPlex& work ,
1714  const char* filename,
1715  const NameSet* rownames,
1716  const NameSet* colnames)
1717 {
1718  MSG_INFO1( (*work.spxout), (*work.spxout) << "Reading basis from file (disables simplifier)" << std::endl; )
1719  if (!work.readBasisFile(filename, rownames, colnames))
1720  {
1721  if ( checkMode )
1722  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP25 error while reading file \"" << filename << "\"" << std::endl; )
1723  else
1724  MSG_INFO1( (*work.spxout), (*work.spxout) << "Error while reading file \"" << filename << "\"" << std::endl; )
1725  exit(1);
1726  }
1727 }
1728 
1729 //------------------------------------------------------------------------
1730 static
1731 void solve_LP(MySoPlex& work)
1732 {
1733  UserTimer timer;
1734  timer.start();
1735 
1736  if ( checkMode )
1737  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP26 solving LP" << std::endl; )
1738  else
1739  MSG_INFO1( (*work.spxout), (*work.spxout) << "\nSolving LP ..." << std::endl; )
1740 
1741  work.solve();
1742  timer.stop();
1743 
1744  MSG_INFO1( (*work.spxout), (*work.spxout) << "\nSoPlex statistics:\n" << work.statistics(); )
1745 }
1746 
1747 //------------------------------------------------------------------------
1748 static
1749 void print_solution_and_status(
1750  MySoPlex& work,
1751  const NameSet& rownames,
1752  const NameSet& colnames,
1753  const int precision,
1754  const bool print_quality,
1755  const bool print_solution,
1756  const bool print_dual,
1757  const bool write_basis,
1758  const char* basisname
1759  )
1760 {
1761  // get the solution status
1762  SPxSolver::Status stat = work.status();
1763 
1764  if ( ! checkMode )
1765  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl; )
1766  switch (stat)
1767  {
1768  case SPxSolver::OPTIMAL:
1769  if ( checkMode )
1770  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP29 solution value is: " << std::setprecision( precision ) << work.objValue() << std::endl; )
1771  else
1772  MSG_INFO1( (*work.spxout), (*work.spxout) << "Solution value is: " << std::setprecision( precision ) << work.objValue() << std::endl; )
1773 
1774  if ( print_quality )
1775  work.displayQuality();
1776 
1777  if ( print_solution )
1778  {
1779  DVector objx(work.nCols());
1780 
1781  if( work.getPrimal(objx) != SPxSolver::ERROR )
1782  {
1783  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl << "Primal solution (name, id, value):" << std::endl; )
1784  for( int i = 0; i < work.nCols(); ++i )
1785  {
1786  if ( isNotZero( objx[i], 0.001 * work.feastol() ) )
1787  MSG_INFO1( (*work.spxout), (*work.spxout) << colnames[ work.cId(i) ] << "\t"
1788  << i << "\t"
1789  << std::setw(17)
1790  << std::setprecision( precision )
1791  << objx[i] << std::endl; )
1792  }
1793  MSG_INFO1( (*work.spxout), (*work.spxout) << "All other variables are zero (within " << std::setprecision(1) << 0.001*work.feastol() << ")." << std::endl; )
1794  }
1795  }
1796  if ( print_dual )
1797  {
1798  DVector objy(work.nRows());
1799  bool allzero = true;
1800 
1801  if( work.getDual(objy) != SPxSolver::ERROR )
1802  {
1803  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl << "Dual multipliers (name, id, value):" << std::endl; )
1804  for( int i = 0; i < work.nRows(); ++i )
1805  {
1806  if ( isNotZero( objy[i] , 0.001 * work.opttol() ) )
1807  {
1808  MSG_INFO1( (*work.spxout), (*work.spxout) << rownames[ work.rId(i) ] << "\t"
1809  << i << "\t"
1810  << std::setw(17)
1811  << std::setprecision( precision )
1812  << objy[i] << std::endl; )
1813  allzero = false;
1814  }
1815  }
1816 
1817  MSG_INFO1( (*work.spxout), (*work.spxout) << "All " << (allzero ? "" : "other ") << "dual values are zero (within "
1818  << std::setprecision(1) << 0.001*work.opttol() << ")." << std::endl; )
1819 
1820  if( !allzero )
1821  {
1822  if( work.spxSense() == SPxLP::MINIMIZE )
1823  {
1824  MSG_INFO1( (*work.spxout), (*work.spxout) << "Minimizing: a positive/negative value corresponds to left-hand (>=) resp. right-hand (<=) side."
1825  << std::endl; )
1826  }
1827  else
1828  {
1829  MSG_INFO1( (*work.spxout), (*work.spxout) << "Maximizing: a positive/negative value corresponds to right-hand (<=) resp. left-hand (>=) side."
1830  << std::endl; )
1831  }
1832  }
1833  }
1834  }
1835  if ( write_basis )
1836  {
1837  MSG_INFO1( (*work.spxout), (*work.spxout) << "Writing basis of original problem to file " << basisname << std::endl; )
1838  if ( ! work.writeBasisFile( basisname, &rownames, &colnames ) )
1839  {
1840  if ( checkMode )
1841  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP30 error while writing file \"" << basisname << "\"" << std::endl; )
1842  else
1843  MSG_INFO1( (*work.spxout), (*work.spxout) << "Error while writing file \"" << basisname << "\"" << std::endl; )
1844  }
1845  }
1846  break;
1847  case SPxSolver::UNBOUNDED:
1848  if ( checkMode )
1849  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP31 LP is unbounded" << std::endl; )
1850  else
1851  MSG_INFO1( (*work.spxout), (*work.spxout) << "LP is unbounded" << std::endl; )
1852 
1853  if ( print_solution )
1854  {
1855  DVector objx(work.nCols());
1856  if( work.getPrimal(objx) != SPxSolver::ERROR )
1857  {
1858  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl << "Primal solution (name, id, value):" << std::endl; )
1859  for( int i = 0; i < work.nCols(); ++i )
1860  {
1861  if ( isNotZero( objx[i], 0.001 * work.feastol() ) )
1862  MSG_INFO1( (*work.spxout), (*work.spxout) << colnames[ work.cId(i) ] << "\t"
1863  << i << "\t"
1864  << std::setw(17)
1865  << std::setprecision( precision )
1866  << objx[i] << std::endl; )
1867  }
1868  MSG_INFO1( (*work.spxout), (*work.spxout) << "All other variables are zero (within " << std::setprecision(1) << 0.001*work.feastol() << ")." << std::endl; )
1869  }
1870 
1871  DVector objcoef(work.nCols());
1872  DVector ray(work.nCols());
1873  if( work.getPrimalray(ray) != SPxSolver::ERROR )
1874  {
1875  Real rayobjval = 0.0;
1876 
1877  work.getObj(objcoef);
1878 
1879  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl << "Primal ray (name, id, value):" << std::endl; )
1880  for( int i = 0; i < work.nCols(); ++i )
1881  {
1882  if ( isNotZero( ray[i], 0.001 * work.feastol() ) )
1883  {
1884  rayobjval += ray[i] * objcoef[i];
1885 
1886  MSG_INFO1( (*work.spxout), (*work.spxout) << colnames[ work.cId(i) ] << "\t"
1887  << i << "\t"
1888  << std::setw(17)
1889  << std::setprecision( precision )
1890  << ray[i] << std::endl; )
1891  }
1892  }
1893  MSG_INFO1( (*work.spxout), (*work.spxout) << "All other variables have zero value (within " << std::setprecision(1) << 0.001*work.feastol() << ")." << std::endl; )
1894  MSG_INFO1( (*work.spxout), (*work.spxout) << "Objective change per unit along primal ray is " << rayobjval << "." << std::endl; )
1895  }
1896  }
1897  break;
1898  case SPxSolver::INFEASIBLE:
1899  if ( checkMode )
1900  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP32 LP is infeasible" << std::endl; )
1901  else
1902  MSG_INFO1( (*work.spxout), (*work.spxout) << "LP is infeasible" << std::endl; )
1903  if ( print_solution )
1904  {
1905  DVector farkasx(work.nRows());
1906 
1907  if( work.getDualfarkas(farkasx) != SPxSolver::ERROR )
1908  {
1909  DVector proofvec(work.nCols());
1910  double lhs;
1911  double rhs;
1912 
1913  lhs = 0.0;
1914  rhs = 0.0;
1915  proofvec.clear();
1916  for( int i = 0; i < work.nRows(); ++i )
1917  {
1918  if ( isNotZero( farkasx[i], 0.001 * work.opttol() ) )
1919  {
1920  MSG_INFO1( (*work.spxout), (*work.spxout) << rownames[ work.rId(i) ] << "\t"
1921  << i << "\t"
1922  << std::setw(16)
1923  << std::setprecision( precision )
1924  << farkasx[i] << "\t"; )
1925  LPRow row;
1926  work.getRow(i, row);
1927  if( row.lhs() > -soplex::infinity )
1928  {
1929  MSG_INFO1( (*work.spxout), (*work.spxout) << row.lhs() << " <= "; );
1930  }
1931  for( int j = 0; j < row.rowVector().size(); ++j )
1932  {
1933  if( row.rowVector().value(j) > 0 )
1934  {
1935  MSG_INFO1( (*work.spxout), (*work.spxout) << "+"; )
1936  }
1937  MSG_INFO1( (*work.spxout), (*work.spxout)
1938  << row.rowVector().value(j) << " "
1939  << colnames[ work.cId(row.rowVector().index(j)) ]
1940  << " "; );
1941  }
1942  if( row.rhs() < soplex::infinity )
1943  {
1944  MSG_INFO1( (*work.spxout), (*work.spxout) << "<= " << row.rhs(); );
1945  }
1946  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl; )
1947  if( farkasx[i] > 0.0 )
1948  {
1949  lhs += farkasx[i] * row.lhs();
1950  rhs += farkasx[i] * row.rhs();
1951  }
1952  else
1953  {
1954  lhs += farkasx[i] * row.rhs();
1955  rhs += farkasx[i] * row.lhs();
1956  }
1957  SVector vec(row.rowVector());
1958  vec *= farkasx[i];
1959  proofvec += vec;
1960  }
1961  }
1962 
1963  MSG_INFO1( (*work.spxout), (*work.spxout) << "All other row multipliers are zero (within " << std::setprecision(1) << 0.001*work.opttol() << ")." << std::endl; )
1964  MSG_INFO1( (*work.spxout), (*work.spxout) << "Farkas infeasibility proof: \t"; )
1965  MSG_INFO1( (*work.spxout), (*work.spxout) << lhs << " <= "; )
1966 
1967  bool nonzerofound = false;
1968  for( int i = 0; i < work.nCols(); ++i )
1969  {
1970  if ( isNotZero( proofvec[i], 0.001 * work.opttol() ) )
1971  {
1972  if( proofvec[i] > 0 )
1973  {
1974  MSG_INFO1( (*work.spxout), (*work.spxout) << "+"; )
1975  }
1976  MSG_INFO1( (*work.spxout), (*work.spxout) << proofvec[i] << " " << colnames[ work.cId(i) ] << " "; )
1977  nonzerofound = true;
1978  }
1979  }
1980  if( !nonzerofound )
1981  {
1982  MSG_INFO1( (*work.spxout), (*work.spxout) << "0 "; );
1983  }
1984  MSG_INFO1( (*work.spxout), (*work.spxout) << "<= " << rhs << std::endl; );
1985  }
1986  }
1987  if ( print_quality )
1988  work.displayInfeasibility();
1989  if ( write_basis ) // write basis even if we are infeasible
1990  if ( ! work.writeBasisFile( basisname, &rownames, &colnames ) )
1991  {
1992  if ( checkMode )
1993  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP30 error while writing file \"" << basisname << "\"" << std::endl; )
1994  else
1995  MSG_INFO1( (*work.spxout), (*work.spxout) << "Error while writing file \"" << basisname << "\"" << std::endl; )
1996  }
1997  break;
1999  if ( checkMode )
2000  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP40 aborted due to cycling" << std::endl; )
2001  else
2002  MSG_INFO1( (*work.spxout), (*work.spxout) << "Aborted due to cycling" << std::endl; )
2003  break;
2004  case SPxSolver::ABORT_TIME:
2005  if ( checkMode )
2006  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP33 aborted due to time limit" << std::endl; )
2007  else
2008  MSG_INFO1( (*work.spxout), (*work.spxout) << "Aborted due to time limit" << std::endl; )
2009  break;
2010  case SPxSolver::ABORT_ITER:
2011  if ( checkMode )
2012  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP34 aborted due to iteration limit" << std::endl; )
2013  else
2014  MSG_INFO1( (*work.spxout), (*work.spxout) << "Aborted due to iteration limit" << std::endl; )
2015  break;
2017  if ( checkMode )
2018  MSG_INFO1( (*work.spxout), (*work.spxout) << "IEXAMP35 aborted due to objective value limit" << std::endl; )
2019  else
2020  MSG_INFO1( (*work.spxout), (*work.spxout) << "Aborted due to objective value limit" << std::endl; )
2021  break;
2022  case SPxSolver::SINGULAR:
2023  if ( checkMode )
2024  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP39 basis is singular" << std::endl; )
2025  else
2026  MSG_INFO1( (*work.spxout), (*work.spxout) << "Basis is singular" << std::endl; )
2027  break;
2028  default:
2029  if ( checkMode )
2030  MSG_INFO1( (*work.spxout), (*work.spxout) << "EEXAMP36 An error occurred during " << "the solution process" << std::endl; )
2031  else
2032  MSG_INFO1( (*work.spxout), (*work.spxout) << "An error occurred during " << "the solution process" << std::endl; )
2033  break;
2034  }
2035  MSG_INFO1( (*work.spxout), (*work.spxout) << std::endl; )
2036 }
2037 
2038 //------------------------------------------------------------------------
2039 static
2040 void clean_up(
2041  SPxScaler*& postscaler,
2042  SPxSimplifier*& simplifier,
2043  SPxStarter*& starter,
2044  SPxPricer*& pricer,
2045  SPxRatioTester*& ratiotester,
2046  char*& basisname
2047  )
2048 {
2049  if ( postscaler != 0 )
2050  {
2051  delete postscaler;
2052  postscaler = 0;
2053  }
2054  if ( simplifier != 0 )
2055  {
2056  delete simplifier;
2057  simplifier = 0;
2058  }
2059  if ( starter != 0 )
2060  {
2061  delete starter;
2062  starter = 0;
2063  }
2064 
2065  assert( pricer != 0 );
2066  delete pricer;
2067  pricer = 0;
2068 
2069  assert( ratiotester != 0 );
2070  delete ratiotester;
2071  ratiotester = 0;
2072 
2073  if ( basisname != 0 )
2074  delete [] basisname;
2075  basisname = 0;
2076 }
2077 
2078 //------------------------------------------------------------------------
2079 // main program
2080 //------------------------------------------------------------------------
2081 
2082 int main(int argc, char* argv[])
2083 {
2084  const char* filename;
2085  char* basisname = 0;
2089  SPxSimplifier* simplifier = 0;
2090  SPxStarter* starter = 0;
2091  SPxPricer* pricer = 0;
2092  SPxRatioTester* ratiotester = 0;
2093  SPxScaler* postscaler = 0;
2094 
2095  SPxOut spxout;
2096 
2097  try {
2098  NameSet rownames;
2099  NameSet colnames;
2100  int starting = 0;
2101  int pricing = 4;
2102  int ratiotest = 3;
2103  int scaling = 2;
2104  int simplifying = 1;
2105  int iterlimit = -1;
2106  Real timelimit = DEFAULT_INFINITY;
2107  Real delta = DEFAULT_BND_VIOL;
2108  Real feastol = DEFAULT_BND_VIOL;
2109  Real opttol = DEFAULT_BND_VIOL;
2110  Real epsilon = DEFAULT_EPS_ZERO;
2111  Real epsilon_factor = DEFAULT_EPS_FACTOR;
2112  Real epsilon_update = DEFAULT_EPS_UPDATE;
2113  int verbose = SPxOut::INFO1;
2114  bool print_solution = false;
2115  bool print_dual = false;
2116  bool print_quality = false;
2117  bool read_basis = false;
2118  bool write_basis = false;
2119  int precision;
2120  int optidx;
2121 
2122  for(optidx = 1; optidx < argc; optidx++)
2123  {
2124  if (*argv[optidx] != '-')
2125  break;
2126 
2127  switch(argv[optidx][1])
2128  {
2129  case 'b' :
2130  check_parameter(argv[optidx][2], argv); // use -b{r,w}, not -b
2131  if (argv[optidx][2] == 'r')
2132  read_basis = true;
2133  if (argv[optidx][2] == 'w')
2134  write_basis = true;
2135  break;
2136  case 'c' :
2137  check_parameter(argv[optidx][2], argv); // use -c[0-3], not -c
2138  starting = atoi(&argv[optidx][2]);
2139  break;
2140  case 'd' :
2141  check_parameter(argv[optidx][2], argv); // use -dx, not -d
2142  delta = atof(&argv[optidx][2]);
2143  break;
2144  case 'f' :
2145  check_parameter(argv[optidx][2], argv); // use -fx, not -f
2146  feastol = atof(&argv[optidx][2]);
2147  break;
2148  case 'o' :
2149  check_parameter(argv[optidx][2], argv); // use -ox, not -o
2150  opttol = atof(&argv[optidx][2]);
2151  break;
2152  case 'e':
2153  type = SPxSolver::ENTER;
2154  break;
2155  case 'g' :
2156  check_parameter(argv[optidx][2], argv); // use -g[0-5], not -g
2157  scaling = atoi(&argv[optidx][2]);
2158  break;
2159  case 'i' :
2160  update = SLUFactor::ETA;
2161  break;
2162  case 'l' :
2163  if (argv[optidx][2] == '\0' ) // use -lx, not -l
2164  print_usage_and_exit( argv );
2165  timelimit = atof(&argv[optidx][2]);
2166  break;
2167  case 'L' :
2168  if (argv[optidx][2] == '\0' ) // use -Lx, not -L
2169  print_usage_and_exit( argv );
2170  iterlimit = atoi(&argv[optidx][2]);
2171  break;
2172  case 'p' :
2173  check_parameter(argv[optidx][2], argv); // use -p[0-5], not -p
2174  pricing = atoi(&argv[optidx][2]);
2175  break;
2176  case 'q' :
2177  print_quality = true;
2178  break;
2179  case 'r' :
2180  representation = SPxSolver::ROW;
2181  break;
2182  case 's' :
2183  check_parameter(argv[optidx][2], argv); // use -s[0-4], not -s
2184  simplifying = atoi(&argv[optidx][2]);
2185  break;
2186  case 't' :
2187  check_parameter(argv[optidx][2], argv); // use -r[0-2], not -r
2188  ratiotest = atoi(&argv[optidx][2]);
2189  break;
2190  case 'v' :
2191  check_parameter(argv[optidx][2], argv); // use -v[0-5], not -v
2192  if (argv[optidx][2] >= '0' && argv[optidx][2] <= '9')
2193  verbose = argv[optidx][2] - '0';
2194  break;
2195  case 'V' :
2196  print_version_info();
2197  exit(0);
2198  case 'x' :
2199  print_solution = true;
2200  break;
2201  case 'y' :
2202  print_dual = true;
2203  break;
2204  case 'z' :
2205  check_parameter(argv[optidx][2], argv); // must not be empty
2206  check_parameter(argv[optidx][3], argv); // must not be empty
2207  switch(argv[optidx][2])
2208  {
2209  case 'z' :
2210  epsilon = atof(&argv[optidx][3]);
2211  break;
2212  case 'f' :
2213  epsilon_factor = atof(&argv[optidx][3]);
2214  break;
2215  case 'u' :
2216  epsilon_update = atof(&argv[optidx][3]);
2217  break;
2218  default :
2219  print_usage_and_exit( argv );
2220  }
2221  break;
2222  case 'C' :
2223  checkMode = true;
2224  break;
2225  case 'h' :
2226  case '?' :
2227  print_version_info();
2228  //lint -fallthrough
2229  default :
2230  print_usage_and_exit( argv );
2231  }
2232  }
2233 
2234  // print version
2235  print_version_info();
2236 
2237  // enough arguments?
2238  if ((argc - optidx) < 1 + (read_basis ? 1 : 0) + (write_basis ? 1 : 0))
2239  print_usage_and_exit( argv );
2240  filename = argv[optidx];
2241 
2242  ++optidx;
2243 
2244  // switch off simplifier when using a starting basis
2245  if ( read_basis )
2246  simplifying = 0;
2247 
2248  if ( read_basis || write_basis )
2249  basisname = strcpy( new char[strlen(argv[optidx]) + 1], argv[optidx] );
2250 
2251  // set some algorithm parameters
2252  Param::setEpsilon ( epsilon );
2253  Param::setEpsilonFactorization( epsilon_factor );
2254  Param::setEpsilonUpdate ( epsilon_update );
2255  spxout.setVerbosity ( (SPxOut::Verbosity) verbose );
2256 
2257  // Set the output precision.
2258  precision = int(-log10(MINIMUM(feastol, opttol))) + 1;
2259 
2260  std::cout.setf( std::ios::scientific | std::ios::showpoint );
2261  std::cerr.setf( std::ios::scientific | std::ios::showpoint );
2262 
2263 #ifdef SEND_ALL_OUTPUT_TO_FILES
2264  // Example of redirecting output to different files.
2265  // Default is cerr for errors and warnings, cout for everything else.
2266  std::ofstream myerrstream ( "errwarn.txt" );
2267  std::ofstream myinfostream( "infos.txt" );
2268  redirect_output(myerrstream, myinfostream);
2269 #endif
2270 
2271  // create an instance of MySoPlex
2272  MySoPlex work( spxout, type, representation );
2273  work.setOutstream ( spxout );
2274  work.setUtype ( update );
2275  work.setFeastol ( MINIMUM(feastol, delta) );
2276  work.setOpttol ( MINIMUM(opttol, delta) );
2277  work.setTerminationTime ( timelimit );
2278  work.setTerminationIter ( iterlimit );
2279  print_algorithm_parameters( work, representation, update );
2280  assert( work.isConsistent() );
2281 
2282  // set pricer, starter, simplifier, and ratio tester
2283  work.setPricer ( pricer = get_pricer (pricing, work.spxout) );
2284  work.setStarter ( starter = get_starter (starting, work.spxout) );
2285  work.setSimplifier( simplifier = get_simplifier (simplifying, work.spxout) );
2286  work.setTester ( ratiotester = get_ratio_tester(ratiotest, work.spxout) );
2287  assert(work.isConsistent());
2288 
2289  // set pre- and postscaler
2290  get_scalers(postscaler, scaling, work.spxout);
2291  work.setPostScaler(postscaler);
2292  assert(work.isConsistent());
2293 
2294  // read the LP from an input file (.lp or .mps)
2295  read_input_file(work, filename, rownames, colnames);
2296 
2297  // read a basis file if specified
2298  if (read_basis)
2299  read_basis_file(work, basisname, &rownames, &colnames);
2300 
2301  // solve the LP
2302  solve_LP(work);
2303 
2304  // print solution, status, infeasibility system,...
2305  print_solution_and_status(work, rownames, colnames, precision, print_quality,
2306  print_solution, print_dual, write_basis, basisname);
2307 
2308  // clean up
2309  clean_up(postscaler, simplifier, starter, pricer, ratiotester, basisname);
2310 
2311  return 0;
2312  }
2313  catch( const SPxException& x )
2314  {
2315  std::cout << "exception caught : " << x.what() << std::endl;
2316  delete [] basisname;
2317  if (simplifier)
2318  delete simplifier;
2319  delete starter;
2320  delete pricer;
2321  delete ratiotester;
2322  delete postscaler;
2323  }
2324 }
2325 #endif
Fast shifting ratio test.
bool isNotZero(Real a, Real eps=Param::epsilon())
returns true iff |a| > eps
Definition: spxdefines.h:422
virtual void setStream(const Verbosity &verbosity, std::ostream &stream)
Sets the stream for the specified verbosity level.
Definition: spxout.h:150
UpdateType
Specifies how to perform change method.
Definition: slufactor.h:49
Bound flipping ratio test ("long step dual") for SoPlex.Class SPxBoundFlippingRT provides an implemen...
#define DEFAULT_EPS_FACTOR
Definition: spxdefines.h:233
void printVersion() const
prints version and compilation options
Definition: soplex.cpp:6856
bool getDualViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of dual multipliers; returns true on success
Definition: soplex.cpp:3558
#define EGlpNumStart()
Definition: soplexmain.cpp:40
int numRowsReal() const
returns number of rows
Definition: soplex.cpp:797
static void setEpsilon(Real eps)
Definition: spxdefines.cpp:50
Devex pricer.The Devex Pricer for SoPlex implements an approximate steepest edge pricing, that does without solving an extra linear system and computing the scalar products.
Definition: spxdevexpr.h:43
#define DEFAULT_BND_VIOL
default allowed bound violation
Definition: spxdefines.h:226
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
Type
Algorithmic type.
Definition: spxsolver.h:124
type of ratio test
Definition: soplex.h:980
Steepest edge pricer.Class SPxSteepExPR implements a steepest edge pricer to be used with SoPlex...
Definition: spxsteepexpr.h:40
Geometric mean row/column scaling.This SPxScaler implementation performs geometric mean scaling of th...
Definition: spxgeometsc.h:35
verbosity level
Definition: soplex.h:965
apply standard floating-point algorithm
Definition: soplex.h:1209
Abstract pricer base class.
bool getPrimalReal(VectorReal &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:2973
int numRowsRational() const
returns number of rows
Definition: soplex.cpp:1089
bool writeDualFileReal(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *intvars=0) const
writes the dual of the real LP to file; LP or MPS format is chosen from the extension in filename; if...
Definition: soplex.cpp:5181
bool getDualRational(VectorRational &vector)
gets the dual solution vector if available; returns true on success
Definition: soplex.cpp:3328
Solution vector based start basis.
time limit in seconds (INFTY if unlimited)
Definition: soplex.h:1295
mode for iterative refinement strategy
Definition: soplex.h:989
Representation
LP basis representation.
Definition: spxsolver.h:105
virtual ~SoPlex()
destructor
Definition: soplex.cpp:756
bool getRedCostRational(VectorRational &vector)
gets the vector of reduced cost values if available; returns true on success
Definition: soplex.cpp:3343
LP geometric mean scaling.
primal feasibility tolerance
Definition: soplex.h:1274
virtual ~Timer()
Definition: timer.h:124
bool writeBasisFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const bool cpxFormat=false) const
writes basis information to filename; if rowNames and colNames are NULL, default names are used; retu...
Definition: soplex.cpp:5389
Abstract ratio test base class.
solve() aborted due to iteration limit.
Definition: spxsolver.h:213
#define SOPLEX_VERSION
Definition: spxdefines.h:45
bool readBasisFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0)
reads basis information from filename and returns true on success; if rowNames and colNames are NULL...
Definition: soplex.cpp:5196
mode for reading LP files
Definition: soplex.h:986
mode for synchronizing real and rational LP
Definition: soplex.h:983
bool getDualFarkasReal(VectorReal &vector)
gets the Farkas proof if available; returns true on success
Definition: soplex.cpp:3048
automatic sync of real and rational LP
Definition: soplex.h:1189
iteration limit (-1 if unlimited)
Definition: soplex.h:953
Implementation of Sparse Linear Solver.
Abstract ratio test base class.Class SPxRatioTester is the virtual base class for computing the ratio...
bool getRowViolationReal(Real &maxviol, Real &sumviol)
gets violation of constraints; returns true on success
Definition: soplex.cpp:3102
bool getRowViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of constraints; returns true on success
Definition: soplex.cpp:3424
#define DEFAULT_INFINITY
Definition: spxdefines.h:241
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxstarter.h:41
bool updateExternalSolution(char *solution)
updates the external solution used for validation
Definition: validation.cpp:25
#define DEFAULT_EPS_UPDATE
Definition: spxdefines.h:236
LP has been proven to be primal infeasible.
Definition: spxsolver.h:222
Dantzig pricer.
General methods in LP preprocessing.
bool readFile(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and integer variables if desired; returns true on success
Definition: soplex.cpp:5118
int intParam(const IntParam param) const
returns integer parameter value
Definition: soplex.cpp:5538
Wrapper for GMP type mpq_class.We wrap mpq_class so that we can replace it by a double type if GMP is...
Definition: rational.h:45
static void disableListMem()
disables list memory
Definition: rational.cpp:3067
Devex pricer.
void printStatistics(std::ostream &os)
prints complete statistics
Definition: soplex.cpp:6767
std::ostream & getStream(const Verbosity &verbosity) const
Returns the stream for the specified verbosity level.
Definition: spxout.h:157
rowwise representation.
Definition: spxsolver.h:107
TimerFactory class.
LP simplification base class.
virtual const std::string what() const
returns exception message
Definition: exceptions.h:57
bool isDualFeasible() const
is stored dual solution feasible?
Definition: soplex.cpp:2928
Partial multiple pricing.Class SPxParMultPr is an implementation class for SPxPricer implementing Dan...
Definition: spxparmultpr.h:47
Wrapper for different output streams and verbosity levels.
SPxSolver::Status optimize()
optimize the given LP
Definition: soplex.cpp:2801
Steepest edge pricer.
virtual void start()=0
start timer, resume accounting user, system and real time.
Entering Simplex.
Definition: spxsolver.h:134
virtual Real stop()=0
stop timer, return accounted user time.
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:48
#define EGlpNumClear()
Definition: soplexmain.cpp:41
Fast shifting ratio test.Class SPxFastRT is an implementation class of SPxRatioTester providing fast ...
Definition: spxfastrt.h:41
Leaving Simplex.
Definition: spxsolver.h:143
standard floating-point parsing
Definition: soplex.h:1199
bool isPrimalFeasible() const
is stored primal solution feasible?
Definition: soplex.cpp:2904
type of scaler
Definition: soplex.h:971
double Real
Definition: spxdefines.h:218
Weighted pricing.Class SPxWeightPR is an implemantation class of SPxPricer that uses weights for colu...
Definition: spxweightpr.h:41
int main(int argc, char *argv[])
runs SoPlex command line
Definition: soplexmain.cpp:468
bool getPrimalRayReal(VectorReal &vector)
gets the primal ray if available; returns true on success
Definition: soplex.cpp:3003
bool hasPrimal() const
is a primal feasible solution available?
Definition: soplex.cpp:2912
static void printUsage(const char *const argv[], int idx)
Definition: soplexmain.cpp:51
virtual const char * getName() const
get name of simplifier.
void validateSolveReal(SoPlex &soplex)
validates the soplex solution using the external solution
Definition: validation.cpp:63
LP simplification abstract base class.Instances of classes derived from SPxSimplifier may be loaded t...
Definition: spxsimplifier.h:41
LP has been solved to optimality.
Definition: spxsolver.h:220
bool hasBasis() const
is an advanced starting basis available?
Definition: soplex.cpp:3848
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Definition: spxdefines.h:114
bool getDualViolationReal(Real &maxviol, Real &sumviol)
gets violation of dual multipliers; returns true on success
Definition: soplex.cpp:3198
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition: spxout.h:63
virtual Real time() const
Definition: usertimer.cpp:100
solve() aborted due to time limit.
Definition: spxsolver.h:212
main LP solver class
an error occured.
Definition: spxsolver.h:204
#define DEFAULT_EPS_ZERO
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Definition: spxdefines.h:230
virtual void setVerbosity(const Verbosity &v)
Definition: spxout.h:111
type of simplifier
Definition: soplex.h:968
static Real epsilonUpdate()
Definition: spxdefines.cpp:65
void printUserSettings()
print non-default parameter values
Definition: soplex.cpp:6217
static void checkSolutionRational(SoPlex &soplex)
performs external feasibility check with rational type
Definition: soplexmain.cpp:196
static void printPrimalSolution(SoPlex &soplex, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false)
Definition: soplexmain.cpp:266
#define MINIMUM(x, y)
Definition: spxdefines.h:247
int numColsRational() const
returns number of columns
Definition: soplex.cpp:1098
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:46
bool getPrimalRational(VectorRational &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:3283
Solution vector based start basis.This version of SPxWeightST can be used to construct a starting bas...
Definition: spxvectorst.h:44
virtual Real stop()
stop timer, return accounted user time.
Definition: usertimer.cpp:86
bool getRedCostReal(VectorReal &vector)
gets the vector of reduced cost values if available; returns true on success
Definition: soplex.cpp:3033
Real realParam(const RealParam param) const
returns real parameter value
Definition: soplex.cpp:5548
virtual Real time() const =0
Simple heuristic SPxStarter.
user sync of real and rational LP
Definition: soplex.h:1192
bool hasDual() const
is a dual feasible solution available?
Definition: soplex.cpp:2936
bool parseSettingsString(char *line)
parses one setting string and returns true on success; note that string is modified ...
Definition: soplex.cpp:6410
SPxOut spxout
Definition: soplex.h:1444
virtual void start()
start timer, resume accounting user, system and real time.
Definition: usertimer.cpp:72
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:43
static void printDualSolution(SoPlex &soplex, NameSet &colnames, NameSet &rownames, bool real=true, bool rational=false)
Definition: soplexmain.cpp:356
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
Definition: lprowbase.h:45
virtual const char * getName() const
get name of ratio tester.
Preconfigured SoPlex LP solver.
Bound flipping ratio test (long step dual) for SoPlex.
Debugging, floating point type and parameter definitions.
static Real epsilon()
Definition: spxdefines.cpp:45
virtual const char * getName() const
get name of scaler
Definition: spxscaler.cpp:100
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
LP least squares scaling.
Hybrid pricer.The hybrid pricer for SoPlex tries to guess the best pricing strategy to use for pricin...
Definition: spxhybridpr.h:43
bool validate
should the soplex solution be validated?
Definition: validation.h:32
Exception base class.This class implements a base class for our SoPlex exceptions We provide a what()...
Definition: exceptions.h:32
Everything should be within this namespace.
bool setRealParam(const RealParam param, const Real value, const bool init=true)
sets real parameter value; returns true on success
Definition: soplex.cpp:5986
Timer class.
returns the current git hash of SoPlex
bool loadSettingsFile(const char *filename)
reads settings file; returns true on success
Definition: soplex.cpp:6361
int numNonzerosReal() const
returns number of nonzeros
Definition: soplex.cpp:815
Dantzig pricer.Class SPxDantzigPR is an implementation class of an SPxPricer implementing Dantzig&#39;s d...
Definition: spxdantzigpr.h:38
bool getRedCostViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of reduced costs; returns true on success
Definition: soplex.cpp:3477
Harris pricing with shifting.
solve() aborted due to detection of cycling.
Definition: spxsolver.h:211
Weighted start basis.
type of pricer
Definition: soplex.h:977
bool getDualReal(VectorReal &vector)
gets the dual solution vector if available; returns true on success
Definition: soplex.cpp:3018
static void checkSolution(SoPlex &soplex)
performs external feasibility check according to check mode
Definition: soplexmain.cpp:249
Steepest edge pricer with exact initialization of weights.
Preconfigured SoPlex LP-solver.
Definition: soplex.h:90
#define MSG_WARNING(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::WARNING.
Definition: spxdefines.h:116
virtual const char * getName() const
get name of pricer.
Definition: spxpricer.h:104
LP scaling base class.
std::streamsize precision() const
Definition: spxout.h:139
static void setEpsilonUpdate(Real eps)
Definition: spxdefines.cpp:70
bool getBoundViolationReal(Real &maxviol, Real &sumviol)
gets violation of bounds; returns true on success
Definition: soplex.cpp:3063
bool writeFileReal(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *intvars=0, const bool unscale=true) const
writes real LP to file; LP or MPS format is chosen from the extension in filename; if rowNames and co...
Definition: soplex.cpp:5136
Simple heuristic SPxStarter.Testing version of an SPxVectorST using a very simplistic heuristic to bu...
Definition: spxsumst.h:37
Weighted start basis.Class SPxWeightST is an implementation of a SPxStarter for generating a Simplex ...
Definition: spxweightst.h:56
decide according to READMODE
Definition: soplex.h:1225
const char * getGitHash()
Definition: spxgithash.cpp:23
mode for a posteriori feasibility checks
Definition: soplex.h:992
Partial multiple pricing.
Verbosity
Verbosity level.
Definition: spxout.h:72
~Validation()
default destructor
Definition: validation.h:49
Textbook ratio test for SoPlex.Class SPxDefaultRT provides an implementation of the textbook ratio te...
Definition: spxdefaultrt.h:42
void clear()
Set vector to 0.
Definition: vectorbase.h:260
bool getDualFarkasRational(VectorRational &vector)
gets the Farkas proof if LP is infeasible; returns true on success
Definition: soplex.cpp:3358
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
Definition: spxscaler.h:76
virtual const char * getName() const
get name of starter.
Definition: spxstarter.h:88
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:118
Validation object for soplex solutions.
bool getRedCostViolationReal(Real &maxviol, Real &sumviol)
gets violation of reduced costs; returns true on success
Definition: soplex.cpp:3144
#define SOPLEX_SUBVERSION
Definition: spxdefines.h:46
static void freeStrings(char *&s1, char *&s2, char *&s3, char *&s4, char *&s5)
Definition: soplexmain.cpp:106
static void setEpsilonFactorization(Real eps)
Definition: spxdefines.cpp:60
#define SOPLEX_COPYRIGHT
Definition: spxdefines.h:48
bool getPrimalRayRational(VectorRational &vector)
gets the primal ray if LP is unbounded; returns true on success
Definition: soplex.cpp:3313
dual feasibility tolerance
Definition: soplex.h:1277
Hybrid pricer.
bool setIntParam(const IntParam param, const int value, const bool init=true)
sets integer parameter value; returns true on success
Definition: soplex.cpp:5632
bool saveSettingsFile(const char *filename, const bool onlyChanged=false) const
writes settings file; returns true on success
Definition: soplex.cpp:6276
static void checkSolutionReal(SoPlex &soplex)
performs external feasibility check with real type
Definition: soplexmain.cpp:138
std::string rationalToString(const Rational &r, const int precision)
convert rational number to string
Definition: rational.cpp:3452
Textbook ratio test for SoPlex.
static Real epsilonFactorization()
Definition: spxdefines.cpp:55
LP equilibrium scaling.
bool updateValidationTolerance(char *tolerance)
updates the tolerance used for validation
Definition: validation.cpp:49
Equilibrium row/column scaling.This SPxScaler implementation performs equilibrium scaling of the LPs ...
Definition: spxequilisc.h:35
int numColsReal() const
returns number of columns
Definition: soplex.cpp:806
Wrapper for the system time query methods.
Definition: timer.h:76
Weighted pricing.
solve() aborted due to objective limit.
Definition: spxsolver.h:214
columnwise representation.
Definition: spxsolver.h:108
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:109
Basis is singular, numerical troubles?
Definition: spxsolver.h:215
Steepest edge pricer.Class SPxSteepPR implements a steepest edge pricer to be used with SoPlex...
Definition: spxsteeppr.h:41
Harris pricing with shifting.Class SPxHarrisRT is a stable implementation of a SPxRatioTester class a...
Definition: spxharrisrt.h:40
bool getBoundViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of bounds; returns true on success
Definition: soplex.cpp:3373
LP simplifier for removing uneccessary row/columns.This SPxSimplifier is mainly based on the paper "P...
Definition: spxmainsm.h:60
LP has been proven to be primal unbounded.
Definition: spxsolver.h:221