Scippy

SoPlex

Sequential object-oriented simPlex

spxsolver.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 #include <sstream>
19 
20 #include "spxdefines.h"
21 #include "soplex.h"
22 #include "spxpricer.h"
23 #include "spxratiotester.h"
24 #include "spxstarter.h"
25 #include "spxout.h"
26 #include "timerfactory.h"
27 
28 namespace soplex
29 {
30 
31 bool SPxSolver::read(std::istream& in, NameSet* rowNames,
32  NameSet* colNames, DIdxSet* intVars)
33 {
34  if( initialized )
35  {
36  clear();
37  unInit();
38 
39  if (thepricer)
40  thepricer->clear();
41 
42  if (theratiotester)
44  }
45 
46  unLoad();
47  if (!SPxLP::read(in, rowNames, colNames, intVars))
48  return false;
49 
50  theLP = this;
51 
52  return true;
53 }
54 
56 {
58  unInit();
59  unLoad();
60  theLP = this;
62  if (thepricer)
63  thepricer->clear();
64  if (theratiotester)
66 }
67 
68 void SPxSolver::loadLP(const SPxLP& lp, bool initSlackBasis)
69 {
70  clear();
71  unInit();
72  unLoad();
74  if (thepricer)
75  thepricer->clear();
76  if (theratiotester)
78  SPxLP::operator=(lp);
79  reDim();
80  SPxBasis::load(this, initSlackBasis);
81 }
82 
83 void SPxSolver::setBasisSolver(SLinSolver* slu, const bool destroy)
84 {
85  // we need to set the outstream before we load the solver to ensure that the basis
86  // can be initialized with this pointer in loadSolver()
87  assert(spxout != 0);
88  slu->spxout = spxout;
89  SPxBasis::loadBasisSolver(slu, destroy);
90 }
91 
93 {
94  unInit();
96  {
97  SPxBasis::load(this, false);
98  }
100  SPxBasis::loadDesc(p_desc);
101 }
102 
103 void SPxSolver::setPricer(SPxPricer* x, const bool destroy)
104 {
105 
106  assert(!freePricer || thepricer != 0);
107 
108  if(freePricer)
109  {
110  delete thepricer;
111  thepricer = 0;
112  }
113 
114  if (x != 0 && x != thepricer)
115  {
116  setPricing(FULL);
117  if (isInitialized())
118  x->load(this);
119  else
120  x->clear();
121  }
122 
123  if (thepricer && thepricer != x)
124  thepricer->clear();
125  thepricer = x;
126 
127  freePricer = destroy;
128 }
129 
130 void SPxSolver::setTester(SPxRatioTester* x, const bool destroy)
131 {
132  assert(!freeRatioTester || theratiotester != 0);
133 
134  if(freeRatioTester)
135  {
136  delete theratiotester;
137  theratiotester = 0;
138  }
139 
140  theratiotester = x;
141 
142  // set the solver pointer inside the ratiotester
143  if( theratiotester != 0 )
144  {
145  if( isInitialized() )
146  theratiotester->load(this);
147  else
149  }
150 
151  freeRatioTester = destroy;
152 }
153 
154 void SPxSolver::setStarter(SPxStarter* x, const bool destroy)
155 {
156 
157  assert(!freeStarter || thestarter != 0);
158 
159  if(freeStarter)
160  {
161  delete thestarter;
162  thestarter = 0;
163  }
164  thestarter = x;
165 
166  freeStarter = destroy;
167 }
168 
170 {
171 
172  if (theType != tp)
173  {
174  theType = tp;
175 
177 
178  unInit();
179 #if 0
180  else
181  {
182  if (!matrixIsSetup)
183  {
184  SPxBasis::load(this);
185  // SPxBasis::load(desc());
186  // not needed, because load(this) allready loads descriptor
187  }
188  factorized = false;
189  m_numCycle = 0;
190 #endif
191  MSG_INFO3( (*spxout), (*spxout) << "Switching to "
192  << static_cast<const char*>((tp == LEAVE)
193  ? "leaving" : "entering")
194  << " algorithm" << std::endl; )
195  }
196 }
197 
199 {
200 
201  Real tmpfeastol = feastol();
202  Real tmpopttol = opttol();
203 
204  theRep = p_rep;
205 
206  if (theRep == COLUMN)
207  {
208  thevectors = colSet();
209  thecovectors = rowSet();
210  theFrhs = &primRhs;
211  theFvec = &primVec;
212  theCoPrhs = &dualRhs;
213  theCoPvec = &dualVec;
214  thePvec = &addVec;
216  theCPvec = thePvec;
221  }
222  else
223  {
224  assert(theRep == ROW);
225 
226  thevectors = rowSet();
227  thecovectors = colSet();
228  theFrhs = &dualRhs;
229  theFvec = &dualVec;
230  theCoPrhs = &primRhs;
231  theCoPvec = &primVec;
232  thePvec = &addVec;
233  theRPvec = thePvec;
239  }
240  unInit();
241  reDim();
242 
244 
245  setFeastol(tmpfeastol);
246  setOpttol(tmpopttol);
247 
251 
252  if (thepricer && thepricer->solver() == this)
253  thepricer->setRep(p_rep);
254 }
255 
257 {
258 
259  if (p_rep != theRep)
260  initRep(p_rep);
261 }
262 
263 // needed for strongbranching. use carefully
265 {
266 
267  initialized = true;
268 
269  if (type() == ENTER)
270  {
271  if (rep() == COLUMN)
272  setPrimalBounds();
273  else
275 
276  setEnterBounds();
278  }
279  else
280  {
281  if (rep() == ROW)
282  setPrimalBounds();
283  else
285 
286  setLeaveBounds();
288  }
289 
291  computePvec();
292  computeFrhs();
294 
295  theShift = 0.0;
296  lastShift = 0.0;
297 
298  if (type() == ENTER)
299  {
300  computeCoTest();
301  computeTest();
302  }
303  else
304  {
305  computeFtest();
306  }
307  assert((testBounds(), 1));
308 }
309 
311 {
312  nClckSkipsLeft = 0;
313  nCallsToTimelim = 0;
314  theCumulativeTime = 0.0;
315 }
316 
318 {
319 
320  assert(thepricer != 0);
321  assert(theratiotester != 0);
322 
323  if (!initialized)
324  {
325  initialized = true;
326  reDim();
327  if (SPxBasis::status() <= SPxBasis::NO_PROBLEM || solver() != this)
328  SPxBasis::load(this);
329  initialized = false;
330  }
331  if (!matrixIsSetup)
333 
334  // Inna/Tobi: don't "upgrade" a singular basis to a regular one
336  return;
337 
338  // catch pathological case for LPs with zero constraints
339  if( dim() == 0 )
340  {
341  factorized = true;
342  }
343 
344  // we better factorize explicitly before solving
345  if( !factorized )
346  {
347  try
348  {
350  }
351  catch( const SPxException& )
352  {
353  // reload inital slack basis in case the factorization failed
357  assert(factorized);
358  }
359  }
360 
361  m_numCycle = 0;
362 
363  if (type() == ENTER)
364  {
365  if (rep() == COLUMN)
366  {
367  setPrimalBounds();
369  }
370  else
371  {
374  }
375  setEnterBounds();
377  // prepare support vectors for sparse pricing
383  }
384  else
385  {
386  if (rep() == ROW)
387  {
388  setPrimalBounds();
390  }
391  else
392  {
395  }
396  setLeaveBounds();
398  // prepare support vectors for sparse pricing
402  }
403 
405  computePvec();
406  computeFrhs();
408 
409  theShift = 0.0;
410 
411  if (type() == ENTER)
412  {
413  shiftFvec();
415 
416  computeCoTest();
417  computeTest();
418  }
419  else
420  {
421  shiftPvec();
423 
424  computeFtest();
425  }
426 
427  if (!initialized)
428  {
429  // if(thepricer->solver() != this)
430  thepricer->load(this);
431  // if(theratiotester->solver() != this)
432  theratiotester->load(this);
433  initialized = true;
434  }
435 }
436 
438 {
439  thePricing = pr;
440  if (initialized && type() == ENTER)
441  {
442  computePvec();
443  computeCoTest();
444  computeTest();
445  }
446 }
447 
449 {
450  if( decomp_stat == FINDSTARTBASIS )
451  getStartingDecompBasis = true;
452  else
453  getStartingDecompBasis = false;
454 }
455 
456 /*
457  The following method resizes all vectors and arrays of |SoPlex|
458  (excluding inherited vectors).
459  */
461 {
462 
463  int newsize = SPxLP::nCols() > SPxLP::nRows() ? SPxLP::nCols() : SPxLP::nRows();
464 
465  if (newsize > unitVecs.size())
466  {
467  unitVecs.reSize(newsize);
468 
469  while (newsize-- > 0)
470  unitVecs[newsize] = UnitVector(newsize);
471  }
472 
473  if (isInitialized())
474  {
475  theFrhs->reDim(dim());
476  theFvec->reDim(dim());
477  thePvec->reDim(coDim());
478 
479  theCoPrhs->reDim(dim());
480  theCoPvec->reDim(dim());
481 
482  theTest.reDim(coDim());
483  theCoTest.reDim(dim());
484 
489  theUBbound.reDim(dim());
490  theLBbound.reDim(dim());
491  }
492 }
493 
495 {
496  unitVecs.reSize(0);
497 
498  dualRhs.clear();
499  dualVec.clear();
500  primRhs.clear();
501  primVec.clear();
502  addVec.clear();
503  theURbound.clear();
504  theLRbound.clear();
505  theUCbound.clear();
506  theLCbound.clear();
507  theTest.clear();
508  theCoTest.clear();
509 
511  unInit();
512  SPxLP::clear();
514  // clear the basis only when theLP is present, because LP data (nrows, ncols) is used in reDim()
515  if( theLP != 0 )
516  SPxBasis::reDim();
517 
522 }
523 
525 {
528  unInit();
529  init();
530 }
531 
533 {
534  theFvec->clearUpdate();
535  thePvec->clearUpdate();
537  solveVector2 = 0;
538  solveVector3 = 0;
539  coSolveVector2 = 0;
540  coSolveVector3 = 0;
541 }
542 
543 /*
544  When the basis matrix factorization is recomputed from scratch,
545  we also recompute the vectors.
546  */
548 {
549 
550  MSG_INFO3( (*spxout), (*spxout) << " --- refactorizing basis matrix" << std::endl; )
551 
552  try
553  {
555  }
556  catch( const SPxStatusException& )
557  {
559  m_status = SINGULAR;
560  std::stringstream s;
561  s << "Basis is singular (numerical troubles, feastol = " << feastol() << ", opttol = " << opttol() << ")";
562  throw SPxStatusException(s.str());
563  }
564 
565  if( !initialized )
566  {
567  init(); // not sure if init() is neccessary here
568  // we must not go on here because not all vectors (e.g. fVec) may be set up correctly
569  return;
570  }
571 
573  {
574 #ifndef NDEBUG
575  DVector ftmp(fVec());
576  DVector ptmp(pVec());
577  DVector ctmp(coPvec());
578 #endif // NDEBUG
579 
580  if (type() == LEAVE)
581  {
582  /* we have to recompute theFrhs, because roundoff errors can occur during updating, especially when
583  * columns/rows with large bounds are present
584  */
585  computeFrhs();
588 
589 #ifndef NDEBUG
590  ftmp -= fVec();
591  ptmp -= pVec();
592  ctmp -= coPvec();
593  if (ftmp.length() > DEFAULT_BND_VIOL)
594  {
595  MSG_DEBUG( std::cout << "DSOLVE21 fVec: " << ftmp.length() << std::endl; )
596  ftmp = fVec();
597  multBaseWith(ftmp);
598  ftmp -= fRhs();
599  if (ftmp.length() > DEFAULT_BND_VIOL)
600  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE29 " << iteration() << ": fVec error = "
601  << ftmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl; )
602  }
603  if (ctmp.length() > DEFAULT_BND_VIOL)
604  {
605  MSG_DEBUG( std::cout << "DSOLVE23 coPvec: " << ctmp.length() << std::endl; )
606  ctmp = coPvec();
607  multWithBase(ctmp);
608  ctmp -= coPrhs();
609  if (ctmp.length() > DEFAULT_BND_VIOL)
610  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE30 " << iteration() << ": coPvec error = "
611  << ctmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl; )
612  }
613  if (ptmp.length() > DEFAULT_BND_VIOL)
614  {
615  MSG_DEBUG( std::cout << "DSOLVE24 pVec: " << ptmp.length() << std::endl; )
616  }
617 #endif // NDEBUG
618 
619  computeFtest();
620  }
621  else
622  {
623  assert(type() == ENTER);
624 
626  computeCoTest();
627 
628  if (pricing() == FULL)
629  {
630  /* to save time only recompute the row activities (in row rep) when we are already nearly optimal to
631  * avoid missing any violations from previous updates */
632  if( rep() == ROW && m_pricingViolCo < entertol() && m_pricingViol < entertol() )
633  computePvec();
634 
635  /* was deactivated, but this leads to warnings in testVecs() */
636  computeTest();
637  }
638  }
639  }
640 
641 #ifdef ENABLE_ADDITIONAL_CHECKS
642  /* moved this test after the computation of fTest and coTest below, since these vectors might not be set up at top, e.g. for an initial basis */
644  testVecs();
645 #endif
646 }
647 
648 /* We compute how much the current solution violates (primal or dual) feasibility. In the
649  row/enter or column/leave algorithm the maximum violation of dual feasibility is
650  computed. In the row/leave or column/enter algorithm the primal feasibility is checked.
651  Additionally, the violation from pricing is taken into account. */
653 {
654  Real inf = 0.0;
655 
656  if (type() == ENTER)
657  {
660 
661  for (int i = 0; i < dim(); i++)
662  {
663  if ((*theFvec)[i] > theUBbound[i])
664  inf = MAXIMUM(inf, (*theFvec)[i] - theUBbound[i]);
665  else if ((*theFvec)[i] < theLBbound[i])
666  inf = MAXIMUM(inf, theLBbound[i] - (*theFvec)[i]);
667  }
668  }
669  else
670  {
671  assert(type() == LEAVE);
672 
674  inf = m_pricingViol;
675 
676  for (int i = 0; i < dim(); i++)
677  {
678  if ((*theCoPvec)[i] > (*theCoUbound)[i])
679  inf = MAXIMUM(inf, (*theCoPvec)[i] - (*theCoUbound)[i]);
680  else if ((*theCoPvec)[i] < (*theCoLbound)[i])
681  inf = MAXIMUM(inf, (*theCoLbound)[i] - (*theCoPvec)[i]);
682  }
683  for (int i = 0; i < coDim(); i++)
684  {
685  if ((*thePvec)[i] > (*theUbound)[i])
686  inf = MAXIMUM(inf, (*thePvec)[i] - (*theUbound)[i]);
687  else if ((*thePvec)[i] < (*theLbound)[i])
688  inf = MAXIMUM(inf, (*theLbound)[i] - (*thePvec)[i]);
689  }
690  }
691 
692  return inf;
693 }
694 
695 /* check for (dual) violations above tol and immediately return false w/o checking the remaining values
696  This method is useful for verifying whether an objective limit can be used as termination criterion */
697 bool SPxSolver::noViols(Real tol) const
698 {
699  assert(tol >= 0.0);
700 
701  if( type() == ENTER )
702  {
703  for( int i = 0; i < dim(); i++ )
704  {
705  if( (*theFvec)[i] - theUBbound[i] > tol )
706  return false;
707  if( theLBbound[i] - (*theFvec)[i] > tol )
708  return false;
709  }
710  }
711  else
712  {
713  assert(type() == LEAVE);
714 
715  for( int i = 0; i < dim(); i++ )
716  {
717  if( (*theCoPvec)[i] - (*theCoUbound)[i] > tol )
718  return false;
719  if( (*theCoLbound)[i] - (*theCoPvec)[i] > tol )
720  return false;
721  }
722  for (int i = 0; i < coDim(); i++)
723  {
724  if( (*thePvec)[i] - (*theUbound)[i] > tol )
725  return false;
726  if( (*theLbound)[i] - (*thePvec)[i] > tol )
727  return false;
728  }
729  }
730  return true;
731 }
732 
734 {
735  int i;
736  Real val = 0;
737  const SPxBasis::Desc& ds = desc();
738 
739 #ifndef ENABLE_ADDITIONAL_CHECKS
740  // if the value is available we don't need to recompute it
742  return m_nonbasicValue;
743 #endif
744 
745  if (rep() == COLUMN)
746  {
747  if (type() == LEAVE)
748  {
749  for (i = nCols() - 1; i >= 0; --i)
750  {
751  switch (ds.colStatus(i))
752  {
754  val += theUCbound[i] * SPxLP::upper(i);
755  //@ val += maxObj(i) * SPxLP::upper(i);
756  break;
758  val += theLCbound[i] * SPxLP::lower(i);
759  //@ val += maxObj(i) * SPxLP::lower(i);
760  break;
762  val += maxObj(i) * SPxLP::lower(i);
763  break;
764  default:
765  break;
766  }
767  }
768  for (i = nRows() - 1; i >= 0; --i)
769  {
770  switch (ds.rowStatus(i))
771  {
773  val += theLRbound[i] * SPxLP::rhs(i);
774  break;
776  val += theURbound[i] * SPxLP::lhs(i);
777  break;
779  val += maxRowObj(i) * SPxLP::lhs(i);
780  break;
781  default:
782  break;
783  }
784  }
785  }
786  else
787  {
788  assert(type() == ENTER);
789  for (i = nCols() - 1; i >= 0; --i)
790  {
791  switch (ds.colStatus(i))
792  {
794  val += maxObj(i) * theUCbound[i];
795  break;
797  val += maxObj(i) * theLCbound[i];
798  break;
800  assert(theLCbound[i] == theUCbound[i]);
801  val += maxObj(i) * theLCbound[i];
802  break;
803  default:
804  break;
805  }
806  }
807  for (i = nRows() - 1; i >= 0; --i)
808  {
809  switch (ds.rowStatus(i))
810  {
812  val += maxRowObj(i) * theLRbound[i];
813  break;
815  val += maxRowObj(i) * theURbound[i];
816  break;
818  val += maxRowObj(i) * theURbound[i];
819  break;
820  default:
821  break;
822  }
823  }
824  }
825  }
826  else
827  {
828  assert(rep() == ROW);
829  assert(type() == ENTER);
830  for (i = nCols() - 1; i >= 0; --i)
831  {
832  switch (ds.colStatus(i))
833  {
835  val += theUCbound[i] * lower(i);
836  break;
838  val += theLCbound[i] * upper(i);
839  break;
841  val += theLCbound[i] * upper(i);
842  val += theUCbound[i] * lower(i);
843  break;
844  default:
845  break;
846  }
847  }
848  for (i = nRows() - 1; i >= 0; --i)
849  {
850  switch (ds.rowStatus(i))
851  {
853  val += theURbound[i] * lhs(i);
854  break;
856  val += theLRbound[i] * rhs(i);
857  break;
859  val += theLRbound[i] * rhs(i);
860  val += theURbound[i] * lhs(i);
861  break;
862  default:
863  break;
864  }
865  }
866  }
867 
868 #ifdef ENABLE_ADDITIONAL_CHECKS
870  {
871  MSG_ERROR( std::cerr << "stored nonbasic value: " << m_nonbasicValue
872  << ", correct nonbasic value: " << val
873  << ", violation: " << val - m_nonbasicValue << std::endl; )
874  assert(EQrel(m_nonbasicValue, val, 1e-12));
875  }
876 #endif
877 
879  {
880  m_nonbasicValue = val;
882  }
883 
884  return val;
885 }
886 
888 {
889  assert(isInitialized());
890 
891  Real x;
892 
893  // calling value() without having a suitable status is an error.
894  if (!isInitialized())
895  return infinity;
896 
897  if (rep() == ROW)
898  {
899  if (type() == LEAVE)
900  x = SPxLP::spxSense() * (coPvec() * fRhs()); // the contribution of maxRowObj() is missing
901  else
902  x = SPxLP::spxSense() * (nonbasicValue() + (coPvec() * fRhs()));
903  }
904  else
905  x = SPxLP::spxSense() * (nonbasicValue() + fVec() * coPrhs());
906 
907  return x + objOffset();
908 }
909 
911 {
913  m_nonbasicValue += objChange;
914 
915  MSG_DEBUG( std::cout
916  << "Iteration: " << iteration()
917  << ": updated objValue: " << objChange
918  << ", new value: " << m_nonbasicValue
919  << ", correct value: " << nonbasicValue()
920  << std::endl;
921  )
922 
924 }
925 
926 
927 
929 {
930 
931  if( d <= 0.0 )
932  throw SPxInterfaceException("XSOLVE30 Cannot set feastol less than or equal to zero.");
933 
934  if( theRep == COLUMN )
935  m_entertol = d;
936  else
937  m_leavetol = d;
938 }
939 
941 {
942 
943  if( d <= 0.0 )
944  throw SPxInterfaceException("XSOLVE31 Cannot set opttol less than or equal to zero.");
945 
946  if( theRep == COLUMN )
947  m_leavetol = d;
948  else
949  m_entertol = d;
950 }
951 
953 {
954 
955  if( d <= 0.0 )
956  throw SPxInterfaceException("XSOLVE32 Cannot set delta less than or equal to zero.");
957 
958  m_entertol = d;
959  m_leavetol = d;
960 }
961 
963 {
964  hyperPricingEnter = h;
965  hyperPricingLeave = h;
966  if( h )
967  {
970  }
971 }
972 
974  Type p_type,
975  Representation p_rep,
976  Timer::TYPE ttype)
977  : theType (p_type)
978  , thePricing(FULL)
979  , theRep(p_rep)
981  , theTime(0)
982  , timerType(ttype)
983  , theCumulativeTime(0.0)
984  , maxIters (-1)
985  , maxTime (infinity)
986  , nClckSkipsLeft(0)
987  , nCallsToTimelim(0)
988  , objLimit(infinity)
989  , m_status(UNKNOWN)
990  , m_nonbasicValue(0.0)
991  , m_nonbasicValueUpToDate(false)
992  , m_pricingViol(0.0)
993  , m_pricingViolUpToDate(false)
994  , m_pricingViolCo(0.0)
995  , m_pricingViolCoUpToDate(false)
996  , theShift (0)
997  , m_maxCycle(100)
998  , m_numCycle(0)
999  , initialized (false)
1000  , solveVector2 (0)
1001  , solveVector3 (0)
1002  , coSolveVector2(0)
1003  , coSolveVector3(0)
1004  , freePricer (false)
1005  , freeRatioTester (false)
1006  , freeStarter (false)
1007  , displayLine (0)
1008  , displayFreq (200)
1010  , getStartingDecompBasis(false)
1011  , computeDegeneracy(false)
1012  , degenCompIterOffset(0)
1013  , fullPerturbation(false)
1014  , printCondition(0)
1015  , unitVecs (0)
1016  , primVec (0, Param::epsilon())
1017  , dualVec (0, Param::epsilon())
1018  , addVec (0, Param::epsilon())
1019  , thepricer (0)
1020  , theratiotester (0)
1021  , thestarter (0)
1022  , infeasibilities(0)
1023  , infeasibilitiesCo(0)
1024  , isInfeasible(0)
1025  , isInfeasibleCo(0)
1026  , sparsePricingLeave(false)
1027  , sparsePricingEnter(false)
1028  , sparsePricingEnterCo(false)
1029  , hyperPricingLeave(true)
1030  , hyperPricingEnter(true)
1034  , integerVariables(0)
1035 {
1037 
1039 
1040  theLP = this;
1041  initRep(p_rep);
1042 
1043  // info: SPxBasis is not consistent in this moment.
1044  //assert(SPxSolver::isConsistent());
1045 }
1046 
1048 {
1049  assert(!freePricer || thepricer != 0);
1050  assert(!freeRatioTester || theratiotester != 0);
1051  assert(!freeStarter || thestarter != 0);
1052 
1053  if(freePricer)
1054  {
1055  delete thepricer;
1056  thepricer = 0;
1057  }
1058 
1059  if(freeRatioTester)
1060  {
1061  delete theratiotester;
1062  theratiotester = 0;
1063  }
1064 
1065  if(freeStarter)
1066  {
1067  delete thestarter;
1068  thestarter = 0;
1069  }
1070 
1071  // free timer
1072  assert(theTime);
1073  theTime->~Timer();
1074  spx_free(theTime);
1075 }
1076 
1077 
1079 {
1080  if(this != &base)
1081  {
1082  SPxLP::operator=(base);
1083  SPxBasis::operator=(base);
1084  theType = base.theType;
1085  thePricing = base.thePricing;
1086  theRep = base.theRep;
1087  polishObj = base.polishObj;
1088  timerType = base.timerType;
1089  maxIters = base.maxIters;
1090  maxTime = base.maxTime;
1091  objLimit = base.objLimit;
1092  m_status = base.m_status;
1099  m_entertol = base.m_entertol;
1100  m_leavetol = base.m_leavetol;
1101  theShift = base.theShift;
1102  lastShift = base.lastShift;
1103  m_maxCycle = base.m_maxCycle;
1104  m_numCycle = base.m_numCycle;
1105  initialized = base.initialized;
1112  displayLine = base.displayLine;
1113  displayFreq = base.displayFreq;
1121  unitVecs = base.unitVecs;
1122  primRhs = base.primRhs;
1123  primVec = base.primVec;
1124  dualRhs = base.dualRhs;
1125  dualVec = base.dualVec;
1126  addVec = base.addVec;
1127  theURbound = base.theURbound;
1128  theLRbound = base.theLRbound;
1129  theUCbound = base.theUCbound;
1130  theLCbound = base.theLCbound;
1131  theUBbound = base.theUBbound;
1132  theLBbound = base.theLBbound;
1133  theCoTest = base.theCoTest;
1134  theTest = base.theTest;
1135  primalRay = base.primalRay;
1136  dualFarkas = base.dualFarkas;
1137  leaveCount = base.leaveCount;
1138  enterCount = base.enterCount;
1140  primalCount = base.primalCount;
1141  polishCount = base.polishCount;
1142  boundflips = base.boundflips;
1144  enterCycles = base.enterCycles;
1145  leaveCycles = base.leaveCycles;
1151  isInfeasible = base.isInfeasible;
1162  spxout = base.spxout;
1164 
1165  if (base.theRep == COLUMN)
1166  {
1167  thevectors = colSet();
1168  thecovectors = rowSet();
1169  theFrhs = &primRhs;
1170  theFvec = &primVec;
1171  theCoPrhs = &dualRhs;
1172  theCoPvec = &dualVec;
1173  thePvec = &addVec;
1174  theRPvec = theCoPvec;
1175  theCPvec = thePvec;
1176  theUbound = &theUCbound;
1177  theLbound = &theLCbound;
1180  }
1181  else
1182  {
1183  assert(base.theRep == ROW);
1184 
1185  thevectors = rowSet();
1186  thecovectors = colSet();
1187  theFrhs = &dualRhs;
1188  theFvec = &dualVec;
1189  theCoPrhs = &primRhs;
1190  theCoPvec = &primVec;
1191  thePvec = &addVec;
1192  theRPvec = thePvec;
1193  theCPvec = theCoPvec;
1194  theUbound = &theURbound;
1195  theLbound = &theLRbound;
1198  }
1199 
1200  SPxBasis::theLP = this;
1201 
1202  assert(!freePricer || thepricer != 0);
1203  assert(!freeRatioTester || theratiotester != 0);
1204  assert(!freeStarter || thestarter != 0);
1205 
1206  // thepricer
1207  if(freePricer)
1208  {
1209  delete thepricer;
1210  thepricer = 0;
1211  }
1212  if(base.thepricer == 0)
1213  {
1214  thepricer = 0;
1215  freePricer = false;
1216  }
1217  else
1218  {
1219  thepricer = base.thepricer->clone();
1220  freePricer = true;
1221  thepricer->load(this);
1222  }
1223 
1224  // theratiotester
1225  if(freeRatioTester)
1226  {
1227  delete theratiotester;
1228  theratiotester = 0;
1229  }
1230  if(base.theratiotester == 0)
1231  {
1232  theratiotester = 0;
1233  freeRatioTester = false;
1234  }
1235  else
1236  {
1238  freeRatioTester = true;
1239  theratiotester->load(this);
1240  }
1241 
1242  // thestarter
1243  if(freeStarter)
1244  {
1245  delete thestarter;
1246  thestarter = 0;
1247  }
1248  if(base.thestarter == 0)
1249  {
1250  thestarter = 0;
1251  freeStarter = false;
1252  }
1253  else
1254  {
1255  thestarter = base.thestarter->clone();
1256  freeStarter = true;
1257  }
1258 
1259  assert(SPxSolver::isConsistent());
1260  }
1261 
1262  return *this;
1263 }
1264 
1265 
1267  : SPxLP (base)
1268  , SPxBasis(base)
1269  , theType(base.theType)
1270  , thePricing(base.thePricing)
1271  , theRep(base.theRep)
1272  , polishObj(base.polishObj)
1273  , timerType(base.timerType)
1275  , maxIters(base.maxIters)
1276  , maxTime(base.maxTime)
1279  , objLimit(base.objLimit)
1280  , m_status(base.m_status)
1287  , m_entertol(base.m_entertol)
1288  , m_leavetol(base.m_leavetol)
1289  , theShift(base.theShift)
1290  , lastShift(base.lastShift)
1291  , m_maxCycle(base.m_maxCycle)
1292  , m_numCycle(base.m_numCycle)
1293  , initialized(base.initialized)
1294  , solveVector2 (0)
1296  , solveVector3 (0)
1298  , coSolveVector2(0)
1300  , coSolveVector3(0)
1308  , displayLine(base.displayLine)
1309  , displayFreq(base.displayFreq)
1317  , unitVecs(base.unitVecs)
1318  , primRhs(base.primRhs)
1319  , primVec(base.primVec)
1320  , dualRhs(base.dualRhs)
1321  , dualVec(base.dualVec)
1322  , addVec(base.addVec)
1323  , theURbound(base.theURbound)
1324  , theLRbound(base.theLRbound)
1325  , theUCbound(base.theUCbound)
1326  , theLCbound(base.theLCbound)
1327  , theUBbound(base.theUBbound)
1328  , theLBbound(base.theLBbound)
1329  , theCoTest(base.theCoTest)
1330  , theTest(base.theTest)
1331  , primalRay(base.primalRay)
1332  , dualFarkas(base.dualFarkas)
1333  , leaveCount(base.leaveCount)
1334  , enterCount(base.enterCount)
1335  , primalCount(base.primalCount)
1336  , polishCount(base.polishCount)
1337  , boundflips(base.boundflips)
1339  , enterCycles(base.enterCycles)
1340  , leaveCycles(base.leaveCycles)
1344  , dualDegenSum(base.dualDegenSum)
1347  , isInfeasible(base.isInfeasible)
1357  , spxout(base.spxout)
1359 {
1361 
1362  if (base.theRep == COLUMN)
1363  {
1364  thevectors = colSet();
1365  thecovectors = rowSet();
1366  theFrhs = &primRhs;
1367  theFvec = &primVec;
1368  theCoPrhs = &dualRhs;
1369  theCoPvec = &dualVec;
1370  thePvec = &addVec;
1371  theRPvec = theCoPvec;
1372  theCPvec = thePvec;
1373  theUbound = &theUCbound;
1374  theLbound = &theLCbound;
1377  }
1378  else
1379  {
1380  assert(base.theRep == ROW);
1381 
1382  thevectors = rowSet();
1383  thecovectors = colSet();
1384  theFrhs = &dualRhs;
1385  theFvec = &dualVec;
1386  theCoPrhs = &primRhs;
1387  theCoPvec = &primVec;
1388  thePvec = &addVec;
1389  theRPvec = thePvec;
1390  theCPvec = theCoPvec;
1391  theUbound = &theURbound;
1392  theLbound = &theLRbound;
1395  }
1396 
1397  SPxBasis::theLP = this;
1398 
1399  if(base.thepricer == 0)
1400  {
1401  thepricer = 0;
1402  freePricer = false;
1403  }
1404  else
1405  {
1406  thepricer = base.thepricer->clone();
1407  freePricer = true;
1408  thepricer->clear();
1409  thepricer->load(this);
1410  }
1411 
1412  if(base.theratiotester == 0)
1413  {
1414  theratiotester = 0;
1415  freeRatioTester = false;
1416  }
1417  else
1418  {
1420  freeRatioTester = true;
1421  theratiotester->clear();
1422  theratiotester->load(this);
1423  }
1424 
1425  if(base.thestarter == 0)
1426  {
1427  thestarter = 0;
1428  freeStarter = false;
1429  }
1430  else
1431  {
1432  thestarter = base.thestarter->clone();
1433  freeStarter = true;
1434  }
1435 
1436  assert(SPxSolver::isConsistent());
1437 }
1438 
1440 {
1441 #ifdef ENABLE_CONSISTENCY_CHECKS
1442  if (epsilon() < 0)
1443  return MSGinconsistent("SPxSolver");
1444 
1446  return MSGinconsistent("SPxSolver");
1447 
1448  if (dualVec.delta().getEpsilon() != addVec.delta().getEpsilon())
1449  return MSGinconsistent("SPxSolver");
1450 
1451  if (unitVecs.size() < SPxLP::nCols() || unitVecs.size() < SPxLP::nRows())
1452  return MSGinconsistent("SPxSolver");
1453 
1454  if (initialized)
1455  {
1456  if (theFrhs->dim() != dim())
1457  return MSGinconsistent("SPxSolver");
1458  if (theFvec->dim() != dim())
1459  return MSGinconsistent("SPxSolver");
1460 
1461  if (theCoPrhs->dim() != dim())
1462  return MSGinconsistent("SPxSolver");
1463  if (thePvec->dim() != coDim())
1464  return MSGinconsistent("SPxSolver");
1465  if (theCoPvec->dim() != dim())
1466  return MSGinconsistent("SPxSolver");
1467 
1468  if (theTest.dim() != coDim())
1469  return MSGinconsistent("SPxSolver");
1470  if (theCoTest.dim() != dim())
1471  return MSGinconsistent("SPxSolver");
1472 
1473  if (theURbound.dim() != SPxLP::nRows())
1474  return MSGinconsistent("SPxSolver");
1475  if (theLRbound.dim() != SPxLP::nRows())
1476  return MSGinconsistent("SPxSolver");
1477  if (theUCbound.dim() != SPxLP::nCols())
1478  return MSGinconsistent("SPxSolver");
1479  if (theLCbound.dim() != SPxLP::nCols())
1480  return MSGinconsistent("SPxSolver");
1481  if (theUBbound.dim() != dim())
1482  return MSGinconsistent("SPxSolver");
1483  if (theLBbound.dim() != dim())
1484  return MSGinconsistent("SPxSolver");
1485  }
1486 
1487  if (rep() == COLUMN)
1488  {
1489  if(thecovectors !=
1490  reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1491  || thevectors !=
1492  reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1493  || theFrhs != &primRhs ||
1494  theFvec != &primVec ||
1495  theCoPrhs != &dualRhs ||
1496  theCoPvec != &dualVec ||
1497  thePvec != &addVec ||
1498  theRPvec != theCoPvec ||
1499  theCPvec != thePvec ||
1500  theUbound != &theUCbound ||
1501  theLbound != &theLCbound ||
1502  theCoUbound != &theURbound ||
1503  theCoLbound != &theLRbound)
1504  return MSGinconsistent("SPxSolver");
1505  }
1506  else
1507  {
1508  if (thecovectors
1509  != reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1510  || thevectors
1511  != reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1512  || theFrhs != &dualRhs ||
1513  theFvec != &dualVec ||
1514  theCoPrhs != &primRhs ||
1515  theCoPvec != &primVec ||
1516  thePvec != &addVec ||
1517  theRPvec != thePvec ||
1518  theCPvec != theCoPvec ||
1519  theUbound != &theURbound ||
1520  theLbound != &theLRbound ||
1521  theCoUbound != &theUCbound ||
1522  theCoLbound != &theLCbound)
1523  return MSGinconsistent("SPxSolver");
1524  }
1525 
1526  return SPxLP::isConsistent()
1527  && primRhs.isConsistent()
1528  && primVec.isConsistent()
1529  && dualRhs.isConsistent()
1530  && dualVec.isConsistent()
1531  && addVec.isConsistent()
1532  && theTest.isConsistent()
1533  && theCoTest.isConsistent()
1539  ;
1540 #else
1541  return true;
1542 #endif
1543 }
1544 
1545 
1547 {
1548  if( p_time < 0.0 )
1549  p_time = 0.0;
1550  maxTime = p_time;
1551 }
1552 
1554 {
1555  return maxTime;
1556 }
1557 
1558 void SPxSolver::setTerminationIter(int p_iteration)
1559 {
1560  if( p_iteration < 0 )
1561  p_iteration = -1;
1562  maxIters = p_iteration;
1563 }
1564 
1566 {
1567  return maxIters;
1568 }
1569 
1570 // returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
1571 bool SPxSolver::isTimeLimitReached(const bool forceCheck)
1572 {
1573  // always update the number of calls, since the user might set a time limit later in the solving process
1574  ++nCallsToTimelim;
1575 
1576  // check if a time limit is actually set
1577  if( maxTime >= infinity )
1578  return false;
1579 
1580  // check if the expensive system call to update the time should be skipped again
1581  if( forceCheck || nCallsToTimelim < NINITCALLS || nClckSkipsLeft <= 0 )
1582  {
1583  Real currtime = time();
1584 
1585  if( currtime >= maxTime )
1586  return true;
1587 
1588  // determine the number of times the clock can be skipped again.
1589  int nClckSkips = MAXNCLCKSKIPS;
1590  Real avgtimeinterval = (currtime + cumulativeTime()) / (Real)(nCallsToTimelim);
1591 
1592  // it would not be safe to skip the clock so many times since we are approaching the time limit
1593  if( SAFETYFACTOR * (maxTime - currtime) / (avgtimeinterval + 1e-6) < nClckSkips )
1594  nClckSkips = 0;
1595  nClckSkipsLeft = nClckSkips;
1596  }
1597  else
1598  --nClckSkipsLeft;
1599 
1600  return false;
1601 }
1602 
1603 
1604 /**@todo A first version for the termination value is
1605  * implemented. Currently we check if no bound violations (shifting)
1606  * is present. It might be even possible to use this termination
1607  * value in case of bound violations (shifting) but in this case it
1608  * is quite difficult to determine if we already reached the limit.
1609  */
1611 {
1612  objLimit = p_value;
1613 }
1614 
1616 {
1617  return objLimit;
1618 }
1619 
1622 {
1623  VarStatus vstat;
1624 
1625  switch( stat )
1626  {
1628  vstat = ON_LOWER;
1629  break;
1631  vstat = ON_UPPER;
1632  break;
1634  vstat = FIXED;
1635  break;
1637  vstat = ZERO;
1638  break;
1644  vstat = BASIC;
1645  break;
1646  default:
1647  MSG_ERROR( std::cerr << "ESOLVE26 ERROR: unknown basis status (" << stat << ")"
1648  << std::endl; )
1649  throw SPxInternalCodeException("XSOLVE22 This should never happen.");
1650  }
1651  return vstat;
1652 }
1653 
1656 {
1657  SPxBasis::Desc::Status rstat;
1658 
1659  switch( stat )
1660  {
1661  case FIXED :
1662  assert(rhs(row) == lhs(row));
1663  rstat = SPxBasis::Desc::P_FIXED;
1664  break;
1665  case ON_UPPER :
1666  assert(rhs(row) < infinity);
1667  rstat = lhs(row) < rhs(row)
1670  break;
1671  case ON_LOWER :
1672  assert(lhs(row) > -infinity);
1673  rstat = lhs(row) < rhs(row)
1676  break;
1677  case ZERO :
1678  /* A 'free' row (i.e., infinite lower & upper bounds) does not really make sense. The user
1679  * might (think to) know better, e.g., when temporarily turning off a row. We therefore apply
1680  * the same adjustment as in the column case in varStatusToBasisStatusCol(). */
1681  if (lhs(row) <= -infinity && rhs(row) >= infinity)
1682  rstat = SPxBasis::Desc::P_FREE;
1683  else
1684  {
1685  if ( lhs(row) == rhs(row) )
1686  {
1687  assert( rhs(row) < infinity );
1688  rstat = SPxBasis::Desc::P_FIXED;
1689  }
1690  else
1691  {
1692  if ( lhs(row) > -infinity )
1694  else
1695  {
1696  assert( rhs(row) < infinity );
1698  }
1699  }
1700  }
1701  break;
1702  case BASIC :
1703  rstat = dualRowStatus(row);
1704  break;
1705  default:
1706  MSG_ERROR( std::cerr << "ESOLVE27 ERROR: unknown VarStatus (" << int(stat) << ")"
1707  << std::endl; )
1708  throw SPxInternalCodeException("XSOLVE23 This should never happen.");
1709  }
1710  return rstat;
1711 }
1712 
1715 {
1716  SPxBasis::Desc::Status cstat;
1717 
1718  switch( stat )
1719  {
1720  case FIXED :
1721  if (upper(col) == lower(col))
1722  cstat = SPxBasis::Desc::P_FIXED;
1723  else if (maxObj(col) > 0.0)
1725  else
1727  break;
1728  case ON_UPPER :
1729  assert(upper(col) < infinity);
1730  cstat = lower(col) < upper(col)
1733  break;
1734  case ON_LOWER :
1735  assert(lower(col) > -infinity);
1736  cstat = lower(col) < upper(col)
1739  break;
1740  case ZERO :
1741  /* In this case the upper and lower bounds on the variable should be infinite. The bounds
1742  * might, however, have changed and we try to recover from this by changing the status to
1743  * 'resonable' settings. A solve has to find the correct values afterwards. Note that the
1744  * approach below is consistent with changesoplex.cpp (e.g., changeUpperStatus() and
1745  * changeLowerStatus() ). */
1746  if (lower(col) <= -infinity && upper(col) >= infinity)
1747  cstat = SPxBasis::Desc::P_FREE;
1748  else
1749  {
1750  if ( lower(col) == upper(col) )
1751  {
1752  assert( upper(col) < infinity );
1753  cstat = SPxBasis::Desc::P_FIXED;
1754  }
1755  else
1756  {
1757  if ( lower(col) > -infinity )
1759  else
1760  {
1761  assert( upper(col) < infinity );
1763  }
1764  }
1765  }
1766  break;
1767  case BASIC :
1768  cstat = dualColStatus(col);
1769  break;
1770  default:
1771  MSG_ERROR( std::cerr << "ESOLVE28 ERROR: unknown VarStatus (" << int(stat) << ")"
1772  << std::endl; )
1773  throw SPxInternalCodeException("XSOLVE24 This should never happen.");
1774  }
1775  return cstat;
1776 }
1777 
1779 {
1780  assert( 0 <= row && row < nRows() );
1781  return basisStatusToVarStatus( desc().rowStatus( row ) );
1782 }
1783 
1785 {
1786  assert( 0 <= col && col < nCols() );
1787  return basisStatusToVarStatus( desc().colStatus( col ) );
1788 }
1789 
1790 SPxSolver::Status SPxSolver::getBasis(VarStatus row[], VarStatus col[], const int rowsSize, const int colsSize) const
1791 {
1792  const SPxBasis::Desc& d = desc();
1793  int i;
1794 
1795  assert(rowsSize < 0 || rowsSize >= nRows());
1796  assert(colsSize < 0 || colsSize >= nCols());
1797 
1798  if (col)
1799  for (i = nCols() - 1; i >= 0; --i)
1800  col[i] = basisStatusToVarStatus( d.colStatus(i) );
1801 
1802  if (row)
1803  for (i = nRows() - 1; i >= 0; --i)
1804  row[i] = basisStatusToVarStatus( d.rowStatus(i) );
1805 
1806  return status();
1807 }
1808 
1810 {
1811 
1812  int basisdim;
1813 
1814  if ( p_rows.size() != nRows() || p_cols.size() != nCols() )
1815  return false;
1816 
1817  basisdim = 0;
1818  for ( int row = nRows()-1; row >= 0; --row )
1819  {
1820  if ( p_rows[row] == UNDEFINED )
1821  return false;
1822  // row is basic
1823  else if ( p_rows[row] == BASIC )
1824  {
1825  basisdim++;
1826  }
1827  // row is nonbasic
1828  else
1829  {
1830  if ( (p_rows[row] == FIXED && lhs(row) != rhs(row))
1831  || (p_rows[row] == ON_UPPER && rhs(row) >= infinity)
1832  || (p_rows[row] == ON_LOWER && lhs(row) <= -infinity) )
1833  return false;
1834  }
1835  }
1836 
1837  for ( int col = nCols()-1; col >= 0; --col )
1838  {
1839  if ( p_cols[col] == UNDEFINED )
1840  return false;
1841  // col is basic
1842  else if ( p_cols[col] == BASIC )
1843  {
1844  basisdim++;
1845  }
1846  // col is nonbasic
1847  else
1848  {
1849  if ( (p_cols[col] == FIXED && lower(col) != upper(col))
1850  || (p_cols[col] == ON_UPPER && upper(col) >= infinity)
1851  || (p_cols[col] == ON_LOWER && lower(col) <= -infinity) )
1852  return false;
1853  }
1854  }
1855 
1856  if ( basisdim != dim() )
1857  return false;
1858 
1859  // basis valid
1860  return true;
1861 }
1862 
1863 void SPxSolver::setBasis(const VarStatus p_rows[], const VarStatus p_cols[])
1864 {
1866  SPxBasis::load(this, false);
1867 
1868  SPxBasis::Desc ds = desc();
1869  int i;
1870 
1871  for(i = 0; i < nRows(); i++)
1872  ds.rowStatus(i) = varStatusToBasisStatusRow( i, p_rows[i] );
1873 
1874  for(i = 0; i < nCols(); i++)
1875  ds.colStatus(i) = varStatusToBasisStatusCol( i, p_cols[i] );
1876 
1877  loadBasis(ds);
1879 }
1880 
1881 void SPxSolver::getNdualNorms(int& nnormsRow, int& nnormsCol) const
1882 {
1883  assert(thepricer != NULL);
1884  return thepricer->getNdualNorms(nnormsRow, nnormsCol);
1885 }
1886 
1887 // NOTE: This only works for the row representation. Need to update to account for column representation.
1888 // The degenvec differs relative to the algorithm being used.
1889 // For the primal simplex, degenvec is the primal solution values.
1890 // For the dual simplex, the degenvec is the feasvec (ROW) and pVec (COLUMN).
1892 {
1893  int numDegenerate = 0;
1894  Real degeneracyLevel = 0;
1895 
1896  // iterating over all columns in the basis matrix
1897  // this identifies the basis indices and those that have a zero dual multiplier (rows) or zero reduced cost (cols).
1898  if( rep() == ROW )
1899  {
1900  for( int i = 0; i < nCols(); ++i ) // @todo Check the use of numColsReal for the reduced problem.
1901  {
1902  // degeneracy in the dual simplex exists if there are rows with a zero dual multiplier or columns with a zero
1903  // reduced costs. This requirement is regardless of the objective sense.
1904  if( isZero(degenvec[i], feastol()) )
1905  numDegenerate++;
1906  }
1907 
1908  if( type() == ENTER ) // dual simplex
1909  degeneracyLevel = Real(numDegenerate)/nCols();
1910  else // primal simplex
1911  {
1912  assert(type() == LEAVE);
1913  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate - (nCols() - nRows())) : 0.0;
1914  degeneracyLevel = degenVars/nRows();
1915  }
1916  }
1917  else
1918  {
1919  assert(rep() == COLUMN);
1920 
1921  for( int i = 0; i < nCols(); i++ )
1922  {
1923  if( type() == LEAVE ) // dual simplex
1924  {
1925  if( isZero(maxObj()[i] - degenvec[i], feastol()) )
1926  numDegenerate++;
1927  }
1928  else // primal simplex
1929  {
1930  assert( type() == ENTER );
1931  if( isZero(degenvec[i], feastol()) )
1932  numDegenerate++;
1933  }
1934  }
1935 
1936 
1937  if( type() == LEAVE ) // dual simplex
1938  {
1939  Real degenVars = nRows() > numDegenerate ? Real(nRows() - numDegenerate) : 0.0;
1940  degeneracyLevel = degenVars/nCols();
1941  }
1942  else // primal simplex
1943  {
1944  assert(type() == ENTER);
1945  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate - (nCols() - nRows())) : 0.0;
1946  degeneracyLevel = degenVars/nRows();
1947  }
1948  }
1949 
1950  return degeneracyLevel;
1951 }
1952 
1953 bool SPxSolver::getDualNorms(int& nnormsRow, int& nnormsCol, Real* norms) const
1954 {
1955  assert(thepricer != NULL);
1956  return thepricer->getDualNorms(nnormsRow, nnormsCol, norms);
1957 }
1958 
1959 bool SPxSolver::setDualNorms(int nnormsRow, int nnormsCol, Real* norms)
1960 {
1961  assert(thepricer != NULL);
1962  return thepricer->setDualNorms(nnormsRow, nnormsCol, norms);
1963 }
1964 
1965 void SPxSolver::setIntegralityInformation(int ncols, int* intInfo)
1966 {
1967  assert(ncols == nCols() || (ncols == 0 && intInfo == NULL));
1968 
1969  integerVariables.reSize(ncols);
1970  for( int i = 0; i < ncols; ++i )
1971  {
1972  integerVariables[i] = intInfo[i];
1973  }
1974 }
1975 
1976 
1977 
1978 //
1979 // Auxiliary functions.
1980 //
1981 
1982 // Pretty-printing of variable status.
1983 std::ostream& operator<<( std::ostream& os,
1984  const SPxSolver::VarStatus& status )
1985 {
1986  switch( status )
1987  {
1988  case SPxSolver::BASIC:
1989  os << "BASIC";
1990  break;
1991  case SPxSolver::FIXED:
1992  os << "FIXED";
1993  break;
1994  case SPxSolver::ON_LOWER:
1995  os << "ON_LOWER";
1996  break;
1997  case SPxSolver::ON_UPPER:
1998  os << "ON_UPPER";
1999  break;
2000  case SPxSolver::ZERO:
2001  os << "ZERO";
2002  break;
2003  case SPxSolver::UNDEFINED:
2004  os << "UNDEFINED";
2005  break;
2006  default:
2007  os << "?invalid?";
2008  break;
2009  }
2010  return os;
2011 }
2012 
2013 // Pretty-printing of solver status.
2014 std::ostream& operator<<( std::ostream& os,
2015  const SPxSolver::Status& status )
2016 {
2017  switch ( status )
2018  {
2019  case SPxSolver::ERROR:
2020  os << "ERROR";
2021  break;
2023  os << "NO_RATIOTESTER";
2024  break;
2025  case SPxSolver::NO_PRICER:
2026  os << "NO_PRICER";
2027  break;
2028  case SPxSolver::NO_SOLVER:
2029  os << "NO_SOLVER";
2030  break;
2031  case SPxSolver::NOT_INIT:
2032  os << "NOT_INIT";
2033  break;
2035  os << "ABORT_CYCLING";
2036  break;
2037  case SPxSolver::ABORT_TIME:
2038  os << "ABORT_TIME";
2039  break;
2040  case SPxSolver::ABORT_ITER:
2041  os << "ABORT_ITER";
2042  break;
2044  os << "ABORT_VALUE";
2045  break;
2046  case SPxSolver::SINGULAR:
2047  os << "SINGULAR";
2048  break;
2049  case SPxSolver::NO_PROBLEM:
2050  os << "NO_PROBLEM";
2051  break;
2052  case SPxSolver::REGULAR:
2053  os << "REGULAR";
2054  break;
2055  case SPxSolver::RUNNING:
2056  os << "RUNNING";
2057  break;
2058  case SPxSolver::UNKNOWN:
2059  os << "UNKNOWN";
2060  break;
2061  case SPxSolver::OPTIMAL:
2062  os << "OPTIMAL";
2063  break;
2064  case SPxSolver::UNBOUNDED:
2065  os << "UNBOUNDED";
2066  break;
2067  case SPxSolver::INFEASIBLE:
2068  os << "INFEASIBLE";
2069  break;
2070  default:
2071  os << "?other?";
2072  break;
2073  }
2074  return os;
2075 }
2076 
2077 // Pretty-printing of algorithm.
2078 std::ostream& operator<<( std::ostream& os,
2079  const SPxSolver::Type& status )
2080 {
2081  switch ( status )
2082  {
2083  case SPxSolver::ENTER:
2084  os << "ENTER";
2085  break;
2086  case SPxSolver::LEAVE:
2087  os << "LEAVE";
2088  break;
2089  default:
2090  os << "?other?";
2091  break;
2092  }
2093  return os;
2094 }
2095 
2096 // Pretty-printing of representation.
2097 std::ostream& operator<<( std::ostream& os,
2099 {
2100  switch ( status )
2101  {
2102  case SPxSolver::ROW:
2103  os << "ROW";
2104  break;
2105  case SPxSolver::COLUMN:
2106  os << "COLUMN";
2107  break;
2108  default:
2109  os << "?other?";
2110  break;
2111  }
2112  return os;
2113 }
2114 
2115 
2116 } // namespace soplex
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
void clearUpdate()
clear ,
Definition: updatevector.h:160
virtual ~SPxSolver()
Definition: spxsolver.cpp:1047
int iteration() const
returns number of basis changes since last load().
Definition: spxbasis.h:545
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.
Basis is dual feasible.
Definition: spxbasis.h:95
free variable fixed to zero.
Definition: spxsolver.h:194
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
Definition: dataarray.h:63
not initialised error
Definition: spxsolver.h:208
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
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
UnitVectorBase< Real > UnitVector
Definition: unitvector.h:29
int enterDegenCand
the number of degenerate candidates in the entering algorithm
Definition: spxsolver.h:375
primal variable is fixed to both bounds
Definition: spxbasis.h:190
int nClckSkipsLeft
remaining number of times the clock can be safely skipped
Definition: spxsolver.h:251
UpdateVector primVec
primal vector
Definition: spxsolver.h:323
const Real & objOffset() const
Returns the objective function value offset.
Definition: spxlpbase.h:516
SPxOut * spxout
message handler
Definition: slinsolver.h:212
bool isConsistent() const
Consistency check.
Definition: dvectorbase.h:302
int boundflips
number of performed bound flips
Definition: spxsolver.h:370
bool getDualNorms(int &nnormsRow, int &nnormsCol, Real *norms) const
get dual norms
Definition: spxsolver.cpp:1953
primal or dual variable has no status
Definition: spxbasis.h:195
void invalidate()
invalidates actual basis.
const VectorBase< Real > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:456
Desc::Status dualColStatus(int i) const
dual Status for the i&#39;th column variable of the loaded LP.
Definition: spxbasis.cpp:69
#define DEFAULT_BND_VIOL
default allowed bound violation
Definition: spxdefines.h:223
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
get number of dual norms
Definition: spxsolver.cpp:1881
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
DVector * theUbound
Upper bound for vars.
Definition: spxsolver.h:353
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:481
void setBasis(const VarStatus rows[], const VarStatus cols[])
set the lp solver&#39;s basis.
Definition: spxsolver.cpp:1863
void testBounds() const
Definition: spxbounds.cpp:311
UpdateVector addVec
storage for thePvec = &addVec
Definition: spxsolver.h:326
DVector theCoTest
Definition: spxsolver.h:359
Abstract pricer base class.
Real leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:770
DVector * theCoUbound
Upper bound for covars.
Definition: spxsolver.h:355
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
Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize=-1, const int colsSize=-1) const
get current basis, and return solver status.
Definition: spxsolver.cpp:1790
virtual void setStarter(SPxStarter *starter, const bool destroy=false)
setup starting basis generator to use. If destroy is true, starter will be freed in destructor...
Definition: spxsolver.cpp:154
int degenCompIterOffset
the number of iterations performed before the degeneracy level is computed
Definition: spxsolver.h:305
virtual void reDim()
reset dimensions of vectors according to loaded LP.
Definition: spxsolver.cpp:460
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:777
UpdateVector dualVec
dual vector
Definition: spxsolver.h:325
void unscaleLPandReloadBasis()
unscales the LP and reloads the basis
Definition: spxsolver.cpp:524
virtual void setBasisSolver(SLinSolver *slu, const bool destroy=false)
setup linear solver to use. If destroy is true, slusolver will be freed in destructor.
Definition: spxsolver.cpp:83
Type theType
entering or leaving algortihm.
Definition: spxsolver.h:242
Status & rowStatus(int i)
Definition: spxbasis.h:239
virtual void getNdualNorms(int &nrows, int &ncols) const
get number of available norms
Definition: spxpricer.h:250
Representation
LP basis representation.
Definition: spxsolver.h:105
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:419
virtual void clear()
clear all data in solver.
Definition: spxsolver.cpp:494
virtual void setRep(SPxSolver::Representation)
sets basis representation.
Definition: spxpricer.h:161
void setType(Type tp)
set LEAVE or ENTER algorithm.
Definition: spxsolver.cpp:169
void clear()
clear vector and update vector
Definition: updatevector.h:153
virtual ~Timer()
Definition: timer.h:124
VarStatus basisStatusToVarStatus(SPxBasis::Desc::Status stat) const
converts basis status to VarStatus
Definition: spxsolver.cpp:1621
Abstract ratio test base class.
solve() aborted due to iteration limit.
Definition: spxsolver.h:213
int leaveDegenCand
the number of degenerate candidates in the leaving algorithm
Definition: spxsolver.h:376
DecompStatus
Improved dual simplex status.
Definition: spxsolver.h:181
virtual int terminationIter() const
return iteration limit.
Definition: spxsolver.cpp:1565
virtual SPxStarter * clone() const =0
clone function for polymorphism
int m_maxCycle
maximum steps before cycling is detected.
Definition: spxsolver.h:268
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
bool NE(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| > eps
Definition: spxdefines.h:381
Real length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition: vectorbase.h:397
Pricing thePricing
full or partial pricing.
Definition: spxsolver.h:243
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
Abstract ratio test base class.Class SPxRatioTester is the virtual base class for computing the ratio...
#define SPARSITYFACTOR
Definition: spxsolver.h:39
DVector primRhs
rhs vector for computing the primal vector
Definition: spxsolver.h:322
SPxLPBase< Real > & operator=(const SPxLPBase< Real > &old)
Assignment operator.
Definition: spxlpbase.h:2581
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1047
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Definition: spxbasis.cpp:979
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxstarter.h:41
virtual bool read(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP or MPS format from input stream in.
Definition: spxlpbase.h:1114
void clear()
remove all elements.
Definition: dataarray.h:205
void reDim(int newdim)
reset dimension
Definition: updatevector.h:167
variable fixed to identical bounds.
Definition: spxsolver.h:193
Real sparsePricingFactor
enable sparse pricing when viols < factor * dim()
Definition: spxsolver.h:301
virtual SPxRatioTester * clone() const =0
clone function for polymorphism
LP has been proven to be primal infeasible.
Definition: spxsolver.h:222
void setPrimalBounds()
setup feasibility bounds for entering algorithm
Definition: spxbounds.cpp:32
SSVector * solveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:273
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
void setOpttol(Real d)
set parameter opttol.
Definition: spxsolver.cpp:940
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2107
bool factorized
true iff factor = matrix .
Definition: spxbasis.h:357
bool freeRatioTester
true iff theratiotester should be freed inside of object
Definition: spxsolver.h:282
void setRep()
sets descriptor representation according to loaded LP.
Definition: spxbasis.cpp:307
Sparse Linear Solver virtual base class.Class SLinSolver provides a class for solving sparse linear s...
Definition: slinsolver.h:43
#define NINITCALLS
Definition: spxsolver.h:48
Real m_nonbasicValue
nonbasic part of current objective value
Definition: spxsolver.h:256
virtual Real value()
current objective value.
Definition: spxsolver.cpp:887
rowwise representation.
Definition: spxsolver.h:107
bool setDualNorms(int nnormsRow, int nnormsCol, Real *norms)
set dual norms
Definition: spxsolver.cpp:1959
Real lastShift
for forcing feasibility.
Definition: spxsolver.h:267
virtual void computeLeaveCoPrhs()
compute theCoPrhs for leaving Simplex.
Definition: spxvecs.cpp:478
TimerFactory class.
SPxSolver(Type type=LEAVE, Representation rep=ROW, Timer::TYPE ttype=Timer::USER_TIME)
default constructor.
Definition: spxsolver.cpp:973
virtual void setTerminationTime(Real time=infinity)
set time limit.
Definition: spxsolver.cpp:1546
Basis is singular.
Definition: spxbasis.h:93
Desc::Status dualRowStatus(int i) const
dual Status for the i&#39;th row variable of the loaded LP.
Definition: spxbasis.cpp:46
#define SAFETYFACTOR
Definition: spxsolver.h:47
bool freePricer
true iff thepricer should be freed inside of object
Definition: spxsolver.h:281
Representation theRep
row or column representation.
Definition: spxsolver.h:244
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
virtual SPxPricer * clone() const =0
clone function for polymorphism
No ratiotester loaded.
Definition: spxsolver.h:205
No pricer loaded.
Definition: spxsolver.h:206
Entering Simplex.
Definition: spxsolver.h:134
const Vector & fRhs() const
right-hand side vector for fVec
Definition: spxsolver.h:1308
primal variable is set to its upper bound
Definition: spxbasis.h:188
UpdateVector & coPvec() const
copricing vector.
Definition: spxsolver.h:1370
int remainingRoundsLeave
number of dense rounds/refactorizations until sparsePricing is enabled again
Definition: spxsolver.h:423
int m_numCycle
actual number of degenerate steps so far.
Definition: spxsolver.h:269
int maxIters
maximum allowed iterations.
Definition: spxsolver.h:249
virtual bool getDualNorms(int &nrows, int &ncols, Real *norms) const
export norms from pricer
Definition: spxpricer.h:276
Leaving Simplex.
Definition: spxsolver.h:143
Real m_entertol
feasibility tolerance maintained during entering algorithm
Definition: spxsolver.h:264
nothing known about basis status (possibly due to a singular basis in transformed problem) ...
Definition: spxsolver.h:196
SPxStatus status() const
returns current SPxStatus.
Definition: spxbasis.h:425
SPxStarter * thestarter
Definition: spxsolver.h:382
SSVector * solveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:275
UpdateVector * theRPvec
row pricing vector
Definition: spxsolver.h:348
bool m_pricingViolCoUpToDate
true, if the stored violation in coDim is up to date
Definition: spxsolver.h:262
void reDim()
resizes internal arrays.
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
#define MAXNCLCKSKIPS
Definition: spxsolver.h:46
#define MAXIMUM(x, y)
Definition: spxdefines.h:243
Pricing
Pricing type.
Definition: spxsolver.h:152
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
DVector * theLbound
Lower bound for vars.
Definition: spxsolver.h:354
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:510
virtual void clear()
unloads LP.
Definition: spxpricer.h:123
Real m_pricingViol
maximal feasibility violation of current solution
Definition: spxsolver.h:259
virtual void unInit()
uninitialize data structures.
Definition: spxsolver.h:1825
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
Definition: basevectors.h:1151
Real entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:763
UpdateVector * thePvec
Definition: spxsolver.h:346
SPxBasis::Desc::Status varStatusToBasisStatusRow(int row, VarStatus stat) const
converts VarStatus to basis status for rows
Definition: spxsolver.cpp:1655
LP has been solved to optimality.
Definition: spxsolver.h:220
bool computeDegeneracy
Definition: spxsolver.h:304
virtual void setPricer(SPxPricer *pricer, const bool destroy=false)
setup pricer to use. If destroy is true, pricer will be freed in destructor.
Definition: spxsolver.cpp:103
Real cumulativeTime() const
cumulative time spent in all calls to method solve().
Definition: spxsolver.h:2123
virtual void setLeaveBounds()
Definition: spxbounds.cpp:297
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Definition: spxdefines.h:111
SPxPricer * thepricer
Definition: spxsolver.h:380
const SVSet * thecovectors
the LP coVectors according to representation
Definition: spxsolver.h:320
virtual Real terminationTime() const
return time limit.
Definition: spxsolver.cpp:1553
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1295
virtual void reinitializeVecs()
setup all vecs fresh
Definition: spxsolver.cpp:264
SPxId instableEnterId
Definition: spxsolver.h:295
dual variable is set to its upper bound
Definition: spxbasis.h:192
solve() aborted due to time limit.
Definition: spxsolver.h:212
DVector theLBbound
Lower Basic Feasibility bound.
Definition: spxsolver.h:339
an error occured.
Definition: spxsolver.h:204
primal variable is left free, but unset
Definition: spxbasis.h:189
const VectorBase< Real > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:253
SPxSolver & operator=(const SPxSolver &base)
assignment operator
Definition: spxsolver.cpp:1078
int primalCount
number of primal iterations
Definition: spxsolver.h:367
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:46
void shiftPvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:79
SSVector * coSolveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:279
variable set to its upper bound.
Definition: spxsolver.h:191
bool updateNonbasicValue(Real objChange)
Definition: spxsolver.cpp:910
Basis descriptor.
Definition: spxbasis.h:104
virtual void loadBasisSolver(SLinSolver *solver, const bool destroy=false)
sets up linear solver to use.
Definition: spxbasis.cpp:342
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
DVector theURbound
Upper Row Feasibility bound.
Definition: spxsolver.h:328
bool freeStarter
true iff thestarter should be freed inside of object
Definition: spxsolver.h:283
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:418
int remainingRoundsEnterCo
Definition: spxsolver.h:425
virtual void load(SPxSolver *p_solver)
loads LP.
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:374
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:43
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
virtual void loadLP(const SPxLP &LP, bool initSlackBasis=true)
copy LP.
Definition: spxsolver.cpp:68
variable set to its lower bound.
Definition: spxsolver.h:192
DVector theUBbound
Upper Basic Feasibility bound.
Definition: spxsolver.h:338
Preconfigured SoPlex LP solver.
#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
DVector * theCoLbound
Lower bound for covars.
Definition: spxsolver.h:356
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
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
Definition: spxbasis.h:82
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
void restoreInitialBasis()
Restores initial basis.
int totalboundflips
total number of bound flips
Definition: spxsolver.h:371
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:368
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:84
SolutionPolish polishObj
objective of solution polishing
Definition: spxsolver.h:245
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1450
virtual void load(SPxSolver *p_solver)
loads LP.
Definition: spxpricer.h:117
bool fullPerturbation
whether to perturb the entire problem or just the bounds relevant for the current pivot ...
Definition: spxsolver.h:308
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
DVector theLRbound
Lower Row Feasibility bound.
Definition: spxsolver.h:329
DVector theUCbound
Upper Column Feasibility bound.
Definition: spxsolver.h:330
void setDualColBounds()
Definition: spxbounds.cpp:103
virtual void setTerminationIter(int iteration=-1)
set iteration limit.
Definition: spxsolver.cpp:1558
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1816
virtual bool read(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
read LP from input stream.
Definition: spxsolver.cpp:31
int decompIterationLimit
the maximum number of iterations before the decomposition simplex is aborted.
Definition: spxsolver.h:306
Status m_status
status of algorithm.
Definition: spxsolver.h:254
int dim() const
Dimension of vector.
Definition: vectorbase.h:215
Starting basis has not been found yet.
Definition: spxsolver.h:184
Exception base class.This class implements a base class for our SoPlex exceptions We provide a what()...
Definition: exceptions.h:32
int remainingRoundsEnter
Definition: spxsolver.h:424
Everything should be within this namespace.
bool isBasisValid(DataArray< VarStatus > rows, DataArray< VarStatus > cols)
check a given basis for validity.
Definition: spxsolver.cpp:1809
TYPE
types of timers
Definition: timer.h:99
bool EQrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff |relDiff(a,b)| <= eps
Definition: spxdefines.h:423
R getEpsilon() const
Returns the non-zero epsilon used.
Definition: ssvectorbase.h:104
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:248
UpdateVector * theFvec
Definition: spxsolver.h:342
virtual void setTester(SPxRatioTester *tester, const bool destroy=false)
setup ratio-tester to use. If destroy is true, tester will be freed in destructor.
Definition: spxsolver.cpp:130
Real dualDegenSum
the sum of the dual degeneracy percentage
Definition: spxsolver.h:378
SSVector * coSolveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:277
virtual bool setDualNorms(int nrows, int ncols, Real *norms)
import norms into pricer
Definition: spxpricer.h:314
solve() aborted due to detection of cycling.
Definition: spxsolver.h:211
Set of LP columns.Class LPColSetBase implements a set of LPColBase%s. Unless for memory limitations...
Definition: lpcolsetbase.h:43
SPxBasis & operator=(const SPxBasis &rhs)
assignment operator
Definition: spxbasis.cpp:1304
primal variable is set to its lower bound
Definition: spxbasis.h:187
bool m_nonbasicValueUpToDate
true, if the stored objValue is up to date
Definition: spxsolver.h:257
const VectorBase< Real > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:429
Exception class for incorrect usage of interface methods.
Definition: exceptions.h:126
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
Definition: spxsolver.cpp:1965
SPxSolver * theLP
the LP
Definition: spxbasis.h:343
DVector theLCbound
Lower Column Feasibility bound.
Definition: spxsolver.h:331
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
VarStatus getBasisRowStatus(int row) const
gets basis status for a single row
Definition: spxsolver.cpp:1778
virtual void factorize()
factorizes the basis matrix.
Definition: spxbasis.cpp:889
bool isConsistent() const
check consistency.
Definition: spxsolver.cpp:1439
variable is basic.
Definition: spxsolver.h:195
VarStatus getBasisColStatus(int col) const
gets basis status for a single column
Definition: spxsolver.cpp:1784
void computeFrhs()
compute feasibility vector from scratch.
Definition: spxvecs.cpp:42
void setDualRowBounds()
Definition: spxbounds.cpp:133
void clear()
Set vector to 0.
Definition: vectorbase.h:260
SPxBasis::Desc::Status varStatusToBasisStatusCol(int col, VarStatus stat) const
converts VarStatus to basis status for columns
Definition: spxsolver.cpp:1714
SPxRatioTester * theratiotester
Definition: spxsolver.h:381
virtual Real terminationValue() const
return objective limit.
Definition: spxsolver.cpp:1615
void shiftFvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:25
DVector * theCoPrhs
Definition: spxsolver.h:344
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
virtual void loadDesc(const Desc &)
sets up basis.
Definition: spxbasis.cpp:188
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
Real theShift
sum of all shifts applied to any bound.
Definition: spxsolver.h:266
void unscaleLP()
unscales the lp and clears basis
virtual SPxSolver * solver() const
returns loaded SPxSolver object.
Definition: spxpricer.h:129
int coDim() const
codimension.
Definition: spxsolver.h:1052
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:421
bool isConsistent() const
Consistency check.
Definition: spxlpbase.h:1810
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:115
bool isConsistent() const
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 Vector & coPrhs() const
Right-hand side vector for coPvec.
Definition: spxsolver.h:1383
int printCondition
printing the current condition number in the log (0 - off, 1 - estimate,exact, 2 - exact)";ratio esti...
Definition: spxsolver.h:309
Array< UnitVector > unitVecs
array of unit vectors
Definition: spxsolver.h:318
const SVSet * thevectors
the LP vectors according to representation
Definition: spxsolver.h:319
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:429
virtual void setEnterBounds()
Definition: spxbounds.cpp:215
dual variable has two bounds
Definition: spxbasis.h:194
Real maxTime
maximum allowed time.
Definition: spxsolver.h:250
Exception class for status exceptions during the computationsThis class is derived from the SoPlex ex...
Definition: exceptions.h:89
void setFeastol(Real d)
set parameter feastol.
Definition: spxsolver.cpp:928
virtual void init()
intialize data structures.
Definition: spxsolver.cpp:317
bool initialized
true, if all vectors are setup.
Definition: spxsolver.h:270
virtual void computeEnterCoPrhs()
compute theCoPrhs for entering Simplex.
Definition: spxvecs.cpp:405
const SVSetBase< R > * colSet() const
Returns the complete SVSetBase.
Definition: lpcolsetbase.h:68
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
Definition: spxdefines.h:411
void forceRecompNonbasicValue()
Definition: spxsolver.h:633
#define MSGinconsistent(name)
Definition: spxdefines.h:123
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:631
void initRep(Representation p_rep)
initialize ROW or COLUMN representation.
Definition: spxsolver.cpp:198
SSVector & delta()
update vector , writeable
Definition: updatevector.h:122
DIdxSet updateViolsCo
Definition: spxsolver.h:407
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:785
bool m_pricingViolUpToDate
true, if the stored violation is up to date
Definition: spxsolver.h:260
void hyperPricing(bool h)
enable or disable hyper sparse pricing
Definition: spxsolver.cpp:962
void setMax(int newmax=1)
sets the maximum number of indices.
Definition: didxset.cpp:22
Real objLimit
< the number of calls to the method isTimeLimitReached()
Definition: spxsolver.h:253
const SVSetBase< Real > * rowSet() const
Returns the complete SVSet.
Definition: lprowsetbase.h:69
virtual void clear()
clears the LP.
Definition: spxlpbase.h:1078
void computePvec()
compute entire pVec().
Definition: spxvecs.cpp:498
virtual void setTerminationValue(Real value=infinity)
set objective limit.
Definition: spxsolver.cpp:1610
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
virtual void unLoad()
unloads the LP from the basis.
Definition: spxbasis.h:873
UpdateVector * theCoPvec
Definition: spxsolver.h:345
virtual void clear()
unloads LP.
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 void reLoad()
reload LP.
Definition: spxsolver.cpp:55
void reSize(int newsize)
reset size to newsize.
Definition: dataarray.h:223
virtual Real maxInfeas() const
maximal infeasibility of basis
Definition: spxsolver.cpp:652
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:403
DVector dualRhs
rhs vector for computing the dual vector
Definition: spxsolver.h:324
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
void setDecompStatus(DecompStatus decomp_stat)
turn on or off the improved dual simplex.
Definition: spxsolver.cpp:448
const Desc & desc() const
Definition: spxbasis.h:463
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:469
Real nonbasicValue()
Compute part of objective value.
Definition: spxsolver.cpp:733
solve() aborted due to objective limit.
Definition: spxsolver.h:214
columnwise representation.
Definition: spxsolver.h:108
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:109
bool isConsistent() const
consistency check.
Definition: spxbasis.cpp:1165
Basis is singular, numerical troubles?
Definition: spxsolver.h:215
UpdateVector * theCPvec
column pricing vector
Definition: spxsolver.h:349
virtual void factorize()
Factorize basis matrix.
Definition: spxsolver.cpp:547
Basis is primal feasible.
Definition: spxbasis.h:96
void resetClockStats()
resets clock average statistics
Definition: spxsolver.cpp:310
SPxSolver * solver() const
returns loaded solver.
Definition: spxbasis.h:563
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
void setBasisStatus(SPxBasis::SPxStatus stat)
set the lp solver&#39;s basis status.
Definition: spxsolver.h:2016
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
Definition: spxsolver.cpp:437
LP has been proven to be primal unbounded.
Definition: spxsolver.h:221
No Problem has been loaded to the basis.
Definition: spxbasis.h:92
No linear solver loaded.
Definition: spxsolver.h:207
void setDelta(Real d)
set parameter delta, i.e., set feastol and opttol to same value.
Definition: spxsolver.cpp:952
Timer::TYPE timerType
type of timer (user or wallclock)
Definition: spxsolver.h:247
void computeCoTest()
compute coTest vector.
Definition: enter.cpp:228
Real primalDegenSum
the sum of the primal degeneracy percentage
Definition: spxsolver.h:377