Scippy

SoPlex

Sequential object-oriented simPlex

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