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-2018 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  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  MSG_INFO3( (*spxout), (*spxout) << "Switching to "
180  << static_cast<const char*>((tp == LEAVE)
181  ? "leaving" : "entering")
182  << " algorithm" << std::endl; )
183  }
184 }
185 
187 {
188 
189  Real tmpfeastol = feastol();
190  Real tmpopttol = opttol();
191 
192  theRep = p_rep;
193 
194  if (theRep == COLUMN)
195  {
196  thevectors = colSet();
197  thecovectors = rowSet();
198  theFrhs = &primRhs;
199  theFvec = &primVec;
200  theCoPrhs = &dualRhs;
201  theCoPvec = &dualVec;
202  thePvec = &addVec;
204  theCPvec = thePvec;
209  }
210  else
211  {
212  assert(theRep == ROW);
213 
214  thevectors = rowSet();
215  thecovectors = colSet();
216  theFrhs = &dualRhs;
217  theFvec = &dualVec;
218  theCoPrhs = &primRhs;
219  theCoPvec = &primVec;
220  thePvec = &addVec;
221  theRPvec = thePvec;
227  }
228  unInit();
229  reDim();
230 
232 
233  setFeastol(tmpfeastol);
234  setOpttol(tmpopttol);
235 
239 
240  if (thepricer && thepricer->solver() == this)
241  thepricer->setRep(p_rep);
242 }
243 
245 {
246 
247  if (p_rep != theRep)
248  initRep(p_rep);
249 }
250 
251 // needed for strongbranching. use carefully
253 {
254 
255  initialized = true;
256 
257  if (type() == ENTER)
258  {
259  if (rep() == COLUMN)
260  setPrimalBounds();
261  else
263 
264  setEnterBounds();
266  }
267  else
268  {
269  if (rep() == ROW)
270  setPrimalBounds();
271  else
273 
274  setLeaveBounds();
276  }
277 
279  computePvec();
280  computeFrhs();
282 
283  theShift = 0.0;
284  lastShift = 0.0;
285 
286  if (type() == ENTER)
287  {
288  computeCoTest();
289  computeTest();
290  }
291  else
292  {
293  computeFtest();
294  }
295  assert((testBounds(), 1));
296 }
297 
299 {
300  nClckSkipsLeft = 0;
301  nCallsToTimelim = 0;
302  theCumulativeTime = 0.0;
303 }
304 
306 {
307 
308  assert(thepricer != 0);
309  assert(theratiotester != 0);
310 
311  if (!initialized)
312  {
313  initialized = true;
314  clearUpdateVecs();
315  reDim();
316  if (SPxBasis::status() <= SPxBasis::NO_PROBLEM || solver() != this)
317  SPxBasis::load(this);
318  initialized = false;
319  }
320  if (!matrixIsSetup)
322 
323  // Inna/Tobi: don't "upgrade" a singular basis to a regular one
325  return;
326 
327  // catch pathological case for LPs with zero constraints
328  if( dim() == 0 )
329  {
330  factorized = true;
331  }
332 
333  // we better factorize explicitly before solving
334  if( !factorized )
335  {
336  try
337  {
339  }
340  catch( const SPxException& )
341  {
342  // reload inital slack basis in case the factorization failed
346  assert(factorized);
347  }
348  }
349 
350  m_numCycle = 0;
351 
352  if (type() == ENTER)
353  {
354  if (rep() == COLUMN)
355  {
356  setPrimalBounds();
358  }
359  else
360  {
363  }
364  setEnterBounds();
366  // prepare support vectors for sparse pricing
372  }
373  else
374  {
375  if (rep() == ROW)
376  {
377  setPrimalBounds();
379  }
380  else
381  {
384  }
385  setLeaveBounds();
387  // prepare support vectors for sparse pricing
391  }
392 
394  computePvec();
395  computeFrhs();
397 
398  theShift = 0.0;
399 
400  if (type() == ENTER)
401  {
402  shiftFvec();
404 
405  computeCoTest();
406  computeTest();
407  }
408  else
409  {
410  shiftPvec();
412 
413  computeFtest();
414  }
415 
416  if (!initialized)
417  {
418  // if(thepricer->solver() != this)
419  thepricer->load(this);
420  // if(theratiotester->solver() != this)
421  theratiotester->load(this);
422  initialized = true;
423  }
424 }
425 
427 {
428  thePricing = pr;
429  if (initialized && type() == ENTER)
430  {
431  computePvec();
432  computeCoTest();
433  computeTest();
434  }
435 }
436 
438 {
439  if( decomp_stat == FINDSTARTBASIS )
440  getStartingDecompBasis = true;
441  else
442  getStartingDecompBasis = false;
443 }
444 
445 /*
446  The following method resizes all vectors and arrays of |SoPlex|
447  (excluding inherited vectors).
448  */
450 {
451 
452  int newsize = SPxLP::nCols() > SPxLP::nRows() ? SPxLP::nCols() : SPxLP::nRows();
453 
454  if (newsize > unitVecs.size())
455  {
456  unitVecs.reSize(newsize);
457 
458  while (newsize-- > 0)
459  unitVecs[newsize] = UnitVector(newsize);
460  }
461 
462  if (isInitialized())
463  {
464  theFrhs->reDim(dim());
465  theFvec->reDim(dim());
466  thePvec->reDim(coDim());
467 
468  theCoPrhs->reDim(dim());
469  theCoPvec->reDim(dim());
470 
471  theTest.reDim(coDim());
472  theCoTest.reDim(dim());
473 
478  theUBbound.reDim(dim());
479  theLBbound.reDim(dim());
480  }
481 }
482 
484 {
485  unitVecs.reSize(0);
486 
487  dualRhs.clear();
488  dualVec.clear();
489  primRhs.clear();
490  primVec.clear();
491  addVec.clear();
492  theURbound.clear();
493  theLRbound.clear();
494  theUCbound.clear();
495  theLCbound.clear();
496  theTest.clear();
497  theCoTest.clear();
498 
500  unInit();
501  SPxLP::clear();
503  // clear the basis only when theLP is present, because LP data (nrows, ncols) is used in reDim()
504  if( theLP != 0 )
505  SPxBasis::reDim();
506 
511 }
512 
514 {
517  unInit();
518  init();
519 }
520 
522 {
523  theFvec->clearUpdate();
524  thePvec->clearUpdate();
526  solveVector2 = 0;
527  solveVector3 = 0;
528  coSolveVector2 = 0;
529  coSolveVector3 = 0;
530 }
531 
532 /*
533  When the basis matrix factorization is recomputed from scratch,
534  we also recompute the vectors.
535  */
537 {
538 
539  MSG_INFO3( (*spxout), (*spxout) << " --- refactorizing basis matrix" << std::endl; )
540 
541  try
542  {
544  }
545  catch( const SPxStatusException& )
546  {
548  m_status = SINGULAR;
549  std::stringstream s;
550  s << "Basis is singular (numerical troubles, feastol = " << feastol() << ", opttol = " << opttol() << ")";
551  throw SPxStatusException(s.str());
552  }
553 
554  if( !initialized )
555  {
556  init(); // not sure if init() is neccessary here
557  // we must not go on here because not all vectors (e.g. fVec) may be set up correctly
558  return;
559  }
560 
562  {
563 #ifndef NDEBUG
564  DVector ftmp(fVec());
565  DVector ptmp(pVec());
566  DVector ctmp(coPvec());
567 #endif // NDEBUG
568 
569  if (type() == LEAVE)
570  {
571  /* we have to recompute theFrhs, because roundoff errors can occur during updating, especially when
572  * columns/rows with large bounds are present
573  */
574  computeFrhs();
577 
578 #ifndef NDEBUG
579  ftmp -= fVec();
580  ptmp -= pVec();
581  ctmp -= coPvec();
582  if (ftmp.length() > DEFAULT_BND_VIOL)
583  {
584  MSG_DEBUG( std::cout << "DSOLVE21 fVec: " << ftmp.length() << std::endl; )
585  ftmp = fVec();
586  multBaseWith(ftmp);
587  ftmp -= fRhs();
588  if (ftmp.length() > DEFAULT_BND_VIOL)
589  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE29 " << iteration() << ": fVec error = "
590  << ftmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl; )
591  }
592  if (ctmp.length() > DEFAULT_BND_VIOL)
593  {
594  MSG_DEBUG( std::cout << "DSOLVE23 coPvec: " << ctmp.length() << std::endl; )
595  ctmp = coPvec();
596  multWithBase(ctmp);
597  ctmp -= coPrhs();
598  if (ctmp.length() > DEFAULT_BND_VIOL)
599  MSG_INFO1( (*spxout), (*spxout) << "ESOLVE30 " << iteration() << ": coPvec error = "
600  << ctmp.length() << " exceeding DEFAULT_BND_VIOL = " << DEFAULT_BND_VIOL << std::endl; )
601  }
602  if (ptmp.length() > DEFAULT_BND_VIOL)
603  {
604  MSG_DEBUG( std::cout << "DSOLVE24 pVec: " << ptmp.length() << std::endl; )
605  }
606 #endif // NDEBUG
607 
608  computeFtest();
609  }
610  else
611  {
612  assert(type() == ENTER);
613 
615  computeCoTest();
616 
617  if (pricing() == FULL)
618  {
619  /* to save time only recompute the row activities (in row rep) when we are already nearly optimal to
620  * avoid missing any violations from previous updates */
621  if( rep() == ROW && m_pricingViolCo < entertol() && m_pricingViol < entertol() )
622  computePvec();
623 
624  /* was deactivated, but this leads to warnings in testVecs() */
625  computeTest();
626  }
627  }
628  }
629 
630 #ifdef ENABLE_ADDITIONAL_CHECKS
631  /* 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 */
633  testVecs();
634 #endif
635 }
636 
637 /* We compute how much the current solution violates (primal or dual) feasibility. In the
638  row/enter or column/leave algorithm the maximum violation of dual feasibility is
639  computed. In the row/leave or column/enter algorithm the primal feasibility is checked.
640  Additionally, the violation from pricing is taken into account. */
642 {
643  Real inf = 0.0;
644 
645  if (type() == ENTER)
646  {
649 
650  for (int i = 0; i < dim(); i++)
651  {
652  if ((*theFvec)[i] > theUBbound[i])
653  inf = MAXIMUM(inf, (*theFvec)[i] - theUBbound[i]);
654  else if ((*theFvec)[i] < theLBbound[i])
655  inf = MAXIMUM(inf, theLBbound[i] - (*theFvec)[i]);
656  }
657  }
658  else
659  {
660  assert(type() == LEAVE);
661 
663  inf = m_pricingViol;
664 
665  for (int i = 0; i < dim(); i++)
666  {
667  if ((*theCoPvec)[i] > (*theCoUbound)[i])
668  inf = MAXIMUM(inf, (*theCoPvec)[i] - (*theCoUbound)[i]);
669  else if ((*theCoPvec)[i] < (*theCoLbound)[i])
670  inf = MAXIMUM(inf, (*theCoLbound)[i] - (*theCoPvec)[i]);
671  }
672  for (int i = 0; i < coDim(); i++)
673  {
674  if ((*thePvec)[i] > (*theUbound)[i])
675  inf = MAXIMUM(inf, (*thePvec)[i] - (*theUbound)[i]);
676  else if ((*thePvec)[i] < (*theLbound)[i])
677  inf = MAXIMUM(inf, (*theLbound)[i] - (*thePvec)[i]);
678  }
679  }
680 
681  return inf;
682 }
683 
684 /* check for (dual) violations above tol and immediately return false w/o checking the remaining values
685  This method is useful for verifying whether an objective limit can be used as termination criterion */
686 bool SPxSolver::noViols(Real tol) const
687 {
688  assert(tol >= 0.0);
689 
690  if( type() == ENTER )
691  {
692  for( int i = 0; i < dim(); i++ )
693  {
694  if( (*theFvec)[i] - theUBbound[i] > tol )
695  return false;
696  if( theLBbound[i] - (*theFvec)[i] > tol )
697  return false;
698  }
699  }
700  else
701  {
702  assert(type() == LEAVE);
703 
704  for( int i = 0; i < dim(); i++ )
705  {
706  if( (*theCoPvec)[i] - (*theCoUbound)[i] > tol )
707  return false;
708  if( (*theCoLbound)[i] - (*theCoPvec)[i] > tol )
709  return false;
710  }
711  for (int i = 0; i < coDim(); i++)
712  {
713  if( (*thePvec)[i] - (*theUbound)[i] > tol )
714  return false;
715  if( (*theLbound)[i] - (*thePvec)[i] > tol )
716  return false;
717  }
718  }
719  return true;
720 }
721 
723 {
724  int i;
725  Real val = 0;
726  const SPxBasis::Desc& ds = desc();
727 
728 #ifndef ENABLE_ADDITIONAL_CHECKS
729  // if the value is available we don't need to recompute it
731  return m_nonbasicValue;
732 #endif
733 
734  if (rep() == COLUMN)
735  {
736  if (type() == LEAVE)
737  {
738  for (i = nCols() - 1; i >= 0; --i)
739  {
740  switch (ds.colStatus(i))
741  {
743  val += theUCbound[i] * SPxLP::upper(i);
744  //@ val += maxObj(i) * SPxLP::upper(i);
745  break;
747  val += theLCbound[i] * SPxLP::lower(i);
748  //@ val += maxObj(i) * SPxLP::lower(i);
749  break;
751  val += maxObj(i) * SPxLP::lower(i);
752  break;
753  default:
754  break;
755  }
756  }
757  for (i = nRows() - 1; i >= 0; --i)
758  {
759  switch (ds.rowStatus(i))
760  {
762  val += theLRbound[i] * SPxLP::rhs(i);
763  break;
765  val += theURbound[i] * SPxLP::lhs(i);
766  break;
768  val += maxRowObj(i) * SPxLP::lhs(i);
769  break;
770  default:
771  break;
772  }
773  }
774  }
775  else
776  {
777  assert(type() == ENTER);
778  for (i = nCols() - 1; i >= 0; --i)
779  {
780  switch (ds.colStatus(i))
781  {
783  val += maxObj(i) * theUCbound[i];
784  break;
786  val += maxObj(i) * theLCbound[i];
787  break;
789  assert(EQ(theLCbound[i], theUCbound[i]));
790  val += maxObj(i) * theLCbound[i];
791  break;
792  default:
793  break;
794  }
795  }
796  for (i = nRows() - 1; i >= 0; --i)
797  {
798  switch (ds.rowStatus(i))
799  {
801  val += maxRowObj(i) * theLRbound[i];
802  break;
804  val += maxRowObj(i) * theURbound[i];
805  break;
807  val += maxRowObj(i) * theURbound[i];
808  break;
809  default:
810  break;
811  }
812  }
813  }
814  }
815  else
816  {
817  assert(rep() == ROW);
818  assert(type() == ENTER);
819  for (i = nCols() - 1; i >= 0; --i)
820  {
821  switch (ds.colStatus(i))
822  {
824  val += theUCbound[i] * lower(i);
825  break;
827  val += theLCbound[i] * upper(i);
828  break;
830  val += theLCbound[i] * upper(i);
831  val += theUCbound[i] * lower(i);
832  break;
833  default:
834  break;
835  }
836  }
837  for (i = nRows() - 1; i >= 0; --i)
838  {
839  switch (ds.rowStatus(i))
840  {
842  val += theURbound[i] * lhs(i);
843  break;
845  val += theLRbound[i] * rhs(i);
846  break;
848  val += theLRbound[i] * rhs(i);
849  val += theURbound[i] * lhs(i);
850  break;
851  default:
852  break;
853  }
854  }
855  }
856 
857 #ifdef ENABLE_ADDITIONAL_CHECKS
859  {
860  MSG_ERROR( std::cerr << "stored nonbasic value: " << m_nonbasicValue
861  << ", correct nonbasic value: " << val
862  << ", violation: " << val - m_nonbasicValue << std::endl; )
863  assert(EQrel(m_nonbasicValue, val, 1e-12));
864  }
865 #endif
866 
868  {
869  m_nonbasicValue = val;
871  }
872 
873  return val;
874 }
875 
877 {
878  assert(isInitialized());
879 
880  Real x;
881 
882  // calling value() without having a suitable status is an error.
883  if (!isInitialized())
884  return infinity;
885 
886  if (rep() == ROW)
887  {
888  if (type() == LEAVE)
889  x = SPxLP::spxSense() * (coPvec() * fRhs()); // the contribution of maxRowObj() is missing
890  else
891  x = SPxLP::spxSense() * (nonbasicValue() + (coPvec() * fRhs()));
892  }
893  else
894  x = SPxLP::spxSense() * (nonbasicValue() + fVec() * coPrhs());
895 
896  return x + objOffset();
897 }
898 
900 {
902  m_nonbasicValue += objChange;
903 
904  MSG_DEBUG( std::cout
905  << "Iteration: " << iteration()
906  << ": updated objValue: " << objChange
907  << ", new value: " << m_nonbasicValue
908  << ", correct value: " << nonbasicValue()
909  << std::endl;
910  )
911 
913 }
914 
915 
916 
918 {
919 
920  if( d <= 0.0 )
921  throw SPxInterfaceException("XSOLVE30 Cannot set feastol less than or equal to zero.");
922 
923  if( theRep == COLUMN )
924  m_entertol = d;
925  else
926  m_leavetol = d;
927 }
928 
930 {
931 
932  if( d <= 0.0 )
933  throw SPxInterfaceException("XSOLVE31 Cannot set opttol less than or equal to zero.");
934 
935  if( theRep == COLUMN )
936  m_leavetol = d;
937  else
938  m_entertol = d;
939 }
940 
942 {
943 
944  if( d <= 0.0 )
945  throw SPxInterfaceException("XSOLVE32 Cannot set delta less than or equal to zero.");
946 
947  m_entertol = d;
948  m_leavetol = d;
949 }
950 
952 {
953  hyperPricingEnter = h;
954  hyperPricingLeave = h;
955  if( h )
956  {
959  }
960 }
961 
963  Type p_type,
964  Representation p_rep,
965  Timer::TYPE ttype)
966  : theType (p_type)
967  , thePricing(FULL)
968  , theRep(p_rep)
970  , theTime(0)
971  , timerType(ttype)
972  , theCumulativeTime(0.0)
973  , maxIters (-1)
974  , maxTime (infinity)
975  , nClckSkipsLeft(0)
976  , nCallsToTimelim(0)
977  , objLimit(infinity)
978  , m_status(UNKNOWN)
979  , m_nonbasicValue(0.0)
980  , m_nonbasicValueUpToDate(false)
981  , m_pricingViol(0.0)
982  , m_pricingViolUpToDate(false)
983  , m_pricingViolCo(0.0)
984  , m_pricingViolCoUpToDate(false)
985  , theShift (0)
986  , m_maxCycle(100)
987  , m_numCycle(0)
988  , initialized (false)
989  , solveVector2 (0)
990  , solveVector3 (0)
991  , coSolveVector2(0)
992  , coSolveVector3(0)
993  , freePricer (false)
994  , freeRatioTester (false)
995  , freeStarter (false)
996  , displayLine (0)
997  , displayFreq (200)
999  , getStartingDecompBasis(false)
1000  , computeDegeneracy(false)
1001  , degenCompIterOffset(0)
1002  , fullPerturbation(false)
1003  , printCondition(0)
1004  , unitVecs (0)
1005  , primVec (0, Param::epsilon())
1006  , dualVec (0, Param::epsilon())
1007  , addVec (0, Param::epsilon())
1008  , thepricer (0)
1009  , theratiotester (0)
1010  , thestarter (0)
1011  , boundrange(0.0)
1012  , siderange(0.0)
1013  , objrange(0.0)
1014  , infeasibilities(0)
1015  , infeasibilitiesCo(0)
1016  , isInfeasible(0)
1017  , isInfeasibleCo(0)
1018  , sparsePricingLeave(false)
1019  , sparsePricingEnter(false)
1020  , sparsePricingEnterCo(false)
1021  , hyperPricingLeave(true)
1022  , hyperPricingEnter(true)
1026  , weights(0)
1027  , coWeights(0)
1028  , weightsAreSetup(false)
1029  , integerVariables(0)
1030 {
1032 
1034 
1035  theLP = this;
1036  initRep(p_rep);
1037 
1038  // info: SPxBasis is not consistent in this moment.
1039  //assert(SPxSolver::isConsistent());
1040 }
1041 
1043 {
1044  assert(!freePricer || thepricer != 0);
1045  assert(!freeRatioTester || theratiotester != 0);
1046  assert(!freeStarter || thestarter != 0);
1047 
1048  if(freePricer)
1049  {
1050  delete thepricer;
1051  thepricer = 0;
1052  }
1053 
1054  if(freeRatioTester)
1055  {
1056  delete theratiotester;
1057  theratiotester = 0;
1058  }
1059 
1060  if(freeStarter)
1061  {
1062  delete thestarter;
1063  thestarter = 0;
1064  }
1065 
1066  // free timer
1067  assert(theTime);
1068  theTime->~Timer();
1069  spx_free(theTime);
1070 }
1071 
1072 
1074 {
1075  if(this != &base)
1076  {
1077  SPxLP::operator=(base);
1078  SPxBasis::operator=(base);
1079  theType = base.theType;
1080  thePricing = base.thePricing;
1081  theRep = base.theRep;
1082  polishObj = base.polishObj;
1083  timerType = base.timerType;
1084  maxIters = base.maxIters;
1085  maxTime = base.maxTime;
1086  objLimit = base.objLimit;
1087  m_status = base.m_status;
1094  m_entertol = base.m_entertol;
1095  m_leavetol = base.m_leavetol;
1096  theShift = base.theShift;
1097  lastShift = base.lastShift;
1098  m_maxCycle = base.m_maxCycle;
1099  m_numCycle = base.m_numCycle;
1100  initialized = base.initialized;
1107  displayLine = base.displayLine;
1108  displayFreq = base.displayFreq;
1116  unitVecs = base.unitVecs;
1117  primRhs = base.primRhs;
1118  primVec = base.primVec;
1119  dualRhs = base.dualRhs;
1120  dualVec = base.dualVec;
1121  addVec = base.addVec;
1122  theURbound = base.theURbound;
1123  theLRbound = base.theLRbound;
1124  theUCbound = base.theUCbound;
1125  theLCbound = base.theLCbound;
1126  theUBbound = base.theUBbound;
1127  theLBbound = base.theLBbound;
1128  theCoTest = base.theCoTest;
1129  theTest = base.theTest;
1130  primalRay = base.primalRay;
1131  dualFarkas = base.dualFarkas;
1132  leaveCount = base.leaveCount;
1133  enterCount = base.enterCount;
1135  primalCount = base.primalCount;
1136  polishCount = base.polishCount;
1137  boundflips = base.boundflips;
1139  enterCycles = base.enterCycles;
1140  leaveCycles = base.leaveCycles;
1144  boundrange = base.boundrange;
1145  siderange = base.siderange;
1146  objrange = base.objrange;
1149  isInfeasible = base.isInfeasible;
1160  weights = base.weights;
1161  coWeights = base.coWeights;
1163  spxout = base.spxout;
1165 
1166  if (base.theRep == COLUMN)
1167  {
1168  thevectors = colSet();
1169  thecovectors = rowSet();
1170  theFrhs = &primRhs;
1171  theFvec = &primVec;
1172  theCoPrhs = &dualRhs;
1173  theCoPvec = &dualVec;
1174  thePvec = &addVec;
1175  theRPvec = theCoPvec;
1176  theCPvec = thePvec;
1177  theUbound = &theUCbound;
1178  theLbound = &theLCbound;
1181  }
1182  else
1183  {
1184  assert(base.theRep == ROW);
1185 
1186  thevectors = rowSet();
1187  thecovectors = colSet();
1188  theFrhs = &dualRhs;
1189  theFvec = &dualVec;
1190  theCoPrhs = &primRhs;
1191  theCoPvec = &primVec;
1192  thePvec = &addVec;
1193  theRPvec = thePvec;
1194  theCPvec = theCoPvec;
1195  theUbound = &theURbound;
1196  theLbound = &theLRbound;
1199  }
1200 
1201  SPxBasis::theLP = this;
1202 
1203  assert(!freePricer || thepricer != 0);
1204  assert(!freeRatioTester || theratiotester != 0);
1205  assert(!freeStarter || thestarter != 0);
1206 
1207  // thepricer
1208  if(freePricer)
1209  {
1210  delete thepricer;
1211  thepricer = 0;
1212  }
1213  if(base.thepricer == 0)
1214  {
1215  thepricer = 0;
1216  freePricer = false;
1217  }
1218  else
1219  {
1220  thepricer = base.thepricer->clone();
1221  freePricer = true;
1222  thepricer->load(this);
1223  }
1224 
1225  // theratiotester
1226  if(freeRatioTester)
1227  {
1228  delete theratiotester;
1229  theratiotester = 0;
1230  }
1231  if(base.theratiotester == 0)
1232  {
1233  theratiotester = 0;
1234  freeRatioTester = false;
1235  }
1236  else
1237  {
1239  freeRatioTester = true;
1240  theratiotester->load(this);
1241  }
1242 
1243  // thestarter
1244  if(freeStarter)
1245  {
1246  delete thestarter;
1247  thestarter = 0;
1248  }
1249  if(base.thestarter == 0)
1250  {
1251  thestarter = 0;
1252  freeStarter = false;
1253  }
1254  else
1255  {
1256  thestarter = base.thestarter->clone();
1257  freeStarter = true;
1258  }
1259 
1260  assert(SPxSolver::isConsistent());
1261  }
1262 
1263  return *this;
1264 }
1265 
1266 
1268  : SPxLP (base)
1269  , SPxBasis(base)
1270  , theType(base.theType)
1271  , thePricing(base.thePricing)
1272  , theRep(base.theRep)
1273  , polishObj(base.polishObj)
1274  , timerType(base.timerType)
1276  , maxIters(base.maxIters)
1277  , maxTime(base.maxTime)
1280  , objLimit(base.objLimit)
1281  , m_status(base.m_status)
1288  , m_entertol(base.m_entertol)
1289  , m_leavetol(base.m_leavetol)
1290  , theShift(base.theShift)
1291  , lastShift(base.lastShift)
1292  , m_maxCycle(base.m_maxCycle)
1293  , m_numCycle(base.m_numCycle)
1294  , initialized(base.initialized)
1295  , solveVector2 (0)
1297  , solveVector3 (0)
1299  , coSolveVector2(0)
1301  , coSolveVector3(0)
1309  , displayLine(base.displayLine)
1310  , displayFreq(base.displayFreq)
1318  , unitVecs(base.unitVecs)
1319  , primRhs(base.primRhs)
1320  , primVec(base.primVec)
1321  , dualRhs(base.dualRhs)
1322  , dualVec(base.dualVec)
1323  , addVec(base.addVec)
1324  , theURbound(base.theURbound)
1325  , theLRbound(base.theLRbound)
1326  , theUCbound(base.theUCbound)
1327  , theLCbound(base.theLCbound)
1328  , theUBbound(base.theUBbound)
1329  , theLBbound(base.theLBbound)
1330  , theCoTest(base.theCoTest)
1331  , theTest(base.theTest)
1332  , primalRay(base.primalRay)
1333  , dualFarkas(base.dualFarkas)
1334  , leaveCount(base.leaveCount)
1335  , enterCount(base.enterCount)
1336  , primalCount(base.primalCount)
1337  , polishCount(base.polishCount)
1338  , boundflips(base.boundflips)
1340  , enterCycles(base.enterCycles)
1341  , leaveCycles(base.leaveCycles)
1345  , dualDegenSum(base.dualDegenSum)
1346  , boundrange(base.boundrange)
1347  , siderange(base.siderange)
1348  , objrange(base.objrange)
1351  , isInfeasible(base.isInfeasible)
1361  , weights(base.weights)
1362  , coWeights(base.coWeights)
1364  , spxout(base.spxout)
1366 {
1368 
1369  if (base.theRep == COLUMN)
1370  {
1371  thevectors = colSet();
1372  thecovectors = rowSet();
1373  theFrhs = &primRhs;
1374  theFvec = &primVec;
1375  theCoPrhs = &dualRhs;
1376  theCoPvec = &dualVec;
1377  thePvec = &addVec;
1378  theRPvec = theCoPvec;
1379  theCPvec = thePvec;
1380  theUbound = &theUCbound;
1381  theLbound = &theLCbound;
1384  }
1385  else
1386  {
1387  assert(base.theRep == ROW);
1388 
1389  thevectors = rowSet();
1390  thecovectors = colSet();
1391  theFrhs = &dualRhs;
1392  theFvec = &dualVec;
1393  theCoPrhs = &primRhs;
1394  theCoPvec = &primVec;
1395  thePvec = &addVec;
1396  theRPvec = thePvec;
1397  theCPvec = theCoPvec;
1398  theUbound = &theURbound;
1399  theLbound = &theLRbound;
1402  }
1403 
1404  SPxBasis::theLP = this;
1405 
1406  if(base.thepricer == 0)
1407  {
1408  thepricer = 0;
1409  freePricer = false;
1410  }
1411  else
1412  {
1413  thepricer = base.thepricer->clone();
1414  freePricer = true;
1415  thepricer->clear();
1416  thepricer->load(this);
1417  }
1418 
1419  if(base.theratiotester == 0)
1420  {
1421  theratiotester = 0;
1422  freeRatioTester = false;
1423  }
1424  else
1425  {
1427  freeRatioTester = true;
1428  theratiotester->clear();
1429  theratiotester->load(this);
1430  }
1431 
1432  if(base.thestarter == 0)
1433  {
1434  thestarter = 0;
1435  freeStarter = false;
1436  }
1437  else
1438  {
1439  thestarter = base.thestarter->clone();
1440  freeStarter = true;
1441  }
1442 
1443  assert(SPxSolver::isConsistent());
1444 }
1445 
1447 {
1448 #ifdef ENABLE_CONSISTENCY_CHECKS
1449  if (epsilon() < 0)
1450  return MSGinconsistent("SPxSolver");
1451 
1453  return MSGinconsistent("SPxSolver");
1454 
1455  if (dualVec.delta().getEpsilon() != addVec.delta().getEpsilon())
1456  return MSGinconsistent("SPxSolver");
1457 
1458  if (unitVecs.size() < SPxLP::nCols() || unitVecs.size() < SPxLP::nRows())
1459  return MSGinconsistent("SPxSolver");
1460 
1461  if (initialized)
1462  {
1463  if (theFrhs->dim() != dim())
1464  return MSGinconsistent("SPxSolver");
1465  if (theFvec->dim() != dim())
1466  return MSGinconsistent("SPxSolver");
1467 
1468  if (theCoPrhs->dim() != dim())
1469  return MSGinconsistent("SPxSolver");
1470  if (thePvec->dim() != coDim())
1471  return MSGinconsistent("SPxSolver");
1472  if (theCoPvec->dim() != dim())
1473  return MSGinconsistent("SPxSolver");
1474 
1475  if (theTest.dim() != coDim())
1476  return MSGinconsistent("SPxSolver");
1477  if (theCoTest.dim() != dim())
1478  return MSGinconsistent("SPxSolver");
1479 
1480  if (theURbound.dim() != SPxLP::nRows())
1481  return MSGinconsistent("SPxSolver");
1482  if (theLRbound.dim() != SPxLP::nRows())
1483  return MSGinconsistent("SPxSolver");
1484  if (theUCbound.dim() != SPxLP::nCols())
1485  return MSGinconsistent("SPxSolver");
1486  if (theLCbound.dim() != SPxLP::nCols())
1487  return MSGinconsistent("SPxSolver");
1488  if (theUBbound.dim() != dim())
1489  return MSGinconsistent("SPxSolver");
1490  if (theLBbound.dim() != dim())
1491  return MSGinconsistent("SPxSolver");
1492  }
1493 
1494  if (rep() == COLUMN)
1495  {
1496  if(thecovectors !=
1497  reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1498  || thevectors !=
1499  reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1500  || theFrhs != &primRhs ||
1501  theFvec != &primVec ||
1502  theCoPrhs != &dualRhs ||
1503  theCoPvec != &dualVec ||
1504  thePvec != &addVec ||
1505  theRPvec != theCoPvec ||
1506  theCPvec != thePvec ||
1507  theUbound != &theUCbound ||
1508  theLbound != &theLCbound ||
1509  theCoUbound != &theURbound ||
1510  theCoLbound != &theLRbound)
1511  return MSGinconsistent("SPxSolver");
1512  }
1513  else
1514  {
1515  if (thecovectors
1516  != reinterpret_cast<const SVSet*>(static_cast<const LPColSet*>(this))
1517  || thevectors
1518  != reinterpret_cast<const SVSet*>(static_cast<const LPRowSet*>(this))
1519  || theFrhs != &dualRhs ||
1520  theFvec != &dualVec ||
1521  theCoPrhs != &primRhs ||
1522  theCoPvec != &primVec ||
1523  thePvec != &addVec ||
1524  theRPvec != thePvec ||
1525  theCPvec != theCoPvec ||
1526  theUbound != &theURbound ||
1527  theLbound != &theLRbound ||
1528  theCoUbound != &theUCbound ||
1529  theCoLbound != &theLCbound)
1530  return MSGinconsistent("SPxSolver");
1531  }
1532 
1533  return SPxLP::isConsistent()
1534  && primRhs.isConsistent()
1535  && primVec.isConsistent()
1536  && dualRhs.isConsistent()
1537  && dualVec.isConsistent()
1538  && addVec.isConsistent()
1539  && theTest.isConsistent()
1540  && theCoTest.isConsistent()
1546  ;
1547 #else
1548  return true;
1549 #endif
1550 }
1551 
1552 
1554 {
1555  if( p_time < 0.0 )
1556  p_time = 0.0;
1557  maxTime = p_time;
1558 }
1559 
1561 {
1562  return maxTime;
1563 }
1564 
1565 void SPxSolver::setTerminationIter(int p_iteration)
1566 {
1567  if( p_iteration < 0 )
1568  p_iteration = -1;
1569  maxIters = p_iteration;
1570 }
1571 
1573 {
1574  return maxIters;
1575 }
1576 
1577 // returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
1578 bool SPxSolver::isTimeLimitReached(const bool forceCheck)
1579 {
1580  // always update the number of calls, since the user might set a time limit later in the solving process
1581  ++nCallsToTimelim;
1582 
1583  // check if a time limit is actually set
1584  if( maxTime >= infinity )
1585  return false;
1586 
1587  // check if the expensive system call to update the time should be skipped again
1588  if( forceCheck || nCallsToTimelim < NINITCALLS || nClckSkipsLeft <= 0 )
1589  {
1590  Real currtime = time();
1591 
1592  if( currtime >= maxTime )
1593  return true;
1594 
1595  // determine the number of times the clock can be skipped again.
1596  int nClckSkips = MAXNCLCKSKIPS;
1597  Real avgtimeinterval = (currtime + cumulativeTime()) / (Real)(nCallsToTimelim);
1598 
1599  // it would not be safe to skip the clock so many times since we are approaching the time limit
1600  if( SAFETYFACTOR * (maxTime - currtime) / (avgtimeinterval + 1e-6) < nClckSkips )
1601  nClckSkips = 0;
1602  nClckSkipsLeft = nClckSkips;
1603  }
1604  else
1605  --nClckSkipsLeft;
1606 
1607  return false;
1608 }
1609 
1610 
1611 /**@todo A first version for the termination value is
1612  * implemented. Currently we check if no bound violations (shifting)
1613  * is present. It might be even possible to use this termination
1614  * value in case of bound violations (shifting) but in this case it
1615  * is quite difficult to determine if we already reached the limit.
1616  */
1618 {
1619  objLimit = p_value;
1620 }
1621 
1623 {
1624  return objLimit;
1625 }
1626 
1629 {
1630  VarStatus vstat;
1631 
1632  switch( stat )
1633  {
1635  vstat = ON_LOWER;
1636  break;
1638  vstat = ON_UPPER;
1639  break;
1641  vstat = FIXED;
1642  break;
1644  vstat = ZERO;
1645  break;
1651  vstat = BASIC;
1652  break;
1653  default:
1654  MSG_ERROR( std::cerr << "ESOLVE26 ERROR: unknown basis status (" << stat << ")"
1655  << std::endl; )
1656  throw SPxInternalCodeException("XSOLVE22 This should never happen.");
1657  }
1658  return vstat;
1659 }
1660 
1663 {
1664  SPxBasis::Desc::Status rstat;
1665 
1666  switch( stat )
1667  {
1668  case FIXED :
1669  assert(EQ(rhs(row), lhs(row), feastol()));
1670  rstat = SPxBasis::Desc::P_FIXED;
1671  break;
1672  case ON_UPPER :
1673  assert(rhs(row) < infinity);
1674  rstat = lhs(row) < rhs(row)
1677  break;
1678  case ON_LOWER :
1679  assert(lhs(row) > -infinity);
1680  rstat = lhs(row) < rhs(row)
1683  break;
1684  case ZERO :
1685  /* A 'free' row (i.e., infinite lower & upper bounds) does not really make sense. The user
1686  * might (think to) know better, e.g., when temporarily turning off a row. We therefore apply
1687  * the same adjustment as in the column case in varStatusToBasisStatusCol(). */
1688  if (lhs(row) <= -infinity && rhs(row) >= infinity)
1689  rstat = SPxBasis::Desc::P_FREE;
1690  else
1691  {
1692  if ( lhs(row) == rhs(row) )
1693  {
1694  assert( rhs(row) < infinity );
1695  rstat = SPxBasis::Desc::P_FIXED;
1696  }
1697  else
1698  {
1699  if ( lhs(row) > -infinity )
1701  else
1702  {
1703  assert( rhs(row) < infinity );
1705  }
1706  }
1707  }
1708  break;
1709  case BASIC :
1710  rstat = dualRowStatus(row);
1711  break;
1712  default:
1713  MSG_ERROR( std::cerr << "ESOLVE27 ERROR: unknown VarStatus (" << int(stat) << ")"
1714  << std::endl; )
1715  throw SPxInternalCodeException("XSOLVE23 This should never happen.");
1716  }
1717  return rstat;
1718 }
1719 
1722 {
1723  SPxBasis::Desc::Status cstat;
1724 
1725  switch( stat )
1726  {
1727  case FIXED :
1728  if (upper(col) == lower(col))
1729  cstat = SPxBasis::Desc::P_FIXED;
1730  else if (maxObj(col) > 0.0)
1732  else
1734  break;
1735  case ON_UPPER :
1736  assert(upper(col) < infinity);
1737  cstat = lower(col) < upper(col)
1740  break;
1741  case ON_LOWER :
1742  assert(lower(col) > -infinity);
1743  cstat = lower(col) < upper(col)
1746  break;
1747  case ZERO :
1748  /* In this case the upper and lower bounds on the variable should be infinite. The bounds
1749  * might, however, have changed and we try to recover from this by changing the status to
1750  * 'resonable' settings. A solve has to find the correct values afterwards. Note that the
1751  * approach below is consistent with changesoplex.cpp (e.g., changeUpperStatus() and
1752  * changeLowerStatus() ). */
1753  if (lower(col) <= -infinity && upper(col) >= infinity)
1754  cstat = SPxBasis::Desc::P_FREE;
1755  else
1756  {
1757  if ( lower(col) == upper(col) )
1758  {
1759  assert( upper(col) < infinity );
1760  cstat = SPxBasis::Desc::P_FIXED;
1761  }
1762  else
1763  {
1764  if ( lower(col) > -infinity )
1766  else
1767  {
1768  assert( upper(col) < infinity );
1770  }
1771  }
1772  }
1773  break;
1774  case BASIC :
1775  cstat = dualColStatus(col);
1776  break;
1777  default:
1778  MSG_ERROR( std::cerr << "ESOLVE28 ERROR: unknown VarStatus (" << int(stat) << ")"
1779  << std::endl; )
1780  throw SPxInternalCodeException("XSOLVE24 This should never happen.");
1781  }
1782  return cstat;
1783 }
1784 
1786 {
1787  assert( 0 <= row && row < nRows() );
1788  return basisStatusToVarStatus( desc().rowStatus( row ) );
1789 }
1790 
1792 {
1793  assert( 0 <= col && col < nCols() );
1794  return basisStatusToVarStatus( desc().colStatus( col ) );
1795 }
1796 
1797 SPxSolver::Status SPxSolver::getBasis(VarStatus row[], VarStatus col[], const int rowsSize, const int colsSize) const
1798 {
1799  const SPxBasis::Desc& d = desc();
1800  int i;
1801 
1802  assert(rowsSize < 0 || rowsSize >= nRows());
1803  assert(colsSize < 0 || colsSize >= nCols());
1804 
1805  if (col)
1806  for (i = nCols() - 1; i >= 0; --i)
1807  col[i] = basisStatusToVarStatus( d.colStatus(i) );
1808 
1809  if (row)
1810  for (i = nRows() - 1; i >= 0; --i)
1811  row[i] = basisStatusToVarStatus( d.rowStatus(i) );
1812 
1813  return status();
1814 }
1815 
1817 {
1818 
1819  int basisdim;
1820 
1821  if ( p_rows.size() != nRows() || p_cols.size() != nCols() )
1822  return false;
1823 
1824  basisdim = 0;
1825  for ( int row = nRows()-1; row >= 0; --row )
1826  {
1827  if ( p_rows[row] == UNDEFINED )
1828  return false;
1829  // row is basic
1830  else if ( p_rows[row] == BASIC )
1831  {
1832  basisdim++;
1833  }
1834  // row is nonbasic
1835  else
1836  {
1837  if ( (p_rows[row] == FIXED && lhs(row) != rhs(row))
1838  || (p_rows[row] == ON_UPPER && rhs(row) >= infinity)
1839  || (p_rows[row] == ON_LOWER && lhs(row) <= -infinity) )
1840  return false;
1841  }
1842  }
1843 
1844  for ( int col = nCols()-1; col >= 0; --col )
1845  {
1846  if ( p_cols[col] == UNDEFINED )
1847  return false;
1848  // col is basic
1849  else if ( p_cols[col] == BASIC )
1850  {
1851  basisdim++;
1852  }
1853  // col is nonbasic
1854  else
1855  {
1856  if ( (p_cols[col] == FIXED && lower(col) != upper(col))
1857  || (p_cols[col] == ON_UPPER && upper(col) >= infinity)
1858  || (p_cols[col] == ON_LOWER && lower(col) <= -infinity) )
1859  return false;
1860  }
1861  }
1862 
1863  if ( basisdim != dim() )
1864  return false;
1865 
1866  // basis valid
1867  return true;
1868 }
1869 
1870 void SPxSolver::setBasis(const VarStatus p_rows[], const VarStatus p_cols[])
1871 {
1873  SPxBasis::load(this, false);
1874 
1875  SPxBasis::Desc ds = desc();
1876  int i;
1877 
1878  for(i = 0; i < nRows(); i++)
1879  ds.rowStatus(i) = varStatusToBasisStatusRow( i, p_rows[i] );
1880 
1881  for(i = 0; i < nCols(); i++)
1882  ds.colStatus(i) = varStatusToBasisStatusCol( i, p_cols[i] );
1883 
1884  loadBasis(ds);
1886 }
1887 
1888 // NOTE: This only works for the row representation. Need to update to account for column representation.
1889 // The degenvec differs relative to the algorithm being used.
1890 // For the primal simplex, degenvec is the primal solution values.
1891 // For the dual simplex, the degenvec is the feasvec (ROW) and pVec (COLUMN).
1893 {
1894  int numDegenerate = 0;
1895  Real degeneracyLevel = 0;
1896 
1897  // iterating over all columns in the basis matrix
1898  // this identifies the basis indices and those that have a zero dual multiplier (rows) or zero reduced cost (cols).
1899  if( rep() == ROW )
1900  {
1901  for( int i = 0; i < nCols(); ++i ) // @todo Check the use of numColsReal for the reduced problem.
1902  {
1903  // degeneracy in the dual simplex exists if there are rows with a zero dual multiplier or columns with a zero
1904  // reduced costs. This requirement is regardless of the objective sense.
1905  if( isZero(degenvec[i], feastol()) )
1906  numDegenerate++;
1907  }
1908 
1909  if( type() == ENTER ) // dual simplex
1910  degeneracyLevel = Real(numDegenerate)/nCols();
1911  else // primal simplex
1912  {
1913  assert(type() == LEAVE);
1914  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate - (nCols() - nRows())) : 0.0;
1915  degeneracyLevel = degenVars/nRows();
1916  }
1917  }
1918  else
1919  {
1920  assert(rep() == COLUMN);
1921 
1922  for( int i = 0; i < nCols(); i++ )
1923  {
1924  if( type() == LEAVE ) // dual simplex
1925  {
1926  if( isZero(maxObj()[i] - degenvec[i], feastol()) )
1927  numDegenerate++;
1928  }
1929  else // primal simplex
1930  {
1931  assert( type() == ENTER );
1932  if( isZero(degenvec[i], feastol()) )
1933  numDegenerate++;
1934  }
1935  }
1936 
1937 
1938  if( type() == LEAVE ) // dual simplex
1939  {
1940  Real degenVars = nRows() > numDegenerate ? Real(nRows() - numDegenerate) : 0.0;
1941  degeneracyLevel = degenVars/nCols();
1942  }
1943  else // primal simplex
1944  {
1945  assert(type() == ENTER);
1946  Real degenVars = (numDegenerate > (nCols() - nRows())) ? Real(numDegenerate - (nCols() - nRows())) : 0.0;
1947  degeneracyLevel = degenVars/nRows();
1948  }
1949  }
1950 
1951  return degeneracyLevel;
1952 }
1953 
1954 void SPxSolver::getNdualNorms(int& nnormsRow, int& nnormsCol) const
1955 {
1956  nnormsRow = 0;
1957  nnormsCol = 0;
1958 
1959  if( weightsAreSetup )
1960  {
1961  if( type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN )
1962  {
1963  nnormsRow = coWeights.dim();
1964  nnormsCol = 0;
1965 
1966  assert(nnormsRow == dim());
1967  }
1968  else if( type() == SPxSolver::ENTER && rep() == SPxSolver::ROW )
1969  {
1970  nnormsRow = weights.dim();
1971  nnormsCol = coWeights.dim();
1972 
1973  assert(nnormsRow == coDim());
1974  assert(nnormsCol == dim());
1975  }
1976  }
1977 }
1978 
1979 bool SPxSolver::getDualNorms(int& nnormsRow, int& nnormsCol, Real* norms) const
1980 {
1981  nnormsRow = 0;
1982  nnormsCol = 0;
1983 
1984  if( !weightsAreSetup )
1985  return false;
1986 
1987  if( type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN )
1988  {
1989  nnormsCol = 0;
1990  nnormsRow = coWeights.dim();
1991 
1992  assert(nnormsRow == dim());
1993 
1994  for( int i = 0; i < nnormsRow; ++i)
1995  norms[i] = coWeights[i];
1996  }
1997  else if( type() == SPxSolver::ENTER && rep() == SPxSolver::ROW )
1998  {
1999  nnormsRow = weights.dim();
2000  nnormsCol = coWeights.dim();
2001 
2002  assert(nnormsCol == dim());
2003  assert(nnormsRow == coDim());
2004 
2005  for( int i = 0; i < nnormsRow; ++i )
2006  norms[i] = weights[i];
2007 
2008  for( int i = 0; i < nnormsCol; ++i )
2009  norms[nnormsRow + i] = coWeights[i];
2010  }
2011  else
2012  return false;
2013 
2014  return true;
2015 }
2016 
2017 bool SPxSolver::setDualNorms(int nnormsRow, int nnormsCol, Real* norms)
2018 {
2019  weightsAreSetup = false;
2020 
2021  if( type() == SPxSolver::LEAVE && rep() == SPxSolver::COLUMN)
2022  {
2023  coWeights.reDim(dim(), false);
2024  assert(coWeights.dim() >= nnormsRow);
2025  for( int i = 0; i < nnormsRow; ++i )
2026  coWeights[i] = norms[i];
2027  weightsAreSetup = true;
2028  }
2029  else if( type() == SPxSolver::ENTER && rep() == SPxSolver::ROW)
2030  {
2031  weights.reDim(coDim(), false);
2032  coWeights.reDim(dim(), false);
2033  assert(weights.dim() >= nnormsRow);
2034  assert(coWeights.dim() >= nnormsCol);
2035  for( int i = 0; i < nnormsRow; ++i )
2036  weights[i] = norms[i];
2037  for( int i = 0; i < nnormsCol; ++i )
2038  coWeights[i] = norms[nnormsRow + i];
2039  weightsAreSetup = true;
2040  }
2041  else
2042  return false;
2043  return true;
2044 }
2045 
2046 void SPxSolver::setIntegralityInformation(int ncols, int* intInfo)
2047 {
2048  assert(ncols == nCols() || (ncols == 0 && intInfo == NULL));
2049 
2050  integerVariables.reSize(ncols);
2051  for( int i = 0; i < ncols; ++i )
2052  {
2053  integerVariables[i] = intInfo[i];
2054  }
2055 }
2056 
2057 
2058 
2059 //
2060 // Auxiliary functions.
2061 //
2062 
2063 // Pretty-printing of variable status.
2064 std::ostream& operator<<( std::ostream& os,
2065  const SPxSolver::VarStatus& status )
2066 {
2067  switch( status )
2068  {
2069  case SPxSolver::BASIC:
2070  os << "BASIC";
2071  break;
2072  case SPxSolver::FIXED:
2073  os << "FIXED";
2074  break;
2075  case SPxSolver::ON_LOWER:
2076  os << "ON_LOWER";
2077  break;
2078  case SPxSolver::ON_UPPER:
2079  os << "ON_UPPER";
2080  break;
2081  case SPxSolver::ZERO:
2082  os << "ZERO";
2083  break;
2084  case SPxSolver::UNDEFINED:
2085  os << "UNDEFINED";
2086  break;
2087  default:
2088  os << "?invalid?";
2089  break;
2090  }
2091  return os;
2092 }
2093 
2094 // Pretty-printing of solver status.
2095 std::ostream& operator<<( std::ostream& os,
2096  const SPxSolver::Status& status )
2097 {
2098  switch ( status )
2099  {
2100  case SPxSolver::ERROR:
2101  os << "ERROR";
2102  break;
2104  os << "NO_RATIOTESTER";
2105  break;
2106  case SPxSolver::NO_PRICER:
2107  os << "NO_PRICER";
2108  break;
2109  case SPxSolver::NO_SOLVER:
2110  os << "NO_SOLVER";
2111  break;
2112  case SPxSolver::NOT_INIT:
2113  os << "NOT_INIT";
2114  break;
2116  os << "ABORT_CYCLING";
2117  break;
2118  case SPxSolver::ABORT_TIME:
2119  os << "ABORT_TIME";
2120  break;
2121  case SPxSolver::ABORT_ITER:
2122  os << "ABORT_ITER";
2123  break;
2125  os << "ABORT_VALUE";
2126  break;
2127  case SPxSolver::SINGULAR:
2128  os << "SINGULAR";
2129  break;
2130  case SPxSolver::NO_PROBLEM:
2131  os << "NO_PROBLEM";
2132  break;
2133  case SPxSolver::REGULAR:
2134  os << "REGULAR";
2135  break;
2136  case SPxSolver::RUNNING:
2137  os << "RUNNING";
2138  break;
2139  case SPxSolver::UNKNOWN:
2140  os << "UNKNOWN";
2141  break;
2142  case SPxSolver::OPTIMAL:
2143  os << "OPTIMAL";
2144  break;
2145  case SPxSolver::UNBOUNDED:
2146  os << "UNBOUNDED";
2147  break;
2148  case SPxSolver::INFEASIBLE:
2149  os << "INFEASIBLE";
2150  break;
2151  default:
2152  os << "?other?";
2153  break;
2154  }
2155  return os;
2156 }
2157 
2158 // Pretty-printing of algorithm.
2159 std::ostream& operator<<( std::ostream& os,
2160  const SPxSolver::Type& status )
2161 {
2162  switch ( status )
2163  {
2164  case SPxSolver::ENTER:
2165  os << "ENTER";
2166  break;
2167  case SPxSolver::LEAVE:
2168  os << "LEAVE";
2169  break;
2170  default:
2171  os << "?other?";
2172  break;
2173  }
2174  return os;
2175 }
2176 
2177 // Pretty-printing of representation.
2178 std::ostream& operator<<( std::ostream& os,
2180 {
2181  switch ( status )
2182  {
2183  case SPxSolver::ROW:
2184  os << "ROW";
2185  break;
2186  case SPxSolver::COLUMN:
2187  os << "COLUMN";
2188  break;
2189  default:
2190  os << "?other?";
2191  break;
2192  }
2193  return os;
2194 }
2195 
2196 
2197 } // 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
Real boundrange
absolute range of all bounds in the problem
Definition: spxsolver.h:390
void clearUpdate()
clear ,
Definition: updatevector.h:160
virtual ~SPxSolver()
Definition: spxsolver.cpp:1042
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:193
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:207
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:381
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:325
const R & objOffset() const
Returns the objective function value offset.
Definition: spxlpbase.h:516
SPxOut * spxout
message handler
Definition: slinsolver.h:214
bool isConsistent() const
Consistency check.
Definition: dvectorbase.h:302
int boundflips
number of performed bound flips
Definition: spxsolver.h:376
bool getDualNorms(int &nnormsRow, int &nnormsCol, Real *norms) const
get dual norms
Definition: spxsolver.cpp:1979
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: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:226
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
get number of dual norms
Definition: spxsolver.cpp:1954
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:419
SPxOut * spxout
message handler
Definition: spxsolver.h:445
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:430
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
Type
Algorithmic type.
Definition: spxsolver.h:123
DVector * theUbound
Upper bound for vars.
Definition: spxsolver.h:359
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:499
Real objrange
absolute range of all objective coefficients in the problem
Definition: spxsolver.h:392
void setBasis(const VarStatus rows[], const VarStatus cols[])
set the lp solver&#39;s basis.
Definition: spxsolver.cpp:1870
void testBounds() const
Definition: spxbounds.cpp:311
UpdateVector addVec
storage for thePvec = &addVec
Definition: spxsolver.h:328
DVector theCoTest
Definition: spxsolver.h:365
Abstract pricer base class.
Real leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:777
DVector * theCoUbound
Upper bound for covars.
Definition: spxsolver.h:361
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:1797
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:307
virtual void reDim()
reset dimensions of vectors according to loaded LP.
Definition: spxsolver.cpp:449
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:784
UpdateVector dualVec
dual vector
Definition: spxsolver.h:327
void unscaleLPandReloadBasis()
unscales the LP and reloads the basis
Definition: spxsolver.cpp:513
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
Representation
LP basis representation.
Definition: spxsolver.h:104
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:432
virtual void clear()
clear all data in solver.
Definition: spxsolver.cpp:483
virtual void setRep(SPxSolver::Representation)
sets basis representation.
Definition: spxpricer.h:160
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:1628
Abstract ratio test base class.
solve() aborted due to iteration limit.
Definition: spxsolver.h:212
int leaveDegenCand
the number of degenerate candidates in the leaving algorithm
Definition: spxsolver.h:382
DecompStatus
Improved dual simplex status.
Definition: spxsolver.h:180
virtual int terminationIter() const
return iteration limit.
Definition: spxsolver.cpp:1572
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:426
No Problem has been loaded.
Definition: spxsolver.h:215
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: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:686
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:324
SPxLPBase< Real > & operator=(const SPxLPBase< Real > &old)
Assignment operator.
Definition: spxlpbase.h:2655
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1054
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:1134
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:192
Real sparsePricingFactor
enable sparse pricing when viols < factor * dim()
Definition: spxsolver.h:303
virtual SPxRatioTester * clone() const =0
clone function for polymorphism
LP has been proven to be primal infeasible.
Definition: spxsolver.h:221
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:1578
void setOpttol(Real d)
set parameter opttol.
Definition: spxsolver.cpp:929
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2120
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:876
rowwise representation.
Definition: spxsolver.h:106
bool setDualNorms(int nnormsRow, int nnormsCol, Real *norms)
set dual norms
Definition: spxsolver.cpp:2017
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:962
virtual void setTerminationTime(Real time=infinity)
set time limit.
Definition: spxsolver.cpp:1553
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:1892
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:204
No pricer loaded.
Definition: spxsolver.h:205
Entering Simplex.
Definition: spxsolver.h:133
const Vector & fRhs() const
right-hand side vector for fVec
Definition: spxsolver.h:1315
primal variable is set to its upper bound
Definition: spxbasis.h:188
UpdateVector & coPvec() const
copricing vector.
Definition: spxsolver.h:1377
int remainingRoundsLeave
number of dense rounds/refactorizations until sparsePricing is enabled again
Definition: spxsolver.h:436
int m_numCycle
actual number of degenerate steps so far.
Definition: spxsolver.h:269
int maxIters
maximum allowed iterations.
Definition: spxsolver.h:249
Leaving Simplex.
Definition: spxsolver.h:142
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:195
SPxStatus status() const
returns current SPxStatus.
Definition: spxbasis.h:425
SPxStarter * thestarter
Definition: spxsolver.h:388
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:354
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: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:278
#define MAXNCLCKSKIPS
Definition: spxsolver.h:46
#define MAXIMUM(x, y)
Definition: spxdefines.h:246
Pricing
Pricing type.
Definition: spxsolver.h:151
DVector * theFrhs
Definition: spxsolver.h:344
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
Status status() const
Status of solution process.
Definition: spxsolve.cpp:2046
DVector * theLbound
Lower bound for vars.
Definition: spxsolver.h:360
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:510
virtual void clear()
unloads LP.
Definition: spxpricer.h:118
Real m_pricingViol
maximal feasibility violation of current solution
Definition: spxsolver.h:259
virtual void unInit()
uninitialize data structures.
Definition: spxsolver.h:1838
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
Definition: basevectors.h:1123
Real entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:770
UpdateVector * thePvec
Definition: spxsolver.h:352
SPxBasis::Desc::Status varStatusToBasisStatusRow(int row, VarStatus stat) const
converts VarStatus to basis status for rows
Definition: spxsolver.cpp:1662
LP has been solved to optimality.
Definition: spxsolver.h:219
bool computeDegeneracy
Definition: spxsolver.h:306
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:2136
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:114
SPxPricer * thepricer
Definition: spxsolver.h:386
const SVSet * thecovectors
the LP coVectors according to representation
Definition: spxsolver.h:322
virtual Real terminationTime() const
return time limit.
Definition: spxsolver.cpp:1560
UpdateVector & fVec() const
feasibility vector.
Definition: spxsolver.h:1302
virtual void reinitializeVecs()
setup all vecs fresh
Definition: spxsolver.cpp:252
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:211
DVector theLBbound
Lower Basic Feasibility bound.
Definition: spxsolver.h:341
an error occured.
Definition: spxsolver.h:203
DVector coWeights
store dual norms
Definition: spxsolver.h:442
primal variable is left free, but unset
Definition: spxbasis.h:189
Real siderange
absolute range of all side in the problem
Definition: spxsolver.h:391
const VectorBase< Real > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:253
SPxSolver & operator=(const SPxSolver &base)
assignment operator
Definition: spxsolver.cpp:1073
int primalCount
number of primal iterations
Definition: spxsolver.h:373
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:190
bool updateNonbasicValue(Real objChange)
Definition: spxsolver.cpp:899
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:330
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:431
int remainingRoundsEnterCo
Definition: spxsolver.h:438
virtual void load(SPxSolver *p_solver)
loads LP.
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:380
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition: timerfactory.h:44
algorithm is running
Definition: spxsolver.h:217
const VectorBase< R > & 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:191
DVector theUBbound
Upper Basic Feasibility bound.
Definition: spxsolver.h:340
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:261
DVector * theCoLbound
Lower bound for covars.
Definition: spxsolver.h:362
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:765
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:377
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:374
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:84
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:245
UpdateVector & pVec() const
pricing vector.
Definition: spxsolver.h:1457
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:310
Full pricing.
Definition: spxsolver.h:159
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:413
DVector theLRbound
Lower Row Feasibility bound.
Definition: spxsolver.h:331
DVector theUCbound
Upper Column Feasibility bound.
Definition: spxsolver.h:332
void setDualColBounds()
Definition: spxbounds.cpp:103
virtual void setTerminationIter(int iteration=-1)
set iteration limit.
Definition: spxsolver.cpp:1565
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1829
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:308
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:183
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:437
Everything should be within this namespace.
bool isBasisValid(DataArray< VarStatus > rows, DataArray< VarStatus > cols)
check a given basis for validity.
Definition: spxsolver.cpp:1816
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:104
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:248
UpdateVector * theFvec
Definition: spxsolver.h:346
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:384
SSVector * coSolveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:277
solve() aborted due to detection of cycling.
Definition: spxsolver.h:210
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:1315
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< R > & 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:2046
SPxSolver * theLP
the LP
Definition: spxbasis.h:343
DVector theLCbound
Lower Column Feasibility bound.
Definition: spxsolver.h:333
virtual void clearUpdateVecs(void)
Definition: spxsolver.cpp:521
int leaveCount
number of LEAVE iterations
Definition: spxsolver.h:371
nothing known on loaded problem.
Definition: spxsolver.h:218
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:1785
virtual void factorize()
factorizes the basis matrix.
Definition: spxbasis.cpp:889
bool isConsistent() const
check consistency.
Definition: spxsolver.cpp:1446
variable is basic.
Definition: spxsolver.h:194
VarStatus getBasisColStatus(int col) const
gets basis status for a single column
Definition: spxsolver.cpp:1791
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:1721
SPxRatioTester * theratiotester
Definition: spxsolver.h:387
virtual Real terminationValue() const
return objective limit.
Definition: spxsolver.cpp:1622
void shiftFvec()
Perform initial shifting to optain an feasible or pricable basis.
Definition: spxshift.cpp:25
DVector * theCoPrhs
Definition: spxsolver.h:349
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:379
DSVector primalRay
stores primal ray in case of unboundedness
Definition: spxsolver.h:368
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:493
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:427
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:124
int coDim() const
codimension.
Definition: spxsolver.h:1059
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:434
bool isConsistent() const
Consistency check.
Definition: spxlpbase.h:1867
#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:369
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:157
int enterCount
number of ENTER iterations
Definition: spxsolver.h:372
const Vector & coPrhs() const
Right-hand side vector for coPvec.
Definition: spxsolver.h:1390
DVector weights
dual pricing norms
Definition: spxsolver.h:441
int printCondition
printing the current condition number in the log (0 - off, 1 - estimate,exact, 2 - exact)";ratio esti...
Definition: spxsolver.h:311
Array< UnitVector > unitVecs
array of unit vectors
Definition: spxsolver.h:320
const SVSet * thevectors
the LP vectors according to representation
Definition: spxsolver.h:321
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:447
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:917
virtual void init()
intialize data structures.
Definition: spxsolver.cpp:305
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:412
void forceRecompNonbasicValue()
Definition: spxsolver.h:651
#define MSGinconsistent(name)
Definition: spxdefines.h:126
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:443
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:631
void initRep(Representation p_rep)
initialize ROW or COLUMN representation.
Definition: spxsolver.cpp:186
SSVector & delta()
update vector , writeable
Definition: updatevector.h:122
DIdxSet updateViolsCo
Definition: spxsolver.h:420
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:792
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:951
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< R > * rowSet() const
Returns the complete SVSet.
Definition: lprowsetbase.h:69
virtual void clear()
clears the LP.
Definition: spxlpbase.h:1098
void computePvec()
compute entire pVec().
Definition: spxvecs.cpp:498
virtual void setTerminationValue(Real value=infinity)
set objective limit.
Definition: spxsolver.cpp:1617
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:305
virtual void unLoad()
unloads the LP from the basis.
Definition: spxbasis.h:873
UpdateVector * theCoPvec
Definition: spxsolver.h:350
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:641
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:416
DVector dualRhs
rhs vector for computing the dual vector
Definition: spxsolver.h:326
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:433
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:437
const Desc & desc() const
Definition: spxbasis.h:463
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:487
Real nonbasicValue()
Compute part of objective value.
Definition: spxsolver.cpp:722
solve() aborted due to objective limit.
Definition: spxsolver.h:213
columnwise representation.
Definition: spxsolver.h:107
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:109
bool isConsistent() const
consistency check.
Definition: spxbasis.cpp:1176
Basis is singular, numerical troubles?
Definition: spxsolver.h:214
UpdateVector * theCPvec
column pricing vector
Definition: spxsolver.h:355
virtual void factorize()
Factorize basis matrix.
Definition: spxsolver.cpp:536
Basis is primal feasible.
Definition: spxbasis.h:96
void resetClockStats()
resets clock average statistics
Definition: spxsolver.cpp:298
SPxSolver * solver() const
returns loaded solver.
Definition: spxbasis.h:563
LP has a usable Basis (maybe LP is changed).
Definition: spxsolver.h:216
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:2029
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
Definition: spxsolver.cpp:426
LP has been proven to be primal unbounded.
Definition: spxsolver.h:220
No Problem has been loaded to the basis.
Definition: spxbasis.h:92
No linear solver loaded.
Definition: spxsolver.h:206
void setDelta(Real d)
set parameter delta, i.e., set feastol and opttol to same value.
Definition: spxsolver.cpp:941
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:383