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 == SolutionPolish::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 == SolutionPolish::MAXBASICSLACK )
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 == SolutionPolish::MINBASICSLACK);
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 == SolutionPolish::MAXBASICSLACK )
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 == SolutionPolish::MINBASICSLACK);
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 
1257  setStatus(SPxStatus::OPTIMAL);
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 | value\n";
1339  }
1340  if( (force || (displayLine % displayFreq == 0)) && !forceHead )
1341  {
1342  (type() == LEAVE) ? (*spxout) << " L |" : (*spxout) << " E |";
1343  (*spxout) << std::fixed << std::setw(7) << std::setprecision(1) << time() << " |";
1344  (*spxout) << std::scientific << std::setprecision(2);
1345  (*spxout) << std::setw(8) << iteration() << " | "
1346  << std::setw(5) << slinSolver()->getFactorCount() << " | "
1347  << shift() << " | "
1348  << MAXIMUM(0.0, m_pricingViol + m_pricingViolCo) << " | "
1349  << std::setprecision(8) << value();
1351  (*spxout) << " (" << std::fixed << std::setprecision(2) << getDegeneracyLevel(fVec()) <<")";
1352  (*spxout) << std::endl;
1353  }
1354  displayLine++;
1355  );
1356 }
1357 
1358 
1360 {
1361 #ifdef ENABLE_ADDITIONAL_CHECKS
1363  testVecs();
1364 #endif
1365 
1366  int redo = dim();
1367  if (redo < 1000)
1368  redo = 1000;
1369 
1370  if (iteration() > 10 && iteration() % redo == 0)
1371  {
1372 #ifdef ENABLE_ADDITIONAL_CHECKS
1373  DVector cr(*theCoPrhs);
1374  DVector fr(*theFrhs);
1375 #endif
1376 
1377  if (type() == ENTER)
1379  else
1381 
1382  computeFrhs();
1383 
1384 #ifdef ENABLE_ADDITIONAL_CHECKS
1385  cr -= *theCoPrhs;
1386  fr -= *theFrhs;
1387  if (cr.length() > leavetol())
1388  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE50 unexpected change of coPrhs "
1389  << cr.length() << std::endl; )
1390  if (fr.length() > entertol())
1391  MSG_WARNING( (*spxout), (*spxout) << "WSOLVE51 unexpected change of Frhs "
1392  << fr.length() << std::endl; )
1393 #endif
1394 
1395  if (updateCount > 1)
1396  {
1397  MSG_INFO3( (*spxout), (*spxout) << " --- terminate triggers refactorization"
1398  << std::endl; )
1399  factorize();
1400  }
1403 
1404  if (pricing() == FULL)
1405  {
1406  computePvec();
1407  if (type() == ENTER)
1408  computeTest();
1409  }
1410 
1411  if (shift() > 0.0)
1412  unShift();
1413  }
1414 
1415  // check time limit and objective limit only for non-terminal bases
1418  {
1419  m_status = UNKNOWN;
1420  return true;
1421  }
1422 
1423  if ( isTimeLimitReached() )
1424  {
1425  MSG_INFO2( (*spxout), (*spxout) << " --- timelimit (" << maxTime
1426  << ") reached" << std::endl; )
1427  m_status = ABORT_TIME;
1428  return true;
1429  }
1430 
1431  // objLimit is set and we are running DUAL:
1432  // - objLimit is set if objLimit < infinity
1433  // - DUAL is running if rep() * type() > 0 == DUAL (-1 == PRIMAL)
1434  //
1435  // In this case we have given a objective value limit, e.g, through a
1436  // MIP solver, and we want stop solving the LP if we figure out that the
1437  // optimal value of the current LP can not be better then this objective
1438  // limit. More precisely:
1439  // - MINIMIZATION Problem
1440  // We want stop the solving process if
1441  // objLimit <= current objective value of the DUAL LP
1442  // - MAXIMIZATION Problem
1443  // We want stop the solving process if
1444  // objLimit >= current objective value of the DUAL LP
1445  if( objLimit < infinity && type() * rep() > 0 )
1446  {
1447  // We have no bound shifts; therefore, we can trust the current
1448  // objective value.
1449  // It might be even possible to use this termination value in case of
1450  // bound violations (shifting) but in this case it is quite difficult
1451  // to determine if we already reached the limit.
1452  if( shift() < epsilon() && noViols(opttol() - shift()) )
1453  {
1454  // SPxSense::MINIMIZE == -1, so we have sign = 1 on minimizing
1455  if( spxSense() * value() <= spxSense() * objLimit )
1456  {
1457  MSG_INFO2( (*spxout), (*spxout) << " --- objective value limit (" << objLimit
1458  << ") reached" << std::endl; )
1459  MSG_DEBUG(
1460  (*spxout) << " --- objective value limit reached" << std::endl
1461  << " (value: " << value()
1462  << ", limit: " << objLimit << ")" << std::endl
1463  << " (spxSense: " << int(spxSense())
1464  << ", rep: " << int(rep())
1465  << ", type: " << int(type()) << ")" << std::endl;
1466  )
1467 
1469  return true;
1470  }
1471  }
1472  }
1473 
1474 
1475 
1477  {
1478  DVector degenvec(nCols());
1479  if( rep() == ROW )
1480  {
1481  if( type() == ENTER ) // dual simplex
1483  else // primal simplex
1484  {
1485  getPrimal(degenvec);
1486  primalDegenSum += getDegeneracyLevel(degenvec);
1487  }
1488  }
1489  else
1490  {
1491  assert(rep() == COLUMN);
1492  if( type() == LEAVE ) // dual simplex
1494  else
1495  {
1496  getPrimal(degenvec);
1497  primalDegenSum += getDegeneracyLevel(degenvec);
1498  }
1499  }
1500  }
1501 
1502 
1503  // the improved dual simplex requires a starting basis
1504  // if the flag getStartingDecompBasis is set to true the simplex will terminate when a dual basis is found
1506  {
1507  Real iterationFrac = 0.6;
1508  if( type() == ENTER && SPxBasis::status() == SPxBasis::DUAL &&
1509  iteration() - lastDegenCheck() > getDegenCompOffset()/*iteration() % 10 == 0*/ )
1510  {
1512 
1514  {
1515  m_status = RUNNING;
1516  return true;
1517  }
1518 
1519  Real degeneracyLevel = 0;
1520  Real degeneracyLB = 0.1;
1521  Real degeneracyUB = 0.9;
1522  degeneracyLevel = getDegeneracyLevel(fVec());
1523  if( (degeneracyLevel < degeneracyUB && degeneracyLevel > degeneracyLB) && iteration() > nRows()*0.2 )
1524  {
1526  return true;
1527  }
1528 
1529  if( degeneracyLevel < degeneracyLB && iteration() > MINIMUM(getDecompIterationLimit(), int(nCols()*iterationFrac)) )
1530  {
1532  setDegenCompOffset(0);
1534  return true;
1535  }
1536  }
1537  else if( type() == LEAVE && iteration() > MINIMUM(getDecompIterationLimit(), int(nCols()*iterationFrac)) )
1538  {
1540  setDegenCompOffset(0);
1542  return true;
1543  }
1544  }
1545 
1547 
1548  return false;
1549 }
1550 
1552 {
1553 
1554  if (!isInitialized())
1555  {
1556  /* exit if presolving/simplifier cleared the problem */
1557  if (status() == NO_PROBLEM)
1558  return status();
1559  throw SPxStatusException("XSOLVE06 Not Initialized");
1560  }
1561  if (rep() == ROW)
1562  p_vector = coPvec();
1563  else
1564  {
1565  const SPxBasis::Desc& ds = desc();
1566 
1567  for (int i = 0; i < nCols(); ++i)
1568  {
1569  switch (ds.colStatus(i))
1570  {
1572  p_vector[i] = SPxLP::lower(i);
1573  break;
1576  p_vector[i] = SPxLP::upper(i);
1577  break;
1578  case SPxBasis::Desc::P_FREE :
1579  p_vector[i] = 0;
1580  break;
1581  case SPxBasis::Desc::D_FREE :
1586  break;
1587  default:
1588  throw SPxInternalCodeException("XSOLVE07 This should never happen.");
1589  }
1590  }
1591  for (int j = 0; j < dim(); ++j)
1592  {
1593  if (baseId(j).isSPxColId())
1594  p_vector[ number(SPxColId(baseId(j))) ] = fVec()[j];
1595  }
1596  }
1597  return status();
1598 }
1599 
1601 {
1602 
1603  assert(isInitialized());
1604 
1605  if (!isInitialized())
1606  {
1607  /* exit if presolving/simplifier cleared the problem */
1608  if (status() == NO_PROBLEM)
1609  return status();
1610  throw SPxStatusException("XSOLVE08 No Problem loaded");
1611  }
1612 
1613  if (rep() == ROW)
1614  {
1615  int i;
1616  p_vector = maxRowObj();
1617  for (i = nCols() - 1; i >= 0; --i)
1618  {
1619  if (baseId(i).isSPxRowId())
1620  p_vector[ number(SPxRowId(baseId(i))) ] = fVec()[i];
1621  }
1622  }
1623  else
1624  p_vector = coPvec();
1625 
1626  p_vector *= Real(spxSense());
1627 
1628  return status();
1629 }
1630 
1632 {
1633 
1634  assert(isInitialized());
1635 
1636  if (!isInitialized())
1637  {
1638  throw SPxStatusException("XSOLVE09 No Problem loaded");
1639  // return NOT_INIT;
1640  }
1641 
1642  if (rep() == ROW)
1643  {
1644  int i;
1645  p_vector.clear();
1646  if (spxSense() == SPxLP::MINIMIZE)
1647  {
1648  for (i = dim() - 1; i >= 0; --i)
1649  {
1650  if (baseId(i).isSPxColId())
1651  p_vector[ number(SPxColId(baseId(i))) ] = -fVec()[i];
1652  }
1653  }
1654  else
1655  {
1656  for (i = dim() - 1; i >= 0; --i)
1657  {
1658  if (baseId(i).isSPxColId())
1659  p_vector[ number(SPxColId(baseId(i))) ] = fVec()[i];
1660  }
1661  }
1662  }
1663  else
1664  {
1665  p_vector = maxObj();
1666  p_vector -= pVec();
1667  if (spxSense() == SPxLP::MINIMIZE)
1668  p_vector *= -1.0;
1669  }
1670 
1671  return status();
1672 }
1673 
1675 {
1676 
1677  assert(isInitialized());
1678 
1679  if (!isInitialized())
1680  {
1681  throw SPxStatusException("XSOLVE10 No Problem loaded");
1682  // return NOT_INIT;
1683  }
1684 
1686  p_vector.clear();
1687  p_vector = primalRay;
1688 
1689  return status();
1690 }
1691 
1693 {
1694 
1695  assert(isInitialized());
1696 
1697  if (!isInitialized())
1698  {
1699  throw SPxStatusException("XSOLVE10 No Problem loaded");
1700  // return NOT_INIT;
1701  }
1702 
1704  p_vector.clear();
1705  p_vector = dualFarkas;
1706 
1707  return status();
1708 }
1709 
1711 {
1712 
1713  assert(isInitialized());
1714 
1715  if (!isInitialized())
1716  {
1717  throw SPxStatusException("XSOLVE11 No Problem loaded");
1718  // return NOT_INIT;
1719  }
1720 
1721  if (rep() == COLUMN)
1722  {
1723  int i;
1724  const SPxBasis::Desc& ds = desc();
1725  for (i = nRows() - 1; i >= 0; --i)
1726  {
1727  switch (ds.rowStatus(i))
1728  {
1730  p_vector[i] = lhs(i);
1731  break;
1734  p_vector[i] = rhs(i);
1735  break;
1736  case SPxBasis::Desc::P_FREE :
1737  p_vector[i] = 0;
1738  break;
1739  case SPxBasis::Desc::D_FREE :
1744  break;
1745  default:
1746  throw SPxInternalCodeException("XSOLVE12 This should never happen.");
1747  }
1748  }
1749  for (i = dim() - 1; i >= 0; --i)
1750  {
1751  if (baseId(i).isSPxRowId())
1752  p_vector[ number(SPxRowId(baseId(i))) ] = -(*theFvec)[i];
1753  }
1754  }
1755  else
1756  p_vector = pVec();
1757 
1758  return status();
1759 }
1760 
1762 {
1763 
1764  if (!isInitialized())
1765  {
1766  throw SPxStatusException("XSOLVE20 Not Initialized");
1767  }
1768 
1769  if (rep() == ROW)
1770  coPvec() = p_vector;
1771  else
1772  {
1773  for (int j = 0; j < dim(); ++j)
1774  {
1775  if (baseId(j).isSPxColId())
1776  fVec()[j] = p_vector[ number(SPxColId(baseId(j))) ];
1777  }
1778  }
1779 }
1780 
1782 {
1783 
1784  assert(isInitialized());
1785 
1786  if (!isInitialized())
1787  {
1788  throw SPxStatusException("XSOLVE21 Not Initialized");
1789  }
1790 
1791  if (rep() == ROW)
1792  {
1793  for (int i = nCols() - 1; i >= 0; --i)
1794  {
1795  if (baseId(i).isSPxRowId())
1796  {
1797  if (spxSense() == SPxLP::MAXIMIZE)
1798  fVec()[i] = p_vector[ number(SPxRowId(baseId(i))) ];
1799  else
1800  fVec()[i] = -p_vector[ number(SPxRowId(baseId(i))) ];
1801  }
1802  }
1803  }
1804  else
1805  {
1806  coPvec() = p_vector;
1807  if (spxSense() == SPxLP::MINIMIZE)
1808  coPvec() *= -1.0;
1809  }
1810 }
1811 
1813 {
1814 
1815  assert(isInitialized());
1816 
1817  if (!isInitialized())
1818  {
1819  throw SPxStatusException("XSOLVE22 Not Initialized");
1820  }
1821 
1822  if (rep() == ROW)
1823  {
1824  for (int i = dim() - 1; i >= 0; --i)
1825  {
1826  if (baseId(i).isSPxColId())
1827  {
1828  if (spxSense() == SPxLP::MINIMIZE)
1829  fVec()[i] = -p_vector[ number(SPxColId(baseId(i))) ];
1830  else
1831  fVec()[i] = p_vector[ number(SPxColId(baseId(i))) ];
1832  }
1833  }
1834  }
1835  else
1836  {
1837  pVec() = maxObj();
1838 
1839  if (spxSense() == SPxLP::MINIMIZE)
1840  pVec() += p_vector;
1841  else
1842  pVec() -= p_vector;
1843  }
1844 }
1845 
1847 {
1848 
1849  assert(isInitialized());
1850 
1851  if (!isInitialized())
1852  {
1853  throw SPxStatusException("XSOLVE23 Not Initialized");
1854  }
1855 
1856  if (rep() == COLUMN)
1857  {
1858  for (int i = dim() - 1; i >= 0; --i)
1859  {
1860  if (baseId(i).isSPxRowId())
1861  (*theFvec)[i] = -p_vector[ number(SPxRowId(baseId(i))) ];
1862  }
1863  }
1864  else
1865  pVec() = p_vector;
1866 }
1867 
1869 {
1870  switch( m_status )
1871  {
1872  case UNKNOWN :
1873  switch (SPxBasis::status())
1874  {
1875  case SPxBasis::NO_PROBLEM :
1876  return NO_PROBLEM;
1877  case SPxBasis::SINGULAR :
1878  return SINGULAR;
1879  case SPxBasis::REGULAR :
1880  case SPxBasis::DUAL :
1881  case SPxBasis::PRIMAL :
1882  return UNKNOWN;
1883  case SPxBasis::OPTIMAL :
1884  return OPTIMAL;
1885  case SPxBasis::UNBOUNDED :
1886  return UNBOUNDED;
1887  case SPxBasis::INFEASIBLE :
1888  return INFEASIBLE;
1889  default:
1890  return ERROR;
1891  }
1892  case SINGULAR :
1893  return m_status;
1894  case OPTIMAL :
1895  assert( SPxBasis::status() == SPxBasis::OPTIMAL );
1896  /*lint -fallthrough*/
1897  case ABORT_EXDECOMP :
1898  case ABORT_DECOMP :
1899  case ABORT_CYCLING :
1900  case ABORT_TIME :
1901  case ABORT_ITER :
1902  case ABORT_VALUE :
1903  case RUNNING :
1904  case REGULAR :
1905  case NOT_INIT :
1906  case NO_SOLVER :
1907  case NO_PRICER :
1908  case NO_RATIOTESTER :
1909  case ERROR:
1910  return m_status;
1911  default:
1912  return ERROR;
1913  }
1914 }
1915 
1917  Real* p_value,
1918  Vector* p_primal,
1919  Vector* p_slacks,
1920  Vector* p_dual,
1921  Vector* reduCosts)
1922 {
1923  if (p_value)
1924  *p_value = this->value();
1925  if (p_primal)
1926  getPrimal(*p_primal);
1927  if (p_slacks)
1928  getSlacks(*p_slacks);
1929  if (p_dual)
1930  getDual(*p_dual);
1931  if (reduCosts)
1932  getRedCost(*reduCosts);
1933  return status();
1934 }
1935 } // 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:1077
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:937
SoPlex start basis generation base class.
virtual Real shift() const
total current shift amount.
Definition: spxsolver.h:1581
int iterations() const
get number of iterations of current solution.
Definition: spxsolver.h:2070
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:712
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:369
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:1345
virtual Status getPrimal(Vector &vector) const
get solution vector for primal variables.
Definition: spxsolve.cpp:1551
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:405
SPxOut * spxout
message handler
Definition: spxsolver.h:426
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:416
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:480
void testBounds() const
Definition: spxbounds.cpp:305
DVector theCoTest
Definition: spxsolver.h:358
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:769
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
Basis is optimal, i.e. dual and primal feasible.
Definition: spxbasis.h:97
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:776
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:418
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:398
void setType(Type tp)
set LEAVE or ENTER algorithm.
Definition: spxsolver.cpp:171
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:412
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:699
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:1035
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Definition: spxbasis.cpp:976
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:1570
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:2095
int getDecompIterationLimit() const
returns the iteration limit for the decomposition simplex initialisation
Definition: spxsolver.h:2217
void setDegenCompOffset(int iterOffset)
sets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2198
void setPrimal(Vector &p_vector)
Definition: spxsolve.cpp:1761
virtual Real value()
current objective value.
Definition: spxsolver.cpp:889
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
dual variable is left free, but unset
Definition: spxbasis.h:191
Real getDegeneracyLevel(Vector degenvec)
get level of dual degeneracy
Definition: spxsolver.cpp:1890
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:1296
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:1358
virtual Status getDualfarkas(Vector &vector) const
get dual farkas proof of infeasibility.
Definition: spxsolve.cpp:1692
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:381
double Real
Definition: spxdefines.h:214
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:1256
#define MAXIMUM(x, y)
Definition: spxdefines.h:242
void setSlacks(Vector &p_vector)
Definition: spxsolve.cpp:1846
void setStatus(SPxStatus stat)
sets basis SPxStatus to stat.
Definition: spxbasis.h:431
DVector * theFrhs
Definition: spxsolver.h:340
#define MSG_DEBUG(x)
Definition: spxdefines.h:128
Status status() const
Status of solution process.
Definition: spxsolve.cpp:1868
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
Definition: spxdefines.h:410
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:762
UpdateVector * thePvec
Definition: spxsolver.h:345
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:116
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:379
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1058
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1283
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:1223
primal variable is left free, but unset
Definition: spxbasis.h:189
void setDual(Vector &p_vector)
Definition: spxsolve.cpp:1781
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:2191
#define MINIMUM(x, y)
Definition: spxdefines.h:243
int primalCount
number of primal iterations
Definition: spxsolver.h:366
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:2205
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:417
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:373
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:118
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:757
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:1916
int totalboundflips
total number of bound flips
Definition: spxsolver.h:370
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:367
SolutionPolish polishObj
objective of solution polishing
Definition: spxsolver.h:245
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1438
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:399
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1804
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:1359
bool EQrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff |relDiff(a,b)| <= eps
Definition: spxdefines.h:434
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:248
UpdateVector * theFvec
Definition: spxsolver.h:341
Real dualDegenSum
the sum of the dual degeneracy percentage
Definition: spxsolver.h:377
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:112
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:534
int leaveCount
number of LEAVE iterations
Definition: spxsolver.h:364
nothing known on loaded problem.
Definition: spxsolver.h:219
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:380
DVector * theCoPrhs
Definition: spxsolver.h:343
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:372
DSVector primalRay
stores primal ray in case of unboundedness
Definition: spxsolver.h:361
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:474
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:413
virtual SPxSolver * solver() const
returns loaded SPxSolver object.
Definition: spxpricer.h:129
int coDim() const
codimension.
Definition: spxsolver.h:1040
virtual Status getRedCost(Vector &vector) const
get vector of reduced costs.
Definition: spxsolve.cpp:1631
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:420
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:114
DSVector dualFarkas
stores dual farkas proof in case of infeasibility
Definition: spxsolver.h:362
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:157
int enterCount
number of ENTER iterations
Definition: spxsolver.h:365
const SLinSolver * slinSolver() const
return loaded SLinSolver.
Definition: spxsolver.h:1730
bool isCoBasic(int i) const
is the i &#39;th covector basic ?
Definition: spxsolver.h:1268
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:428
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:319
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:632
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:624
DIdxSet updateViolsCo
Definition: spxsolver.h:406
Textbook ratio test for SoPlex.
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:784
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:1250
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:2211
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:323
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:344
const SPxBasis & basis() const
Return current basis.
Definition: spxsolver.h:1715
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:654
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:402
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:419
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:468
solve() aborted due to objective limit.
Definition: spxsolver.h:214
columnwise representation.
Definition: spxsolver.h:108
void setRedCost(Vector &p_vector)
Definition: spxsolve.cpp:1812
#define MAXCYCLES
Definition: spxsolve.cpp:28
virtual Status getDual(Vector &vector) const
get current solution vector for dual variables.
Definition: spxsolve.cpp:1600
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:1674
virtual void factorize()
Factorize basis matrix.
Definition: spxsolver.cpp:549
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:1710
void setBasisStatus(SPxBasis::SPxStatus stat)
set the lp solver&#39;s basis status.
Definition: spxsolver.h:2004
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:376