Scippy

SoPlex

Sequential object-oriented simPlex

spxsolve.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 #include <assert.h>
17 #include <iostream>
18 
19 #include "spxdefines.h"
20 #include "rational.h"
21 #include "spxsolver.h"
22 #include "spxpricer.h"
23 #include "spxratiotester.h"
24 #include "spxdefaultrt.h"
25 #include "spxstarter.h"
26 #include "spxout.h"
27 
28 #define MAXCYCLES 400
29 #define MAXSTALLS 10000
30 #define MAXSTALLRECOVERS 10
31 #define MAXREFACPIVOTS 10
32 
33 namespace soplex
34 {
35 
36 /**@todo check separately for ENTER and LEAVE algorithm */
37 bool SPxSolver::precisionReached(Real& newpricertol) const
38 {
39  Real maxViolRedCost;
40  Real sumViolRedCost;
41  Real maxViolBounds;
42  Real sumViolBounds;
43  Real maxViolConst;
44  Real sumViolConst;
45 
46  qualRedCostViolation(maxViolRedCost, sumViolRedCost);
47  qualBoundViolation(maxViolBounds, sumViolBounds);
48  qualConstraintViolation(maxViolConst, sumViolConst);
49 
50  // is the solution good enough ?
51  bool reached = maxViolRedCost < opttol() && maxViolBounds < feastol() && maxViolConst < feastol();
52 
53  if (!reached)
54  {
55  newpricertol = thepricer->epsilon() / 10.0;
56 
57  MSG_INFO3( (*spxout), (*spxout) << "Precision not reached: Pricer tolerance = "
58  << thepricer->epsilon()
59  << " new tolerance = " << newpricertol
60  << std::endl
61  << " maxViolRedCost= " << maxViolRedCost
62  << " maxViolBounds= " << maxViolBounds
63  << " maxViolConst= " << maxViolConst
64  << std::endl
65  << " sumViolRedCost= " << sumViolRedCost
66  << " sumViolBounds= " << sumViolBounds
67  << " sumViolConst= " << sumViolConst
68  << std::endl; );
69  }
70  return reached;
71 }
72 
74 {
75 
76  SPxId enterId;
77  int leaveNum;
78  int loopCount = 0;
79  Real minShift = infinity;
80  int cycleCount = 0;
81  bool priced = false;
82  Real lastDelta = 1;
83 
84  /* store the last (primal or dual) feasible objective value to recover/abort in case of stalling */
85  Real stallRefValue;
86  Real stallRefShift;
87  int stallRefIter;
88  int stallNumRecovers;
89 
90  if (dim() <= 0 && coDim() <= 0) // no problem loaded
91  {
93  throw SPxStatusException("XSOLVE01 No Problem loaded");
94  }
95 
96  if (slinSolver() == 0) // linear system solver is required.
97  {
99  throw SPxStatusException("XSOLVE02 No Solver loaded");
100  }
101  if (thepricer == 0) // pricer is required.
102  {
104  throw SPxStatusException("XSOLVE03 No Pricer loaded");
105  }
106  if (theratiotester == 0) // ratiotester is required.
107  {
109  throw SPxStatusException("XSOLVE04 No RatioTester loaded");
110  }
111  theTime->reset();
112  theTime->start();
113 
114  m_numCycle = 0;
115  iterCount = 0;
116  lastIterCount = 0;
117  iterDegenCheck = 0;
118  if (!isInitialized())
119  {
120  /*
121  if(SPxBasis::status() <= NO_PROBLEM)
122  SPxBasis::load(this);
123  */
124  /**@todo != REGULAR is not enough. Also OPTIMAL/DUAL/PRIMAL should
125  * be tested and acted accordingly.
126  */
127  if (thestarter != 0 && status() != REGULAR) // no basis and no starter.
128  thestarter->generate(*this); // generate start basis.
129 
130  init();
131 
132  // Inna/Tobi: init might fail, if the basis is singular
133  if( !isInitialized() )
134  {
136  m_status = UNKNOWN;
137  return status();
138  }
139  }
140 
141  //setType(type());
142 
143  if (!matrixIsSetup)
144  SPxBasis::load(this);
145 
146  //factorized = false;
147 
148  assert(thepricer->solver() == this);
149  assert(theratiotester->solver() == this);
150 
151  // maybe this should be done in init() ?
152  thepricer->setType(type());
154 
155  MSG_INFO3( (*spxout),
156  (*spxout) << "starting value = " << value() << std::endl
157  << "starting shift = " << shift() << std::endl;
158  )
159 
162 
163  m_status = RUNNING;
164  bool stop = terminate();
165  leaveCount = 0;
166  enterCount = 0;
167  primalCount = 0;
168  polishCount = 0;
169  boundflips = 0;
170  totalboundflips = 0;
171  enterCycles = 0;
172  leaveCycles = 0;
173  primalDegenSum = 0;
174  dualDegenSum = 0;
175 
176  stallNumRecovers = 0;
177 
178  /* if we run into a singular basis, we will retry from regulardesc with tighter tolerance in the ratio test */
179  SPxSolver::Type tightenedtype = type();
180  bool tightened = false;
181 
182  while (!stop)
183  {
184  const SPxBasis::Desc regulardesc = desc();
185 
186  // we need to reset these pointers to avoid unnecessary/wrong solves in leave() or enter()
187  solveVector2 = 0;
188  solveVector3 = 0;
189  coSolveVector2 = 0;
190  coSolveVector3 = 0;
191 
192  updateViols.clear();
194 
195  try
196  {
197 
198  if (type() == ENTER)
199  {
201 
202  int enterCycleCount = 0;
203  int enterFacPivotCount = 0;
204 
205  instableEnterVal = 0;
207  instableEnter = false;
208 
209  stallRefIter = iteration()-1;
210  stallRefShift = shift();
211  stallRefValue = value();
212 
213  /* in the entering algorithm, entertol() should be maintained by the ratio test and leavetol() should be
214  * reached by the pricer
215  */
216  Real maxpricertol = leavetol();
217  Real minpricertol = 0.01 * maxpricertol;
218 
219  thepricer->setEpsilon(maxpricertol);
220  priced = false;
221 
222  // to avoid shifts we restrict tolerances in the ratio test
223  if( loopCount > 0 )
224  {
225  lastDelta = (lastDelta < entertol()) ? lastDelta : entertol();
226  lastDelta *= 0.01;
227  theratiotester->setDelta(lastDelta);
228  assert(theratiotester->getDelta() > 0);
229  MSG_DEBUG( std::cout << "decreased delta for ratiotest to: " << theratiotester->getDelta() << std::endl; )
230  }
231  else
232  {
233  lastDelta = 1;
235  }
236 
237  printDisplayLine(true);
238  do
239  {
241 
242  enterId = thepricer->selectEnter();
243 
244  if (!enterId.isValid() && instableEnterId.isValid() && lastUpdate() == 0)
245  {
246  /* no entering variable was found, but because of valid instableEnterId we know
247  that this is due to the scaling of the test values. Thus, we use
248  instableEnterId and SPxFastRT::selectEnter shall accept even an instable
249  leaving variable. */
250  MSG_INFO3( (*spxout), (*spxout) << " --- trying instable enter iteration" << std::endl; )
251 
252  enterId = instableEnterId;
253  instableEnter = true;
254  // we also need to reset the test() or coTest() value for getEnterVals()
255  assert(instableEnterVal < 0);
256  if( enterId.isSPxColId() )
257  {
258  int idx = number(SPxColId(enterId));
259  if( rep() == COLUMN )
260  {
261  theTest[idx] = instableEnterVal;
263  {
266  }
267  if( hyperPricingEnter )
268  updateViolsCo.addIdx(idx);
269  }
270  else
271  {
274  {
275  infeasibilities.addIdx(idx);
277  }
278  if( hyperPricingEnter )
279  updateViols.addIdx(idx);
280  }
281  }
282  else
283  {
284  int idx = number(SPxRowId(enterId));
285  if( rep() == COLUMN )
286  {
289  {
290  infeasibilities.addIdx(idx);
292  }
293  if( hyperPricingEnter )
294  updateViols.addIdx(idx);
295  }
296  else
297  {
298  theTest[idx] = instableEnterVal;
300  {
303  }
304  if( hyperPricingEnter )
305  updateViolsCo.addIdx(idx);
306  }
307  }
308  }
309  else
310  {
311  instableEnter = false;
312  }
313 
314  if (!enterId.isValid())
315  {
316  // we are not infeasible and have no shift
317  if ( shift() <= epsilon()
321  {
322  Real newpricertol = minpricertol;
323 
324  MSG_INFO2( (*spxout), (*spxout) << " --- checking feasibility and optimality\n")
325  computeTest();
326  computeCoTest();
327 
328  // is the solution good enough ?
329  // max three times reduced
330  if ((thepricer->epsilon() > minpricertol) && !precisionReached(newpricertol))
331  { // no!
332  // we reduce the pricer tolerance. Note that if the pricer does not find a candiate
333  // with the reduced tolerance, we quit, regardless of the violations.
334  if (newpricertol < minpricertol)
335  newpricertol = minpricertol;
336 
337  thepricer->setEpsilon(newpricertol);
338 
339  MSG_INFO2( (*spxout), (*spxout) << " --- setting pricer tolerance to "
340  << thepricer->epsilon()
341  << std::endl; )
342  }
343  // solution seems good, no check whether we are precise enough
344  else if (lastUpdate() == 0)
345  {
346  priced = true;
347  break;
348  }
349  // We have an iterationlimit and everything looks good? Then stop!
350  // 6 is just a number picked.
351  else if (!(instableEnterId.isValid()) && maxIters > 0 && lastUpdate() < 6)
352  {
353  priced = true;
354  break;
355  }
356  }
357  MSG_INFO3( (*spxout), (*spxout) << " --- solve(enter) triggers refactorization" << std::endl; )
358 
359  // if the factorization is not fresh, we better refactorize and call the pricer again; however, this can
360  // create cycling, so it is performed only a limited number of times per ENTER round
361  if( lastUpdate() > 0 && enterFacPivotCount < MAXREFACPIVOTS )
362  {
363  factorize();
364 
365  // if the factorization was found out to be singular, we have to quit
367  {
368  MSG_INFO1( (*spxout), (*spxout) << "Something wrong with factorization, Basis status: " << SPxBasis::status() << std::endl; )
369  stop = true;
370  break;
371  }
372 
373  // call pricer again
374  enterId = thepricer->selectEnter();
375 
376  // count how often the pricer has found something only after refactorizing
377  if( enterId.isValid() )
378  enterFacPivotCount++;
379  }
380 
381  if( !enterId.isValid() )
382  {
383  priced = true;
384  break;
385  }
386  }
387 
388  /* check if we have iterations left */
389  if (maxIters >= 0 && iterations() >= maxIters)
390  {
391  MSG_INFO2( (*spxout), (*spxout) << " --- maximum number of iterations (" << maxIters
392  << ") reached" << std::endl; )
394  stop = true;
395  break;
396  }
397 
398  enter(enterId);
399  assert((testBounds(), 1));
401  stop = terminate();
402  clearUpdateVecs();
403 
404  /* if a successful pivot was performed or a nonbasic variable was flipped to its other bound, we reset the
405  * cycle counter
406  */
407  if( lastEntered().isValid() )
408  enterCycleCount = 0;
409  else if( basis().status() != SPxBasis::INFEASIBLE )
410  {
411  enterCycleCount++;
412  if( enterCycleCount > MAXCYCLES )
413  {
414  MSG_INFO2( (*spxout), (*spxout) << " --- abort solving due to cycling in "
415  << "entering algorithm" << std::endl; );
417  stop = true;
418  }
419  }
420 
421  /* only if the basis has really changed, we increase the iterations counter; this is not the case when only
422  * a nonbasic variable was flipped to its other bound
423  */
424  if( lastIndex() >= 0 )
425  {
426  enterCount++;
427  assert(lastEntered().isValid());
428  }
429 
430  /* check every MAXSTALLS iterations whether shift and objective value have not changed */
431  if( (iteration() - stallRefIter) % MAXSTALLS == 0 && basis().status() != SPxBasis::INFEASIBLE )
432  {
433  if( spxAbs(value() - stallRefValue) <= epsilon() && spxAbs(shift() - stallRefShift) <= epsilon() )
434  {
435  if( stallNumRecovers < MAXSTALLRECOVERS )
436  {
437  /* try to recover by unshifting/switching algorithm up to MAXSTALLRECOVERS times (just a number picked) */
438  MSG_INFO3( (*spxout), (*spxout) << " --- stalling detected - trying to recover by switching to LEAVING algorithm." << std::endl; )
439 
440  ++stallNumRecovers;
441  break;
442  }
443  else
444  {
445  /* giving up */
446  MSG_INFO2( (*spxout), (*spxout) << " --- abort solving due to stalling in entering algorithm." << std::endl; );
447 
449  stop = true;
450  }
451  }
452  else
453  {
454  /* merely update reference values */
455  stallRefIter = iteration()-1;
456  stallRefShift = shift();
457  stallRefValue = value();
458  }
459  }
460 
461  //@ assert(isConsistent());
462  }
463  while (!stop);
464 
465  MSG_INFO3( (*spxout),
466  (*spxout) << " --- enter finished. iteration: " << iteration()
467  << ", value: " << value()
468  << ", shift: " << shift()
469  << ", epsilon: " << epsilon()
470  << ", feastol: " << feastol()
471  << ", opttol: " << opttol()
472  << std::endl
473  << "ISOLVE56 stop: " << stop
474  << ", basis status: " << SPxBasis::status() << " (" << int(SPxBasis::status()) << ")"
475  << ", solver status: " << m_status << " (" << int(m_status) << ")" << std::endl;
476  )
477 
478  if (!stop)
479  {
480  /**@todo technically it would be ok to finish already when (priced && maxinfeas + shift() <= entertol()) is
481  * satisfied; maybe at least in the case when SoPlex keeps jumping back between ENTER and LEAVE always
482  * shifting (looping), we may relax this condition here;
483  * note also that unShift may increase shift() slightly due to roundoff errors
484  */
485  if (shift() <= epsilon())
486  {
487  // factorize();
488  unShift();
489 
490  Real maxinfeas = maxInfeas();
491 
492  MSG_INFO3( (*spxout),
493  (*spxout) << " --- maxInfeas: " << maxinfeas
494  << ", shift: " << shift()
495  << ", entertol: " << entertol() << std::endl;
496  )
497 
498  if (priced && maxinfeas + shift() <= entertol())
499  {
501  m_status = OPTIMAL;
502  break;
503  }
504  }
505  setType(LEAVE);
506  init();
507  thepricer->setType(type());
509  }
510  }
511  else
512  {
513  assert(type() == LEAVE);
514 
516 
517  int leaveCycleCount = 0;
518  int leaveFacPivotCount = 0;
519 
520  instableLeaveNum = -1;
521  instableLeave = false;
522  instableLeaveVal = 0;
523 
524  stallRefIter = iteration()-1;
525  stallRefShift = shift();
526  stallRefValue = value();
527 
528  /* in the leaving algorithm, leavetol() should be maintained by the ratio test and entertol() should be reached
529  * by the pricer
530  */
531  Real maxpricertol = entertol();
532  Real minpricertol = 0.01 * maxpricertol;
533 
534  thepricer->setEpsilon(maxpricertol);
535  priced = false;
536 
537  // to avoid shifts we restrict tolerances in the ratio test
538  if( loopCount > 0 )
539  {
540  lastDelta = (lastDelta < leavetol()) ? lastDelta : leavetol();
541  lastDelta *= 0.01;
542  theratiotester->setDelta(lastDelta);
543  assert(theratiotester->getDelta() > 0);
544  MSG_DEBUG( std::cout << "decreased delta for ratiotest to: " << theratiotester->getDelta() << std::endl; )
545  }
546  else
547  {
548  lastDelta = 1;
550  }
551 
552  printDisplayLine(true);
553  do
554  {
556 
557  leaveNum = thepricer->selectLeave();
558 
559  if (leaveNum < 0 && instableLeaveNum >= 0 && lastUpdate() == 0)
560  {
561  /* no leaving variable was found, but because of instableLeaveNum >= 0 we know
562  that this is due to the scaling of theCoTest[...]. Thus, we use
563  instableLeaveNum and SPxFastRT::selectEnter shall accept even an instable
564  entering variable. */
565  MSG_INFO3( (*spxout),
566  (*spxout) << " --- trying instable leave iteration" << std::endl;
567  )
568 
569  leaveNum = instableLeaveNum;
570  instableLeave = true;
571  // we also need to reset the fTest() value for getLeaveVals()
572  assert(instableLeaveVal < 0);
574 
575  if ( sparsePricingLeave )
576  {
578  {
581  }
582  if( hyperPricingLeave )
584  }
585  }
586  else
587  {
588  instableLeave = false;
589  }
590 
591  if (leaveNum < 0)
592  {
593  // we are not infeasible and have no shift
594  if ( shift() <= epsilon()
598  {
599  Real newpricertol = minpricertol;
600 
601  MSG_INFO2( (*spxout), (*spxout) << " --- checking feasibility and optimality\n")
602  computeFtest();
603 
604  // is the solution good enough ?
605  // max three times reduced
606  if ((thepricer->epsilon() > minpricertol) && !precisionReached(newpricertol))
607  { // no
608  // we reduce the pricer tolerance. Note that if the pricer does not find a candiate
609  // with the reduced pricer tolerance, we quit, regardless of the violations.
610  if (newpricertol < minpricertol)
611  newpricertol = minpricertol;
612 
613  thepricer->setEpsilon(newpricertol);
614 
615  MSG_INFO2( (*spxout), (*spxout) << " --- setting pricer tolerance to "
616  << thepricer->epsilon()
617  << std::endl; );
618  }
619  // solution seems good, no check whether we are precise enough
620  else if (lastUpdate() == 0)
621  {
622  priced = true;
623  break;
624  }
625  // We have an iteration limit and everything looks good? Then stop!
626  // 6 is just a number picked.
627  else if (instableLeaveNum == -1 && maxIters > 0 && lastUpdate() < 6)
628  {
629  priced = true;
630  break;
631  }
632  }
633  MSG_INFO3( (*spxout), (*spxout) << " --- solve(leave) triggers refactorization" << std::endl; )
634 
635  // if the factorization is not fresh, we better refactorize and call the pricer again; however, this can
636  // create cycling, so it is performed only a limited number of times per LEAVE round
637  if( lastUpdate() > 0 && leaveFacPivotCount < MAXREFACPIVOTS )
638  {
639  factorize();
640 
641  // Inna/Tobi: if the factorization was found out to be singular, we have to quit
643  {
644  MSG_INFO1( (*spxout), (*spxout) << "Something wrong with factorization, Basis status: " << SPxBasis::status() << std::endl; )
645  stop = true;
646  break;
647  }
648 
649  // call pricer again
650  leaveNum = thepricer->selectLeave();
651 
652  // count how often the pricer has found something only after refactorizing
653  if( leaveNum >= 0 )
654  leaveFacPivotCount++;
655  }
656 
657  if (leaveNum < 0)
658  {
659  priced = true;
660  break;
661  }
662  }
663 
664  /* check if we have iterations left */
665  if (maxIters >= 0 && iterations() >= maxIters)
666  {
667  MSG_INFO2( (*spxout), (*spxout) << " --- maximum number of iterations (" << maxIters
668  << ") reached" << std::endl; )
670  stop = true;
671  break;
672  }
673 
674  leave(leaveNum);
675  assert((testBounds(), 1));
677  stop = terminate();
678  clearUpdateVecs();
679 
680  /* if a successful pivot was performed or a nonbasic variable was flipped to its other bound, we reset the
681  * cycle counter
682  */
683  if( lastIndex() >= 0 )
684  leaveCycleCount = 0;
685  else if( basis().status() != SPxBasis::INFEASIBLE)
686  {
687  leaveCycleCount++;
688  if( leaveCycleCount > MAXCYCLES )
689  {
690  MSG_INFO2( (*spxout), (*spxout) << " --- abort solving due to cycling in leaving algorithm" << std::endl; );
692  stop = true;
693  }
694  }
695 
696  /* only if the basis has really changed, we increase the iterations counter; this is not the case when only
697  * a nonbasic variable was flipped to its other bound
698  */
699  if( lastEntered().isValid() )
700  {
701  leaveCount++;
702  assert(lastIndex() >= 0);
703  }
704 
705  /* check every MAXSTALLS iterations whether shift and objective value have not changed */
706  if( (iteration() - stallRefIter) % MAXSTALLS == 0 && basis().status() != SPxBasis::INFEASIBLE )
707  {
708  if( spxAbs(value() - stallRefValue) <= epsilon() && spxAbs(shift() - stallRefShift) <= epsilon() )
709  {
710  if( stallNumRecovers < MAXSTALLRECOVERS )
711  {
712  /* try to recover by switching algorithm up to MAXSTALLRECOVERS times */
713  MSG_INFO3( (*spxout), (*spxout) << " --- stalling detected - trying to recover by switching to ENTERING algorithm." << std::endl; )
714 
715  ++stallNumRecovers;
716  break;
717  }
718  else
719  {
720  /* giving up */
721  MSG_INFO2( (*spxout), (*spxout) << " --- abort solving due to stalling in leaving algorithm" << std::endl; );
722 
724  stop = true;
725  }
726  }
727  else
728  {
729  /* merely update reference values */
730  stallRefIter = iteration()-1;
731  stallRefShift = shift();
732  stallRefValue = value();
733  }
734  }
735 
736  //@ assert(isConsistent());
737  }
738  while (!stop);
739 
740  MSG_INFO3( (*spxout),
741  (*spxout) << " --- leave finished. iteration: " << iteration()
742  << ", value: " << value()
743  << ", shift: " << shift()
744  << ", epsilon: " << epsilon()
745  << ", feastol: " << feastol()
746  << ", opttol: " << opttol()
747  << std::endl
748  << "ISOLVE57 stop: " << stop
749  << ", basis status: " << SPxBasis::status() << " (" << int(SPxBasis::status()) << ")"
750  << ", solver status: " << m_status << " (" << int(m_status) << ")" << std::endl;
751  )
752 
753  if (!stop)
754  {
755  if( shift() < minShift )
756  {
757  minShift = shift();
758  cycleCount = 0;
759  }
760  else
761  {
762  cycleCount++;
763  if( cycleCount > MAXCYCLES )
764  {
766  throw SPxStatusException("XSOLVE13 Abort solving due to cycling");
767  }
768  MSG_INFO3( (*spxout),
769  (*spxout) << " --- maxInfeas: " << maxInfeas()
770  << ", shift: " << shift()
771  << ", leavetol: " << leavetol()
772  << ", cycle count: " << cycleCount << std::endl;
773  )
774  }
775 
776  /**@todo technically it would be ok to finish already when (priced && maxinfeas + shift() <= entertol()) is
777  * satisfied; maybe at least in the case when SoPlex keeps jumping back between ENTER and LEAVE always
778  * shifting (looping), we may relax this condition here;
779  * note also that unShift may increase shift() slightly due to roundoff errors
780  */
781  if (shift() <= epsilon())
782  {
783  cycleCount = 0;
784  // factorize();
785  unShift();
786 
787  Real maxinfeas = maxInfeas();
788 
789  MSG_INFO3( (*spxout),
790  (*spxout) << " --- maxInfeas: " << maxinfeas
791  << ", shift: " << shift()
792  << ", leavetol: " << leavetol() << std::endl;
793  )
794 
795  // We stop if we are indeed optimal, or if we have already been
796  // two times at this place. In this case it seems futile to
797  // continue.
798  if (loopCount > 2)
799  {
801  throw SPxStatusException("XSOLVE14 Abort solving due to looping");
802  }
803  else if (priced && maxinfeas + shift() <= leavetol())
804  {
806  m_status = OPTIMAL;
807  break;
808  }
809  loopCount++;
810  }
811  setType(ENTER);
812  init();
813  thepricer->setType(type());
815  }
816  }
817  assert(m_status != SINGULAR);
818 
819  }
820  catch( const SPxException& E )
821  {
822  // if we stopped due to a singular basis, we reload the original basis and try again with tighter
823  // tolerance (only once)
824  if (m_status == SINGULAR && !tightened)
825  {
826  tightenedtype = type();
827 
828  if( tightenedtype == ENTER )
829  {
830  m_entertol = 0.01 * m_entertol;
831 
832  MSG_INFO2( (*spxout), (*spxout) << " --- basis singular: reloading basis and solving with tighter ratio test tolerance " << m_entertol << std::endl; )
833  }
834  else
835  {
836  m_leavetol = 0.01 * m_leavetol;
837 
838  MSG_INFO2( (*spxout), (*spxout) << " --- basis singular: reloading basis and solving with tighter ratio test tolerance " << m_leavetol << std::endl; )
839  }
840 
841  // load original basis
842  int niters = iterations();
843  loadBasis(regulardesc);
844 
845  // remember iteration count
846  iterCount = niters;
847 
848  // try initializing basis (might fail if starting basis was already singular)
849  try
850  {
851  init();
853  }
854  catch( const SPxException& Ex )
855  {
856  MSG_INFO2( (*spxout), (*spxout) << " --- reloaded basis singular, resetting original tolerances" << std::endl; )
857 
858  if( tightenedtype == ENTER )
859  m_entertol = 100.0 * m_entertol;
860  else
861  m_leavetol = 100.0 * m_leavetol;
862 
864 
865  throw Ex;
866  }
867 
868  // reset status and counters
869  m_status = RUNNING;
870  m_numCycle = 0;
871  leaveCount = 0;
872  enterCount = 0;
873  stallNumRecovers = 0;
874 
875  // continue
876  stop = false;
877  tightened = true;
878  }
879  // reset tolerance to its original value and pass on the exception
880  else if (tightened)
881  {
882  if( tightenedtype == ENTER )
883  m_entertol = 100.0 * m_entertol;
884  else
885  m_leavetol = 100.0 * m_leavetol;
886 
888 
889  throw E;
890  }
891  // pass on the exception
892  else
893  throw E;
894  }
895  }
896 
897  // reset tolerance to its original value
898  if (tightened)
899  {
900  if( tightenedtype == ENTER )
901  m_entertol = 100.0 * m_entertol;
902  else
903  m_leavetol = 100.0 * m_leavetol;
904 
906  }
907 
908  theTime->stop();
909  theCumulativeTime += time();
910 
911  if (m_status == RUNNING)
912  {
913  m_status = ERROR;
914  throw SPxStatusException("XSOLVE05 Status is still RUNNING when it shouldn't be");
915  }
916 
917  MSG_INFO3( (*spxout),
918  (*spxout) << "Finished solving (status=" << status()
919  << ", iters=" << iterCount
920  << ", leave=" << leaveCount
921  << ", enter=" << enterCount
922  << ", flips=" << totalboundflips;
923  if( status() == OPTIMAL )
924  (*spxout) << ", objValue=" << value();
925  (*spxout) << ")" << std::endl;
926  )
927 
928 #ifdef ENABLE_ADDITIONAL_CHECKS
929  /* check if solution is really feasible */
930  if( status() == OPTIMAL )
931  {
932  int c;
933  Real val;
934  DVector sol( nCols() );
935 
936  getPrimal( sol );
937 
938  for(int row = 0; row < nRows(); ++row )
939  {
940  const SVector& rowvec = rowVector( row );
941  val = 0.0;
942  for( c = 0; c < rowvec.size(); ++c )
943  val += rowvec.value( c ) * sol[rowvec.index( c )];
944 
945  if( LT( val, lhs( row ), feastol() ) ||
946  GT( val, rhs( row ), feastol() ) )
947  {
948  // Minor rhs violations happen frequently, so print these
949  // warnings only with verbose level INFO2 and higher.
950  MSG_INFO2( (*spxout), (*spxout) << "WSOLVE88 Warning! Constraint " << row
951  << " is violated by solution" << std::endl
952  << " lhs:" << lhs( row )
953  << " <= val:" << val
954  << " <= rhs:" << rhs( row ) << std::endl; )
955 
956  if( type() == LEAVE && isRowBasic( row ) )
957  {
958  // find basis variable
959  for( c = 0; c < nRows(); ++c )
960  if (basis().baseId(c).isSPxRowId()
961  && (number(basis().baseId(c)) == row))
962  break;
963 
964  assert( c < nRows() );
965 
966  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE90 basis idx:" << c
967  << " fVec:" << fVec()[c]
968  << " fRhs:" << fRhs()[c]
969  << " fTest:" << fTest()[c] << std::endl; )
970  }
971  }
972  }
973  for(int col = 0; col < nCols(); ++col )
974  {
975  if( LT( sol[col], lower( col ), feastol() ) ||
976  GT( sol[col], upper( col ), feastol() ) )
977  {
978  // Minor bound violations happen frequently, so print these
979  // warnings only with verbose level INFO2 and higher.
980  MSG_INFO2( (*spxout), (*spxout) << "WSOLVE91 Warning! Bound for column " << col
981  << " is violated by solution" << std::endl
982  << " lower:" << lower( col )
983  << " <= val:" << sol[col]
984  << " <= upper:" << upper( col ) << std::endl; )
985 
986  if( type() == LEAVE && isColBasic( col ) )
987  {
988  for( c = 0; c < nRows() ; ++c)
989  if ( basis().baseId( c ).isSPxColId()
990  && ( number( basis().baseId( c ) ) == col ))
991  break;
992 
993  assert( c < nRows() );
994  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE92 basis idx:" << c
995  << " fVec:" << fVec()[c]
996  << " fRhs:" << fRhs()[c]
997  << " fTest:" << fTest()[c] << std::endl; )
998  }
999  }
1000  }
1001  }
1002 #endif // ENABLE_ADDITIONAL_CHECKS
1003 
1004  primalCount = ( rep() == SPxSolver::COLUMN )
1005  ? enterCount
1006  : leaveCount;
1007 
1008  printDisplayLine(true);
1010 
1011  return status();
1012 }
1013 
1015 {
1016  // only polish an already optimal basis
1017  if( polishObj == POLISH_OFF || status() != OPTIMAL )
1018  return;
1019 
1020  // the current objective value must not be changed
1021 #ifndef NDEBUG
1022  Real objVal = value();
1023 #endif
1024 
1025  int nSuccessfulPivots;
1026  const SPxBasis::Desc& ds = desc();
1028  SPxId polishId;
1029  bool success = false;
1030  // catch rare case that the iteration limit is exactly reached at optimality
1031  bool stop = (maxIters >= 0 && iterations() >= maxIters);
1032 
1033  MSG_INFO2( (*spxout), (*spxout) << " --- perform solution polishing" << std::endl; )
1034 
1035  if( rep() == COLUMN )
1036  {
1037  setType(ENTER); // use primal simplex to preserve feasibility
1038  init();
1039  instableEnter = false;
1041  if( polishObj == POLISH_INTEGRALITY )
1042  {
1043  while( !stop )
1044  {
1045  nSuccessfulPivots = 0;
1046  // identify nonbasic slack variables, i.e. rows, that may be moved into the basis
1047  for( int i = 0; i < dim() && !stop; ++i )
1048  {
1049  stat = ds.coStatus(i);
1050  if( !isBasic(stat) )
1051  {
1052  // only consider rows with zero dual multiplier to preserve optimality
1053  if( EQrel((*theCoPvec)[i], 0) &&
1055  {
1056  polishId = coId(i);
1057  MSG_DEBUG( std::cout << "try pivoting: " << polishId << " stat: " << stat; )
1058  success = enter(polishId, true);
1059  clearUpdateVecs();
1060  assert(EQrel(objVal, value(), entertol()));
1061  assert(EQrel(shift(), 0.0, entertol()));
1062  if( success )
1063  {
1064  MSG_DEBUG( std::cout << " -> success!"; )
1065  ++nSuccessfulPivots;
1066  if( maxIters >= 0 && iterations() >= maxIters )
1067  stop = true;
1068  }
1069  MSG_DEBUG( std::cout << std::endl; )
1070  }
1071  }
1072  }
1073  // identify nonbasic variables that may be moved into the basis
1074  if( !stop && integerVariables.size() == nCols() )
1075  {
1076  for( int i = 0; i < coDim() && !stop; ++i )
1077  {
1078  stat = ds.status(i);
1079  if( !isBasic(stat) )
1080  {
1081  // only consider continuous variables with zero dual multiplier to preserve optimality
1082  if( EQrel(maxObj(i) - (*thePvec)[i], 0) &&
1083  integerVariables[i] == 0 &&
1085  {
1086  polishId = id(i);
1087  MSG_DEBUG( std::cout << "try pivoting: " << polishId << " stat: " << stat; )
1088  success = enter(polishId, true);
1089  clearUpdateVecs();
1090  assert(EQrel(objVal, value(), entertol()));
1091  assert(EQrel(shift(), 0.0, entertol()));
1092  if( success )
1093  {
1094  MSG_DEBUG( std::cout << " -> success!"; )
1095  ++nSuccessfulPivots;
1096  if( maxIters >= 0 && iterations() >= maxIters )
1097  stop = true;
1098  }
1099  MSG_DEBUG( std::cout << std::endl; )
1100  }
1101  }
1102  }
1103  }
1104  // terminate if in the last round no more polishing steps were performed
1105  if( nSuccessfulPivots == 0 )
1106  stop = true;
1107  polishCount += nSuccessfulPivots;
1108  }
1109  }
1110  else
1111  {
1112  assert(polishObj == POLISH_FRACTIONALITY);
1113  while( !stop )
1114  {
1115  nSuccessfulPivots = 0;
1116  // identify nonbasic variables, i.e. columns, that may be moved into the basis
1117  for( int i = 0; i < coDim() && !stop; ++i )
1118  {
1119  // only look for columns, i.e. variables
1120  stat = ds.status(i);
1121  if( !isBasic(stat) )
1122  {
1123  // only consider variables with zero reduced costs to preserve optimality
1124  if( EQrel(maxObj(i) - (*thePvec)[i], 0) &&
1126  {
1127  polishId = id(i);
1128  MSG_DEBUG( std::cout << "try pivoting: " << polishId << " stat: " << stat; )
1129  success = enter(polishId, true);
1130  clearUpdateVecs();
1131  assert(EQrel(objVal, value(), entertol()));
1132  assert(EQrel(shift(), 0.0, entertol()));
1133  if( success )
1134  {
1135  MSG_DEBUG( std::cout << " -> success!"; )
1136  ++nSuccessfulPivots;
1137  if( maxIters >= 0 && iterations() >= maxIters )
1138  stop = true;
1139  }
1140  MSG_DEBUG( std::cout << std::endl; )
1141  }
1142  }
1143  }
1144  // terminate if in the last round no more polishing steps were performed
1145  if( nSuccessfulPivots == 0 )
1146  stop = true;
1147  polishCount += nSuccessfulPivots;
1148  }
1149  }
1150  }
1151  else
1152  {
1153  setType(LEAVE); // use primal simplex to preserve feasibility
1154  init();
1155  instableLeave = false;
1157  bool useIntegrality = false;
1158 
1159  if( integerVariables.size() == nCols() )
1160  useIntegrality = true;
1161 
1162  // in ROW rep: pivot slack out of the basis
1163  if( polishObj == POLISH_INTEGRALITY )
1164  {
1165  while( !stop )
1166  {
1167  nSuccessfulPivots = 0;
1168  // identify basic slack variables and continuous variables, that may be moved out of the basis
1169  for( int i = 0; i < dim() && !stop; ++i )
1170  {
1171  polishId = baseId(i);
1172 
1173  if( polishId.isSPxRowId() )
1174  stat = ds.rowStatus(number(polishId));
1175  else
1176  {
1177  // skip (integer) variables
1178  if( !useIntegrality || integerVariables[number(SPxColId(polishId))] == 1 )
1179  continue;
1180  stat = ds.colStatus(number(polishId));
1181  }
1182 
1183  if( EQrel((*theFvec)[i], 0) && (stat == SPxBasis::Desc::P_ON_LOWER || stat == SPxBasis::Desc::P_ON_UPPER) )
1184  {
1185  MSG_DEBUG( std::cout << "try pivoting: " << polishId << " stat: " << stat; )
1186  success = leave(i, true);
1187  clearUpdateVecs();
1188  assert(EQrel(objVal, value(), leavetol()));
1189  assert(EQrel(shift(), 0.0, leavetol()));
1190  if( success )
1191  {
1192  MSG_DEBUG( std::cout << " -> success!"; )
1193  ++nSuccessfulPivots;
1194  if( maxIters >= 0 && iterations() >= maxIters )
1195  stop = true;
1196  }
1197  MSG_DEBUG( std::cout << std::endl; )
1198  }
1199  }
1200  // terminate if in the last round no more polishing steps were performed
1201  if( nSuccessfulPivots == 0 )
1202  stop = true;
1203  polishCount += nSuccessfulPivots;
1204  }
1205  }
1206  else
1207  {
1208  assert(polishObj == POLISH_FRACTIONALITY);
1209  while( !stop )
1210  {
1211  nSuccessfulPivots = 0;
1212  // identify basic (integer) variables, that may be moved out of the basis
1213  for( int i = 0; i < dim(); ++i )
1214  {
1215  polishId = baseId(i);
1216 
1217  if( polishId.isSPxRowId() )
1218  continue;
1219  else
1220  {
1221  if( useIntegrality && integerVariables[number(SPxColId(polishId))] == 0 )
1222  continue;
1223  stat = ds.colStatus(i);
1224  }
1225 
1226  if( EQrel((*theFvec)[i], 0) && (stat == SPxBasis::Desc::P_ON_LOWER || stat == SPxBasis::Desc::P_ON_UPPER) )
1227  {
1228  MSG_DEBUG( std::cout << "try pivoting: " << polishId << " stat: " << stat; )
1229  success = leave(i, true);
1230  clearUpdateVecs();
1231  assert(EQrel(objVal, value(), leavetol()));
1232  assert(EQrel(shift(), 0.0, leavetol()));
1233  if( success )
1234  {
1235  MSG_DEBUG( std::cout << " -> success!"; )
1236  ++nSuccessfulPivots;
1237  if( maxIters >= 0 && iterations() >= maxIters )
1238  {
1239  stop = true;
1240  break;
1241  }
1242  }
1243  MSG_DEBUG( std::cout << std::endl; )
1244  }
1245  }
1246  // terminate if in the last round no more polishing steps were performed
1247  if( nSuccessfulPivots == 0 )
1248  stop = true;
1249  polishCount += nSuccessfulPivots;
1250  }
1251  }
1252  }
1253 
1254  MSG_INFO1( (*spxout),
1255  (*spxout) << " --- finished solution polishing (" << polishCount << " pivots)" << std::endl; )
1256 
1258 }
1259 
1260 
1262 {
1263 
1265 
1266  DVector tmp(dim());
1267 
1268  tmp = *theCoPvec;
1269  multWithBase(tmp);
1270  tmp -= *theCoPrhs;
1271  if (tmp.length() > leavetol())
1272  {
1273  MSG_INFO3( (*spxout), (*spxout) << "ISOLVE93 " << iteration() << ":\tcoP error = \t"
1274  << tmp.length() << std::endl; )
1275 
1276  tmp.clear();
1278  multWithBase(tmp);
1279  tmp -= *theCoPrhs;
1280  MSG_INFO3( (*spxout), (*spxout) << "ISOLVE94\t\t" << tmp.length() << std::endl; )
1281 
1282  tmp.clear();
1284  tmp -= *theCoPvec;
1285  MSG_INFO3( (*spxout), (*spxout) << "ISOLVE95\t\t" << tmp.length() << std::endl; )
1286  }
1287 
1288  tmp = *theFvec;
1289  multBaseWith(tmp);
1290  tmp -= *theFrhs;
1291  if (tmp.length() > entertol())
1292  {
1293  MSG_INFO3( (*spxout), (*spxout) << "ISOLVE96 " << iteration() << ":\t F error = \t"
1294  << tmp.length() << std::endl; )
1295 
1296  tmp.clear();
1297  SPxBasis::solve(tmp, *theFrhs);
1298  tmp -= *theFvec;
1299  MSG_INFO3( (*spxout), (*spxout) << "ISOLVE97\t\t" << tmp.length() << std::endl; )
1300  }
1301 
1302  if (type() == ENTER)
1303  {
1304  for (int i = 0; i < dim(); ++i)
1305  {
1306  if (theCoTest[i] < -leavetol() && isCoBasic(i))
1307  {
1308  /// @todo Error message "this shalt not be": shalt this be an assert (also below)?
1309  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE98 testVecs: theCoTest: this shalt not be!"
1310  << std::endl
1311  << " i=" << i
1312  << ", theCoTest[i]=" << theCoTest[i]
1313  << ", leavetol()=" << leavetol() << std::endl; )
1314  }
1315  }
1316 
1317  for (int i = 0; i < coDim(); ++i)
1318  {
1319  if (theTest[i] < -leavetol() && isBasic(i))
1320  {
1321  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE99 testVecs: theTest: this shalt not be!"
1322  << std::endl
1323  << " i=" << i
1324  << ", theTest[i]=" << theTest[i]
1325  << ", leavetol()=" << leavetol() << std::endl; )
1326  }
1327  }
1328  }
1329 }
1330 
1331 
1332 /// print display line of flying table
1333 void SPxSolver::printDisplayLine(const bool force, const bool forceHead)
1334 {
1335  MSG_INFO1( (*spxout),
1336  if( forceHead || displayLine % (displayFreq*30) == 0 )
1337  {
1338  (*spxout) << "type | time | iters | facts | shift | violation | obj value ";
1339  if( printCondition > 0 )
1340  (*spxout) << " | condition";
1341  (*spxout) << std::endl;
1342  }
1343  if( (force || (displayLine % displayFreq == 0)) && !forceHead )
1344  {
1345  (type() == LEAVE) ? (*spxout) << " L |" : (*spxout) << " E |";
1346  (*spxout) << std::fixed << std::setw(7) << std::setprecision(1) << time() << " |";
1347  (*spxout) << std::scientific << std::setprecision(2);
1348  (*spxout) << std::setw(8) << iteration() << " | "
1349  << std::setw(5) << slinSolver()->getFactorCount() << " | "
1350  << shift() << " | "
1351  << MAXIMUM(0.0, m_pricingViol + m_pricingViolCo) << " | "
1352  << std::setprecision(8) << value();
1354  (*spxout) << " (" << std::fixed << std::setprecision(2) << getDegeneracyLevel(fVec()) <<")";
1355  if( printCondition == 1 )
1356  (*spxout) << " | " << std::scientific << std::setprecision(2) << basis().getFastCondition(0);
1357  if( printCondition == 2 )
1358  (*spxout) << " | " << std::scientific << std::setprecision(2) << basis().getFastCondition(1);
1359  if( printCondition == 3 )
1360  (*spxout) << " | " << std::scientific << std::setprecision(2) << basis().getFastCondition(2);
1361  if( printCondition == 4 )
1362  (*spxout) << " | " << std::scientific << std::setprecision(2) << basis().getEstimatedCondition();
1363  (*spxout) << std::endl;
1364  }
1365  displayLine++;
1366  );
1367 }
1368 
1369 
1371 {
1372 #ifdef ENABLE_ADDITIONAL_CHECKS
1374  testVecs();
1375 #endif
1376 
1377  int redo = dim();
1378  if (redo < 1000)
1379  redo = 1000;
1380 
1381  if (iteration() > 10 && iteration() % redo == 0)
1382  {
1383 #ifdef ENABLE_ADDITIONAL_CHECKS
1384  DVector cr(*theCoPrhs);
1385  DVector fr(*theFrhs);
1386 #endif
1387 
1388  if (type() == ENTER)
1390  else
1392 
1393  computeFrhs();
1394 
1395 #ifdef ENABLE_ADDITIONAL_CHECKS
1396  cr -= *theCoPrhs;
1397  fr -= *theFrhs;
1398  if (cr.length() > leavetol())
1399  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE50 unexpected change of coPrhs "
1400  << cr.length() << std::endl; )
1401  if (fr.length() > entertol())
1402  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE51 unexpected change of Frhs "
1403  << fr.length() << std::endl; )
1404 #endif
1405 
1406  if (updateCount > 1)
1407  {
1408  MSG_INFO3( (*spxout), (*spxout) << " --- terminate triggers refactorization"
1409  << std::endl; )
1410  factorize();
1411  }
1414 
1415  if (pricing() == FULL)
1416  {
1417  computePvec();
1418  if (type() == ENTER)
1419  computeTest();
1420  }
1421 
1422  if (shift() > 0.0)
1423  unShift();
1424  }
1425 
1426  // check time limit and objective limit only for non-terminal bases
1429  {
1430  m_status = UNKNOWN;
1431  return true;
1432  }
1433 
1434  if ( isTimeLimitReached() )
1435  {
1436  MSG_INFO2( (*spxout), (*spxout) << " --- timelimit (" << maxTime
1437  << ") reached" << std::endl; )
1438  m_status = ABORT_TIME;
1439  return true;
1440  }
1441 
1442  // objLimit is set and we are running DUAL:
1443  // - objLimit is set if objLimit < infinity
1444  // - DUAL is running if rep() * type() > 0 == DUAL (-1 == PRIMAL)
1445  //
1446  // In this case we have given a objective value limit, e.g, through a
1447  // MIP solver, and we want stop solving the LP if we figure out that the
1448  // optimal value of the current LP can not be better then this objective
1449  // limit. More precisely:
1450  // - MINIMIZATION Problem
1451  // We want stop the solving process if
1452  // objLimit <= current objective value of the DUAL LP
1453  // - MAXIMIZATION Problem
1454  // We want stop the solving process if
1455  // objLimit >= current objective value of the DUAL LP
1456  if( objLimit < infinity && type() * rep() > 0 )
1457  {
1458  // We have no bound shifts; therefore, we can trust the current
1459  // objective value.
1460  // It might be even possible to use this termination value in case of
1461  // bound violations (shifting) but in this case it is quite difficult
1462  // to determine if we already reached the limit.
1463  if( shift() < epsilon() && noViols(opttol() - shift()) )
1464  {
1465  // SPxSense::MINIMIZE == -1, so we have sign = 1 on minimizing
1466  if( spxSense() * value() <= spxSense() * objLimit )
1467  {
1468  MSG_INFO2( (*spxout), (*spxout) << " --- objective value limit (" << objLimit
1469  << ") reached" << std::endl; )
1470  MSG_DEBUG(
1471  (*spxout) << " --- objective value limit reached" << std::endl
1472  << " (value: " << value()
1473  << ", limit: " << objLimit << ")" << std::endl
1474  << " (spxSense: " << int(spxSense())
1475  << ", rep: " << int(rep())
1476  << ", type: " << int(type()) << ")" << std::endl;
1477  )
1478 
1480  return true;
1481  }
1482  }
1483  }
1484 
1485 
1486 
1488  {
1489  DVector degenvec(nCols());
1490  if( rep() == ROW )
1491  {
1492  if( type() == ENTER ) // dual simplex
1494  else // primal simplex
1495  {
1496  getPrimal(degenvec);
1497  primalDegenSum += getDegeneracyLevel(degenvec);
1498  }
1499  }
1500  else
1501  {
1502  assert(rep() == COLUMN);
1503  if( type() == LEAVE ) // dual simplex
1505  else
1506  {
1507  getPrimal(degenvec);
1508  primalDegenSum += getDegeneracyLevel(degenvec);
1509  }
1510  }
1511  }
1512 
1513 
1514  // the improved dual simplex requires a starting basis
1515  // if the flag getStartingDecompBasis is set to true the simplex will terminate when a dual basis is found
1517  {
1518  Real iterationFrac = 0.6;
1519  if( type() == ENTER && SPxBasis::status() == SPxBasis::DUAL &&
1520  iteration() - lastDegenCheck() > getDegenCompOffset()/*iteration() % 10 == 0*/ )
1521  {
1523 
1525  {
1526  m_status = RUNNING;
1527  return true;
1528  }
1529 
1530  Real degeneracyLevel = 0;
1531  Real degeneracyLB = 0.1;
1532  Real degeneracyUB = 0.9;
1533  degeneracyLevel = getDegeneracyLevel(fVec());
1534  if( (degeneracyLevel < degeneracyUB && degeneracyLevel > degeneracyLB) && iteration() > nRows()*0.2 )
1535  {
1537  return true;
1538  }
1539 
1540  if( degeneracyLevel < degeneracyLB && iteration() > MINIMUM(getDecompIterationLimit(), int(nCols()*iterationFrac)) )
1541  {
1543  setDegenCompOffset(0);
1545  return true;
1546  }
1547  }
1548  else if( type() == LEAVE && iteration() > MINIMUM(getDecompIterationLimit(), int(nCols()*iterationFrac)) )
1549  {
1551  setDegenCompOffset(0);
1553  return true;
1554  }
1555  }
1556 
1558 
1559  return false;
1560 }
1561 
1563 {
1564 
1565  if (!isInitialized())
1566  {
1567  /* exit if presolving/simplifier cleared the problem */
1568  if (status() == NO_PROBLEM)
1569  return status();
1570  throw SPxStatusException("XSOLVE06 Not Initialized");
1571  }
1572  if (rep() == ROW)
1573  p_vector = coPvec();
1574  else
1575  {
1576  const SPxBasis::Desc& ds = desc();
1577 
1578  for (int i = 0; i < nCols(); ++i)
1579  {
1580  switch (ds.colStatus(i))
1581  {
1583  p_vector[i] = SPxLP::lower(i);
1584  break;
1587  p_vector[i] = SPxLP::upper(i);
1588  break;
1589  case SPxBasis::Desc::P_FREE :
1590  p_vector[i] = 0;
1591  break;
1592  case SPxBasis::Desc::D_FREE :
1597  break;
1598  default:
1599  throw SPxInternalCodeException("XSOLVE07 This should never happen.");
1600  }
1601  }
1602  for (int j = 0; j < dim(); ++j)
1603  {
1604  if (baseId(j).isSPxColId())
1605  p_vector[ number(SPxColId(baseId(j))) ] = fVec()[j];
1606  }
1607  }
1608  return status();
1609 }
1610 
1612 {
1613 
1614  assert(isInitialized());
1615 
1616  if (!isInitialized())
1617  {
1618  /* exit if presolving/simplifier cleared the problem */
1619  if (status() == NO_PROBLEM)
1620  return status();
1621  throw SPxStatusException("XSOLVE08 No Problem loaded");
1622  }
1623 
1624  if (rep() == ROW)
1625  {
1626  int i;
1627  p_vector = maxRowObj();
1628  for (i = nCols() - 1; i >= 0; --i)
1629  {
1630  if (baseId(i).isSPxRowId())
1631  p_vector[ number(SPxRowId(baseId(i))) ] = fVec()[i];
1632  }
1633  }
1634  else
1635  p_vector = coPvec();
1636 
1637  p_vector *= Real(spxSense());
1638 
1639  return status();
1640 }
1641 
1643 {
1644 
1645  assert(isInitialized());
1646 
1647  if (!isInitialized())
1648  {
1649  throw SPxStatusException("XSOLVE09 No Problem loaded");
1650  // return NOT_INIT;
1651  }
1652 
1653  if (rep() == ROW)
1654  {
1655  int i;
1656  p_vector.clear();
1657  if (spxSense() == SPxLP::MINIMIZE)
1658  {
1659  for (i = dim() - 1; i >= 0; --i)
1660  {
1661  if (baseId(i).isSPxColId())
1662  p_vector[ number(SPxColId(baseId(i))) ] = -fVec()[i];
1663  }
1664  }
1665  else
1666  {
1667  for (i = dim() - 1; i >= 0; --i)
1668  {
1669  if (baseId(i).isSPxColId())
1670  p_vector[ number(SPxColId(baseId(i))) ] = fVec()[i];
1671  }
1672  }
1673  }
1674  else
1675  {
1676  p_vector = maxObj();
1677  p_vector -= pVec();
1678  if (spxSense() == SPxLP::MINIMIZE)
1679  p_vector *= -1.0;
1680  }
1681 
1682  return status();
1683 }
1684 
1686 {
1687 
1688  assert(isInitialized());
1689 
1690  if (!isInitialized())
1691  {
1692  throw SPxStatusException("XSOLVE10 No Problem loaded");
1693  // return NOT_INIT;
1694  }
1695 
1697  p_vector.clear();
1698  p_vector = primalRay;
1699 
1700  return status();
1701 }
1702 
1704 {
1705 
1706  assert(isInitialized());
1707 
1708  if (!isInitialized())
1709  {
1710  throw SPxStatusException("XSOLVE10 No Problem loaded");
1711  // return NOT_INIT;
1712  }
1713 
1715  p_vector.clear();
1716  p_vector = dualFarkas;
1717 
1718  return status();
1719 }
1720 
1722 {
1723 
1724  assert(isInitialized());
1725 
1726  if (!isInitialized())
1727  {
1728  throw SPxStatusException("XSOLVE11 No Problem loaded");
1729  // return NOT_INIT;
1730  }
1731 
1732  if (rep() == COLUMN)
1733  {
1734  int i;
1735  const SPxBasis::Desc& ds = desc();
1736  for (i = nRows() - 1; i >= 0; --i)
1737  {
1738  switch (ds.rowStatus(i))
1739  {
1741  p_vector[i] = lhs(i);
1742  break;
1745  p_vector[i] = rhs(i);
1746  break;
1747  case SPxBasis::Desc::P_FREE :
1748  p_vector[i] = 0;
1749  break;
1750  case SPxBasis::Desc::D_FREE :
1755  break;
1756  default:
1757  throw SPxInternalCodeException("XSOLVE12 This should never happen.");
1758  }
1759  }
1760  for (i = dim() - 1; i >= 0; --i)
1761  {
1762  if (baseId(i).isSPxRowId())
1763  p_vector[ number(SPxRowId(baseId(i))) ] = -(*theFvec)[i];
1764  }
1765  }
1766  else
1767  p_vector = pVec();
1768 
1769  return status();
1770 }
1771 
1773 {
1774 
1775  if (!isInitialized())
1776  {
1777  throw SPxStatusException("XSOLVE20 Not Initialized");
1778  }
1779 
1780  if (rep() == ROW)
1781  coPvec() = p_vector;
1782  else
1783  {
1784  for (int j = 0; j < dim(); ++j)
1785  {
1786  if (baseId(j).isSPxColId())
1787  fVec()[j] = p_vector[ number(SPxColId(baseId(j))) ];
1788  }
1789  }
1790 }
1791 
1793 {
1794 
1795  assert(isInitialized());
1796 
1797  if (!isInitialized())
1798  {
1799  throw SPxStatusException("XSOLVE21 Not Initialized");
1800  }
1801 
1802  if (rep() == ROW)
1803  {
1804  for (int i = nCols() - 1; i >= 0; --i)
1805  {
1806  if (baseId(i).isSPxRowId())
1807  {
1808  if (spxSense() == SPxLP::MAXIMIZE)
1809  fVec()[i] = p_vector[ number(SPxRowId(baseId(i))) ];
1810  else
1811  fVec()[i] = -p_vector[ number(SPxRowId(baseId(i))) ];
1812  }
1813  }
1814  }
1815  else
1816  {
1817  coPvec() = p_vector;
1818  if (spxSense() == SPxLP::MINIMIZE)
1819  coPvec() *= -1.0;
1820  }
1821 }
1822 
1824 {
1825 
1826  assert(isInitialized());
1827 
1828  if (!isInitialized())
1829  {
1830  throw SPxStatusException("XSOLVE22 Not Initialized");
1831  }
1832 
1833  if (rep() == ROW)
1834  {
1835  for (int i = dim() - 1; i >= 0; --i)
1836  {
1837  if (baseId(i).isSPxColId())
1838  {
1839  if (spxSense() == SPxLP::MINIMIZE)
1840  fVec()[i] = -p_vector[ number(SPxColId(baseId(i))) ];
1841  else
1842  fVec()[i] = p_vector[ number(SPxColId(baseId(i))) ];
1843  }
1844  }
1845  }
1846  else
1847  {
1848  pVec() = maxObj();
1849 
1850  if (spxSense() == SPxLP::MINIMIZE)
1851  pVec() += p_vector;
1852  else
1853  pVec() -= p_vector;
1854  }
1855 }
1856 
1858 {
1859 
1860  assert(isInitialized());
1861 
1862  if (!isInitialized())
1863  {
1864  throw SPxStatusException("XSOLVE23 Not Initialized");
1865  }
1866 
1867  if (rep() == COLUMN)
1868  {
1869  for (int i = dim() - 1; i >= 0; --i)
1870  {
1871  if (baseId(i).isSPxRowId())
1872  (*theFvec)[i] = -p_vector[ number(SPxRowId(baseId(i))) ];
1873  }
1874  }
1875  else
1876  pVec() = p_vector;
1877 }
1878 
1880 {
1881  switch( m_status )
1882  {
1883  case UNKNOWN :
1884  switch (SPxBasis::status())
1885  {
1886  case SPxBasis::NO_PROBLEM :
1887  return NO_PROBLEM;
1888  case SPxBasis::SINGULAR :
1889  return SINGULAR;
1890  case SPxBasis::REGULAR :
1891  case SPxBasis::DUAL :
1892  case SPxBasis::PRIMAL :
1893  return UNKNOWN;
1894  case SPxBasis::OPTIMAL :
1895  return OPTIMAL;
1896  case SPxBasis::UNBOUNDED :
1897  return UNBOUNDED;
1898  case SPxBasis::INFEASIBLE :
1899  return INFEASIBLE;
1900  default:
1901  return ERROR;
1902  }
1903  case SINGULAR :
1904  return m_status;
1905  case OPTIMAL :
1906  assert( SPxBasis::status() == SPxBasis::OPTIMAL );
1907  /*lint -fallthrough*/
1908  case ABORT_EXDECOMP :
1909  case ABORT_DECOMP :
1910  case ABORT_CYCLING :
1911  case ABORT_TIME :
1912  case ABORT_ITER :
1913  case ABORT_VALUE :
1914  case RUNNING :
1915  case REGULAR :
1916  case NOT_INIT :
1917  case NO_SOLVER :
1918  case NO_PRICER :
1919  case NO_RATIOTESTER :
1920  case ERROR:
1921  return m_status;
1922  default:
1923  return ERROR;
1924  }
1925 }
1926 
1928  Real* p_value,
1929  Vector* p_primal,
1930  Vector* p_slacks,
1931  Vector* p_dual,
1932  Vector* reduCosts)
1933 {
1934  if (p_value)
1935  *p_value = this->value();
1936  if (p_primal)
1937  getPrimal(*p_primal);
1938  if (p_slacks)
1939  getSlacks(*p_slacks);
1940  if (p_dual)
1941  getDual(*p_dual);
1942  if (reduCosts)
1943  getRedCost(*reduCosts);
1944  return status();
1945 }
1946 } // namespace soplex
virtual void unShift(void)
remove shift as much as possible.
Definition: spxshift.cpp:496
const VectorBase< Real > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:219
void computeFtest()
compute basis feasibility test vector.
Definition: leave.cpp:38
virtual void entered4(SPxId, int)
performs entering pivot.
Definition: spxpricer.h:214
int iterDegenCheck
number of calls to change() since last degeneracy check
Definition: spxbasis.h:390
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:3909
virtual void setType(SPxSolver::Type)
sets Simplex type.
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1089
int iteration() const
returns number of basis changes since last load().
Definition: spxbasis.h:545
bool enter(SPxId &id, bool polish=false)
Definition: enter.cpp:1091
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
Definition: exceptions.h:109
Vector & multWithBase(Vector &x) const
Vector-basis product.
Definition: spxbasis.cpp:940
SoPlex start basis generation base class.
virtual Real shift() const
total current shift amount.
Definition: spxsolver.h:1593
int iterations() const
get number of iterations of current solution.
Definition: spxsolver.h:2082
Basis is dual feasible.
Definition: spxbasis.h:95
Status & coStatus(int i)
Definition: spxbasis.h:284
not initialised error
Definition: spxsolver.h:208
Basis is not known to be dual nor primal feasible.
Definition: spxbasis.h:94
void coSolve(Vector &x, const Vector &rhs)
Cosolves linear system with basis matrix.
Definition: spxbasis.h:719
virtual SPxId selectEnter()=0
selects Id to enter basis.
primal variable is fixed to both bounds
Definition: spxbasis.h:190
virtual Real getDelta()
get allowed bound violation
int boundflips
number of performed bound flips
Definition: spxsolver.h:370
primal or dual variable has no status
Definition: spxbasis.h:195
const VectorBase< Real > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:456
#define MAXSTALLRECOVERS
Definition: spxsolve.cpp:30
const Vector & fTest() const
Violations of fVec.
Definition: spxsolver.h:1357
virtual Status getPrimal(Vector &vector) const
get solution vector for primal variables.
Definition: spxsolve.cpp:1562
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:406
SPxOut * spxout
message handler
Definition: spxsolver.h:427
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:417
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
Type
Algorithmic type.
Definition: spxsolver.h:124
bool leave(int i, bool polish=false)
Definition: leave.cpp:644
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:481
void testBounds() const
Definition: spxbounds.cpp:311
DVector theCoTest
Definition: spxsolver.h:359
virtual void qualRedCostViolation(Real &maxviol, Real &sumviol) const
get violation of optimality criterion.
Definition: spxquality.cpp:118
Abstract pricer base class.
int size() const
Number of used indices.
Definition: svectorbase.h:152
Real leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:770
SSVector * solveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:274
void computeTest()
compute test vector in ENTERing Simplex.
Definition: enter.cpp:102
int updateCount
number of calls to change() since last factorize()
Definition: spxbasis.h:391
minimize number of basic slack variables, i.e. more variables in between bounds
Definition: spxsolver.h:231
Basis is optimal, i.e. dual and primal feasible.
Definition: spxbasis.h:97
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:777
Status & rowStatus(int i)
Definition: spxbasis.h:239
int lastIndex() const
returns index in basis where last update was done.
Definition: spxbasis.h:533
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:419
virtual void qualBoundViolation(Real &maxviol, Real &sumviol) const
get violations of bounds.
Definition: spxquality.cpp:60
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
Definition: spxdefines.h:387
void setType(Type tp)
set LEAVE or ENTER algorithm.
Definition: spxsolver.cpp:169
Abstract ratio test base class.
solve() aborted due to iteration limit.
Definition: spxsolver.h:213
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:413
No Problem has been loaded.
Definition: spxsolver.h:216
Real length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition: vectorbase.h:397
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:522
void clear()
removes all indices.
Definition: idxset.h:184
virtual bool noViols(Real tol) const
check for violations above tol and immediately return false w/o checking the remaining values ...
Definition: spxsolver.cpp:697
int lastUpdate() const
returns number of basis changes since last refactorization.
Definition: spxbasis.h:539
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1047
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Definition: spxbasis.cpp:979
Real getFastCondition(int type=0)
Definition: spxbasis.cpp:1112
LP has been proven to be primal infeasible.
Definition: spxsolver.h:222
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:254
bool isTimeLimitReached(const bool forceCheck=false)
returns whether current time limit is reached; call to time() may be skipped unless forceCheck is tru...
Definition: spxsolver.cpp:1571
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
Definition: spxid.h:36
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2107
int getDecompIterationLimit() const
returns the iteration limit for the decomposition simplex initialisation
Definition: spxsolver.h:2229
void setDegenCompOffset(int iterOffset)
sets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2210
void setPrimal(Vector &p_vector)
Definition: spxsolve.cpp:1772
virtual Real value()
current objective value.
Definition: spxsolver.cpp:887
rowwise representation.
Definition: spxsolver.h:107
virtual void computeLeaveCoPrhs()
compute theCoPrhs for leaving Simplex.
Definition: spxvecs.cpp:478
Basis is singular.
Definition: spxbasis.h:93
int lastIterCount
number of calls to change() before halting the simplex
Definition: spxbasis.h:389
maximize number of basic slack variables, i.e. more variables on bounds
Definition: spxsolver.h:230
dual variable is left free, but unset
Definition: spxbasis.h:191
Real getDegeneracyLevel(Vector degenvec)
get level of dual degeneracy
Definition: spxsolver.cpp:1891
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:151
No ratiotester loaded.
Definition: spxsolver.h:205
No pricer loaded.
Definition: spxsolver.h:206
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.
const Vector & fRhs() const
right-hand side vector for fVec
Definition: spxsolver.h:1308
virtual int getFactorCount() const =0
get number of factorizations
primal variable is set to its upper bound
Definition: spxbasis.h:188
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
UpdateVector & coPvec() const
copricing vector.
Definition: spxsolver.h:1370
virtual Status getDualfarkas(Vector &vector) const
get dual farkas proof of infeasibility.
Definition: spxsolve.cpp:1703
int m_numCycle
actual number of degenerate steps so far.
Definition: spxsolver.h:269
int maxIters
maximum allowed iterations.
Definition: spxsolver.h:249
Leaving Simplex.
Definition: spxsolver.h:143
Real m_entertol
feasibility tolerance maintained during entering algorithm
Definition: spxsolver.h:264
SPxStatus status() const
returns current SPxStatus.
Definition: spxbasis.h:425
SPxStarter * thestarter
Definition: spxsolver.h:382
double Real
Definition: spxdefines.h:215
SSVector * coSolveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:278
bool isColBasic(int i) const
is the i &#39;th column vector basic ?
Definition: spxsolver.h:1268
#define MAXIMUM(x, y)
Definition: spxdefines.h:243
void setSlacks(Vector &p_vector)
Definition: spxsolve.cpp:1857
void setStatus(SPxStatus stat)
sets basis SPxStatus to stat.
Definition: spxbasis.h:431
DVector * theFrhs
Definition: spxsolver.h:341
#define MSG_DEBUG(x)
Definition: spxdefines.h:129
Status status() const
Status of solution process.
Definition: spxsolve.cpp:1879
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
Definition: spxdefines.h:399
virtual void left4(int, SPxId)
performs leaving pivot.
Definition: spxpricer.h:186
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:510
int & index(int n)
Reference to index of n &#39;th nonzero.
Definition: svectorbase.h:236
Real m_pricingViol
maximal feasibility violation of current solution
Definition: spxsolver.h:259
Real entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:763
UpdateVector * thePvec
Definition: spxsolver.h:346
void performSolutionPolishing()
Definition: spxsolve.cpp:1014
LP has been solved to optimality.
Definition: spxsolver.h:220
#define MSG_INFO2(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO2.
Definition: spxdefines.h:117
virtual bool precisionReached(Real &newpricertol) const
is the solution precise enough, or should we increase delta() ?
Definition: spxsolve.cpp:37
SPxPricer * thepricer
Definition: spxsolver.h:380
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1070
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1295
Wrapper for GMP types.
SPxId instableEnterId
Definition: spxsolver.h:295
bool isSPxColId() const
is id a column id?
Definition: spxid.h:165
dual variable is set to its upper bound
Definition: spxbasis.h:192
solve() aborted due to commence decomposition simplex
Definition: spxsolver.h:210
solve() aborted due to time limit.
Definition: spxsolver.h:212
main LP solver class
an error occured.
Definition: spxsolver.h:204
void addIdx(int i)
adds index i to the index set
Definition: didxset.h:75
bool isBasic(SPxBasis::Desc::Status stat) const
does stat describe a basic index ?
Definition: spxsolver.h:1235
primal variable is left free, but unset
Definition: spxbasis.h:189
void setDual(Vector &p_vector)
Definition: spxsolve.cpp:1792
solve() aborted to exit decomposition simplex
Definition: spxsolver.h:209
const VectorBase< Real > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:253
bool getComputeDegeneracy() const
returns whether the degeneracy is computed in each iteration
Definition: spxsolver.h:2203
Real getEstimatedCondition()
Definition: spxbasis.h:607
#define MINIMUM(x, y)
Definition: spxdefines.h:244
int primalCount
number of primal iterations
Definition: spxsolver.h:367
Basis descriptor.
Definition: spxbasis.h:104
int getDegenCompOffset() const
gets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2217
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:418
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:374
virtual void generate(SPxSolver &base)=0
generates start basis for loaded basis.
algorithm is running
Definition: spxsolver.h:218
const VectorBase< Real > & maxRowObj() const
Definition: spxlpbase.h:297
Timer * theTime
time spent in last call to method solve()
Definition: spxsolver.h:246
virtual void setDelta(Real newDelta)
set allowed bound violation
Status & colStatus(int i)
Definition: spxbasis.h:254
Real m_leavetol
feasibility tolerance maintained during leaving algorithm
Definition: spxsolver.h:265
SPxId & baseId(int i)
Definition: spxbasis.h:503
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Definition: spxdefines.h:119
Real m_pricingViolCo
maximal feasibility violation of current solution in coDim
Definition: spxsolver.h:261
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:758
Debugging, floating point type and parameter definitions.
virtual void loadBasis(const SPxBasis::Desc &)
set a start basis.
Definition: spxsolver.cpp:92
virtual void setEpsilon(Real eps)
sets violation bound.
Definition: spxpricer.h:143
#define MAXSTALLS
Definition: spxsolve.cpp:29
Status getResult(Real *value=0, Vector *primal=0, Vector *slacks=0, Vector *dual=0, Vector *reduCost=0)
get all results of last solve.
Definition: spxsolve.cpp:1927
int totalboundflips
total number of bound flips
Definition: spxsolver.h:371
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:368
SolutionPolish polishObj
objective of solution polishing
Definition: spxsolver.h:245
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1450
Full pricing.
Definition: spxsolver.h:160
SSVector * solveVector2
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:272
DIdxSet infeasibilities
Definition: spxsolver.h:400
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1816
Status m_status
status of algorithm.
Definition: spxsolver.h:254
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.
virtual void setType(SPxSolver::Type)
sets pricing type.
Definition: spxpricer.h:154
virtual bool terminate()
Termination criterion.
Definition: spxsolve.cpp:1370
bool EQrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff |relDiff(a,b)| <= eps
Definition: spxdefines.h:423
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:248
UpdateVector * theFvec
Definition: spxsolver.h:342
Real dualDegenSum
the sum of the dual degeneracy percentage
Definition: spxsolver.h:378
SPxId lastLeft() const
returns SPxId of last vector that left the basis.
Definition: spxbasis.h:527
virtual void printDisplayLine(const bool force=false, const bool forceHead=false)
print display line of flying table
Definition: spxsolve.cpp:1333
solve() aborted due to detection of cycling.
Definition: spxsolver.h:211
int prevIteration() const
returns the number of iterations prior to the last break in execution
Definition: spxbasis.h:551
virtual SPxSolver * solver() const
returns loaded LP solver.
#define MSG_WARNING(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::WARNING.
Definition: spxdefines.h:113
primal variable is set to its lower bound
Definition: spxbasis.h:187
const VectorBase< Real > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:429
virtual void clearUpdateVecs(void)
Definition: spxsolver.cpp:532
int leaveCount
number of LEAVE iterations
Definition: spxsolver.h:365
nothing known on loaded problem.
Definition: spxsolver.h:219
don&#39;t perform modifications on optimal basis
Definition: spxsolver.h:229
const SVectorBase< Real > & rowVector(int i) const
Gets row vector of row i.
Definition: spxlpbase.h:204
void computeFrhs()
compute feasibility vector from scratch.
Definition: spxvecs.cpp:42
virtual Real epsilon() const
returns violation bound theeps.
Definition: spxpricer.h:135
void clear()
Set vector to 0.
Definition: vectorbase.h:260
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:160
SPxRatioTester * theratiotester
Definition: spxsolver.h:381
DVector * theCoPrhs
Definition: spxsolver.h:344
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:150
dual variable is set to its lower bound
Definition: spxbasis.h:193
int enterCycles
the number of degenerate steps during the entering algorithm
Definition: spxsolver.h:373
DSVector primalRay
stores primal ray in case of unboundedness
Definition: spxsolver.h:362
int size() const
return nr. of elements.
Definition: dataarray.h:211
#define MAXREFACPIVOTS
Definition: spxsolve.cpp:31
Type type() const
return current Type.
Definition: spxsolver.h:475
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:414
virtual SPxSolver * solver() const
returns loaded SPxSolver object.
Definition: spxpricer.h:129
int coDim() const
codimension.
Definition: spxsolver.h:1052
virtual Status getRedCost(Vector &vector) const
get vector of reduced costs.
Definition: spxsolve.cpp:1642
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:421
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:115
DSVector dualFarkas
stores dual farkas proof in case of infeasibility
Definition: spxsolver.h:363
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:157
int enterCount
number of ENTER iterations
Definition: spxsolver.h:366
const SLinSolver * slinSolver() const
return loaded SLinSolver.
Definition: spxsolver.h:1742
int printCondition
printing the current condition number in the log (0 - off, 1 - estimate,exact, 2 - exact)";ratio esti...
Definition: spxsolver.h:309
bool isCoBasic(int i) const
is the i &#39;th covector basic ?
Definition: spxsolver.h:1280
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:429
dual variable has two bounds
Definition: spxbasis.h:194
Real maxTime
maximum allowed time.
Definition: spxsolver.h:250
virtual int selectLeave()=0
returns selected index to leave basis.
Exception class for status exceptions during the computationsThis class is derived from the SoPlex ex...
Definition: exceptions.h:89
virtual void init()
intialize data structures.
Definition: spxsolver.cpp:317
SPxId lastEntered() const
returns SPxId of last vector included to the basis.
Definition: spxbasis.h:521
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
Definition: spxid.h:55
virtual void computeEnterCoPrhs()
compute theCoPrhs for entering Simplex.
Definition: spxvecs.cpp:405
void forceRecompNonbasicValue()
Definition: spxsolver.h:633
virtual void qualConstraintViolation(Real &maxviol, Real &sumviol) const
get violation of constraints.
Definition: spxquality.cpp:25
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:631
DIdxSet updateViolsCo
Definition: spxsolver.h:407
Textbook ratio test for SoPlex.
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:785
virtual void reset()=0
initialize timer, set timing accounts to zero.
bool isRowBasic(int i) const
is the i &#39;th row vector basic ?
Definition: spxsolver.h:1262
Status & status(int i)
Definition: spxbasis.h:269
Real objLimit
< the number of calls to the method isTimeLimitReached()
Definition: spxsolver.h:253
void setDecompIterationLimit(int iterationLimit)
sets the iteration limit for the decomposition simplex initialisation
Definition: spxsolver.h:2223
void computePvec()
compute entire pVec().
Definition: spxvecs.cpp:498
virtual void load(SPxSolver *lp, bool initSlackBasis=true)
loads the LP lp to the basis.
Definition: spxbasis.cpp:326
bool getStartingDecompBasis
flag to indicate whether the simplex is solved to get the starting improved dual simplex basis ...
Definition: spxsolver.h:303
UpdateVector * theCoPvec
Definition: spxsolver.h:345
const SPxBasis & basis() const
Return current basis.
Definition: spxsolver.h:1727
int iterCount
number of calls to change() since last manipulation
Definition: spxbasis.h:388
Status
Status of a variable.
Definition: spxbasis.h:185
SSVector * coSolveVector2
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:276
virtual Status solve()
solve loaded LP.
Definition: spxsolve.cpp:73
LP has been proven to be primal unbounded.
Definition: spxbasis.h:98
virtual Real maxInfeas() const
maximal infeasibility of basis
Definition: spxsolver.cpp:652
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:403
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:420
const VectorBase< Real > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:483
const Desc & desc() const
Definition: spxbasis.h:463
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:469
solve() aborted due to objective limit.
Definition: spxsolver.h:214
columnwise representation.
Definition: spxsolver.h:108
void setRedCost(Vector &p_vector)
Definition: spxsolve.cpp:1823
#define MAXCYCLES
Definition: spxsolve.cpp:28
virtual Status getDual(Vector &vector) const
get current solution vector for dual variables.
Definition: spxsolve.cpp:1611
Basis is singular, numerical troubles?
Definition: spxsolver.h:215
virtual Status getPrimalray(Vector &vector) const
get primal ray in case of unboundedness.
Definition: spxsolve.cpp:1685
virtual void factorize()
Factorize basis matrix.
Definition: spxsolver.cpp:547
Basis is primal feasible.
Definition: spxbasis.h:96
int lastDegenCheck() const
returns the number of iterations since the last degeneracy check
Definition: spxbasis.h:557
LP has a usable Basis (maybe LP is changed).
Definition: spxsolver.h:217
bool matrixIsSetup
true iff the pointers in matrix are set up correctly.
Definition: spxbasis.h:349
virtual Status getSlacks(Vector &vector) const
get vector of slack variables.
Definition: spxsolve.cpp:1721
void setBasisStatus(SPxBasis::SPxStatus stat)
set the lp solver&#39;s basis status.
Definition: spxsolver.h:2016
LP has been proven to be primal unbounded.
Definition: spxsolver.h:221
LP has been proven to be primal infeasible.
Definition: spxbasis.h:99
No Problem has been loaded to the basis.
Definition: spxbasis.h:92
No linear solver loaded.
Definition: spxsolver.h:207
void computeCoTest()
compute coTest vector.
Definition: enter.cpp:228
Real primalDegenSum
the sum of the primal degeneracy percentage
Definition: spxsolver.h:377