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-2019 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 "soplex/spxdefines.h"
21 #include "soplex.h"
22 #include "soplex/spxpricer.h"
23 #include "soplex/spxratiotester.h"
24 #include "soplex/spxstarter.h"
25 #include "soplex/spxout.h"
26 #include "soplex/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 
48  if(!SPxLP::read(in, rowNames, colNames, intVars))
49  return false;
50 
51  theLP = this;
52 
53  return true;
54 }
55 
57 {
59  unInit();
60  unLoad();
61  theLP = this;
63 
64  if(thepricer)
65  thepricer->clear();
66 
67  if(theratiotester)
69 }
70 
71 void SPxSolver::loadLP(const SPxLP& lp, bool initSlackBasis)
72 {
73  clear();
74  unInit();
75  unLoad();
77 
78  if(thepricer)
79  thepricer->clear();
80 
81  if(theratiotester)
83 
84  SPxLP::operator=(lp);
85  reDim();
86  SPxBasis::load(this, initSlackBasis);
87 }
88 
89 void SPxSolver::setBasisSolver(SLinSolver* slu, const bool destroy)
90 {
91  // we need to set the outstream before we load the solver to ensure that the basis
92  // can be initialized with this pointer in loadSolver()
93  assert(spxout != 0);
94  slu->spxout = spxout;
95  SPxBasis::loadBasisSolver(slu, destroy);
96 }
97 
99 {
100  unInit();
101 
103  {
104  SPxBasis::load(this, false);
105  }
106 
108  SPxBasis::loadDesc(p_desc);
109 }
110 
111 void SPxSolver::setPricer(SPxPricer* x, const bool destroy)
112 {
113 
114  assert(!freePricer || thepricer != 0);
115 
116  if(freePricer)
117  {
118  delete thepricer;
119  thepricer = 0;
120  }
121 
122  if(x != 0 && x != thepricer)
123  {
124  setPricing(FULL);
125 
126  if(isInitialized())
127  x->load(this);
128  else
129  x->clear();
130  }
131 
132  if(thepricer && thepricer != x)
133  thepricer->clear();
134 
135  thepricer = x;
136 
137  freePricer = destroy;
138 }
139 
140 void SPxSolver::setTester(SPxRatioTester* x, const bool destroy)
141 {
142  assert(!freeRatioTester || theratiotester != 0);
143 
144  if(freeRatioTester)
145  {
146  delete theratiotester;
147  theratiotester = 0;
148  }
149 
150  theratiotester = x;
151 
152  // set the solver pointer inside the ratiotester
153  if(theratiotester != 0)
154  {
155  if(isInitialized())
156  theratiotester->load(this);
157  else
159  }
160 
161  freeRatioTester = destroy;
162 }
163 
164 void SPxSolver::setStarter(SPxStarter* x, const bool destroy)
165 {
166 
167  assert(!freeStarter || thestarter != 0);
168 
169  if(freeStarter)
170  {
171  delete thestarter;
172  thestarter = 0;
173  }
174 
175  thestarter = x;
176 
177  freeStarter = destroy;
178 }
179 
181 {
182 
183  if(theType != tp)
184  {
185  theType = tp;
186 
188 
189  unInit();
190  MSG_INFO3((*spxout), (*spxout) << "Switching to "
191  << static_cast<const char*>((tp == LEAVE)
192  ? "leaving" : "entering")
193  << " algorithm" << std::endl;)
194  }
195 }
196 
198 {
199 
200  Real tmpfeastol = feastol();
201  Real tmpopttol = opttol();
202 
203  theRep = p_rep;
204 
205  if(theRep == COLUMN)
206  {
207  thevectors = colSet();
208  thecovectors = rowSet();
209  theFrhs = &primRhs;
210  theFvec = &primVec;
211  theCoPrhs = &dualRhs;
212  theCoPvec = &dualVec;
213  thePvec = &addVec;
215  theCPvec = thePvec;
220  }
221  else
222  {
223  assert(theRep == ROW);
224 
225  thevectors = rowSet();
226  thecovectors = colSet();
227  theFrhs = &dualRhs;
228  theFvec = &dualVec;
229  theCoPrhs = &primRhs;
230  theCoPvec = &primVec;
231  thePvec = &addVec;
232  theRPvec = thePvec;
238  }
239 
240  unInit();
241  reDim();
242 
244 
245  setFeastol(tmpfeastol);
246  setOpttol(tmpopttol);
247 
249 
252 
253  if(thepricer && thepricer->solver() == this)
254  thepricer->setRep(p_rep);
255 }
256 
258 {
259 
260  if(p_rep != theRep)
261  initRep(p_rep);
262 }
263 
264 // needed for strongbranching. use carefully
266 {
267 
268  initialized = true;
269 
270  if(type() == ENTER)
271  {
272  if(rep() == COLUMN)
273  setPrimalBounds();
274  else
276 
277  setEnterBounds();
279  }
280  else
281  {
282  if(rep() == ROW)
283  setPrimalBounds();
284  else
286 
287  setLeaveBounds();
289  }
290 
292  computePvec();
293  computeFrhs();
295 
296  theShift = 0.0;
297  lastShift = 0.0;
298 
299  if(type() == ENTER)
300  {
301  computeCoTest();
302  computeTest();
303  }
304  else
305  {
306  computeFtest();
307  }
308 
309  assert((testBounds(), 1));
310 }
311 
313 {
314  nClckSkipsLeft = 0;
315  nCallsToTimelim = 0;
316  theCumulativeTime = 0.0;
317 }
318 
320 {
321 
322  assert(thepricer != 0);
323  assert(theratiotester != 0);
324 
325  if(!initialized)
326  {
327  initialized = true;
328  clearUpdateVecs();
329  reDim();
330 
331  if(SPxBasis::status() <= SPxBasis::NO_PROBLEM || solver() != this)
332  SPxBasis::load(this);
333 
334  initialized = false;
335  }
336 
337  if(!matrixIsSetup)
339 
340  // Inna/Tobi: don't "upgrade" a singular basis to a regular one
342  return;
343 
344  // catch pathological case for LPs with zero constraints
345  if(dim() == 0)
346  {
347  factorized = true;
348  }
349 
350  // we better factorize explicitly before solving
351  if(!factorized)
352  {
353  try
354  {
356  }
357  catch(const SPxException&)
358  {
359  // reload inital slack basis in case the factorization failed
363  assert(factorized);
364  }
365  }
366 
367  m_numCycle = 0;
368 
369  if(type() == ENTER)
370  {
371  if(rep() == COLUMN)
372  {
373  setPrimalBounds();
375  }
376  else
377  {
380  }
381 
382  setEnterBounds();
384  // prepare support vectors for sparse pricing
390  }
391  else
392  {
393  if(rep() == ROW)
394  {
395  setPrimalBounds();
397  }
398  else
399  {
402  }
403 
404  setLeaveBounds();
406  // prepare support vectors for sparse pricing
410  }
411 
413  computePvec();
414  computeFrhs();
416 
417  theShift = 0.0;
418 
419  if(type() == ENTER)
420  {
421  shiftFvec();
423 
424  computeCoTest();
425  computeTest();
426  }
427  else
428  {
429  shiftPvec();
431 
432  computeFtest();
433  }
434 
435  if(!initialized)
436  {
437  // if(thepricer->solver() != this)
438  thepricer->load(this);
439  // if(theratiotester->solver() != this)
440  theratiotester->load(this);
441  initialized = true;
442  }
443 }
444 
446 {
447  thePricing = pr;
448 
449  if(initialized && type() == ENTER)
450  {
451  computePvec();
452  computeCoTest();
453  computeTest();
454  }
455 }
456 
458 {
459  if(decomp_stat == FINDSTARTBASIS)
460  getStartingDecompBasis = true;
461  else
462  getStartingDecompBasis = false;
463 }
464 
465 /*
466  The following method resizes all vectors and arrays of |SoPlex|
467  (excluding inherited vectors).
468  */
470 {
471 
472  int newsize = SPxLP::nCols() > SPxLP::nRows() ? SPxLP::nCols() : SPxLP::nRows();
473 
474  if(newsize > unitVecs.size())
475  {
476  unitVecs.reSize(newsize);
477 
478  while(newsize-- > 0)
479  unitVecs[newsize] = UnitVector(newsize);
480  }
481 
482  if(isInitialized())
483  {
484  theFrhs->reDim(dim());
485  theFvec->reDim(dim());
486  thePvec->reDim(coDim());
487 
488  theCoPrhs->reDim(dim());
489  theCoPvec->reDim(dim());
490 
491  theTest.reDim(coDim());
492  theCoTest.reDim(dim());
493 
498  theUBbound.reDim(dim());
499  theLBbound.reDim(dim());
500  }
501 }
502 
504 {
505  unitVecs.reSize(0);
506 
507  dualRhs.clear();
508  dualVec.clear();
509  primRhs.clear();
510  primVec.clear();
511  addVec.clear();
512  theURbound.clear();
513  theLRbound.clear();
514  theUCbound.clear();
515  theLCbound.clear();
516  theTest.clear();
517  theCoTest.clear();
518 
520  unInit();
521  SPxLP::clear();
523 
524  // clear the basis only when theLP is present, because LP data (nrows, ncols) is used in reDim()
525  if(theLP != 0)
526  SPxBasis::reDim();
527 
532 }
533 
535 {
538  unInit();
539  init();
540 }
541 
543 {
544  theFvec->clearUpdate();
545  thePvec->clearUpdate();
547  solveVector2 = 0;
548  solveVector3 = 0;
549  coSolveVector2 = 0;
550  coSolveVector3 = 0;
551 }
552 
553 /*
554  When the basis matrix factorization is recomputed from scratch,
555  we also recompute the vectors.
556  */
558 {
559 
560  MSG_INFO3((*spxout), (*spxout) << " --- refactorizing basis matrix" << std::endl;)
561 
562  try
563  {
565  }
566  catch(const SPxStatusException&)
567  {
569  m_status = SINGULAR;
570  std::stringstream s;
571  s << "Basis is singular (numerical troubles, feastol = " << feastol() << ", opttol = " << opttol()
572  << ")";
573  throw SPxStatusException(s.str());
574  }
575 
576  if(!initialized)
577  {
578  init(); // not sure if init() is neccessary here
579  // we must not go on here because not all vectors (e.g. fVec) may be set up correctly
580  return;
581  }
582 
584  {
585 #ifndef NDEBUG
586  DVector ftmp(fVec());
587  DVector ptmp(pVec());
588  DVector ctmp(coPvec());
589 #endif // NDEBUG
590 
591  if(type() == LEAVE)
592  {
593  /* we have to recompute theFrhs, because roundoff errors can occur during updating, especially when
594  * columns/rows with large bounds are present
595  */
596  computeFrhs();
599 
600 #ifndef NDEBUG
601  ftmp -= fVec();
602  ptmp -= pVec();
603  ctmp -= coPvec();
604 
605  if(ftmp.length() > DEFAULT_BND_VIOL)
606  {
607  MSG_DEBUG(std::cout << "DSOLVE21 fVec: " << ftmp.length() << std::endl;)
608  ftmp = fVec();
609  multBaseWith(ftmp);
610  ftmp -= fRhs();
611 
612  if(ftmp.length() > DEFAULT_BND_VIOL)
613  MSG_INFO1((*spxout), (*spxout) << "ESOLVE29 " << iteration() << ": fVec error = "
614  << ftmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl;)
615  }
616 
617  if(ctmp.length() > DEFAULT_BND_VIOL)
618  {
619  MSG_DEBUG(std::cout << "DSOLVE23 coPvec: " << ctmp.length() << std::endl;)
620  ctmp = coPvec();
621  multWithBase(ctmp);
622  ctmp -= coPrhs();
623 
624  if(ctmp.length() > DEFAULT_BND_VIOL)
625  MSG_INFO1((*spxout), (*spxout) << "ESOLVE30 " << iteration() << ": coPvec error = "
626  << ctmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl;)
627  }
628 
629  if(ptmp.length() > DEFAULT_BND_VIOL)
630  {
631  MSG_DEBUG(std::cout << "DSOLVE24 pVec: " << ptmp.length() << std::endl;)
632  }
633 
634 #endif // NDEBUG
635 
636  computeFtest();
637  }
638  else
639  {
640  assert(type() == ENTER);
641 
643  computeCoTest();
644 
645  if(pricing() == FULL)
646  {
647  /* to save time only recompute the row activities (in row rep) when we are already nearly optimal to
648  * avoid missing any violations from previous updates */
649  if(rep() == ROW && m_pricingViolCo < entertol() && m_pricingViol < entertol())
650  computePvec();
651 
652  /* was deactivated, but this leads to warnings in testVecs() */
653  computeTest();
654  }
655  }
656  }
657 
658 #ifdef ENABLE_ADDITIONAL_CHECKS
659 
660  /* 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 */
662  testVecs();
663 
664 #endif
665 }
666 
667 /* We compute how much the current solution violates (primal or dual) feasibility. In the
668  row/enter or column/leave algorithm the maximum violation of dual feasibility is
669  computed. In the row/leave or column/enter algorithm the primal feasibility is checked.
670  Additionally, the violation from pricing is taken into account. */
672 {
673  Real inf = 0.0;
674 
675  if(type() == ENTER)
676  {
679 
680  for(int i = 0; i < dim(); i++)
681  {
682  if((*theFvec)[i] > theUBbound[i])
683  inf = MAXIMUM(inf, (*theFvec)[i] - theUBbound[i]);
684  else if((*theFvec)[i] < theLBbound[i])
685  inf = MAXIMUM(inf, theLBbound[i] - (*theFvec)[i]);
686  }
687  }
688  else
689  {
690  assert(type() == LEAVE);
691 
693  inf = m_pricingViol;
694 
695  for(int i = 0; i < dim(); i++)
696  {
697  if((*theCoPvec)[i] > (*theCoUbound)[i])
698  inf = MAXIMUM(inf, (*theCoPvec)[i] - (*theCoUbound)[i]);
699  else if((*theCoPvec)[i] < (*theCoLbound)[i])
700  inf = MAXIMUM(inf, (*theCoLbound)[i] - (*theCoPvec)[i]);
701  }
702 
703  for(int i = 0; i < coDim(); i++)
704  {
705  if((*thePvec)[i] > (*theUbound)[i])
706  inf = MAXIMUM(inf, (*thePvec)[i] - (*theUbound)[i]);
707  else if((*thePvec)[i] < (*theLbound)[i])
708  inf = MAXIMUM(inf, (*theLbound)[i] - (*thePvec)[i]);
709  }
710  }
711 
712  return inf;
713 }
714 
715 /* check for (dual) violations above tol and immediately return false w/o checking the remaining values
716  This method is useful for verifying whether an objective limit can be used as termination criterion */
717 bool SPxSolver::noViols(Real tol) const
718 {
719  assert(tol >= 0.0);
720 
721  if(type() == ENTER)
722  {
723  for(int i = 0; i < dim(); i++)
724  {
725  if((*theFvec)[i] - theUBbound[i] > tol)
726  return false;
727 
728  if(theLBbound[i] - (*theFvec)[i] > tol)
729  return false;
730  }
731  }
732  else
733  {
734  assert(type() == LEAVE);
735 
736  for(int i = 0; i < dim(); i++)
737  {
738  if((*theCoPvec)[i] - (*theCoUbound)[i] > tol)
739  return false;
740 
741  if((*theCoLbound)[i] - (*theCoPvec)[i] > tol)
742  return false;
743  }
744 
745  for(int i = 0; i < coDim(); i++)
746  {
747  if((*thePvec)[i] - (*theUbound)[i] > tol)
748  return false;
749 
750  if((*theLbound)[i] - (*thePvec)[i] > tol)
751  return false;
752  }
753  }
754 
755  return true;
756 }
757 
759 {
760  int i;
761  StableSum<Real> val;
762  const SPxBasis::Desc& ds = desc();
763 
764 #ifndef ENABLE_ADDITIONAL_CHECKS
765 
766  // if the value is available we don't need to recompute it
768  return m_nonbasicValue;
769 
770 #endif
771 
772  if(rep() == COLUMN)
773  {
774  if(type() == LEAVE)
775  {
776  for(i = nCols() - 1; i >= 0; --i)
777  {
778  switch(ds.colStatus(i))
779  {
781  val += theUCbound[i] * SPxLP::upper(i);
782  //@ val += maxObj(i) * SPxLP::upper(i);
783  break;
784 
786  val += theLCbound[i] * SPxLP::lower(i);
787  //@ val += maxObj(i) * SPxLP::lower(i);
788  break;
789 
791  val += maxObj(i) * SPxLP::lower(i);
792  break;
793 
794  default:
795  break;
796  }
797  }
798 
799  for(i = nRows() - 1; i >= 0; --i)
800  {
801  switch(ds.rowStatus(i))
802  {
804  val += theLRbound[i] * SPxLP::rhs(i);
805  break;
806 
808  val += theURbound[i] * SPxLP::lhs(i);
809  break;
810 
812  val += maxRowObj(i) * SPxLP::lhs(i);
813  break;
814 
815  default:
816  break;
817  }
818  }
819  }
820  else
821  {
822  assert(type() == ENTER);
823 
824  for(i = nCols() - 1; i >= 0; --i)
825  {
826  switch(ds.colStatus(i))
827  {
829  val += maxObj(i) * theUCbound[i];
830  break;
831 
833  val += maxObj(i) * theLCbound[i];
834  break;
835 
837  assert(EQ(theLCbound[i], theUCbound[i]));
838  val += maxObj(i) * theLCbound[i];
839  break;
840 
841  default:
842  break;
843  }
844  }
845 
846  for(i = nRows() - 1; i >= 0; --i)
847  {
848  switch(ds.rowStatus(i))
849  {
851  val += maxRowObj(i) * theLRbound[i];
852  break;
853 
855  val += maxRowObj(i) * theURbound[i];
856  break;
857 
859  val += maxRowObj(i) * theURbound[i];
860  break;
861 
862  default:
863  break;
864  }
865  }
866  }
867  }
868  else
869  {
870  assert(rep() == ROW);
871  assert(type() == ENTER);
872 
873  for(i = nCols() - 1; i >= 0; --i)
874  {
875  switch(ds.colStatus(i))
876  {
878  val += theUCbound[i] * lower(i);
879  break;
880 
882  val += theLCbound[i] * upper(i);
883  break;
884 
886  val += theLCbound[i] * upper(i);
887  val += theUCbound[i] * lower(i);
888  break;
889 
890  default:
891  break;
892  }
893  }
894 
895  for(i = nRows() - 1; i >= 0; --i)
896  {
897  switch(ds.rowStatus(i))
898  {
900  val += theURbound[i] * lhs(i);
901  break;
902 
904  val += theLRbound[i] * rhs(i);
905  break;
906 
908  val += theLRbound[i] * rhs(i);
909  val += theURbound[i] * lhs(i);
910  break;
911 
912  default:
913  break;
914  }
915  }
916  }
917 
918 #ifdef ENABLE_ADDITIONAL_CHECKS
919 
921  {
922  MSG_ERROR(std::cerr << "stored nonbasic value: " << m_nonbasicValue
923  << ", correct nonbasic value: " << val
924  << ", violation: " << val - m_nonbasicValue << std::endl;)
925  assert(EQrel(m_nonbasicValue, val, 1e-12));
926  }
927 
928 #endif
929 
931  {
932  m_nonbasicValue = val;
934  }
935 
936  return val;
937 }
938 
940 {
941  assert(isInitialized());
942 
943  Real x;
944 
945  // calling value() without having a suitable status is an error.
946  if(!isInitialized())
947  return infinity;
948 
949  if(rep() == ROW)
950  {
951  if(type() == LEAVE)
952  x = SPxLP::spxSense() * (coPvec() * fRhs()); // the contribution of maxRowObj() is missing
953  else
954  x = SPxLP::spxSense() * (nonbasicValue() + (coPvec() * fRhs()));
955  }
956  else
957  x = SPxLP::spxSense() * (nonbasicValue() + fVec() * coPrhs());
958 
959  return x + objOffset();
960 }
961 
963 {
965  m_nonbasicValue += objChange;
966 
967  MSG_DEBUG(std::cout
968  << "Iteration: " << iteration()
969  << ": updated objValue: " << objChange
970  << ", new value: " << m_nonbasicValue
971  << ", correct value: " << nonbasicValue()
972  << std::endl;
973  )
974 
976 }
977 
978 
979 
981 {
982 
983  if(d <= 0.0)
984  throw SPxInterfaceException("XSOLVE30 Cannot set feastol less than or equal to zero.");
985 
986  if(theRep == COLUMN)
987  m_entertol = d;
988  else
989  m_leavetol = d;
990 }
991 
993 {
994 
995  if(d <= 0.0)
996  throw SPxInterfaceException("XSOLVE31 Cannot set opttol less than or equal to zero.");
997 
998  if(theRep == COLUMN)
999  m_leavetol = d;
1000  else
1001  m_entertol = d;
1002 }
1003 
1005 {
1006 
1007  if(d <= 0.0)
1008  throw SPxInterfaceException("XSOLVE32 Cannot set delta less than or equal to zero.");
1009 
1010  m_entertol = d;
1011  m_leavetol = d;
1012 }
1013 
1015 {
1016  hyperPricingEnter = h;
1017  hyperPricingLeave = h;
1018 
1019  if(h)
1020  {
1021  updateViols.setMax(dim());
1023  }
1024 }
1025 
1027  Type p_type,
1028  Representation p_rep,
1029  Timer::TYPE ttype)
1030  : theType(p_type)
1031  , thePricing(FULL)
1032  , theRep(p_rep)
1034  , theTime(0)
1035  , timerType(ttype)
1036  , theCumulativeTime(0.0)
1037  , maxIters(-1)
1038  , maxTime(infinity)
1039  , nClckSkipsLeft(0)
1040  , nCallsToTimelim(0)
1041  , objLimit(infinity)
1042  , m_status(UNKNOWN)
1043  , m_nonbasicValue(0.0)
1044  , m_nonbasicValueUpToDate(false)
1045  , m_pricingViol(0.0)
1046  , m_pricingViolUpToDate(false)
1047  , m_pricingViolCo(0.0)
1048  , m_pricingViolCoUpToDate(false)
1049  , theShift(0)
1050  , m_maxCycle(100)
1051  , m_numCycle(0)
1052  , initialized(false)
1053  , solveVector2(0)
1054  , solveVector3(0)
1055  , coSolveVector2(0)
1056  , coSolveVector3(0)
1057  , freePricer(false)
1058  , freeRatioTester(false)
1059  , freeStarter(false)
1060  , displayLine(0)
1061  , displayFreq(200)
1063  , getStartingDecompBasis(false)
1064  , computeDegeneracy(false)
1065  , degenCompIterOffset(0)
1066  , fullPerturbation(false)
1067  , printCondition(0)
1068  , unitVecs(0)
1069  , primVec(0, Param::epsilon())
1070  , dualVec(0, Param::epsilon())
1071  , addVec(0, Param::epsilon())
1072  , thepricer(0)
1073  , theratiotester(0)
1074  , thestarter(0)
1075  , boundrange(0.0)
1076  , siderange(0.0)
1077  , objrange(0.0)
1078  , infeasibilities(0)
1079  , infeasibilitiesCo(0)
1080  , isInfeasible(0)
1081  , isInfeasibleCo(0)
1082  , sparsePricingLeave(false)
1083  , sparsePricingEnter(false)
1084  , sparsePricingEnterCo(false)
1085  , hyperPricingLeave(true)
1086  , hyperPricingEnter(true)
1090  , weights(0)
1091  , coWeights(0)
1092  , weightsAreSetup(false)
1093  , integerVariables(0)
1094 {
1096 
1098 
1099  theLP = this;
1100  initRep(p_rep);
1101 
1102  // info: SPxBasis is not consistent in this moment.
1103  //assert(SPxSolver::isConsistent());
1104 }
1105 
1107 {
1108  assert(!freePricer || thepricer != 0);
1109  assert(!freeRatioTester || theratiotester != 0);
1110  assert(!freeStarter || thestarter != 0);
1111 
1112  if(freePricer)
1113  {
1114  delete thepricer;
1115  thepricer = 0;
1116  }
1117 
1118  if(freeRatioTester)
1119  {
1120  delete theratiotester;
1121  theratiotester = 0;
1122  }
1123 
1124  if(freeStarter)
1125  {
1126  delete thestarter;
1127  thestarter = 0;
1128  }
1129 
1130  // free timer
1131  assert(theTime);
1132  theTime->~Timer();
1133  spx_free(theTime);
1134 }
1135 
1136 
1138 {
1139  if(this != &base)
1140  {
1141  SPxLP::operator=(base);
1142  SPxBasis::operator=(base);
1143  theType = base.theType;
1144  thePricing = base.thePricing;
1145  theRep = base.theRep;
1146  polishObj = base.polishObj;
1147  timerType = base.timerType;
1148  maxIters = base.maxIters;
1149  maxTime = base.maxTime;
1150  objLimit = base.objLimit;
1151  m_status = base.m_status;
1158  m_entertol = base.m_entertol;
1159  m_leavetol = base.m_leavetol;
1160  theShift = base.theShift;
1161  lastShift = base.lastShift;
1162  m_maxCycle = base.m_maxCycle;
1163  m_numCycle = base.m_numCycle;
1164  initialized = base.initialized;
1171  displayLine = base.displayLine;
1172  displayFreq = base.displayFreq;
1180  unitVecs = base.unitVecs;
1181  primRhs = base.primRhs;
1182  primVec = base.primVec;
1183  dualRhs = base.dualRhs;
1184  dualVec = base.dualVec;
1185  addVec = base.addVec;
1186  theURbound = base.theURbound;
1187  theLRbound = base.theLRbound;
1188  theUCbound = base.theUCbound;
1189  theLCbound = base.theLCbound;
1190  theUBbound = base.theUBbound;
1191  theLBbound = base.theLBbound;
1192  theCoTest = base.theCoTest;
1193  theTest = base.theTest;
1194  primalRay = base.primalRay;
1195  dualFarkas = base.dualFarkas;
1196  leaveCount = base.leaveCount;
1197  enterCount = base.enterCount;
1199  primalCount = base.primalCount;
1200  polishCount = base.polishCount;
1201  boundflips = base.boundflips;
1203  enterCycles = base.enterCycles;
1204  leaveCycles = base.leaveCycles;
1208  boundrange = base.boundrange;
1209  siderange = base.siderange;
1210  objrange = base.objrange;
1213  isInfeasible = base.isInfeasible;
1224  weights = base.weights;
1225  coWeights = base.coWeights;
1227  spxout = base.spxout;
1229 
1230  if(base.theRep == COLUMN)
1231  {
1232  thevectors = colSet();
1233  thecovectors = rowSet();
1234  theFrhs = &primRhs;
1235  theFvec = &primVec;
1236  theCoPrhs = &dualRhs;
1237  theCoPvec = &dualVec;
1238  thePvec = &addVec;
1239  theRPvec = theCoPvec;
1240  theCPvec = thePvec;
1241  theUbound = &theUCbound;
1242  theLbound = &theLCbound;
1245  }
1246  else
1247  {
1248  assert(base.theRep == ROW);
1249 
1250  thevectors = rowSet();
1251  thecovectors = colSet();
1252  theFrhs = &dualRhs;
1253  theFvec = &dualVec;
1254  theCoPrhs = &primRhs;
1255  theCoPvec = &primVec;
1256  thePvec = &addVec;
1257  theRPvec = thePvec;
1258  theCPvec = theCoPvec;
1259  theUbound = &theURbound;
1260  theLbound = &theLRbound;
1263  }
1264 
1265  SPxBasis::theLP = this;
1266 
1267  assert(!freePricer || thepricer != 0);
1268  assert(!freeRatioTester || theratiotester != 0);
1269  assert(!freeStarter || thestarter != 0);
1270 
1271  // thepricer
1272  if(freePricer)
1273  {
1274  delete thepricer;
1275  thepricer = 0;
1276  }
1277 
1278  if(base.thepricer == 0)
1279  {
1280  thepricer = 0;
1281  freePricer = false;
1282  }
1283  else
1284  {
1285  thepricer = base.thepricer->clone();
1286  freePricer = true;
1287  thepricer->load(this);
1288  }
1289 
1290  // theratiotester
1291  if(freeRatioTester)
1292  {
1293  delete theratiotester;
1294  theratiotester = 0;
1295  }
1296 
1297  if(base.theratiotester == 0)
1298  {
1299  theratiotester = 0;
1300  freeRatioTester = false;
1301  }
1302  else
1303  {
1305  freeRatioTester = true;
1306  theratiotester->load(this);
1307  }
1308 
1309  // thestarter
1310  if(freeStarter)
1311  {
1312  delete thestarter;
1313  thestarter = 0;
1314  }
1315 
1316  if(base.thestarter == 0)
1317  {
1318  thestarter = 0;
1319  freeStarter = false;
1320  }
1321  else
1322  {
1323  thestarter = base.thestarter->clone();
1324  freeStarter = true;
1325  }
1326 
1327  assert(SPxSolver::isConsistent());
1328  }
1329 
1330  return *this;
1331 }
1332 
1333 
1335  : SPxLP(base)
1336  , SPxBasis(base)
1337  , theType(base.theType)
1338  , thePricing(base.thePricing)
1339  , theRep(base.theRep)
1340  , polishObj(base.polishObj)
1341  , timerType(base.timerType)
1343  , maxIters(base.maxIters)
1344  , maxTime(base.maxTime)
1347  , objLimit(base.objLimit)
1348  , m_status(base.m_status)
1355  , m_entertol(base.m_entertol)
1356  , m_leavetol(base.m_leavetol)
1357  , theShift(base.theShift)
1358  , lastShift(base.lastShift)
1359  , m_maxCycle(base.m_maxCycle)
1360  , m_numCycle(base.m_numCycle)
1361  , initialized(base.initialized)
1362  , solveVector2(0)
1364  , solveVector3(0)
1366  , coSolveVector2(0)
1368  , coSolveVector3(0)
1376  , displayLine(base.displayLine)
1377  , displayFreq(base.displayFreq)
1385  , unitVecs(base.unitVecs)
1386  , primRhs(base.primRhs)
1387  , primVec(base.primVec)
1388  , dualRhs(base.dualRhs)
1389  , dualVec(base.dualVec)
1390  , addVec(base.addVec)
1391  , theURbound(base.theURbound)
1392  , theLRbound(base.theLRbound)
1393  , theUCbound(base.theUCbound)
1394  , theLCbound(base.theLCbound)
1395  , theUBbound(base.theUBbound)
1396  , theLBbound(base.theLBbound)
1397  , theCoTest(base.theCoTest)
1398  , theTest(base.theTest)
1399  , primalRay(base.primalRay)
1400  , dualFarkas(base.dualFarkas)
1401  , leaveCount(base.leaveCount)
1402  , enterCount(base.enterCount)
1403  , primalCount(base.primalCount)
1404  , polishCount(base.polishCount)
1405  , boundflips(base.boundflips)
1407  , enterCycles(base.enterCycles)
1408  , leaveCycles(base.leaveCycles)
1412  , dualDegenSum(base.dualDegenSum)
1413  , boundrange(base.boundrange)
1414  , siderange(base.siderange)
1415  , objrange(base.objrange)
1418  , isInfeasible(base.isInfeasible)
1428  , weights(base.weights)
1429  , coWeights(base.coWeights)
1431  , spxout(base.spxout)
1433 {
1435 
1436  if(base.theRep == COLUMN)
1437  {
1438  thevectors = colSet();
1439  thecovectors = rowSet();
1440  theFrhs = &primRhs;
1441  theFvec = &primVec;
1442  theCoPrhs = &dualRhs;
1443  theCoPvec = &dualVec;
1444  thePvec = &addVec;
1445  theRPvec = theCoPvec;
1446  theCPvec = thePvec;
1447  theUbound = &theUCbound;
1448  theLbound = &theLCbound;
1451  }
1452  else
1453  {
1454  assert(base.theRep == ROW);
1455 
1456  thevectors = rowSet();
1457  thecovectors = colSet();
1458  theFrhs = &dualRhs;
1459  theFvec = &dualVec;
1460  theCoPrhs = &primRhs;
1461  theCoPvec = &primVec;
1462  thePvec = &addVec;
1463  theRPvec = thePvec;
1464  theCPvec = theCoPvec;
1465  theUbound = &theURbound;
1466  theLbound = &theLRbound;
1469  }
1470 
1471  SPxBasis::theLP = this;
1472 
1473  if(base.thepricer == 0)
1474  {
1475  thepricer = 0;
1476  freePricer = false;
1477  }
1478  else
1479  {
1480  thepricer = base.thepricer->clone();
1481  freePricer = true;
1482  thepricer->clear();
1483  thepricer->load(this);
1484  }
1485 
1486  if(base.theratiotester == 0)
1487  {
1488  theratiotester = 0;
1489  freeRatioTester = false;
1490  }
1491  else
1492  {
1494  freeRatioTester = true;
1495  theratiotester->clear();
1496  theratiotester->load(this);
1497  }
1498 
1499  if(base.thestarter == 0)
1500  {
1501  thestarter = 0;
1502  freeStarter = false;
1503  }
1504  else
1505  {
1506  thestarter = base.thestarter->clone();
1507  freeStarter = true;
1508  }
1509 
1510  assert(SPxSolver::isConsistent());
1511 }
1512 
1514 {
1515 #ifdef ENABLE_CONSISTENCY_CHECKS
1516 
1517  if(epsilon() < 0)
1518  return MSGinconsistent("SPxSolver");
1519 
1521  return MSGinconsistent("SPxSolver");
1522 
1524  return MSGinconsistent("SPxSolver");
1525 
1526  if(unitVecs.size() < SPxLP::nCols() || unitVecs.size() < SPxLP::nRows())
1527  return MSGinconsistent("SPxSolver");
1528 
1529  if(initialized)
1530  {
1531  if(theFrhs->dim() != dim())
1532  return MSGinconsistent("SPxSolver");
1533 
1534  if(theFvec->dim() != dim())
1535  return MSGinconsistent("SPxSolver");
1536 
1537  if(theCoPrhs->dim() != dim())
1538  return MSGinconsistent("SPxSolver");
1539 
1540  if(thePvec->dim() != coDim())
1541  return MSGinconsistent("SPxSolver");
1542 
1543  if(theCoPvec->dim() != dim())
1544  return MSGinconsistent("SPxSolver");
1545 
1546  if(theTest.dim() != coDim())
1547  return MSGinconsistent("SPxSolver");
1548 
1549  if(theCoTest.dim() != dim())
1550  return MSGinconsistent("SPxSolver");
1551 
1552  if(theURbound.dim() != SPxLP::nRows())
1553  return MSGinconsistent("SPxSolver");
1554 
1555  if(theLRbound.dim() != SPxLP::nRows())
1556  return MSGinconsistent("SPxSolver");
1557 
1558  if(theUCbound.dim() != SPxLP::nCols())
1559  return MSGinconsistent("SPxSolver");
1560 
1561  if(theLCbound.dim() != SPxLP::nCols())
1562  return MSGinconsistent("SPxSolver");
1563 
1564  if(theUBbound.dim() != dim())
1565  return MSGinconsistent("SPxSolver");
1566 
1567  if(theLBbound.dim() != dim())
1568  return MSGinconsistent("SPxSolver");
1569  }
1570 
1571  if(rep() == COLUMN)
1572  {
1573  if(thecovectors !=
1574  reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1575  || thevectors !=
1576  reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1577  || theFrhs != &primRhs ||
1578  theFvec != &primVec ||
1579  theCoPrhs != &dualRhs ||
1580  theCoPvec != &dualVec ||
1581  thePvec != &addVec ||
1582  theRPvec != theCoPvec ||
1583  theCPvec != thePvec ||
1584  theUbound != &theUCbound ||
1585  theLbound != &theLCbound ||
1586  theCoUbound != &theURbound ||
1587  theCoLbound != &theLRbound)
1588  return MSGinconsistent("SPxSolver");
1589  }
1590  else
1591  {
1592  if(thecovectors
1593  != reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1594  || thevectors
1595  != reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1596  || theFrhs != &dualRhs ||
1597  theFvec != &dualVec ||
1598  theCoPrhs != &primRhs ||
1599  theCoPvec != &primVec ||
1600  thePvec != &addVec ||
1601  theRPvec != thePvec ||
1602  theCPvec != theCoPvec ||
1603  theUbound != &theURbound ||
1604  theLbound != &theLRbound ||
1605  theCoUbound != &theUCbound ||
1606  theCoLbound != &theLCbound)
1607  return MSGinconsistent("SPxSolver");
1608  }
1609 
1610  return SPxLP::isConsistent()
1611  && primRhs.isConsistent()
1612  && primVec.isConsistent()
1613  && dualRhs.isConsistent()
1614  && dualVec.isConsistent()
1615  && addVec.isConsistent()
1616  && theTest.isConsistent()
1617  && theCoTest.isConsistent()
1623  ;
1624 #else
1625  return true;
1626 #endif
1627 }
1628 
1629 
1631 {
1632  if(p_time < 0.0)
1633  p_time = 0.0;
1634 
1635  maxTime = p_time;
1636 }
1637 
1639 {
1640  return maxTime;
1641 }
1642 
1643 void SPxSolver::setTerminationIter(int p_iteration)
1644 {
1645  if(p_iteration < 0)
1646  p_iteration = -1;
1647 
1648  maxIters = p_iteration;
1649 }
1650 
1652 {
1653  return maxIters;
1654 }
1655 
1656 // returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
1657 bool SPxSolver::isTimeLimitReached(const bool forceCheck)
1658 {
1659  // always update the number of calls, since the user might set a time limit later in the solving process
1660  ++nCallsToTimelim;
1661 
1662  // check if a time limit is actually set
1663  if(maxTime >= infinity)
1664  return false;
1665 
1666  // check if the expensive system call to update the time should be skipped again
1667  if(forceCheck || nCallsToTimelim < NINITCALLS || nClckSkipsLeft <= 0)
1668  {
1669  Real currtime = time();
1670 
1671  if(currtime >= maxTime)
1672  return true;
1673 
1674  // determine the number of times the clock can be skipped again.
1675  int nClckSkips = MAXNCLCKSKIPS;
1676  Real avgtimeinterval = (currtime + cumulativeTime()) / (Real)(nCallsToTimelim);
1677 
1678  // it would not be safe to skip the clock so many times since we are approaching the time limit
1679  if(SAFETYFACTOR * (maxTime - currtime) / (avgtimeinterval + 1e-6) < nClckSkips)
1680  nClckSkips = 0;
1681 
1682  nClckSkipsLeft = nClckSkips;
1683  }
1684  else
1685  --nClckSkipsLeft;
1686 
1687  return false;
1688 }
1689 
1690 
1691 /**@todo A first version for the termination value is
1692  * implemented. Currently we check if no bound violations (shifting)
1693  * is present. It might be even possible to use this termination
1694  * value in case of bound violations (shifting) but in this case it
1695  * is quite difficult to determine if we already reached the limit.
1696  */
1698 {
1699  objLimit = p_value;
1700 }
1701 
1703 {
1704  return objLimit;
1705 }
1706 
1709 {
1710  VarStatus vstat;
1711 
1712  switch(stat)
1713  {
1715  vstat = ON_LOWER;
1716  break;
1717 
1719  vstat = ON_UPPER;
1720  break;
1721 
1723  vstat = FIXED;
1724  break;
1725 
1727  vstat = ZERO;
1728  break;
1729 
1735  vstat = BASIC;
1736  break;
1737 
1738  default:
1739  MSG_ERROR(std::cerr << "ESOLVE26 ERROR: unknown basis status (" << stat << ")"
1740  << std::endl;)
1741  throw SPxInternalCodeException("XSOLVE22 This should never happen.");
1742  }
1743 
1744  return vstat;
1745 }
1746 
1749 {
1750  SPxBasis::Desc::Status rstat;
1751 
1752  switch(stat)
1753  {
1754  case FIXED :
1755  assert(EQ(rhs(row), lhs(row), feastol()));
1756  rstat = SPxBasis::Desc::P_FIXED;
1757  break;
1758 
1759  case ON_UPPER :
1760  assert(rhs(row) < infinity);
1761  rstat = lhs(row) < rhs(row)
1764  break;
1765 
1766  case ON_LOWER :
1767  assert(lhs(row) > -infinity);
1768  rstat = lhs(row) < rhs(row)
1771  break;
1772 
1773  case ZERO :
1774 
1775  /* A 'free' row (i.e., infinite lower & upper bounds) does not really make sense. The user
1776  * might (think to) know better, e.g., when temporarily turning off a row. We therefore apply
1777  * the same adjustment as in the column case in varStatusToBasisStatusCol(). */
1778  if(lhs(row) <= -infinity && rhs(row) >= infinity)
1779  rstat = SPxBasis::Desc::P_FREE;
1780  else
1781  {
1782  if(lhs(row) == rhs(row))
1783  {
1784  assert(rhs(row) < infinity);
1785  rstat = SPxBasis::Desc::P_FIXED;
1786  }
1787  else
1788  {
1789  if(lhs(row) > -infinity)
1791  else
1792  {
1793  assert(rhs(row) < infinity);
1795  }
1796  }
1797  }
1798 
1799  break;
1800 
1801  case BASIC :
1802  rstat = dualRowStatus(row);
1803  break;
1804 
1805  default:
1806  MSG_ERROR(std::cerr << "ESOLVE27 ERROR: unknown VarStatus (" << int(stat) << ")"
1807  << std::endl;)
1808  throw SPxInternalCodeException("XSOLVE23 This should never happen.");
1809  }
1810 
1811  return rstat;
1812 }
1813 
1816 {
1817  SPxBasis::Desc::Status cstat;
1818 
1819  switch(stat)
1820  {
1821  case FIXED :
1822  if(upper(col) == lower(col))
1823  cstat = SPxBasis::Desc::P_FIXED;
1824  else if(maxObj(col) > 0.0)
1826  else
1828 
1829  break;
1830 
1831  case ON_UPPER :
1832  assert(upper(col) < infinity);
1833  cstat = lower(col) < upper(col)
1836  break;
1837 
1838  case ON_LOWER :
1839  assert(lower(col) > -infinity);
1840  cstat = lower(col) < upper(col)
1843  break;
1844 
1845  case ZERO :
1846 
1847  /* In this case the upper and lower bounds on the variable should be infinite. The bounds
1848  * might, however, have changed and we try to recover from this by changing the status to
1849  * 'resonable' settings. A solve has to find the correct values afterwards. Note that the
1850  * approach below is consistent with changesoplex.cpp (e.g., changeUpperStatus() and
1851  * changeLowerStatus() ). */
1852  if(lower(col) <= -infinity && upper(col) >= infinity)
1853  cstat = SPxBasis::Desc::P_FREE;
1854  else
1855  {
1856  if(lower(col) == upper(col))
1857  {
1858  assert(upper(col) < infinity);
1859  cstat = SPxBasis::Desc::P_FIXED;
1860  }
1861  else
1862  {
1863  if(lower(col) > -infinity)
1865  else
1866  {
1867  assert(upper(col) < infinity);
1869  }
1870  }
1871  }
1872 
1873  break;
1874 
1875  case BASIC :
1876  cstat = dualColStatus(col);
1877  break;
1878 
1879  default:
1880  MSG_ERROR(std::cerr << "ESOLVE28 ERROR: unknown VarStatus (" << int(stat) << ")"
1881  << std::endl;)
1882  throw SPxInternalCodeException("XSOLVE24 This should never happen.");
1883  }
1884 
1885  return cstat;
1886 }
1887 
1889 {
1890  assert(0 <= row && row < nRows());
1891  return basisStatusToVarStatus(desc().rowStatus(row));
1892 }
1893 
1895 {
1896  assert(0 <= col && col < nCols());
1897  return basisStatusToVarStatus(desc().colStatus(col));
1898 }
1899 
1901  const int colsSize) const
1902 {
1903  const SPxBasis::Desc& d = desc();
1904  int i;
1905 
1906  assert(rowsSize < 0 || rowsSize >= nRows());
1907  assert(colsSize < 0 || colsSize >= nCols());
1908 
1909  if(col)
1910  for(i = nCols() - 1; i >= 0; --i)
1911  col[i] = basisStatusToVarStatus(d.colStatus(i));
1912 
1913  if(row)
1914  for(i = nRows() - 1; i >= 0; --i)
1915  row[i] = basisStatusToVarStatus(d.rowStatus(i));
1916 
1917  return status();
1918 }
1919 
1921 {
1922 
1923  int basisdim;
1924 
1925  if(p_rows.size() != nRows() || p_cols.size() != nCols())
1926  return false;
1927 
1928  basisdim = 0;
1929 
1930  for(int row = nRows() - 1; row >= 0; --row)
1931  {
1932  if(p_rows[row] == UNDEFINED)
1933  return false;
1934  // row is basic
1935  else if(p_rows[row] == BASIC)
1936  {
1937  basisdim++;
1938  }
1939  // row is nonbasic
1940  else
1941  {
1942  if((p_rows[row] == FIXED && lhs(row) != rhs(row))
1943  || (p_rows[row] == ON_UPPER && rhs(row) >= infinity)
1944  || (p_rows[row] == ON_LOWER && lhs(row) <= -infinity))
1945  return false;
1946  }
1947  }
1948 
1949  for(int col = nCols() - 1; col >= 0; --col)
1950  {
1951  if(p_cols[col] == UNDEFINED)
1952  return false;
1953  // col is basic
1954  else if(p_cols[col] == BASIC)
1955  {
1956  basisdim++;
1957  }
1958  // col is nonbasic
1959  else
1960  {
1961  if((p_cols[col] == FIXED && lower(col) != upper(col))
1962  || (p_cols[col] == ON_UPPER && upper(col) >= infinity)
1963  || (p_cols[col] == ON_LOWER && lower(col) <= -infinity))
1964  return false;
1965  }
1966  }
1967 
1968  if(basisdim != dim())
1969  return false;
1970 
1971  // basis valid
1972  return true;
1973 }
1974 
1975 void SPxSolver::setBasis(const VarStatus p_rows[], const VarStatus p_cols[])
1976 {
1978  SPxBasis::load(this, false);
1979 
1980  SPxBasis::Desc ds = desc();
1981  int i;
1982 
1983  for(i = 0; i < nRows(); i++)
1984  ds.rowStatus(i) = varStatusToBasisStatusRow(i, p_rows[i]);
1985 
1986  for(i = 0; i < nCols(); i++)
1987  ds.colStatus(i) = varStatusToBasisStatusCol(i, p_cols[i]);
1988 
1989  loadBasis(ds);
1991 }
1992 
1993 // NOTE: This only works for the row representation. Need to update to account for column representation.
1994 // The degenvec differs relative to the algorithm being used.
1995 // For the primal simplex, degenvec is the primal solution values.
1996 // For the dual simplex, the degenvec is the feasvec (ROW) and pVec (COLUMN).
1998 {
1999  int numDegenerate = 0;
2000  Real degeneracyLevel = 0;
2001 
2002  // iterating over all columns in the basis matrix
2003  // this identifies the basis indices and those that have a zero dual multiplier (rows) or zero reduced cost (cols).
2004  if(rep() == ROW)
2005  {
2006  for(int i = 0; i < nCols(); ++i) // @todo Check the use of numColsReal for the reduced problem.
2007  {
2008  // degeneracy in the dual simplex exists if there are rows with a zero dual multiplier or columns with a zero
2009  // reduced costs. This requirement is regardless of the objective sense.
2010  if(isZero(degenvec[i], feastol()))
2011  numDegenerate++;
2012  }
2013 
2014  if(type() == ENTER) // dual simplex
2015  degeneracyLevel = Real(numDegenerate) / nCols();
2016  else // primal simplex
2017  {
2018  assert(type() == LEAVE);
2019  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate -
2020  (nCols() - nRows())) : 0.0;
2021  degeneracyLevel = degenVars / nRows();
2022  }
2023  }
2024  else
2025  {
2026  assert(rep() == COLUMN);
2027 
2028  for(int i = 0; i < nCols(); i++)
2029  {
2030  if(type() == LEAVE) // dual simplex
2031  {
2032  if(isZero(maxObj()[i] - degenvec[i], feastol()))
2033  numDegenerate++;
2034  }
2035  else // primal simplex
2036  {
2037  assert(type() == ENTER);
2038 
2039  if(isZero(degenvec[i], feastol()))
2040  numDegenerate++;
2041  }
2042  }
2043 
2044 
2045  if(type() == LEAVE) // dual simplex
2046  {
2047  Real degenVars = nRows() > numDegenerate ? Real(nRows() - numDegenerate) : 0.0;
2048  degeneracyLevel = degenVars / nCols();
2049  }
2050  else // primal simplex
2051  {
2052  assert(type() == ENTER);
2053  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate -
2054  (nCols() - nRows())) : 0.0;
2055  degeneracyLevel = degenVars / nRows();
2056  }
2057  }
2058 
2059  return degeneracyLevel;
2060 }
2061 
2062 void SPxSolver::getNdualNorms(int& nnormsRow, int& nnormsCol) const
2063 {
2064  nnormsRow = 0;
2065  nnormsCol = 0;
2066 
2067  if(weightsAreSetup)
2068  {
2069  if(type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN)
2070  {
2071  nnormsRow = coWeights.dim();
2072  nnormsCol = 0;
2073 
2074  assert(nnormsRow == dim());
2075  }
2076  else if(type() == SPxSolver::ENTER && rep() == SPxSolver::ROW)
2077  {
2078  nnormsRow = weights.dim();
2079  nnormsCol = coWeights.dim();
2080 
2081  assert(nnormsRow == coDim());
2082  assert(nnormsCol == dim());
2083  }
2084  }
2085 }
2086 
2087 bool SPxSolver::getDualNorms(int& nnormsRow, int& nnormsCol, Real* norms) const
2088 {
2089  nnormsRow = 0;
2090  nnormsCol = 0;
2091 
2092  if(!weightsAreSetup)
2093  return false;
2094 
2095  if(type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN)
2096  {
2097  nnormsCol = 0;
2098  nnormsRow = coWeights.dim();
2099 
2100  assert(nnormsRow == dim());
2101 
2102  for(int i = 0; i < nnormsRow; ++i)
2103  norms[i] = coWeights[i];
2104  }
2105  else if(type() == SPxSolver::ENTER && rep() == SPxSolver::ROW)
2106  {
2107  nnormsRow = weights.dim();
2108  nnormsCol = coWeights.dim();
2109 
2110  assert(nnormsCol == dim());
2111  assert(nnormsRow == coDim());
2112 
2113  for(int i = 0; i < nnormsRow; ++i)
2114  norms[i] = weights[i];
2115 
2116  for(int i = 0; i < nnormsCol; ++i)
2117  norms[nnormsRow + i] = coWeights[i];
2118  }
2119  else
2120  return false;
2121 
2122  return true;
2123 }
2124 
2125 bool SPxSolver::setDualNorms(int nnormsRow, int nnormsCol, Real* norms)
2126 {
2127  weightsAreSetup = false;
2128 
2129  if(type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN)
2130  {
2131  coWeights.reDim(dim(), false);
2132  assert(coWeights.dim() >= nnormsRow);
2133 
2134  for(int i = 0; i < nnormsRow; ++i)
2135  coWeights[i] = norms[i];
2136 
2137  weightsAreSetup = true;
2138  }
2139  else if(type() == SPxSolver::ENTER && rep() == SPxSolver::ROW)
2140  {
2141  weights.reDim(coDim(), false);
2142  coWeights.reDim(dim(), false);
2143  assert(weights.dim() >= nnormsRow);
2144  assert(coWeights.dim() >= nnormsCol);
2145 
2146  for(int i = 0; i < nnormsRow; ++i)
2147  weights[i] = norms[i];
2148 
2149  for(int i = 0; i < nnormsCol; ++i)
2150  coWeights[i] = norms[nnormsRow + i];
2151 
2152  weightsAreSetup = true;
2153  }
2154  else
2155  return false;
2156 
2157  return true;
2158 }
2159 
2160 void SPxSolver::setIntegralityInformation(int ncols, int* intInfo)
2161 {
2162  assert(ncols == nCols() || (ncols == 0 && intInfo == NULL));
2163 
2164  integerVariables.reSize(ncols);
2165 
2166  for(int i = 0; i < ncols; ++i)
2167  {
2168  integerVariables[i] = intInfo[i];
2169  }
2170 }
2171 
2172 
2173 
2174 //
2175 // Auxiliary functions.
2176 //
2177 
2178 // Pretty-printing of variable status.
2179 std::ostream& operator<<(std::ostream& os,
2181 {
2182  switch(status)
2183  {
2184  case SPxSolver::BASIC:
2185  os << "BASIC";
2186  break;
2187 
2188  case SPxSolver::FIXED:
2189  os << "FIXED";
2190  break;
2191 
2192  case SPxSolver::ON_LOWER:
2193  os << "ON_LOWER";
2194  break;
2195 
2196  case SPxSolver::ON_UPPER:
2197  os << "ON_UPPER";
2198  break;
2199 
2200  case SPxSolver::ZERO:
2201  os << "ZERO";
2202  break;
2203 
2204  case SPxSolver::UNDEFINED:
2205  os << "UNDEFINED";
2206  break;
2207 
2208  default:
2209  os << "?invalid?";
2210  break;
2211  }
2212 
2213  return os;
2214 }
2215 
2216 // Pretty-printing of solver status.
2217 std::ostream& operator<<(std::ostream& os,
2218  const SPxSolver::Status& status)
2219 {
2220  switch(status)
2221  {
2222  case SPxSolver::ERROR:
2223  os << "ERROR";
2224  break;
2225 
2227  os << "NO_RATIOTESTER";
2228  break;
2229 
2230  case SPxSolver::NO_PRICER:
2231  os << "NO_PRICER";
2232  break;
2233 
2234  case SPxSolver::NO_SOLVER:
2235  os << "NO_SOLVER";
2236  break;
2237 
2238  case SPxSolver::NOT_INIT:
2239  os << "NOT_INIT";
2240  break;
2241 
2243  os << "ABORT_CYCLING";
2244  break;
2245 
2246  case SPxSolver::ABORT_TIME:
2247  os << "ABORT_TIME";
2248  break;
2249 
2250  case SPxSolver::ABORT_ITER:
2251  os << "ABORT_ITER";
2252  break;
2253 
2255  os << "ABORT_VALUE";
2256  break;
2257 
2258  case SPxSolver::SINGULAR:
2259  os << "SINGULAR";
2260  break;
2261 
2262  case SPxSolver::NO_PROBLEM:
2263  os << "NO_PROBLEM";
2264  break;
2265 
2266  case SPxSolver::REGULAR:
2267  os << "REGULAR";
2268  break;
2269 
2270  case SPxSolver::RUNNING:
2271  os << "RUNNING";
2272  break;
2273 
2274  case SPxSolver::UNKNOWN:
2275  os << "UNKNOWN";
2276  break;
2277 
2278  case SPxSolver::OPTIMAL:
2279  os << "OPTIMAL";
2280  break;
2281 
2282  case SPxSolver::UNBOUNDED:
2283  os << "UNBOUNDED";
2284  break;
2285 
2286  case SPxSolver::INFEASIBLE:
2287  os << "INFEASIBLE";
2288  break;
2289 
2290  default:
2291  os << "?other?";
2292  break;
2293  }
2294 
2295  return os;
2296 }
2297 
2298 // Pretty-printing of algorithm.
2299 std::ostream& operator<<(std::ostream& os,
2300  const SPxSolver::Type& status)
2301 {
2302  switch(status)
2303  {
2304  case SPxSolver::ENTER:
2305  os << "ENTER";
2306  break;
2307 
2308  case SPxSolver::LEAVE:
2309  os << "LEAVE";
2310  break;
2311 
2312  default:
2313  os << "?other?";
2314  break;
2315  }
2316 
2317  return os;
2318 }
2319 
2320 // Pretty-printing of representation.
2321 std::ostream& operator<<(std::ostream& os,
2323 {
2324  switch(status)
2325  {
2326  case SPxSolver::ROW:
2327  os << "ROW";
2328  break;
2329 
2330  case SPxSolver::COLUMN:
2331  os << "COLUMN";
2332  break;
2333 
2334  default:
2335  os << "?other?";
2336  break;
2337  }
2338 
2339  return os;
2340 }
2341 
2342 
2343 } // namespace soplex
const VectorBase< Real > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:221
void computeFtest()
compute basis feasibility test vector.
Definition: leave.cpp:39
Real boundrange
absolute range of all bounds in the problem
Definition: spxsolver.h:406
void clearUpdate()
clear ,
Definition: updatevector.h:160
virtual ~SPxSolver()
Definition: spxsolver.cpp:1106
int iteration() const
returns number of basis changes since last load().
Definition: spxbasis.h:546
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:984
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:253
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:730
UnitVectorBase< Real > UnitVector
Definition: unitvector.h:29
int enterDegenCand
the number of degenerate candidates in the entering algorithm
Definition: spxsolver.h:397
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:252
UpdateVector primVec
primal vector
Definition: spxsolver.h:341
const R & objOffset() const
Returns the objective function value offset.
Definition: spxlpbase.h:521
SPxOut * spxout
message handler
Definition: slinsolver.h:214
bool isConsistent() const
Consistency check.
Definition: dvectorbase.h:307
int boundflips
number of performed bound flips
Definition: spxsolver.h:392
bool getDualNorms(int &nnormsRow, int &nnormsCol, Real *norms) const
get dual norms
Definition: spxsolver.cpp:2087
primal or dual variable is undefined
Definition: spxbasis.h:195
void invalidate()
invalidates actual basis.
const VectorBase< Real > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:461
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:226
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
get number of dual norms
Definition: spxsolver.cpp:2062
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:435
SPxOut * spxout
message handler
Definition: spxsolver.h:463
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:448
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
Type
Algorithmic type.
Definition: spxsolver.h:124
DVector * theUbound
Upper bound for vars.
Definition: spxsolver.h:375
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:518
Real objrange
absolute range of all objective coefficients in the problem
Definition: spxsolver.h:408
void setBasis(const VarStatus rows[], const VarStatus cols[])
set the lp solver&#39;s basis.
Definition: spxsolver.cpp:1975
void testBounds() const
Definition: spxbounds.cpp:328
UpdateVector addVec
storage for thePvec = &addVec
Definition: spxsolver.h:344
DVector theCoTest
Definition: spxsolver.h:381
Abstract pricer base class.
Real leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:796
DVector * theCoUbound
Upper bound for covars.
Definition: spxsolver.h:377
SSVector * solveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:279
void computeTest()
compute test vector in ENTERing Simplex.
Definition: enter.cpp:108
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:1900
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:164
int degenCompIterOffset
the number of iterations performed before the degeneracy level is computed
Definition: spxsolver.h:320
virtual void reDim()
reset dimensions of vectors according to loaded LP.
Definition: spxsolver.cpp:469
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:803
UpdateVector dualVec
dual vector
Definition: spxsolver.h:343
void unscaleLPandReloadBasis()
unscales the LP and reloads the basis
Definition: spxsolver.cpp:534
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:89
Type theType
entering or leaving algortihm.
Definition: spxsolver.h:243
Status & rowStatus(int i)
Definition: spxbasis.h:239
Representation
LP basis representation.
Definition: spxsolver.h:105
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:450
virtual void clear()
clear all data in solver.
Definition: spxsolver.cpp:503
virtual void setRep(SPxSolver::Representation)
sets basis representation.
Definition: spxpricer.h:160
void setType(Type tp)
set LEAVE or ENTER algorithm.
Definition: spxsolver.cpp:180
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:1708
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:398
DecompStatus
Improved dual simplex status.
Definition: spxsolver.h:181
virtual int terminationIter() const
return iteration limit.
Definition: spxsolver.cpp:1651
virtual SPxStarter * clone() const =0
clone function for polymorphism
int m_maxCycle
maximum steps before cycling is detected.
Definition: spxsolver.h:270
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:443
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:382
Real length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition: vectorbase.h:399
Pricing thePricing
full or partial pricing.
Definition: spxsolver.h:244
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:717
Abstract ratio test base class.Class SPxRatioTester is the virtual base class for computing the ratio...
#define SPARSITYFACTOR
Definition: spxsolver.h:40
DVector primRhs
rhs vector for computing the primal vector
Definition: spxsolver.h:340
SPxLPBase< Real > & operator=(const SPxLPBase< Real > &old)
Assignment operator.
Definition: spxlpbase.h:2760
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1075
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Definition: spxbasis.cpp:1023
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:1171
void clear()
remove all elements.
Definition: dataarray.h:208
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:314
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:277
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:1657
void setOpttol(Real d)
set parameter opttol.
Definition: spxsolver.cpp:992
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2143
bool factorized
true iff factor = matrix .
Definition: spxbasis.h:357
bool freeRatioTester
true iff theratiotester should be freed inside of object
Definition: spxsolver.h:292
void setRep()
sets descriptor representation according to loaded LP.
Definition: spxbasis.cpp:326
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:49
Real m_nonbasicValue
nonbasic part of current objective value
Definition: spxsolver.h:257
virtual Real value()
current objective value.
Definition: spxsolver.cpp:939
rowwise representation.
Definition: spxsolver.h:107
bool setDualNorms(int nnormsRow, int nnormsCol, Real *norms)
set dual norms
Definition: spxsolver.cpp:2125
Real lastShift
for forcing feasibility.
Definition: spxsolver.h:269
virtual void computeLeaveCoPrhs()
compute theCoPrhs for leaving Simplex.
Definition: spxvecs.cpp:505
TimerFactory class.
SPxSolver(Type type=LEAVE, Representation rep=ROW, Timer::TYPE ttype=Timer::USER_TIME)
default constructor.
Definition: spxsolver.cpp:1026
virtual void setTerminationTime(Real time=infinity)
set time limit.
Definition: spxsolver.cpp:1630
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:48
bool freePricer
true iff thepricer should be freed inside of object
Definition: spxsolver.h:291
Representation theRep
row or column representation.
Definition: spxsolver.h:245
dual variable is left free, but unset
Definition: spxbasis.h:191
Real getDegeneracyLevel(Vector degenvec)
get level of dual degeneracy
Definition: spxsolver.cpp:1997
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:152
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:1336
primal variable is set to its upper bound
Definition: spxbasis.h:188
UpdateVector & coPvec() const
copricing vector.
Definition: spxsolver.h:1398
int remainingRoundsLeave
number of dense rounds/refactorizations until sparsePricing is enabled again
Definition: spxsolver.h:454
int m_numCycle
actual number of degenerate steps so far.
Definition: spxsolver.h:271
int maxIters
maximum allowed iterations.
Definition: spxsolver.h:250
Leaving Simplex.
Definition: spxsolver.h:143
Real m_entertol
feasibility tolerance maintained during entering algorithm
Definition: spxsolver.h:266
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:404
SSVector * solveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:281
UpdateVector * theRPvec
row pricing vector
Definition: spxsolver.h:370
bool m_pricingViolCoUpToDate
true, if the stored violation in coDim is up to date
Definition: spxsolver.h:264
void reDim()
resizes internal arrays.
double Real
Definition: spxdefines.h:218
SSVector * coSolveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:287
#define MAXNCLCKSKIPS
Definition: spxsolver.h:47
#define MAXIMUM(x, y)
Definition: spxdefines.h:246
Pricing
Pricing type.
Definition: spxsolver.h:152
DVector * theFrhs
Definition: spxsolver.h:360
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
Status status() const
Status of solution process.
Definition: spxsolve.cpp:2213
DVector * theLbound
Lower bound for vars.
Definition: spxsolver.h:376
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:515
virtual void clear()
unloads LP.
Definition: spxpricer.h:118
Real m_pricingViol
maximal feasibility violation of current solution
Definition: spxsolver.h:260
virtual void unInit()
uninitialize data structures.
Definition: spxsolver.h:1859
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
Definition: basevectors.h:1136
Real entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:789
UpdateVector * thePvec
Definition: spxsolver.h:368
SPxBasis::Desc::Status varStatusToBasisStatusRow(int row, VarStatus stat) const
converts VarStatus to basis status for rows
Definition: spxsolver.cpp:1748
LP has been solved to optimality.
Definition: spxsolver.h:220
bool computeDegeneracy
Definition: spxsolver.h:318
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:111
Real cumulativeTime() const
cumulative time spent in all calls to method solve().
Definition: spxsolver.h:2159
virtual void setLeaveBounds()
Definition: spxbounds.cpp:314
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Definition: spxdefines.h:114
SPxPricer * thepricer
Definition: spxsolver.h:402
const SVSet * thecovectors
the LP coVectors according to representation
Definition: spxsolver.h:338
virtual Real terminationTime() const
return time limit.
Definition: spxsolver.cpp:1638
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1323
virtual void reinitializeVecs()
setup all vecs fresh
Definition: spxsolver.cpp:265
SPxId instableEnterId
Definition: spxsolver.h:305
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:357
an error occured.
Definition: spxsolver.h:204
DVector coWeights
store dual norms
Definition: spxsolver.h:460
primal variable is left free, but unset
Definition: spxbasis.h:189
Real siderange
absolute range of all side in the problem
Definition: spxsolver.h:407
const VectorBase< Real > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:255
SPxSolver & operator=(const SPxSolver &base)
assignment operator
Definition: spxsolver.cpp:1137
int primalCount
number of primal iterations
Definition: spxsolver.h:389
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:81
SSVector * coSolveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:289
variable set to its upper bound.
Definition: spxsolver.h:191
bool updateNonbasicValue(Real objChange)
Definition: spxsolver.cpp:962
Basis descriptor.
Definition: spxbasis.h:104
virtual void loadBasisSolver(SLinSolver *solver, const bool destroy=false)
sets up linear solver to use.
Definition: spxbasis.cpp:361
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:346
bool freeStarter
true iff thestarter should be freed inside of object
Definition: spxsolver.h:293
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:449
int remainingRoundsEnterCo
Definition: spxsolver.h:456
virtual void load(SPxSolver *p_solver)
loads LP.
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:396
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:44
algorithm is running
Definition: spxsolver.h:218
const VectorBase< R > & maxRowObj() const
Definition: spxlpbase.h:300
Timer * theTime
time spent in last call to method solve()
Definition: spxsolver.h:247
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:267
virtual void loadLP(const SPxLP &LP, bool initSlackBasis=true)
copy LP.
Definition: spxsolver.cpp:71
variable set to its lower bound.
Definition: spxsolver.h:192
DVector theUBbound
Upper Basic Feasibility bound.
Definition: spxsolver.h:356
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:122
Real m_pricingViolCo
maximal feasibility violation of current solution in coDim
Definition: spxsolver.h:263
DVector * theCoLbound
Lower bound for covars.
Definition: spxsolver.h:378
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:784
Debugging, floating point type and parameter definitions.
virtual void loadBasis(const SPxBasis::Desc &)
set a start basis.
Definition: spxsolver.cpp:98
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:393
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:390
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
Definition: spxdefines.h:376
SolutionPolish polishObj
objective of solution polishing
Definition: spxsolver.h:246
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1478
virtual void load(SPxSolver *p_solver)
loads LP.
Definition: spxpricer.h:112
bool fullPerturbation
whether to perturb the entire problem or just the bounds relevant for the current pivot ...
Definition: spxsolver.h:325
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:275
DIdxSet infeasibilities
Definition: spxsolver.h:429
DVector theLRbound
Lower Row Feasibility bound.
Definition: spxsolver.h:347
DVector theUCbound
Upper Column Feasibility bound.
Definition: spxsolver.h:348
void setDualColBounds()
Definition: spxbounds.cpp:105
virtual void setTerminationIter(int iteration=-1)
set iteration limit.
Definition: spxsolver.cpp:1643
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1850
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:322
Status m_status
status of algorithm.
Definition: spxsolver.h:255
int dim() const
Dimension of vector.
Definition: vectorbase.h:217
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:455
Everything should be within this namespace.
bool isBasisValid(DataArray< VarStatus > rows, DataArray< VarStatus > cols)
check a given basis for validity.
Definition: spxsolver.cpp:1920
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:424
R getEpsilon() const
Returns the non-zero epsilon used.
Definition: ssvectorbase.h:105
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:249
UpdateVector * theFvec
Definition: spxsolver.h:362
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:140
Real dualDegenSum
the sum of the dual degeneracy percentage
Definition: spxsolver.h:400
SSVector * coSolveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:285
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:1373
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:258
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:434
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:2160
SPxSolver * theLP
the LP
Definition: spxbasis.h:343
DVector theLCbound
Lower Column Feasibility bound.
Definition: spxsolver.h:349
virtual void clearUpdateVecs(void)
Definition: spxsolver.cpp:542
int leaveCount
number of LEAVE iterations
Definition: spxsolver.h:387
nothing known on loaded problem.
Definition: spxsolver.h:219
don&#39;t perform modifications on optimal basis
Definition: spxsolver.h:230
VarStatus getBasisRowStatus(int row) const
gets basis status for a single row
Definition: spxsolver.cpp:1888
virtual void factorize()
factorizes the basis matrix.
Definition: spxbasis.cpp:928
bool isConsistent() const
check consistency.
Definition: spxsolver.cpp:1513
variable is basic.
Definition: spxsolver.h:195
VarStatus getBasisColStatus(int col) const
gets basis status for a single column
Definition: spxsolver.cpp:1894
void computeFrhs()
compute feasibility vector from scratch.
Definition: spxvecs.cpp:42
void setDualRowBounds()
Definition: spxbounds.cpp:135
void clear()
Set vector to 0.
Definition: vectorbase.h:262
SPxBasis::Desc::Status varStatusToBasisStatusCol(int col, VarStatus stat) const
converts VarStatus to basis status for columns
Definition: spxsolver.cpp:1815
SPxRatioTester * theratiotester
Definition: spxsolver.h:403
virtual Real terminationValue() const
return objective limit.
Definition: spxsolver.cpp:1702
void shiftFvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:25
DVector * theCoPrhs
Definition: spxsolver.h:365
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:395
DSVector primalRay
stores primal ray in case of unboundedness
Definition: spxsolver.h:384
int size() const
return nr. of elements.
Definition: dataarray.h:214
virtual void loadDesc(const Desc &)
sets up basis.
Definition: spxbasis.cpp:201
Type type() const
return current Type.
Definition: spxsolver.h:512
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:445
Real theShift
sum of all shifts applied to any bound.
Definition: spxsolver.h:268
void unscaleLP()
unscales the lp and clears basis
virtual SPxSolver * solver() const
returns loaded SPxSolver object.
Definition: spxpricer.h:124
int coDim() const
codimension.
Definition: spxsolver.h:1080
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:452
bool isConsistent() const
Consistency check.
Definition: spxlpbase.h:1938
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:118
bool isConsistent() const
DSVector dualFarkas
stores dual farkas proof in case of infeasibility
Definition: spxsolver.h:385
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:158
int enterCount
number of ENTER iterations
Definition: spxsolver.h:388
const Vector & coPrhs() const
Right-hand side vector for coPvec.
Definition: spxsolver.h:1411
DVector weights
dual pricing norms
Definition: spxsolver.h:459
int printCondition
printing the current condition number in the log (0 - off, 1 - estimate,exact, 2 - exact)";ratio esti...
Definition: spxsolver.h:327
Array< UnitVector > unitVecs
array of unit vectors
Definition: spxsolver.h:336
const SVSet * thevectors
the LP vectors according to representation
Definition: spxsolver.h:337
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:466
virtual void setEnterBounds()
Definition: spxbounds.cpp:225
dual variable has two bounds
Definition: spxbasis.h:194
Real maxTime
maximum allowed time.
Definition: spxsolver.h:251
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:980
virtual void init()
intialize data structures.
Definition: spxsolver.cpp:319
bool initialized
true, if all vectors are setup.
Definition: spxsolver.h:272
virtual void computeEnterCoPrhs()
compute theCoPrhs for entering Simplex.
Definition: spxvecs.cpp:426
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:412
void forceRecompNonbasicValue()
Definition: spxsolver.h:670
#define MSGinconsistent(name)
Definition: spxdefines.h:126
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:461
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:632
void initRep(Representation p_rep)
initialize ROW or COLUMN representation.
Definition: spxsolver.cpp:197
SSVector & delta()
update vector , writeable
Definition: updatevector.h:122
DIdxSet updateViolsCo
Definition: spxsolver.h:436
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:811
bool m_pricingViolUpToDate
true, if the stored violation is up to date
Definition: spxsolver.h:261
void hyperPricing(bool h)
enable or disable hyper sparse pricing
Definition: spxsolver.cpp:1014
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:254
const SVSetBase< R > * rowSet() const
Returns the complete SVSet.
Definition: lprowsetbase.h:69
virtual void clear()
clears the LP.
Definition: spxlpbase.h:1133
void computePvec()
compute entire pVec().
Definition: spxvecs.cpp:526
virtual void setTerminationValue(Real value=infinity)
set objective limit.
Definition: spxsolver.cpp:1697
virtual void load(SPxSolver *lp, bool initSlackBasis=true)
loads the LP lp to the basis.
Definition: spxbasis.cpp:345
bool getStartingDecompBasis
flag to indicate whether the simplex is solved to get the starting improved dual simplex basis ...
Definition: spxsolver.h:317
virtual void unLoad()
unloads the LP from the basis.
Definition: spxbasis.h:893
UpdateVector * theCoPvec
Definition: spxsolver.h:366
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:283
virtual void reLoad()
reload LP.
Definition: spxsolver.cpp:56
void reSize(int newsize)
reset size to newsize.
Definition: dataarray.h:226
virtual Real maxInfeas() const
maximal infeasibility of basis
Definition: spxsolver.cpp:671
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:432
DVector dualRhs
rhs vector for computing the dual vector
Definition: spxsolver.h:342
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:451
const VectorBase< Real > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:488
void setDecompStatus(DecompStatus decomp_stat)
turn on or off the improved dual simplex.
Definition: spxsolver.cpp:457
const Desc & desc() const
Definition: spxbasis.h:464
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:506
Real nonbasicValue()
Compute part of objective value.
Definition: spxsolver.cpp:758
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:110
bool isConsistent() const
consistency check.
Definition: spxbasis.cpp:1232
Basis is singular, numerical troubles?
Definition: spxsolver.h:215
UpdateVector * theCPvec
column pricing vector
Definition: spxsolver.h:371
virtual void factorize()
Factorize basis matrix.
Definition: spxsolver.cpp:557
Basis is primal feasible.
Definition: spxbasis.h:96
void resetClockStats()
resets clock average statistics
Definition: spxsolver.cpp:312
SPxSolver * solver() const
returns loaded solver.
Definition: spxbasis.h:564
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:2051
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
Definition: spxsolver.cpp:445
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:1004
Timer::TYPE timerType
type of timer (user or wallclock)
Definition: spxsolver.h:248
void computeCoTest()
compute coTest vector.
Definition: enter.cpp:243
Real primalDegenSum
the sum of the primal degeneracy percentage
Definition: spxsolver.h:399