Scippy

SoPlex

Sequential object-oriented simPlex

spxsolver.h
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-2020 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 /**@file spxsolver.h
17  * @brief main LP solver class
18  */
19 #ifndef _SPXSOLVER_H_
20 #define _SPXSOLVER_H_
21 
22 #include <assert.h>
23 #include <iostream>
24 #include <iomanip>
25 #include <sstream>
26 
27 #include "soplex/spxdefines.h"
28 #include "soplex/timer.h"
29 #include "soplex/timerfactory.h"
30 #include "soplex/spxlp.h"
31 #include "soplex/spxbasis.h"
32 #include "soplex/array.h"
33 #include "soplex/random.h"
34 #include "soplex/unitvector.h"
35 #include "soplex/updatevector.h"
36 #include "soplex/stablesum.h"
37 
38 #include "soplex/spxlpbase.h"
39 
40 #define HYPERPRICINGTHRESHOLD 5000 /**< do (auto) hyper pricing only if problem size (cols+rows) is larger than HYPERPRICINGTHRESHOLD */
41 #define HYPERPRICINGSIZE 100 /**< size of initial candidate list for hyper pricing */
42 #define SPARSITYFACTOR 0.6 /**< percentage of infeasibilities that is considered sparse */
43 #define DENSEROUNDS 5 /**< number of refactorizations until sparsity is tested again */
44 #define SPARSITY_TRADEOFF 0.8 /**< threshold to decide whether Ids or coIds are preferred to enter the basis;
45  * coIds are more likely to enter if SPARSITY_TRADEOFF is close to 0
46  */
47 #define MAXNCLCKSKIPS 32 /**< maximum number of clock skips (iterations without time measuring) */
48 #define SAFETYFACTOR 1e-2 /**< the probability to skip the clock when the time limit has been reached */
49 #define NINITCALLS 200 /**< the number of clock updates in isTimelimitReached() before clock skipping starts */
50 namespace soplex
51 {
52 template <class R>
53 class SPxPricer;
54 template <class R>
55 class SPxRatioTester;
56 template <class R>
57 class SPxStarter;
58 template <class R>
59 class SPxFastRT;
60 template <class R>
61 class SPxBoundFlippingRT;
62 
63 /**@brief Sequential object-oriented SimPlex.
64  @ingroup Algo
65 
66  SPxSolverBase is an LP solver class using the revised Simplex algorithm. It
67  provides two basis representations, namely a column basis and a row basis
68  (see #Representation). For both representations, a primal and
69  dual algorithm is available (see \ref Type).
70 
71  In addition, SPxSolverBase can be customized with various respects:
72  - pricing algorithms using SPxPricer
73  - ratio test using class SPxRatioTester
74  - computation of a start basis using class SPxStarter
75  - preprocessing of the LP using class SPxSimplifier
76  - termination criteria by overriding
77 
78  SPxSolverBase is derived from SPxLPBase<R> that is used to store the LP to be solved.
79  Hence, the LPs solved with SPxSolverBase have the general format
80 
81  \f[
82  \begin{array}{rl}
83  \hbox{max} & \mbox{maxObj}^T x \\
84  \hbox{s.t.} & \mbox{lhs} \le Ax \le \mbox{rhs} \\
85  & \mbox{low} \le x \le \mbox{up}
86  \end{array}
87  \f]
88 
89  Also, SPxLPBase<R> provide all manipulation methods for the LP. They allow
90  SPxSolverBase to be used within cutting plane algorithms.
91 */
92 
93 template <class R>
94 class SPxSolverBase : public SPxLPBase<R>, protected SPxBasisBase<R>
95 {
96  friend SPxFastRT<R>;
97  friend SPxBoundFlippingRT<R>;
98 
99 public:
100 
101  //-----------------------------
102  /**@name Data Types */
103  ///@{
104  /// LP basis representation.
105  /** Solving LPs with the Simplex algorithm requires the definition of a
106  * \em basis. A basis can be defined as a set of column vectors or a
107  * set of row vectors building a nonsingular matrix. We will refer to
108  * the first case as the \em columnwise representation and the latter
109  * case will be called the \em rowwise representation.
110  *
111  * Type Representation determines the representation of SPxSolverBase, i.e.
112  * a columnwise (#COLUMN == 1) or rowwise (#ROW == -1) one.
113  */
114  enum Representation
115  {
116  ROW = -1, ///< rowwise representation.
117  COLUMN = 1 ///< columnwise representation.
118  };
120  /// Algorithmic type.
121  /** SPxSolverBase uses the reviesed Simplex algorithm to solve LPs.
122  * Mathematically, one distinguishes the \em primal from the
123  * \em dual algorihm. Algorithmically, these relate to the two
124  * types #ENTER or #LEAVE. How they relate, depends on the chosen
125  * basis representation. This is desribed by the following table:
126  *
127  * <TABLE>
128  * <TR><TD>&nbsp;</TD><TD>ENTER </TD><TD>LEAVE </TD></TR>
129  * <TR><TD>ROW </TD><TD>DUAL </TD><TD>PRIMAL</TD></TR>
130  * <TR><TD>COLUMN</TD><TD>PRIMAL</TD><TD>DUAL </TD></TR>
131  * </TABLE>
132  */
133  enum Type
134  {
135  /// Entering Simplex.
136  /** The Simplex loop for the entering Simplex can be sketched
137  * as follows:
138  * - \em Pricing : Select a variable to #ENTER the basis.
139  * - \em Ratio-Test : Select variable to #LEAVE the
140  * basis such that the basis remains feasible.
141  * - Perform the basis update.
142  */
143  ENTER = -1,
144  /// Leaving Simplex.
145  /** The Simplex loop for the leaving Simplex can be sketched
146  * as follows:
147  * - \em Pricing: Select a variable to #LEAVE the basis.
148  * - \em Ratio-Test: Select variable to #ENTER the
149  * basis such that the basis remains priced.
150  * - Perform the basis update.
151  */
152  LEAVE = 1
153  };
155  /// Pricing type.
156  /** In case of the #ENTER%ing Simplex algorithm, for performance
157  * reasons it may be advisable not to compute and maintain up to
158  * date vectors #pVec() and #test() and instead compute only some
159  * of its elements explicitely. This is controled by the #Pricing type.
160  */
161  enum Pricing
162  {
163  /// Full pricing.
164  /** If #FULL pricing in selected for the #ENTER%ing Simplex,
165  * vectors #pVec() and #test() are kept up to date by
166  * SPxSolverBase. An SPxPricer only needs to select an Id such
167  * that the #test() or #coTest() value is < 0.
168  */
169  FULL,
170  /// Partial pricing.
171  /** When #PARTIAL pricing in selected for the #ENTER%ing
172  * Simplex, vectors #pVec() and #test() are not set up and
173  * updated by SPxSolverBase. However, vectors #coPvec() and
174  * #coTest() are still kept up to date by SPxSolverBase.
175  * An SPxPricer object needs to compute the values for
176  * #pVec() and #test() itself in order to select an
177  * appropriate pivot with #test() < 0. Methods \ref computePvec(int)
178  * "computePvec(i)" and \ref computeTest(int) "computeTest(i)"
179  * will assist the used to do so. Note
180  * that it may be feasible for a pricer to return an Id with
181  * #test() > 0; such will be rejected by SPxSolverBase.
182  */
183  PARTIAL
184  };
186  /// Improved dual simplex status
187  /** The improved dual simplex requires a starting basis to perform the problem partitioning. This flag sets the
188  * status of the improved dual simplex to indicate whether the starting basis must be found or not.
189  */
190  enum DecompStatus
191  {
192  /// Starting basis has not been found yet
193  FINDSTARTBASIS = 0,
194  /// Starting basis has been found and the simplex can be executed as normal
196  };
198  enum VarStatus
199  {
200  ON_UPPER, ///< variable set to its upper bound.
201  ON_LOWER, ///< variable set to its lower bound.
202  FIXED, ///< variable fixed to identical bounds.
203  ZERO, ///< free variable fixed to zero.
204  BASIC, ///< variable is basic.
205  UNDEFINED ///< nothing known about basis status (possibly due to a singular basis in transformed problem)
206  };
208  /**@todo In spxchange, change the status to
209  if (m_status > 0) m_status = REGULAR;
210  */
211  enum Status
212  {
213  ERROR = -15, ///< an error occured.
214  NO_RATIOTESTER = -14, ///< No ratiotester loaded
215  NO_PRICER = -13, ///< No pricer loaded
216  NO_SOLVER = -12, ///< No linear solver loaded
217  NOT_INIT = -11, ///< not initialised error
218  ABORT_EXDECOMP = -10, ///< solve() aborted to exit decomposition simplex
219  ABORT_DECOMP = -9, ///< solve() aborted due to commence decomposition simplex
220  ABORT_CYCLING = -8, ///< solve() aborted due to detection of cycling.
221  ABORT_TIME = -7, ///< solve() aborted due to time limit.
222  ABORT_ITER = -6, ///< solve() aborted due to iteration limit.
223  ABORT_VALUE = -5, ///< solve() aborted due to objective limit.
224  SINGULAR = -4, ///< Basis is singular, numerical troubles?
225  NO_PROBLEM = -3, ///< No Problem has been loaded.
226  REGULAR = -2, ///< LP has a usable Basis (maybe LP is changed).
227  RUNNING = -1, ///< algorithm is running
228  UNKNOWN = 0, ///< nothing known on loaded problem.
229  OPTIMAL = 1, ///< LP has been solved to optimality.
230  UNBOUNDED = 2, ///< LP has been proven to be primal unbounded.
231  INFEASIBLE = 3, ///< LP has been proven to be primal infeasible.
232  INForUNBD = 4, ///< LP is primal infeasible or unbounded.
233  OPTIMAL_UNSCALED_VIOLATIONS = 5 ///< LP has beed solved to optimality but unscaled solution contains violations.
234  };
236  /// objective for solution polishing
237  enum SolutionPolish
238  {
239  POLISH_OFF, ///< don't perform modifications on optimal basis
240  POLISH_INTEGRALITY, ///< maximize number of basic slack variables, i.e. more variables on bounds
241  POLISH_FRACTIONALITY ///< minimize number of basic slack variables, i.e. more variables in between bounds
242  };
244 
245  ///@}
246 
247 private:
248 
249  //-----------------------------
250  /**@name Private data */
251  ///@{
252  Type theType; ///< entering or leaving algortihm.
253  Pricing thePricing; ///< full or partial pricing.
254  Representation theRep; ///< row or column representation.
255  SolutionPolish polishObj; ///< objective of solution polishing
256  Timer* theTime; ///< time spent in last call to method solve()
257  Timer::TYPE timerType; ///< type of timer (user or wallclock)
258  Real theCumulativeTime; ///< cumulative time spent in all calls to method solve()
259  int maxIters; ///< maximum allowed iterations.
260  Real maxTime; ///< maximum allowed time.
261  int nClckSkipsLeft; ///< remaining number of times the clock can be safely skipped
262  long nCallsToTimelim; /// < the number of calls to the method isTimeLimitReached()
263  R objLimit; ///< objective value limit.
264  Status m_status; ///< status of algorithm.
266  R m_nonbasicValue; ///< nonbasic part of current objective value
267  bool m_nonbasicValueUpToDate; ///< true, if the stored objValue is up to date
269  R m_pricingViol; ///< maximal feasibility violation of current solution
270  bool m_pricingViolUpToDate; ///< true, if the stored violation is up to date
272  R
273  m_pricingViolCo; ///< maximal feasibility violation of current solution in coDim
274  bool m_pricingViolCoUpToDate; ///< true, if the stored violation in coDim is up to date
275  int m_numViol; ///< number of violations of current solution
277  R m_entertol; ///< feasibility tolerance maintained during entering algorithm
278  R m_leavetol; ///< feasibility tolerance maintained during leaving algorithm
279  R theShift; ///< sum of all shifts applied to any bound.
280  R lastShift; ///< for forcing feasibility.
281  int m_maxCycle; ///< maximum steps before cycling is detected.
282  int m_numCycle; ///< actual number of degenerate steps so far.
283  bool initialized; ///< true, if all vectors are setup.
286  solveVector2; ///< when 2 systems are to be solved at a time; typically for speepest edge weights
288  solveVector2rhs; ///< when 2 systems are to be solved at a time; typically for speepest edge weights
290  solveVector3; ///< when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic solution will be modified!)
292  solveVector3rhs; ///< when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic solution will be modified!)
294  coSolveVector2; ///< when 2 systems are to be solved at a time; typically for speepest edge weights
296  coSolveVector2rhs; ///< when 2 systems are to be solved at a time; typically for speepest edge weights
298  coSolveVector3; ///< when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic solution will be modified!)
300  coSolveVector3rhs; ///< when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic solution will be modified!)
301 
302  bool freePricer; ///< true iff thepricer should be freed inside of object
303  bool freeRatioTester; ///< true iff theratiotester should be freed inside of object
304  bool freeStarter; ///< true iff thestarter should be freed inside of object
306  /* Store the index of a leaving variable if only an instable entering variable has been found.
307  instableLeave == true iff this instable basis change should be performed.
308  (see spxsolve.hpp and leave.hpp) */
309  int instableLeaveNum;
310  bool instableLeave;
313  /* Store the id of an entering row or column if only an instable pivot has been found.
314  instableEnter == true iff this instable basis change should be performed.
315  (see spxsolve.hpp and enter.hpp) */
317  bool instableEnter;
320  bool
321  recomputedVectors; ///< flag to perform clean up step to reduce numerical errors only once
322 
324  int displayFreq;
325  R sparsePricingFactor; ///< enable sparse pricing when viols < factor * dim()
327  bool
328  getStartingDecompBasis; ///< flag to indicate whether the simplex is solved to get the starting improved dual simplex basis
329  bool computeDegeneracy;
330  int
331  degenCompIterOffset; ///< the number of iterations performed before the degeneracy level is computed
332  int
333  decompIterationLimit; ///< the maximum number of iterations before the decomposition simplex is aborted.
334 
335  bool
336  fullPerturbation; ///< whether to perturb the entire problem or just the bounds relevant for the current pivot
337  int
338  printBasisMetric; ///< printing the current basis metric in the log (-1: off, 0: condition estimate, 1: trace, 2: determinant, 3: condition)
339 
340  ///@}
341 
342 protected:
343 
344  //-----------------------------
345  /**@name Protected data */
346  ///@{
347  Array < UnitVectorBase<R> > unitVecs; ///< array of unit vectors
348  const SVSetBase<R>* thevectors; ///< the LP vectors according to representation
349  const SVSetBase<R>* thecovectors; ///< the LP coVectors according to representation
351  VectorBase<R> primRhs; ///< rhs VectorBase<R> for computing the primal vector
352  UpdateVector<R> primVec; ///< primal vector
353  VectorBase<R> dualRhs; ///< rhs VectorBase<R> for computing the dual vector
354  UpdateVector<R> dualVec; ///< dual vector
355  UpdateVector<R> addVec; ///< storage for thePvec = &addVec
357  VectorBase<R> theURbound; ///< Upper Row Feasibility bound
358  VectorBase<R> theLRbound; ///< Lower Row Feasibility bound
359  VectorBase<R> theUCbound; ///< Upper Column Feasibility bound
360  VectorBase<R> theLCbound; ///< Lower Column Feasibility bound
362  /** In entering Simplex algorithm, the ratio test must ensure that all
363  * \em basic variables remain within their feasibility bounds. To give fast
364  * acces to them, the bounds of basic variables are copied into the
365  * following two vectors.
366  */
367  VectorBase<R> theUBbound; ///< Upper Basic Feasibility bound
368  VectorBase<R> theLBbound; ///< Lower Basic Feasibility bound
370  /** The values of the rhs corresponding to the current basis.*/
372  /** The values of all basis variables. */
374 
375  /* The Copricing rhs and VectorBase<R> */
378  /** The pricing VectorBase<R> */
380 
381  UpdateVector<R>* theRPvec; ///< row pricing vector
382  UpdateVector<R>* theCPvec; ///< column pricing vector
384  // The following vectors serve for the virtualization of shift bounds
385  //@todo In prinziple this schould be references.
386  VectorBase<R>* theUbound; ///< Upper bound for vars
387  VectorBase<R>* theLbound; ///< Lower bound for vars
388  VectorBase<R>* theCoUbound; ///< Upper bound for covars
389  VectorBase<R>* theCoLbound; ///< Lower bound for covars
391  // The following vectors serve for the virtualization of testing vectors
395  DSVectorBase<R> primalRay; ///< stores primal ray in case of unboundedness
396  DSVectorBase<R> dualFarkas; ///< stores dual farkas proof in case of infeasibility
398  int leaveCount; ///< number of LEAVE iterations
399  int enterCount; ///< number of ENTER iterations
400  int primalCount; ///< number of primal iterations
401  int polishCount; ///< number of solution polishing iterations
403  int boundflips; ///< number of performed bound flips
404  int totalboundflips; ///< total number of bound flips
406  int enterCycles; ///< the number of degenerate steps during the entering algorithm
407  int leaveCycles; ///< the number of degenerate steps during the leaving algorithm
408  int enterDegenCand; ///< the number of degenerate candidates in the entering algorithm
409  int leaveDegenCand; ///< the number of degenerate candidates in the leaving algorithm
410  R primalDegenSum; ///< the sum of the primal degeneracy percentage
411  R dualDegenSum; ///< the sum of the dual degeneracy percentage
417  R boundrange; ///< absolute range of all bounds in the problem
418  R siderange; ///< absolute range of all side in the problem
419  R objrange; ///< absolute range of all objective coefficients in the problem
420  ///@}
422  //-----------------------------
423  /**@name Precision */
424  ///@{
425  /// is the solution precise enough, or should we increase delta() ?
426  virtual bool precisionReached(R& newpricertol) const;
427 
428  /// determine ranges of problem values for bounds, sides and objective to assess numerical difficulties
429  void calculateProblemRanges();
430  ///@}
431 
432 public:
433 
434  /// The random number generator used throughout the whole computation. Its seed can be modified.
435  Random random;
436 
437  /** For the leaving Simplex algorithm this vector contains the indices of infeasible basic variables;
438  * for the entering Simplex algorithm this vector contains the indices of infeasible slack variables.
439  */
441  /**For the entering Simplex algorithm these vectors contains the indices of infeasible basic variables.
442  */
444 
445  /// store indices that were changed in the previous iteration and must be checked in hyper pricing
449  /** Binary vectors to store whether basic indices are infeasible
450  * the i-th entry equals false, if the i-th basic variable is not infeasible
451  * the i-th entry equals true, if the i-th basic variable is infeasible
452  */
454  isInfeasible; ///< 0: index not violated, 1: index violated, 2: index violated and among candidate list
456  isInfeasibleCo; ///< 0: index not violated, 1: index violated, 2: index violated and among candidate list
457 
458  /// These values enable or disable sparse pricing
459  bool sparsePricingLeave; ///< true if sparsePricing is turned on in the leaving Simplex
460  bool sparsePricingEnter; ///< true if sparsePricing is turned on in the entering Simplex for slack variables
461  bool sparsePricingEnterCo; ///< true if sparsePricing is turned on in the entering Simplex
462  bool hyperPricingLeave; ///< true if hyper sparse pricing is turned on in the leaving Simplex
463  bool hyperPricingEnter; ///< true if hyper sparse pricing is turned on in the entering Simplex
465  int remainingRoundsLeave; ///< number of dense rounds/refactorizations until sparsePricing is enabled again
469  /// dual pricing norms
470  VectorBase<R> weights; ///< store dual norms
471  VectorBase<R> coWeights; ///< store dual norms
472  bool weightsAreSetup; ///< are the dual norms already set up?
475  Timer* multTimeSparse; ///< time spent in setupPupdate() exploiting sparsity
476  Timer* multTimeFull; ///< time spent in setupPupdate() ignoring sparsity
477  Timer* multTimeColwise; ///< time spent in setupPupdate(), columnwise multiplication
478  Timer* multTimeUnsetup; ///< time spent in setupPupdate() w/o sparsity information
479  int multSparseCalls; ///< number of products exploiting sparsity
480  int multFullCalls; ///< number of products ignoring sparsity
481  int multColwiseCalls; ///< number of products, columnwise multiplication
482  int multUnsetupCalls; ///< number of products w/o sparsity information
484  SPxOut* spxout; ///< message handler
485 
487  integerVariables; ///< supplementary variable information, 0: continous variable, 1: integer variable
488 
489  //-----------------------------
490  void setOutstream(SPxOut& newOutstream)
491  {
492  spxout = &newOutstream;
493  SPxLPBase<R>::spxout = &newOutstream;
494  }
495 
496  /// set refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix
497  void setNonzeroFactor(R f)
498  {
500  }
501 
502  /// set refactor threshold for fill-in in current factor update compared to fill-in in last factorization
503  void setFillFactor(R f)
504  {
506  }
507 
508  /// set refactor threshold for memory growth in current factor update compared to the last factorization
509  void setMemFactor(R f)
510  {
512  }
513 
514  /**@name Access */
515  ///@{
516  /// return the version of SPxSolverBase as number like 123 for 1.2.3
517  int version() const
518  {
520  }
521  /// return the internal subversion of SPxSolverBase as number
522  int subversion() const
523  {
525  }
526  /// return the current basis representation.
527  Representation rep() const
528  {
529  return theRep;
530  }
531 
532  /// return current Type.
533  Type type() const
534  {
535  return theType;
536  }
537 
538  /// return current Pricing.
539  Pricing pricing() const
540  {
541  return thePricing;
542  }
543 
544  /// return current starter.
545  SPxStarter<R>* starter() const
546  {
547  return thestarter;
548  }
549  ///@}
550 
551  //-----------------------------
552  /**@name Setup
553  * Before solving an LP with an instance of SPxSolverBase,
554  * the following steps must be performed:
555  *
556  * -# Load the LP by copying an external LP or reading it from an
557  * input stream.
558  * -# Setup the pricer to use by loading an \ref soplex::SPxPricer
559  * "SPxPricer" object (if not already done in a previous call).
560  * -# Setup the ratio test method to use by loading an
561  * \ref soplex::SPxRatioTester "SPxRatioTester" object
562  * (if not already done in a previous call).
563  * -# Setup the linear system solver to use by loading an
564  * \ref soplex::SLinSolver "SLinSolver" object
565  * (if not already done in a previous call).
566  * -# Optionally setup an start basis generation method by loading an
567  * \ref soplex::SPxStarter "SPxStarter" object.
568  * -# Optionally setup a start basis by loading a
569  * \ref soplex::SPxBasisBase<R>::Desc "SPxBasisBase<R>::Desc" object.
570  * -# Optionally switch to another basis
571  * \ref soplex::SPxSolverBase<R>::Representation "Representation"
572  * by calling method \ref soplex::SPxSolverBase<R>::setRep() "setRep()".
573  * -# Optionally switch to another algorithm
574  * \ref soplex::SPxSolverBase<R>::Type "Type"
575  * by calling method \ref soplex::SPxSolverBase<R>::setType() "setType()".
576  *
577  * Now the solver is ready for execution. If the loaded LP is to be solved
578  * again from scratch, this can be done with method
579  * \ref soplex::SPxSolverBase<R>::reLoad() "reLoad()". Finally,
580  * \ref soplex::SPxSolverBase<R>::clear() "clear()" removes the LP from the solver.
581  */
582  ///@{
583  /// read LP from input stream.
584  virtual bool read(std::istream& in, NameSet* rowNames = 0,
585  NameSet* colNames = 0, DIdxSet* intVars = 0);
586 
587  /// copy LP.
588  virtual void loadLP(const SPxLPBase<R>& LP, bool initSlackBasis = true);
589  /// setup linear solver to use. If \p destroy is true, \p slusolver will be freed in destructor.
590  virtual void setBasisSolver(SLinSolver<R>* slu, const bool destroy = false);
591  /// setup pricer to use. If \p destroy is true, \p pricer will be freed in destructor.
592  virtual void setPricer(SPxPricer<R>* pricer, const bool destroy = false);
593  /// setup ratio-tester to use. If \p destroy is true, \p tester will be freed in destructor.
594  virtual void setTester(SPxRatioTester<R>* tester, const bool destroy = false);
595  /// setup starting basis generator to use. If \p destroy is true, \p starter will be freed in destructor.
596  virtual void setStarter(SPxStarter<R>* starter, const bool destroy = false);
597  /// set a start basis.
598  virtual void loadBasis(const typename SPxBasisBase<R>::Desc&);
599 
600  /// initialize #ROW or #COLUMN representation.
601  void initRep(Representation p_rep);
602  /// switch to #ROW or #COLUMN representation if not already used.
603  void setRep(Representation p_rep);
604  /// set \ref soplex::SPxSolverBase<R>::LEAVE "LEAVE" or \ref soplex::SPxSolverBase<R>::ENTER "ENTER" algorithm.
605  void setType(Type tp);
606  /// set \ref soplex::SPxSolverBase<R>::FULL "FULL" or \ref soplex::SPxSolverBase<R>::PARTIAL "PARTIAL" pricing.
607  void setPricing(Pricing pr);
608  /// turn on or off the improved dual simplex.
609  void setDecompStatus(DecompStatus decomp_stat);
610 
611  /// reload LP.
612  virtual void reLoad();
613 
614  /// clear all data in solver.
615  virtual void clear();
616 
617  /// unscales the LP and reloads the basis
619 
620  /** Load basis from \p filename in MPS format. If \p rowNames and \p
621  * colNames are \c NULL, default names are used for the constraints and
622  * variables.
623  */
624  virtual bool readBasisFile(const char* filename,
625  const NameSet* rowNames, const NameSet* colNames);
626 
627  /** Write basis to \p filename in MPS format. If \p rowNames and \p
628  * colNames are \c NULL, default names are used for the constraints and
629  * variables.
630  */
631  virtual bool writeBasisFile(const char* filename,
632  const NameSet* rowNames, const NameSet* colNames, const bool cpxFormat = false) const;
633 
634  /** Write current LP, basis, and parameter settings.
635  * LP is written in MPS format to "\p filename".mps, basis is written in "\p filename".bas, and parameters
636  * are written to "\p filename".set. If \p rowNames and \p colNames are \c NULL, default names are used for
637  * the constraints and variables.
638  */
639  virtual bool writeState(const char* filename,
640  const NameSet* rowNames = NULL, const NameSet* colNames = NULL, const bool cpxFormat = false) const;
641 
642  ///@}
643 
644  /**@name Solving LPs */
645  ///@{
646  /// solve loaded LP.
647  /** Solves the loaded LP by processing the Simplex iteration until
648  * the termination criteria is fullfilled (see #terminate()).
649  * The SPxStatus of the solver will indicate the reason for termination.
650  *
651  * @throw SPxStatusException if either no problem, solver, pricer
652  * or ratiotester loaded or if solve is still running when it shouldn't be
653  */
654  virtual Status solve();
655 
656  /** Identify primal basic variables that have zero reduced costs and
657  * try to pivot them out of the basis to make them tight.
658  * This is supposed to decrease the number of fractional variables
659  * when solving LP relaxations of (mixed) integer programs.
660  * The objective must not be modified during this procedure.
661  */
663 
664  /// set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack)
665  void setSolutionPolishing(SolutionPolish _polishObj)
666  {
667  polishObj = _polishObj;
668  }
669 
670  /// return objective of solution polishing
672  {
673  return polishObj;
674  }
675 
676  /// Status of solution process.
677  Status status() const;
678 
679  /// current objective value.
680  /**@return Objective value of the current solution vector
681  * (see #getPrimalSol()).
682  */
683  virtual R value();
684 
685  // update nonbasic part of the objective value by the given amount
686  /**@return whether nonbasic part of objective is reliable
687  */
688  bool updateNonbasicValue(R objChange);
689 
690  // trigger a recomputation of the nonbasic part of the objective value
692  {
693  m_nonbasicValue = 0.0;
694  m_nonbasicValueUpToDate = false;
695  }
696 
697  /// get solution vector for primal variables.
698  /** This method returns the Status of the basis.
699  * If it is #REGULAR or better,
700  * the primal solution vector of the current basis will be copied
701  * to the argument \p vector. Hence, \p vector must be of dimension
702  * #nCols().
703  *
704  * @throw SPxStatusException if not initialized
705  */
706  virtual Status getPrimalSol(VectorBase<R>& vector) const;
707 
708  /// get VectorBase<R> of slack variables.
709  /** This method returns the Status of the basis.
710  * If it is #REGULAR or better,
711  * the slack variables of the current basis will be copied
712  * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
713  * #nRows().
714  *
715  * @warning Because SPxSolverBase supports range constraints as its
716  * default, slack variables are defined in a nonstandard way:
717  * Let \em x be the current solution vector and \em A the constraint
718  * matrix. Then the vector of slack variables is defined as
719  * \f$s = Ax\f$.
720  *
721  * @throw SPxStatusException if no problem loaded
722  */
723  virtual Status getSlacks(VectorBase<R>& vector) const;
724 
725  /// get current solution VectorBase<R> for dual variables.
726  /** This method returns the Status of the basis.
727  * If it is #REGULAR or better,
728  * the VectorBase<R> of dual variables of the current basis will be copied
729  * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
730  * #nRows().
731  *
732  * @warning Even though mathematically, each range constraint would
733  * account for two dual variables (one for each inequaility), only
734  * #nRows() dual variables are setup via the following
735  * construction: Given a range constraint, there are three possible
736  * situations:
737  * - None of its inequalities is tight: The dual variables
738  * for both are 0. However, when shifting (see below)
739  * occurs, it may be set to a value other than 0, which
740  * models a perturbed objective vector.
741  * - Both of its inequalities are tight: In this case the
742  * range constraint models an equality and we adopt the
743  * standard definition.
744  * - One of its inequalities is tight while the other is not:
745  * In this case only the dual variable for the tight
746  * constraint is given with the standard definition, while
747  * the other constraint is implicitely set to 0.
748  *
749  * @throw SPxStatusException if no problem loaded
750  */
751  virtual Status getDualSol(VectorBase<R>& vector) const;
752 
753  /// get vector of reduced costs.
754  /** This method returns the Status of the basis.
755  * If it is #REGULAR or better,
756  * the vector of reduced costs of the current basis will be copied
757  * to the argument \p vector. Hence, \p vector must be of dimension
758  * #nCols().
759  *
760  * Let \em d denote the vector of dual variables, as defined above,
761  * and \em A the LPs constraint matrix. Then the reduced cost vector
762  * \em r is defined as \f$r^T = c^T - d^TA\f$.
763  *
764  * @throw SPxStatusException if no problem loaded
765  */
766  virtual Status getRedCostSol(VectorBase<R>& vector) const;
767 
768  /// get primal ray in case of unboundedness.
769  /// @throw SPxStatusException if no problem loaded
770  virtual Status getPrimalray(VectorBase<R>& vector) const;
771 
772  /// get dual farkas proof of infeasibility.
773  /// @throw SPxStatusException if no problem loaded
774  virtual Status getDualfarkas(VectorBase<R>& vector) const;
775 
776  /// print display line of flying table
777  virtual void printDisplayLine(const bool force = false, const bool forceHead = false);
778 
779  /// Termination criterion.
780  /** This method is called in each Simplex iteration to determine, if
781  * the algorithm is to terminate. In this case a nonzero value is
782  * returned.
783  *
784  * This method is declared virtual to allow for implementation of
785  * other stopping criteria or using it as callback method within the
786  * Simplex loop, by overriding the method in a derived class.
787  * However, all implementations must terminate with the
788  * statement \c return SPxSolverBase<R>::#terminate(), if no own termination
789  * criteria is encountered.
790  *
791  * Note, that the Simplex loop stopped even when #terminate()
792  * returns 0, if the LP has been solved to optimality (i.e. no
793  * further pricing succeeds and no shift is present).
794  */
795  virtual bool terminate();
796  ///@}
797 
798  //-----------------------------
799  /**@name Control Parameters */
800  ///@{
801  /// values \f$|x| < \epsilon\f$ are considered to be 0.
802  /** if you want another value for epsilon, use
803  * \ref soplex::Param::setEpsilon() "Param::setEpsilon()".
804  */
805  R epsilon() const
806  {
807  return primVec.delta().getEpsilon();
808  }
809  /// feasibility tolerance maintained by ratio test during ENTER algorithm.
810  R entertol() const
811  {
812  assert(m_entertol > 0.0);
813 
814  return m_entertol;
815  }
816  /// feasibility tolerance maintained by ratio test during LEAVE algorithm.
817  R leavetol() const
818  {
819  assert(m_leavetol > 0.0);
820 
821  return m_leavetol;
822  }
823  /// allowed primal feasibility tolerance.
824  R feastol() const
825  {
826  assert(m_entertol > 0.0);
827  assert(m_leavetol > 0.0);
828 
829  return theRep == COLUMN ? m_entertol : m_leavetol;
830  }
831  /// allowed optimality, i.e., dual feasibility tolerance.
832  R opttol() const
833  {
834  assert(m_entertol > 0.0);
835  assert(m_leavetol > 0.0);
836 
837  return theRep == COLUMN ? m_leavetol : m_entertol;
838  }
839  /// guaranteed primal and dual bound violation for optimal solution, returning the maximum of feastol() and opttol(), i.e., the less tight tolerance.
840  R delta() const
841  {
842  assert(m_entertol > 0.0);
843  assert(m_leavetol > 0.0);
844 
845  return m_entertol > m_leavetol ? m_entertol : m_leavetol;
846  }
847  /// set parameter \p feastol.
848  void setFeastol(R d);
849  /// set parameter \p opttol.
850  void setOpttol(R d);
851  /// set parameter \p delta, i.e., set \p feastol and \p opttol to same value.
852  void setDelta(R d);
853  /// set timing type
854  void setTiming(Timer::TYPE ttype)
855  {
856  theTime = TimerFactory::switchTimer(theTime, ttype);
857  multTimeSparse = TimerFactory::switchTimer(multTimeSparse, ttype);
858  multTimeFull = TimerFactory::switchTimer(multTimeFull, ttype);
859  multTimeColwise = TimerFactory::switchTimer(multTimeColwise, ttype);
860  multTimeUnsetup = TimerFactory::switchTimer(multTimeUnsetup, ttype);
861  timerType = ttype;
862  }
863 
864  /// set timing type
866  {
867  assert(timerType == theTime->type());
868  assert(timerType == multTimeSparse->type());
869  assert(timerType == multTimeFull->type());
870  assert(timerType == multTimeColwise->type());
871  assert(timerType == multTimeUnsetup->type());
872  return timerType;
873  }
874 
875  /// set display frequency
876  void setDisplayFreq(int freq)
877  {
878  displayFreq = freq;
879  }
880 
881  /// get display frequency
882  int getDisplayFreq()
883  {
884  return displayFreq;
885  }
886 
887  /// print basis metric within the usual output
888  void setMetricInformation(int type)
889  {
891  }
892 
893  // enable sparse pricing when viols < fac * dim()
894  void setSparsePricingFactor(R fac)
895  {
896  sparsePricingFactor = fac;
897  }
898  /// enable or disable hyper sparse pricing
899  void hyperPricing(bool h);
900 
901  /** SPxSolverBase considers a Simplex step as degenerate if the
902  * steplength does not exceed #epsilon(). Cycling occurs if only
903  * degenerate steps are taken. To prevent this situation, SPxSolverBase
904  * perturbs the problem such that nondegenerate steps are ensured.
905  *
906  * maxCycle() controls how agressive such perturbation is
907  * performed, since no more than maxCycle() degenerate steps are
908  * accepted before perturbing the LP. The current number of consecutive
909  * degenerate steps is counted by numCycle().
910  */
911  /// maximum number of degenerate simplex steps before we detect cycling.
912  int maxCycle() const
913  {
914  return m_maxCycle;
915  }
916  /// actual number of degenerate simplex steps encountered so far.
917  int numCycle() const
918  {
919  return m_numCycle;
920  }
921 
922  /// perturb entire problem or only the bounds relevant to the current pivot
923  void useFullPerturbation(bool full)
924  {
925  fullPerturbation = full;
926  }
927 
928  virtual R getBasisMetric(int type)
929  {
930  return basis().getMatrixMetric(type);
931  }
932 
933  ///@}
934 
935 private:
936 
937  //-----------------------------
938  /**@name Private helpers */
939  ///@{
940  ///
941  void localAddRows(int start);
942  ///
943  void localAddCols(int start);
944  ///
945  void setPrimal(VectorBase<R>& p_vector);
946  ///
947  void setSlacks(VectorBase<R>& p_vector);
948  ///
949  void setDual(VectorBase<R>& p_vector);
950  ///
951  void setRedCost(VectorBase<R>& p_vector);
952  ///@}
953 
954 protected:
955 
956  //-----------------------------
957  /**@name Protected helpers */
958  ///@{
959  ///
960  virtual void addedRows(int n);
961  ///
962  virtual void addedCols(int n);
963  ///
964  virtual void doRemoveRow(int i);
965  ///
966  virtual void doRemoveRows(int perm[]);
967  ///
968  virtual void doRemoveCol(int i);
969  ///
970  virtual void doRemoveCols(int perm[]);
971  ///@}
972 
973 public:
974 
975  //-----------------------------
976  /**@name Modification */
977  /// \p scale determines whether the new data needs to be scaled according to the existing LP (persistent scaling)
978  ///@{
979  ///
980  virtual void changeObj(const VectorBase<R>& newObj, bool scale = false);
981  ///
982  virtual void changeObj(int i, const R& newVal, bool scale = false);
983  ///
984  using SPxLPBase<R>::changeObj; /// overloading a virtual function
985  virtual void changeObj(SPxColId p_id, const R& p_newVal, bool scale = false)
986  {
987  changeObj(this->number(p_id), p_newVal, scale);
988  }
989  ///
990  virtual void changeMaxObj(const VectorBase<R>& newObj, bool scale = false);
991  ///
992  virtual void changeMaxObj(int i, const R& newVal, bool scale = false);
993  ///
994  using SPxLPBase<R>::changeMaxObj; /// overloading a virtual function
995  virtual void changeMaxObj(SPxColId p_id, const R& p_newVal, bool scale = false)
996  {
997  changeMaxObj(this->number(p_id), p_newVal, scale);
998  }
999  ///
1000  virtual void changeRowObj(const VectorBase<R>& newObj, bool scale = false);
1001  ///
1002  virtual void changeRowObj(int i, const R& newVal, bool scale = false);
1003  ///
1005  virtual void changeRowObj(SPxRowId p_id, const R& p_newVal, bool scale = false)
1006  {
1007  changeRowObj(this->number(p_id), p_newVal);
1008  }
1009  ///
1010  virtual void clearRowObjs()
1011  {
1013  unInit();
1014  }
1015  ///
1016  virtual void changeLowerStatus(int i, R newLower, R oldLower = 0.0);
1017  ///
1018  virtual void changeLower(const VectorBase<R>& newLower, bool scale = false);
1019  ///
1020  virtual void changeLower(int i, const R& newLower, bool scale = false);
1021  ///
1023  virtual void changeLower(SPxColId p_id, const R& p_newLower, bool scale = false)
1024  {
1025  changeLower(this->number(p_id), p_newLower, scale);
1026  }
1027  ///
1028  virtual void changeUpperStatus(int i, R newUpper, R oldLower = 0.0);
1029  ///
1030  virtual void changeUpper(const VectorBase<R>& newUpper, bool scale = false);
1031  ///
1032  virtual void changeUpper(int i, const R& newUpper, bool scale = false);
1033  ///
1034  using SPxLPBase<R>::changeUpper; /// overloading virtual function
1035  virtual void changeUpper(SPxColId p_id, const R& p_newUpper, bool scale = false)
1036  {
1037  changeUpper(this->number(p_id), p_newUpper, scale);
1038  }
1039  ///
1040  virtual void changeBounds(const VectorBase<R>& newLower, const VectorBase<R>& newUpper,
1041  bool scale = false);
1042  ///
1043  virtual void changeBounds(int i, const R& newLower, const R& newUpper, bool scale = false);
1044  ///
1046  virtual void changeBounds(SPxColId p_id, const R& p_newLower, const R& p_newUpper,
1047  bool scale = false)
1048  {
1049  changeBounds(this->number(p_id), p_newLower, p_newUpper, scale);
1050  }
1051  ///
1052  virtual void changeLhsStatus(int i, R newLhs, R oldLhs = 0.0);
1053  ///
1054  virtual void changeLhs(const VectorBase<R>& newLhs, bool scale = false);
1055  ///
1056  virtual void changeLhs(int i, const R& newLhs, bool scale = false);
1057  ///
1059  virtual void changeLhs(SPxRowId p_id, const R& p_newLhs, bool scale = false)
1060  {
1061  changeLhs(this->number(p_id), p_newLhs, scale);
1062  }
1063  ///
1064  virtual void changeRhsStatus(int i, R newRhs, R oldRhs = 0.0);
1065  ///
1066  virtual void changeRhs(const VectorBase<R>& newRhs, bool scale = false);
1067  ///
1068  virtual void changeRhs(int i, const R& newRhs, bool scale = false);
1069  ///
1071  virtual void changeRhs(SPxRowId p_id, const R& p_newRhs, bool scale = false)
1072  {
1073  changeRhs(this->number(p_id), p_newRhs, scale);
1074  }
1075  ///
1076  virtual void changeRange(const VectorBase<R>& newLhs, const VectorBase<R>& newRhs,
1077  bool scale = false);
1078  ///
1079  virtual void changeRange(int i, const R& newLhs, const R& newRhs, bool scale = false);
1080  ///
1082  virtual void changeRange(SPxRowId p_id, const R& p_newLhs, const R& p_newRhs, bool scale = false)
1083  {
1084  changeRange(this->number(p_id), p_newLhs, p_newRhs, scale);
1085  }
1086  ///
1087  virtual void changeRow(int i, const LPRowBase<R>& newRow, bool scale = false);
1088  ///
1090  virtual void changeRow(SPxRowId p_id, const LPRowBase<R>& p_newRow, bool scale = false)
1091  {
1092  changeRow(this->number(p_id), p_newRow, scale);
1093  }
1094  ///
1095  virtual void changeCol(int i, const LPColBase<R>& newCol, bool scale = false);
1096  ///
1098  virtual void changeCol(SPxColId p_id, const LPColBase<R>& p_newCol, bool scale = false)
1099  {
1100  changeCol(this->number(p_id), p_newCol, scale);
1101  }
1102  ///
1103  virtual void changeElement(int i, int j, const R& val, bool scale = false);
1104  ///
1106  virtual void changeElement(SPxRowId rid, SPxColId cid, const R& val, bool scale = false)
1107  {
1108  changeElement(this->number(rid), this->number(cid), val, scale);
1109  }
1110  ///
1111  virtual void changeSense(typename SPxLPBase<R>::SPxSense sns);
1112  ///@}
1113 
1114  //------------------------------------
1115  /**@name Dimension and codimension */
1116  ///@{
1117  /// dimension of basis matrix.
1118  int dim() const
1119  {
1120  return thecovectors->num();
1121  }
1122  /// codimension.
1123  int coDim() const
1124  {
1125  return thevectors->num();
1126  }
1127  ///@}
1128 
1129  //------------------------------------
1130  /**@name Variables and Covariables
1131  * Class SPxLPBase<R> introduces \ref soplex::SPxId "SPxIds" to identify
1132  * row or column data of an LP. SPxSolverBase uses this concept to
1133  * access data with respect to the chosen representation.
1134  */
1135  ///@{
1136  /// id of \p i 'th vector.
1137  /** The \p i 'th Id is the \p i 'th SPxRowId for a rowwise and the
1138  * \p i 'th SPxColId for a columnwise basis represenation. Hence,
1139  * 0 <= i < #coDim().
1140  */
1141  SPxId id(int i) const
1142  {
1143  if(rep() == ROW)
1144  {
1145  SPxRowId rid = SPxLPBase<R>::rId(i);
1146  return SPxId(rid);
1147  }
1148  else
1149  {
1150  SPxColId cid = SPxLPBase<R>::cId(i);
1151  return SPxId(cid);
1152  }
1153  }
1154 
1155  /// id of \p i 'th covector.
1156  /** The \p i 'th #coId() is the \p i 'th SPxColId for a rowwise and the
1157  * \p i 'th SPxRowId for a columnwise basis represenation. Hence,
1158  * 0 <= i < #dim().
1159  */
1160  SPxId coId(int i) const
1161  {
1162  if(rep() == ROW)
1163  {
1164  SPxColId cid = SPxLPBase<R>::cId(i);
1165  return SPxId(cid);
1166  }
1167  else
1168  {
1169  SPxRowId rid = SPxLPBase<R>::rId(i);
1170  return SPxId(rid);
1171  }
1172  }
1173 
1174  /// Is \p p_id an SPxId ?
1175  /** This method returns wheather or not \p p_id identifies a vector
1176  * with respect to the chosen representation.
1177  */
1178  bool isId(const SPxId& p_id) const
1179  {
1180  return p_id.info * theRep > 0;
1181  }
1182 
1183  /// Is \p p_id a CoId.
1184  /** This method returns wheather or not \p p_id identifies a coVector
1185  * with respect to the chosen representation.
1186  */
1187  bool isCoId(const SPxId& p_id) const
1188  {
1189  return p_id.info * theRep < 0;
1190  }
1191  ///@}
1192 
1193  //------------------------------------
1194  /**@name Vectors and Covectors */
1195  ///@{
1196  /// \p i 'th vector.
1197  /**@return a reference to the \p i 'th, 0 <= i < #coDim(), vector of
1198  * the loaded LP (with respect to the chosen representation).
1199  */
1200  const SVectorBase<R>& vector(int i) const
1201  {
1202  return (*thevectors)[i];
1203  }
1204 
1205  ///
1206  const SVectorBase<R>& vector(const SPxRowId& rid) const
1207  {
1208  assert(rid.isValid());
1209  return (rep() == ROW)
1210  ? (*thevectors)[this->number(rid)]
1211  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(rid)]);
1212  }
1213  ///
1214  const SVectorBase<R>& vector(const SPxColId& cid) const
1215  {
1216  assert(cid.isValid());
1217  return (rep() == COLUMN)
1218  ? (*thevectors)[this->number(cid)]
1219  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1220  }
1221 
1222  /// VectorBase<R> associated to \p p_id.
1223  /**@return Returns a reference to the VectorBase<R> of the loaded LP corresponding
1224  * to \p id (with respect to the chosen representation). If \p p_id is
1225  * an id, a vector of the constraint matrix is returned, otherwise
1226  * the corresponding unit vector (of the slack variable or bound
1227  * inequality) is returned.
1228  * @todo The implementation does not exactly look like it will do
1229  * what is promised in the describtion.
1230  */
1231  const SVectorBase<R>& vector(const SPxId& p_id) const
1232  {
1233  assert(p_id.isValid());
1234 
1235  return p_id.isSPxRowId()
1236  ? vector(SPxRowId(p_id))
1237  : vector(SPxColId(p_id));
1238  }
1239 
1240  /// \p i 'th covector of LP.
1241  /**@return a reference to the \p i 'th, 0 <= i < #dim(), covector of
1242  * the loaded LP (with respect to the chosen representation).
1243  */
1244  const SVectorBase<R>& coVector(int i) const
1245  {
1246  return (*thecovectors)[i];
1247  }
1248  ///
1249  const SVectorBase<R>& coVector(const SPxRowId& rid) const
1250  {
1251  assert(rid.isValid());
1252  return (rep() == COLUMN)
1253  ? (*thecovectors)[this->number(rid)]
1254  : static_cast<const SVector&>(unitVecs[this->number(rid)]);
1255  }
1256  ///
1257  const SVectorBase<R>& coVector(const SPxColId& cid) const
1258  {
1259  assert(cid.isValid());
1260  return (rep() == ROW)
1261  ? (*thecovectors)[this->number(cid)]
1262  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1263  }
1264  /// coVector associated to \p p_id.
1265  /**@return a reference to the covector of the loaded LP
1266  * corresponding to \p p_id (with respect to the chosen
1267  * representation). If \p p_id is a coid, a covector of the constraint
1268  * matrix is returned, otherwise the corresponding unit vector is
1269  * returned.
1270  */
1271  const SVectorBase<R>& coVector(const SPxId& p_id) const
1272  {
1273  assert(p_id.isValid());
1274  return p_id.isSPxRowId()
1275  ? coVector(SPxRowId(p_id))
1276  : coVector(SPxColId(p_id));
1277  }
1278  /// return \p i 'th unit vector.
1279  const SVectorBase<R>& unitVector(int i) const
1280  {
1281  return unitVecs[i];
1282  }
1283  ///@}
1284 
1285  //------------------------------------
1286  /**@name Variable status
1287  * The Simplex basis assigns a \ref soplex::SPxBasisBase<R>::Desc::Status
1288  * "Status" to each variable and covariable. Depending on the
1289  * representation, the status indicates that the corresponding
1290  * vector is in the basis matrix or not.
1291  */
1292  ///@{
1293  /// Status of \p i 'th variable.
1294  typename SPxBasisBase<R>::Desc::Status varStatus(int i) const
1295  {
1296  return this->desc().status(i);
1297  }
1298 
1299  /// Status of \p i 'th covariable.
1300  typename SPxBasisBase<R>::Desc::Status covarStatus(int i) const
1301  {
1302  return this->desc().coStatus(i);
1303  }
1304 
1305  /// does \p stat describe a basic index ?
1306  bool isBasic(typename SPxBasisBase<R>::Desc::Status stat) const
1307  {
1308  return (stat * rep() > 0);
1309  }
1310 
1311  /// is the \p p_id 'th vector basic ?
1312  bool isBasic(const SPxId& p_id) const
1313  {
1314  assert(p_id.isValid());
1315  return p_id.isSPxRowId()
1316  ? isBasic(SPxRowId(p_id))
1317  : isBasic(SPxColId(p_id));
1318  }
1319 
1320  /// is the \p rid 'th vector basic ?
1321  bool isBasic(const SPxRowId& rid) const
1322  {
1323  return isBasic(this->desc().rowStatus(this->number(rid)));
1324  }
1325 
1326  /// is the \p cid 'th vector basic ?
1327  bool isBasic(const SPxColId& cid) const
1328  {
1329  return isBasic(this->desc().colStatus(this->number(cid)));
1330  }
1331 
1332  /// is the \p i 'th row vector basic ?
1333  bool isRowBasic(int i) const
1334  {
1335  return isBasic(this->desc().rowStatus(i));
1336  }
1337 
1338  /// is the \p i 'th column vector basic ?
1339  bool isColBasic(int i) const
1340  {
1341  return isBasic(this->desc().colStatus(i));
1342  }
1343 
1344  /// is the \p i 'th vector basic ?
1345  bool isBasic(int i) const
1346  {
1347  return isBasic(this->desc().status(i));
1348  }
1349 
1350  /// is the \p i 'th covector basic ?
1351  bool isCoBasic(int i) const
1352  {
1353  return isBasic(this->desc().coStatus(i));
1354  }
1355  ///@}
1356 
1357  /// feasibility vector.
1358  /** This method return the \em feasibility vector. If it satisfies its
1359  * bound, the basis is called feasible (independently of the chosen
1360  * representation). The feasibility vector has dimension #dim().
1361  *
1362  * For the entering Simplex, #fVec is kept within its bounds. In
1363  * contrast to this, the pricing of the leaving Simplex selects an
1364  * element of #fVec, that violates its bounds.
1365  */
1366  UpdateVector<R>& fVec() const
1367  {
1368  return *theFvec;
1369  }
1370  /// right-hand side vector for \ref soplex::SPxSolverBase<R>::fVec "fVec"
1371  /** The feasibility vector is computed by solving a linear system with the
1372  * basis matrix. The right-hand side vector of this system is referred
1373  * to as \em feasibility, \em right-hand \em side \em vector #fRhs().
1374  *
1375  * For a row basis, #fRhs() is the objective vector (ignoring shifts).
1376  * For a column basis, it is the sum of all nonbasic vectors scaled by
1377  * the factor of their bound.
1378  */
1379  const VectorBase<R>& fRhs() const
1380  {
1381  return *theFrhs;
1382  }
1383  /// upper bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1384  const VectorBase<R>& ubBound() const
1385  {
1386  return theUBbound;
1387  }
1388  /// upper bound for #fVec, writable.
1389  /** This method returns the upper bound for the feasibility vector.
1390  * It may only be called for the #ENTER%ing Simplex.
1391  *
1392  * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1393  * maintained to fullfill its bounds. As #fVec itself, also its
1394  * bounds depend on the chosen representation. Further, they may
1395  * need to be shifted (see below).
1396  */
1398  {
1399  return theUBbound;
1400  }
1401  /// lower bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1402  const VectorBase<R>& lbBound() const
1403  {
1404  return theLBbound;
1405  }
1406  /// lower bound for #fVec, writable.
1407  /** This method returns the lower bound for the feasibility vector.
1408  * It may only be called for the #ENTER%ing Simplex.
1409  *
1410  * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1411  * maintained to fullfill its bounds. As #fVec itself, also its
1412  * bound depend on the chosen representation. Further, they may
1413  * need to be shifted (see below).
1414  */
1416  {
1417  return theLBbound;
1418  }
1419 
1420  /// Violations of \ref soplex::SPxSolverBase<R>::fVec "fVec"
1421  /** For the leaving Simplex algorithm, pricing involves selecting a
1422  * variable from #fVec that violates its bounds that is to leave
1423  * the basis. When a SPxPricer is called to select such a
1424  * leaving variable, #fTest() contains the vector of violations:
1425  * For #fTest()[i] < 0, the \c i 'th basic variable violates one of
1426  * its bounds by the given value. Otherwise no bound is violated.
1427  */
1428  const VectorBase<R>& fTest() const
1429  {
1430  assert(type() == LEAVE);
1431  return theCoTest;
1432  }
1433 
1434  /// copricing vector.
1435  /** The copricing vector #coPvec along with the pricing vector
1436  * #pVec are used for pricing in the #ENTER%ing Simplex algorithm,
1437  * i.e. one variable is selected, that violates its bounds. In
1438  * contrast to this, the #LEAVE%ing Simplex algorithm keeps both
1439  * vectors within their bounds.
1440  */
1441  UpdateVector<R>& coPvec() const
1442  {
1443  return *theCoPvec;
1444  }
1445 
1446  /// Right-hand side vector for \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1447  /** The vector #coPvec is computed by solving a linear system with the
1448  * basis matrix and #coPrhs as the right-hand side vector. For
1449  * column basis representation, #coPrhs is build up of the
1450  * objective vector elements of all basic variables. For a row
1451  * basis, it consists of the tight bounds of all basic
1452  * constraints.
1453  */
1454  const VectorBase<R>& coPrhs() const
1455  {
1456  return *theCoPrhs;
1457  }
1458 
1459  ///
1460  const VectorBase<R>& ucBound() const
1461  {
1462  assert(theType == LEAVE);
1463  return *theCoUbound;
1464  }
1465  /// upper bound for #coPvec.
1466  /** This method returns the upper bound for #coPvec. It may only be
1467  * called for the leaving Simplex algorithm.
1468  *
1469  * For the leaving Simplex algorithms #coPvec is maintained to
1470  * fullfill its bounds. As #coPvec itself, also its bound depend
1471  * on the chosen representation. Further, they may need to be
1472  * shifted (see below).
1473  */
1475  {
1476  assert(theType == LEAVE);
1477  return *theCoUbound;
1478  }
1479 
1480  ///
1481  const VectorBase<R>& lcBound() const
1482  {
1483  assert(theType == LEAVE);
1484  return *theCoLbound;
1485  }
1486  /// lower bound for #coPvec.
1487  /** This method returns the lower bound for #coPvec. It may only be
1488  * called for the leaving Simplex algorithm.
1489  *
1490  * For the leaving Simplex algorithms #coPvec is maintained to
1491  * fullfill its bounds. As #coPvec itself, also its bound depend
1492  * on the chosen representation. Further, they may need to be
1493  * shifted (see below).
1494  */
1496  {
1497  assert(theType == LEAVE);
1498  return *theCoLbound;
1499  }
1500 
1501  /// violations of \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1502  /** In entering Simplex pricing selects checks vectors #coPvec()
1503  * and #pVec() for violation of its bounds. #coTest() contains
1504  * the violations for #coPvec() which are indicated by a negative
1505  * value. That is, if #coTest()[i] < 0, the \p i 'th element of #coPvec()
1506  * is violated by -#coTest()[i].
1507  */
1508  const VectorBase<R>& coTest() const
1509  {
1510  assert(type() == ENTER);
1511  return theCoTest;
1512  }
1513  /// pricing vector.
1514  /** The pricing vector #pVec is the product of #coPvec with the
1515  * constraint matrix. As #coPvec, also #pVec is maintained within
1516  * its bound for the leaving Simplex algorithm, while the bounds
1517  * are tested for the entering Simplex. #pVec is of dimension
1518  * #coDim(). Vector #pVec() is only up to date for #LEAVE%ing
1519  * Simplex or #FULL pricing in #ENTER%ing Simplex.
1520  */
1521  UpdateVector<R>& pVec() const
1522  {
1523  return *thePvec;
1524  }
1525  ///
1526  const VectorBase<R>& upBound() const
1527  {
1528  assert(theType == LEAVE);
1529  return *theUbound;
1530  }
1531  /// upper bound for #pVec.
1532  /** This method returns the upper bound for #pVec. It may only be
1533  * called for the leaving Simplex algorithm.
1534  *
1535  * For the leaving Simplex algorithms #pVec is maintained to
1536  * fullfill its bounds. As #pVec itself, also its bound depend
1537  * on the chosen representation. Further, they may need to be
1538  * shifted (see below).
1539  */
1541  {
1542  assert(theType == LEAVE);
1543  return *theUbound;
1544  }
1545 
1546  ///
1547  const VectorBase<R>& lpBound() const
1548  {
1549  assert(theType == LEAVE);
1550  return *theLbound;
1551  }
1552  /// lower bound for #pVec.
1553  /** This method returns the lower bound for #pVec. It may only be
1554  * called for the leaving Simplex algorithm.
1555  *
1556  * For the leaving Simplex algorithms #pVec is maintained to
1557  * fullfill its bounds. As #pVec itself, also its bound depend
1558  * on the chosen representation. Further, they may need to be
1559  * shifted (see below).
1560  */
1562  {
1563  assert(theType == LEAVE);
1564  return *theLbound;
1565  }
1566 
1567  /// Violations of \ref soplex::SPxSolverBase<R>::pVec "pVec".
1568  /** In entering Simplex pricing selects checks vectors #coPvec()
1569  * and #pVec() for violation of its bounds. Vector #test()
1570  * contains the violations for #pVec(), i.e., if #test()[i] < 0,
1571  * the i'th element of #pVec() is violated by #test()[i].
1572  * Vector #test() is only up to date for #FULL pricing.
1573  */
1574  const VectorBase<R>& test() const
1575  {
1576  assert(type() == ENTER);
1577  return theTest;
1578  }
1579 
1580  /// compute and return \ref soplex::SPxSolverBase<R>::pVec() "pVec()"[i].
1581  R computePvec(int i);
1582  /// compute entire \ref soplex::SPxSolverBase<R>::pVec() "pVec()".
1583  void computePvec();
1584  /// compute and return \ref soplex::SPxSolverBase<R>::test() "test()"[i] in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1585  R computeTest(int i);
1586  /// compute test VectorBase<R> in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1587  void computeTest();
1588 
1589  //------------------------------------
1590  /**@name Shifting
1591  * The task of the ratio test (implemented in SPxRatioTester classes)
1592  * is to select a variable for the basis update, such that the basis
1593  * remains priced (i.e. both, the pricing and copricing vectors satisfy
1594  * their bounds) or feasible (i.e. the feasibility vector satisfies its
1595  * bounds). However, this can lead to numerically instable basis matrices
1596  * or -- after accumulation of various errors -- even to a singular basis
1597  * matrix.
1598  *
1599  * The key to overcome this problem is to allow the basis to become "a
1600  * bit" infeasible or unpriced, in order provide a better choice for the
1601  * ratio test to select a stable variable. This is equivalent to enlarging
1602  * the bounds by a small amount. This is referred to as \em shifting.
1603  *
1604  * These methods serve for shifting feasibility bounds, either in order
1605  * to maintain numerical stability or initially for computation of
1606  * phase 1. The sum of all shifts applied to any bound is stored in
1607  * \ref soplex::SPxSolverBase<R>::theShift "theShift".
1608  *
1609  * The following methods are used to shift individual bounds. They are
1610  * mainly intended for stable implenentations of SPxRatioTester.
1611  */
1612  ///@{
1613  /// Perform initial shifting to optain an feasible or pricable basis.
1614  void shiftFvec();
1615  /// Perform initial shifting to optain an feasible or pricable basis.
1616  void shiftPvec();
1617 
1618  /// shift \p i 'th \ref soplex::SPxSolver::ubBound "ubBound" to \p to.
1619  void shiftUBbound(int i, R to)
1620  {
1621  assert(theType == ENTER);
1622  // use maximum to not count tightened bounds in case of equality shifts
1623  theShift += MAXIMUM(to - theUBbound[i], 0.0);
1624  theUBbound[i] = to;
1625  }
1626  /// shift \p i 'th \ref soplex::SPxSolver::lbBound "lbBound" to \p to.
1627  void shiftLBbound(int i, R to)
1628  {
1629  assert(theType == ENTER);
1630  // use maximum to not count tightened bounds in case of equality shifts
1631  theShift += MAXIMUM(theLBbound[i] - to, 0.0);
1632  theLBbound[i] = to;
1633  }
1634  /// shift \p i 'th \ref soplex::SPxSolver::upBound "upBound" to \p to.
1635  void shiftUPbound(int i, R to)
1636  {
1637  assert(theType == LEAVE);
1638  // use maximum to not count tightened bounds in case of equality shifts
1639  theShift += MAXIMUM(to - (*theUbound)[i], 0.0);
1640  (*theUbound)[i] = to;
1641  }
1642  /// shift \p i 'th \ref soplex::SPxSolver::lpBound "lpBound" to \p to.
1643  void shiftLPbound(int i, R to)
1644  {
1645  assert(theType == LEAVE);
1646  // use maximum to not count tightened bounds in case of equality shifts
1647  theShift += MAXIMUM((*theLbound)[i] - to, 0.0);
1648  (*theLbound)[i] = to;
1649  }
1650  /// shift \p i 'th \ref soplex::SPxSolver::ucBound "ucBound" to \p to.
1651  void shiftUCbound(int i, R to)
1652  {
1653  assert(theType == LEAVE);
1654  // use maximum to not count tightened bounds in case of equality shifts
1655  theShift += MAXIMUM(to - (*theCoUbound)[i], 0.0);
1656  (*theCoUbound)[i] = to;
1657  }
1658  /// shift \p i 'th \ref soplex::SPxSolver::lcBound "lcBound" to \p to.
1659  void shiftLCbound(int i, R to)
1660  {
1661  assert(theType == LEAVE);
1662  // use maximum to not count tightened bounds in case of equality shifts
1663  theShift += MAXIMUM((*theCoLbound)[i] - to, 0.0);
1664  (*theCoLbound)[i] = to;
1665  }
1666  ///
1667  void testBounds() const;
1668 
1669  /// total current shift amount.
1670  virtual R shift() const
1671  {
1672  return theShift;
1673  }
1674  /// remove shift as much as possible.
1675  virtual void unShift(void);
1676 
1677  /// get violation of constraints.
1678  virtual void qualConstraintViolation(R& maxviol, R& sumviol) const;
1679  /// get violations of bounds.
1680  virtual void qualBoundViolation(R& maxviol, R& sumviol) const;
1681  /// get the residuum |Ax-b|.
1682  virtual void qualSlackViolation(R& maxviol, R& sumviol) const;
1683  /// get violation of optimality criterion.
1684  virtual void qualRedCostViolation(R& maxviol, R& sumviol) const;
1685  ///@}
1686 
1687 private:
1688 
1689  //------------------------------------
1690  /**@name Perturbation */
1691  ///@{
1692  ///
1693  void perturbMin(
1694  const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1695  int start = 0, int incr = 1);
1696  ///
1697  void perturbMax(
1698  const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1699  int start = 0, int incr = 1);
1700  ///
1701  R perturbMin(const UpdateVector<R>& uvec,
1702  VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1703  const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1704  ///
1705  R perturbMax(const UpdateVector<R>& uvec,
1706  VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1707  const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1708  ///@}
1709 
1710  //------------------------------------
1711  /**@name The Simplex Loop
1712  * We now present a set of methods that may be usefull when implementing
1713  * own SPxPricer or SPxRatioTester classes. Here is, how
1714  * SPxSolverBase will call methods from its loaded SPxPricer and
1715  * SPxRatioTester.
1716  *
1717  * For the entering Simplex:
1718  * -# \ref soplex::SPxPricer::selectEnter() "SPxPricer::selectEnter()"
1719  * -# \ref soplex::SPxRatioTester::selectLeave() "SPxRatioTester::selectLeave()"
1720  * -# \ref soplex::SPxPricer::entered4() "SPxPricer::entered4()"
1721  *
1722  * For the leaving Simplex:
1723  * -# \ref soplex::SPxPricer::selectLeave() "SPxPricer::selectLeave()"
1724  * -# \ref soplex::SPxRatioTester::selectEnter() "SPxRatioTester::selectEnter()"
1725  * -# \ref soplex::SPxPricer::left4() "SPxPricer::left4()"
1726  */
1727  ///@{
1728 public:
1729  /// Setup vectors to be solved within Simplex loop.
1730  /** Load vector \p y to be #solve%d with the basis matrix during the
1731  * #LEAVE Simplex. The system will be solved after #SPxSolverBase%'s call
1732  * to SPxRatioTester. The system will be solved along with
1733  * another system. Solving two linear system at a time has
1734  * performance advantages over solving the two linear systems
1735  * seperately.
1736  */
1737  void setup4solve(SSVectorBase<R>* p_y, SSVectorBase<R>* p_rhs)
1738  {
1739  assert(type() == LEAVE);
1740  solveVector2 = p_y;
1741  solveVector2rhs = p_rhs;
1742  }
1743  /// Setup vectors to be solved within Simplex loop.
1744  /** Load a second additional vector \p y2 to be #solve%d with the
1745  * basis matrix during the #LEAVE Simplex. The system will be
1746  * solved after #SPxSolverBase%'s call to SPxRatioTester.
1747  * The system will be solved along with at least one
1748  * other system. Solving several linear system at a time has
1749  * performance advantages over solving them seperately.
1750  */
1751  void setup4solve2(SSVectorBase<R>* p_y2, SSVectorBase<R>* p_rhs2)
1752  {
1753  assert(type() == LEAVE);
1754  solveVector3 = p_y2;
1755  solveVector3rhs = p_rhs2;
1756  }
1757  /// Setup vectors to be cosolved within Simplex loop.
1758  /** Load vector \p y to be #coSolve%d with the basis matrix during
1759  * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1760  * call to SPxRatioTester. The system will be solved along
1761  * with another system. Solving two linear system at a time has
1762  * performance advantages over solving the two linear systems
1763  * seperately.
1764  */
1765  void setup4coSolve(SSVectorBase<R>* p_y, SSVectorBase<R>* p_rhs)
1766  {
1767  assert(type() == ENTER);
1768  coSolveVector2 = p_y;
1769  coSolveVector2rhs = p_rhs;
1770  }
1771  /// Setup vectors to be cosolved within Simplex loop.
1772  /** Load a second vector \p z to be #coSolve%d with the basis matrix during
1773  * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1774  * call to SPxRatioTester. The system will be solved along
1775  * with two other systems.
1776  */
1778  {
1779  assert(type() == ENTER);
1780  coSolveVector3 = p_z;
1781  coSolveVector3rhs = p_rhs;
1782  }
1783 
1784  /// maximal infeasibility of basis
1785  /** This method is called before concluding optimality. Since it is
1786  * possible that some stable implementation of class
1787  * SPxRatioTester yielded a slightly infeasible (or unpriced)
1788  * basis, this must be checked before terminating with an optimal
1789  * solution.
1790  */
1791  virtual R maxInfeas() const;
1792 
1793  /// check for violations above tol and immediately return false w/o checking the remaining values
1794  /** This method is useful for verifying whether an objective limit can be used as termination criterion
1795  */
1796  virtual bool noViols(R tol) const;
1797 
1798  /// Return current basis.
1799  /**@note The basis can be used to solve linear systems or use
1800  * any other of its (const) methods. It is, however, encuraged
1801  * to use methods #setup4solve() and #setup4coSolve() for solving
1802  * systems, since this is likely to have perfomance advantages.
1803  */
1804  const SPxBasisBase<R>& basis() const
1805  {
1806  return *this;
1807  }
1808  ///
1810  {
1811  return *this;
1812  }
1813  /// return loaded SPxPricer.
1814  const SPxPricer<R>* pricer() const
1815  {
1816  return thepricer;
1817  }
1818  /// return loaded SLinSolver.
1819  const SLinSolver<R>* slinSolver() const
1820  {
1822  }
1823  /// return loaded SPxRatioTester.
1824  const SPxRatioTester<R>* ratiotester() const
1825  {
1827  }
1828 
1829  /// Factorize basis matrix.
1830  /// @throw SPxStatusException if loaded matrix is singular
1831  virtual void factorize();
1832 
1833 private:
1834 
1835  /** let index \p i leave the basis and manage entering of another one.
1836  @returns \c false if LP is unbounded/infeasible. */
1837  bool leave(int i, bool polish = false);
1838  /** let id enter the basis and manage leaving of another one.
1839  @returns \c false if LP is unbounded/infeasible. */
1840  bool enter(SPxId& id, bool polish = false);
1841 
1842  /// test coVector \p i with status \p stat.
1843  R coTest(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1844  /// compute coTest vector.
1845  void computeCoTest();
1846  /// recompute coTest vector.
1847  void updateCoTest();
1848 
1849  /// test VectorBase<R> \p i with status \p stat.
1850  R test(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1851  /// recompute test vector.
1852  void updateTest();
1853 
1854  /// compute basis feasibility test vector.
1855  void computeFtest();
1856  /// update basis feasibility test vector.
1857  void updateFtest();
1858 
1859  ///@}
1860 
1861  //------------------------------------
1862  /**@name Parallelization
1863  * In this section we present the methods, that are provided in order to
1864  * allow a parallel version to be implemented as a derived class, thereby
1865  * inheriting most of the code of SPxSolverBase.
1866  *
1867  * @par Initialization
1868  * These methods are used to setup all the vectors used in the Simplex
1869  * loop, that where described in the previous sectios.
1870  */
1871  ///@{
1872 public:
1873  /// intialize data structures.
1874  /** If SPxSolverBase is not \ref isInitialized() "initialized", the method
1875  * #solve() calls #init() to setup all vectors and internal data structures.
1876  * Most of the other methods within this section are called by #init().
1877  *
1878  * Derived classes should add the initialization of additional
1879  * data structures by overriding this method. Don't forget,
1880  * however, to call SPxSolverBase<R>::init().
1881  */
1882  virtual void init();
1883 
1884 protected:
1885 
1886  /// has the internal data been initialized?
1887  /** As long as an instance of SPxSolverBase is not initialized, no member
1888  * contains setup data. Initialization is performed via method
1889  * #init(). Afterwards all data structures are kept up to date (even
1890  * for all manipulation methods), until #unInit() is called. However,
1891  * some manipulation methods call #unInit() themselfs.
1892  */
1893  bool isInitialized() const
1894  {
1895  return initialized;
1896  }
1897 
1898  /// resets clock average statistics
1899  void resetClockStats();
1900 
1901  /// uninitialize data structures.
1902  virtual void unInit()
1903  {
1904  initialized = false;
1905  }
1906  /// setup all vecs fresh
1907  virtual void reinitializeVecs();
1908  /// reset dimensions of vectors according to loaded LP.
1909  virtual void reDim();
1910  /// compute feasibility vector from scratch.
1911  void computeFrhs();
1912  ///
1913  virtual void computeFrhsXtra();
1914  ///
1915  virtual void computeFrhs1(const VectorBase<R>&, const VectorBase<R>&);
1916  ///
1918  /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for entering Simplex.
1919  virtual void computeEnterCoPrhs();
1920  ///
1921  void computeEnterCoPrhs4Row(int i, int n);
1922  ///
1923  void computeEnterCoPrhs4Col(int i, int n);
1924  /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for leaving Simplex.
1925  virtual void computeLeaveCoPrhs();
1926  ///
1927  void computeLeaveCoPrhs4Row(int i, int n);
1928  ///
1929  void computeLeaveCoPrhs4Col(int i, int n);
1930 
1931  /// Compute part of objective value.
1932  /** This method is called from #value() in order to compute the part of
1933  * the objective value resulting form nonbasic variables for #COLUMN
1934  * Representation.
1935  */
1936  R nonbasicValue();
1937 
1938  /// Get pointer to the \p id 'th vector
1939  virtual const SVectorBase<R>* enterVector(const SPxId& p_id)
1940  {
1941  assert(p_id.isValid());
1942  return p_id.isSPxRowId()
1943  ? &vector(SPxRowId(p_id)) : &vector(SPxColId(p_id));
1944  }
1945  ///
1946  virtual void getLeaveVals(int i,
1947  typename SPxBasisBase<R>::Desc::Status& leaveStat, SPxId& leaveId,
1948  R& leaveMax, R& leavebound, int& leaveNum, StableSum<R>& objChange);
1949  ///
1950  virtual void getLeaveVals2(R leaveMax, SPxId enterId,
1951  R& enterBound, R& newUBbound,
1952  R& newLBbound, R& newCoPrhs, StableSum<R>& objChange);
1953  ///
1954  virtual void getEnterVals(SPxId id, R& enterTest,
1955  R& enterUB, R& enterLB, R& enterVal, R& enterMax,
1956  R& enterPric, typename SPxBasisBase<R>::Desc::Status& enterStat, R& enterRO,
1957  StableSum<R>& objChange);
1958  ///
1959  virtual void getEnterVals2(int leaveIdx,
1960  R enterMax, R& leaveBound, StableSum<R>& objChange);
1961  ///
1962  virtual void ungetEnterVal(SPxId enterId, typename SPxBasisBase<R>::Desc::Status enterStat,
1963  R leaveVal, const SVectorBase<R>& vec, StableSum<R>& objChange);
1964  ///
1965  virtual void rejectEnter(SPxId enterId,
1966  R enterTest, typename SPxBasisBase<R>::Desc::Status enterStat);
1967  ///
1968  virtual void rejectLeave(int leaveNum, SPxId leaveId,
1969  typename SPxBasisBase<R>::Desc::Status leaveStat, const SVectorBase<R>* newVec = 0);
1970  ///
1971  virtual void setupPupdate(void);
1972  ///
1973  virtual void doPupdate(void);
1974  ///
1975  virtual void clearUpdateVecs(void);
1976  ///
1977  virtual void perturbMinEnter(void);
1978  /// perturb basis bounds.
1979  virtual void perturbMaxEnter(void);
1980  ///
1981  virtual void perturbMinLeave(void);
1982  /// perturb nonbasic bounds.
1983  virtual void perturbMaxLeave(void);
1984  ///@}
1985 
1986  //------------------------------------
1987  /** The following methods serve for initializing the bounds for dual or
1988  * primal Simplex algorithm of entering or leaving type.
1989  */
1990  ///@{
1991  ///
1992  void clearDualBounds(typename SPxBasisBase<R>::Desc::Status, R&, R&) const;
1993  ///
1994  void setDualColBounds();
1995  ///
1996  void setDualRowBounds();
1997  /// setup feasibility bounds for entering algorithm
1998  void setPrimalBounds();
1999  ///
2000  void setEnterBound4Col(int, int);
2001  ///
2002  void setEnterBound4Row(int, int);
2003  ///
2004  virtual void setEnterBounds();
2005  ///
2006  void setLeaveBound4Row(int i, int n);
2007  ///
2008  void setLeaveBound4Col(int i, int n);
2009  ///
2010  virtual void setLeaveBounds();
2011  ///@}
2012 
2013  //------------------------------------
2014  /** Compute the primal ray or the farkas proof in case of unboundedness
2015  * or infeasibility.
2016  */
2017  ///@{
2018  ///
2019  void computePrimalray4Col(R direction, SPxId enterId);
2020  ///
2021  void computePrimalray4Row(R direction);
2022  ///
2023  void computeDualfarkas4Col(R direction);
2024  ///
2025  void computeDualfarkas4Row(R direction, SPxId enterId);
2026  ///@}
2027 
2028 public:
2029 
2030  //------------------------------------
2031  /** Limits and status inquiry */
2032  ///@{
2033  /// set time limit.
2034  virtual void setTerminationTime(Real time = infinity);
2035  /// return time limit.
2036  virtual Real terminationTime() const;
2037  /// set iteration limit.
2038  virtual void setTerminationIter(int iteration = -1);
2039  /// return iteration limit.
2040  virtual int terminationIter() const;
2041  /// set objective limit.
2042  virtual void setTerminationValue(R value = R(infinity));
2043  /// return objective limit.
2044  virtual R terminationValue() const;
2045  /// get objective value of current solution.
2046  virtual R objValue()
2047  {
2048  return value();
2049  }
2050  /// get all results of last solve.
2051  Status
2052  getResult(R* value = 0, VectorBase<R>* primal = 0,
2053  VectorBase<R>* slacks = 0, VectorBase<R>* dual = 0,
2054  VectorBase<R>* reduCost = 0);
2055 
2056 protected:
2057 
2058  /**@todo put the following basis methods near the variable status methods!*/
2059  /// converts basis status to VarStatus
2061 
2062  /// converts VarStatus to basis status for rows
2064  const;
2065 
2066  /// converts VarStatus to basis status for columns
2068  const;
2069 
2070 public:
2071 
2072  /// gets basis status for a single row
2073  VarStatus getBasisRowStatus(int row) const;
2074 
2075  /// gets basis status for a single column
2076  VarStatus getBasisColStatus(int col) const;
2077 
2078  /// get current basis, and return solver status.
2079  Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize = -1,
2080  const int colsSize = -1) const;
2081 
2082  /// gets basis status
2084  {
2086  }
2087 
2088  /// check a given basis for validity.
2090 
2091  /// set the lp solver's basis.
2092  void setBasis(const VarStatus rows[], const VarStatus cols[]);
2093 
2094  /// set the lp solver's basis status.
2095  void setBasisStatus(typename SPxBasisBase<R>::SPxStatus stat)
2096  {
2097  if(m_status == OPTIMAL)
2098  m_status = UNKNOWN;
2099 
2101  }
2102 
2103  /// setting the solver status external from the solve loop.
2104  void setSolverStatus(typename SPxSolverBase<R>::Status stat)
2105  {
2106  m_status = stat;
2107  }
2108 
2109  /// get level of dual degeneracy
2110  // this function is used for the improved dual simplex
2111  R getDegeneracyLevel(VectorBase<R> degenvec);
2112 
2113  /// get number of dual norms
2114  void getNdualNorms(int& nnormsRow, int& nnormsCol) const;
2115 
2116  /// get dual norms
2117  bool getDualNorms(int& nnormsRow, int& nnormsCol, R* norms) const;
2118 
2119  /// set dual norms
2120  bool setDualNorms(int nnormsRow, int nnormsCol, R* norms);
2121 
2122  /// pass integrality information about the variables to the solver
2123  void setIntegralityInformation(int ncols, int* intInfo);
2124 
2125  /// reset cumulative time counter to zero.
2126  void resetCumulativeTime()
2127  {
2128  theCumulativeTime = 0.0;
2129  }
2130 
2131  /// get number of bound flips.
2132  int boundFlips() const
2133  {
2135  }
2136 
2137  /// get number of dual degenerate pivots
2138  int dualDegeneratePivots()
2139  {
2140  return (rep() == ROW) ? enterCycles : leaveCycles;
2141  }
2142 
2143  /// get number of primal degenerate pivots
2145  {
2146  return (rep() == ROW) ? leaveCycles : enterCycles;
2147  }
2148 
2149  /// get the sum of dual degeneracy
2150  R sumDualDegeneracy()
2151  {
2153  }
2154 
2155  /// get the sum of primal degeneracy
2157  {
2159  }
2160 
2161  /// get number of iterations of current solution.
2162  int iterations() const
2163  {
2164  return basis().iteration();
2165  }
2166 
2167  /// return number of iterations done with primal algorithm
2168  int primalIterations()
2169  {
2170  assert(iterations() == 0 || primalCount <= iterations());
2171  return (iterations() == 0) ? 0 : primalCount;
2172  }
2173 
2174  /// return number of iterations done with primal algorithm
2175  int dualIterations()
2176  {
2178  }
2179 
2180  /// return number of iterations done with primal algorithm
2181  int polishIterations()
2182  {
2183  return polishCount;
2184  }
2185 
2186  /// time spent in last call to method solve().
2187  Real time() const
2188  {
2189  return theTime->time();
2190  }
2191 
2192  /// returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
2193  ///
2194  bool isTimeLimitReached(const bool forceCheck = false);
2195 
2196  /// the maximum runtime
2197  Real getMaxTime()
2198  {
2199  return maxTime;
2200  }
2201 
2202  /// cumulative time spent in all calls to method solve().
2203  Real cumulativeTime() const
2204  {
2206  }
2207 
2208  /// the maximum number of iterations
2209  int getMaxIters()
2210  {
2211  return maxIters;
2212  }
2213 
2214  /// return const lp's rows if available.
2215  const LPRowSetBase<R>& rows() const
2216  {
2217  return *this->lprowset();
2218  }
2219 
2220  /// return const lp's cols if available.
2221  const LPColSet& cols() const
2222  {
2223  return *this->lpcolset();
2224  }
2225 
2226  /// copy lower bound VectorBase<R> to \p p_low.
2227  void getLower(VectorBase<R>& p_low) const
2228  {
2230  }
2231  /// copy upper bound VectorBase<R> to \p p_up.
2232  void getUpper(VectorBase<R>& p_up) const
2233  {
2235  }
2236 
2237  /// copy lhs value VectorBase<R> to \p p_lhs.
2238  void getLhs(VectorBase<R>& p_lhs) const
2239  {
2241  }
2242 
2243  /// copy rhs value VectorBase<R> to \p p_rhs.
2244  void getRhs(VectorBase<R>& p_rhs) const
2245  {
2247  }
2248 
2249  /// optimization sense.
2250  typename SPxLPBase<R>::SPxSense sense() const
2251  {
2252  return this->spxSense();
2253  }
2254 
2255  /// returns statistical information in form of a string.
2256  std::string statistics() const
2257  {
2258  std::stringstream s;
2259  s << basis().statistics()
2260  << "Solution time : " << std::setw(10) << std::fixed << std::setprecision(
2261  2) << time() << std::endl
2262  << "Iterations : " << std::setw(10) << iterations() << std::endl;
2263 
2264  return s.str();
2265  }
2266 
2267  /// returns whether a basis needs to be found for the improved dual simplex
2269  {
2270  if(getStartingDecompBasis)
2271  return FINDSTARTBASIS;
2272  else
2273  return DONTFINDSTARTBASIS;
2274  }
2275 
2276  /// sets whether the degeneracy is computed at each iteration
2277  void setComputeDegenFlag(bool computeDegen)
2278  {
2279  computeDegeneracy = computeDegen;
2280  }
2281 
2282 
2283  /// returns whether the degeneracy is computed in each iteration
2284  bool getComputeDegeneracy() const
2285  {
2287  }
2288 
2289 
2290  /// sets the offset for the number of iterations before the degeneracy is computed
2291  void setDegenCompOffset(int iterOffset)
2292  {
2293  degenCompIterOffset = iterOffset;
2294  }
2295 
2296 
2297  /// gets the offset for the number of iterations before the degeneracy is computed
2298  int getDegenCompOffset() const
2299  {
2301  }
2302 
2303  /// sets the iteration limit for the decomposition simplex initialisation
2304  void setDecompIterationLimit(int iterationLimit)
2305  {
2306  decompIterationLimit = iterationLimit;
2307  }
2308 
2309  /// returns the iteration limit for the decomposition simplex initialisation
2310  int getDecompIterationLimit() const
2311  {
2313  }
2314  ///@}
2315 
2316  //------------------------------------
2317  /** Mapping between numbers and Ids */
2318  ///@{
2319  /// RowId of \p i 'th inequality.
2320  SPxRowId rowId(int i) const
2321  {
2322  return this->rId(i);
2323  }
2324  /// ColId of \p i 'th column.
2325  SPxColId colId(int i) const
2326  {
2327  return this->cId(i);
2328  }
2329  ///@}
2330 
2331  //------------------------------------
2332  /** Constructors / destructors */
2333  ///@{
2334  /// default constructor.
2335  explicit
2336  SPxSolverBase(Type type = LEAVE,
2338  Timer::TYPE ttype = Timer::USER_TIME);
2339  // virtual destructor
2340  virtual ~SPxSolverBase();
2341  ///@}
2342 
2343  //------------------------------------
2344  /** Miscellaneous */
2345  ///@{
2346  /// check consistency.
2347  bool isConsistent() const;
2348  ///@}
2349 
2350  //------------------------------------
2351  /** assignment operator and copy constructor */
2352  ///@{
2353  /// assignment operator
2355  /// copy constructor
2356  SPxSolverBase(const SPxSolverBase<R>& base);
2357  ///@}
2358 
2359  void testVecs();
2360 };
2361 
2362 //
2363 // Auxiliary functions.
2364 //
2365 
2366 /// Pretty-printing of variable status.
2367 template <class R>
2368 std::ostream& operator<<(std::ostream& os,
2369  const typename SPxSolverBase<R>::VarStatus& status);
2370 
2371 /// Pretty-printing of solver status.
2372 template <class R>
2373 std::ostream& operator<<(std::ostream& os,
2374  const typename SPxSolverBase<R>::Status& status);
2375 
2376 /// Pretty-printing of algorithm.
2377 template <class R>
2378 std::ostream& operator<<(std::ostream& os,
2379  const typename SPxSolverBase<R>::Type& status);
2380 
2381 /// Pretty-printing of representation.
2382 template <class R>
2383 std::ostream& operator<<(std::ostream& os,
2384  const typename SPxSolverBase<R>::Representation& status);
2385 
2386 /* For Backwards compatibility */
2388 
2389 } // namespace soplex
2390 
2391 // For general templated functions
2392 #include "spxsolver.hpp"
2393 #include "spxsolve.hpp"
2394 #include "changesoplex.hpp"
2395 #include "leave.hpp"
2396 #include "enter.hpp"
2397 #include "spxshift.hpp"
2398 #include "spxbounds.hpp"
2399 #include "spxchangebasis.hpp"
2400 #include "spxvecs.hpp"
2401 #include "spxwritestate.hpp"
2402 #include "spxfileio.hpp"
2403 #include "spxquality.hpp"
2404 
2405 #endif // _SPXSOLVER_H_
const VectorBase< R > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:239
bool freePricer
true iff thepricer should be freed inside of object
Definition: spxsolver.h:304
virtual void qualConstraintViolation(R &maxviol, R &sumviol) const
get violation of constraints.
virtual void setBasisSolver(SLinSolver< R > *slu, const bool destroy=false)
setup linear solver to use. If destroy is true, slusolver will be freed in destructor.
Real theCumulativeTime
cumulative time spent in all calls to method solve()
Definition: spxsolver.h:260
Timer * multTimeColwise
time spent in setupPupdate(), columnwise multiplication
Definition: spxsolver.h:479
Random numbers.
solve() aborted due to commence decomposition simplex
Definition: spxsolver.h:221
virtual void changeLower(SPxColId p_id, const R &p_newLower, bool scale=false)
Definition: spxsolver.h:1025
R sumDualDegeneracy()
get the sum of dual degeneracy
Definition: spxsolver.h:2152
void setup4solve(SSVectorBase< R > *p_y, SSVectorBase< R > *p_rhs)
Setup vectors to be solved within Simplex loop.
Definition: spxsolver.h:1739
void calculateProblemRanges()
determine ranges of problem values for bounds, sides and objective to assess numerical difficulties ...
virtual void changeRange(const VectorBase< R > &newLhs, const VectorBase< R > &newRhs, bool scale=false)
virtual bool terminate()
Termination criterion.
virtual void qualRedCostViolation(R &maxviol, R &sumviol) const
get violation of optimality criterion.
const SVectorBase< R > & vector(int i) const
i &#39;th vector.
Definition: spxsolver.h:1202
Representation
LP basis representation.
Definition: spxsolver.h:116
VectorBase< R > low
vector of lower bounds.
Definition: lpcolsetbase.h:53
SSVectorBase< R > * solveVector2
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:288
int dualIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2177
nothing known about basis status (possibly due to a singular basis in transformed problem) ...
Definition: spxsolver.h:207
solve() aborted due to time limit.
Definition: spxsolver.h:223
Bound flipping ratio test ("long step dual") for SoPlex.Class SPxBoundFlippingRT provides an implemen...
SPxRowId rId(int n) const
Returns the row identifier for row n.
Definition: spxlpbase.h:585
variable fixed to identical bounds.
Definition: spxsolver.h:204
bool updateNonbasicValue(R objChange)
bool m_nonbasicValueUpToDate
true, if the stored objValue is up to date
Definition: spxsolver.h:269
bool isId(const SPxId &p_id) const
Is p_id an SPxId ?
Definition: spxsolver.h:1180
void setEnterBound4Col(int, int)
virtual void changeRow(int i, const LPRowBase< R > &newRow, bool scale=false)
virtual void setupPupdate(void)
SPxColId colId(int i) const
ColId of i &#39;th column.
Definition: spxsolver.h:2327
void resetCumulativeTime()
reset cumulative time counter to zero.
Definition: spxsolver.h:2128
R epsilon() const
values are considered to be 0.
Definition: spxsolver.h:807
const SPxRatioTester< R > * ratiotester() const
return loaded SPxRatioTester.
Definition: spxsolver.h:1826
SPxPricer< R > * thepricer
Definition: spxsolver.h:415
void shiftUPbound(int i, R to)
shift i &#39;th upBound to to.
Definition: spxsolver.h:1637
const VectorBase< R > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:479
virtual void changeLhs(const VectorBase< R > &newLhs, bool scale=false)
bool getComputeDegeneracy() const
returns whether the degeneracy is computed in each iteration
Definition: spxsolver.h:2286
const VectorBase< R > & coPrhs() const
Right-hand side vector for coPvec.
Definition: spxsolver.h:1456
UpdateVector< R > & fVec() const
feasibility vector.
Definition: spxsolver.h:1368
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:32
maximize number of basic slack variables, i.e. more variables on bounds
Definition: spxsolver.h:242
Timer * multTimeSparse
time spent in setupPupdate() exploiting sparsity
Definition: spxsolver.h:477
VectorBase< R > * theCoLbound
Lower bound for covars.
Definition: spxsolver.h:391
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:529
VarStatus getBasisRowStatus(int row) const
gets basis status for a single row
R dualDegenSum
the sum of the dual degeneracy percentage
Definition: spxsolver.h:413
VectorBase< R > theLBbound
Lower Basic Feasibility bound.
Definition: spxsolver.h:370
Timer * multTimeFull
time spent in setupPupdate() ignoring sparsity
Definition: spxsolver.h:478
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2189
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
Definition: dsvectorbase.h:28
virtual void getLeaveVals(int i, typename SPxBasisBase< R >::Desc::Status &leaveStat, SPxId &leaveId, R &leaveMax, R &leavebound, int &leaveNum, StableSum< R > &objChange)
Starting basis has been found and the simplex can be executed as normal.
Definition: spxsolver.h:197
Timer::TYPE timerType
type of timer (user or wallclock)
Definition: spxsolver.h:259
variable set to its lower bound.
Definition: spxsolver.h:203
virtual void changeLower(const VectorBase< R > &newLower, bool scale=false)
virtual R shift() const
total current shift amount.
Definition: spxsolver.h:1672
void computeLeaveCoPrhs4Col(int i, int n)
No ratiotester loaded.
Definition: spxsolver.h:216
virtual R maxInfeas() const
maximal infeasibility of basis
virtual void computeLeaveCoPrhs()
compute theCoPrhs for leaving Simplex.
const VectorBase< R > & ucBound() const
Definition: spxsolver.h:1462
void computeLeaveCoPrhs4Row(int i, int n)
virtual void changeRow(SPxRowId p_id, const LPRowBase< R > &p_newRow, bool scale=false)
Definition: spxsolver.h:1092
bool getStartingDecompBasis
flag to indicate whether the simplex is solved to get the starting improved dual simplex basis ...
Definition: spxsolver.h:330
void shiftUBbound(int i, R to)
shift i &#39;th ubBound to to.
Definition: spxsolver.h:1621
int enterCycles
the number of degenerate steps during the entering algorithm
Definition: spxsolver.h:408
void computeFtest()
compute basis feasibility test vector.
VectorBase< R > coWeights
store dual norms
Definition: spxsolver.h:473
Random numbers.Class Random provides random Real variables, i.e. a value variable that gives another ...
Definition: random.h:56
virtual void perturbMinLeave(void)
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
minimize number of basic slack variables, i.e. more variables in between bounds
Definition: spxsolver.h:243
virtual void computeEnterCoPrhs()
compute theCoPrhs for entering Simplex.
void resetClockStats()
resets clock average statistics
virtual Real terminationTime() const
return time limit.
void setType(Type tp)
set LEAVE or ENTER algorithm.
free variable fixed to zero.
Definition: spxsolver.h:205
bool isBasic(typename SPxBasisBase< R >::Desc::Status stat) const
does stat describe a basic index ?
Definition: spxsolver.h:1308
SPxSolverBase< Real > SPxSolver
Definition: spxsolver.h:2389
Status & status(int i)
Definition: spxbasis.h:272
int primalCount
number of primal iterations
Definition: spxsolver.h:402
UpdateVector< R > & coPvec() const
copricing vector.
Definition: spxsolver.h:1443
R objrange
absolute range of all objective coefficients in the problem
Definition: spxsolver.h:421
Simplex basis.Consider the linear program as provided from class SPxLP: where , and ...
Definition: spxbasis.h:84
int primalDegeneratePivots()
get number of primal degenerate pivots
Definition: spxsolver.h:2146
SSVectorBase< R > * coSolveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:300
DIdxSet updateViols
store indices that were changed in the previous iteration and must be checked in hyper pricing ...
Definition: spxsolver.h:448
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
Definition: dsvectorbase.h:43
#define SOPLEX_VERSION
Definition: spxdefines.h:54
int enterDegenCand
the number of degenerate candidates in the entering algorithm
Definition: spxsolver.h:410
void getRhs(VectorBase< R > &p_rhs) const
copy rhs value VectorBase<R> to p_rhs.
Definition: spxsolver.h:2246
const VectorBase< R > & lcBound() const
Definition: spxsolver.h:1483
SPxRatioTester< R > * theratiotester
Definition: spxsolver.h:416
Safe arrays of arbitrary types.Class Array provides safe arrays of arbitrary type. Array elements are accessed just like ordinary C++ array elements by means of the index operator[](). Safety is provided by.
Definition: array.h:63
DecompStatus
Improved dual simplex status.
Definition: spxsolver.h:192
void setRep()
sets descriptor representation according to loaded LP.
int printBasisMetric
printing the current basis metric in the log (-1: off, 0: condition estimate, 1: trace, 2: determinant, 3: condition)
Definition: spxsolver.h:340
int subversion() const
return the internal subversion of SPxSolverBase as number
Definition: spxsolver.h:524
VectorBase< R > theURbound
Upper Row Feasibility bound.
Definition: spxsolver.h:359
virtual void addedCols(int n)
void setup4solve2(SSVectorBase< R > *p_y2, SSVectorBase< R > *p_rhs2)
Setup vectors to be solved within Simplex loop.
Definition: spxsolver.h:1753
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:545
const LPRowSetBase< R > & rows() const
return const lp&#39;s rows if available.
Definition: spxsolver.h:2217
virtual Status getPrimalSol(VectorBase< R > &vector) const
get solution vector for primal variables.
Abstract ratio test base class.Class SPxRatioTester is the virtual base class for computing the ratio...
Real maxTime
maximum allowed time.
Definition: spxsolver.h:262
virtual void perturbMaxEnter(void)
perturb basis bounds.
const LPRowSetBase< R > * lprowset() const
Returns the LP as an LPRowSetBase.
Definition: spxlpbase.h:2053
R m_leavetol
feasibility tolerance maintained during leaving algorithm
Definition: spxsolver.h:280
bool enter(SPxId &id, bool polish=false)
const VectorBase< R > & test() const
Violations of pVec.
Definition: spxsolver.h:1576
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxsolver.h:59
bool m_pricingViolUpToDate
true, if the stored violation is up to date
Definition: spxsolver.h:272
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
void setDecompIterationLimit(int iterationLimit)
sets the iteration limit for the decomposition simplex initialisation
Definition: spxsolver.h:2306
int dualDegeneratePivots()
get number of dual degenerate pivots
Definition: spxsolver.h:2140
int remainingRoundsLeave
number of dense rounds/refactorizations until sparsePricing is enabled again
Definition: spxsolver.h:467
void setLeaveBound4Row(int i, int n)
Timer * multTimeUnsetup
time spent in setupPupdate() w/o sparsity information
Definition: spxsolver.h:480
void computePrimalray4Row(R direction)
virtual void init()
intialize data structures.
const SVSetBase< R > * thevectors
the LP vectors according to representation
Definition: spxsolver.h:350
R m_entertol
feasibility tolerance maintained during entering algorithm
Definition: spxsolver.h:279
virtual Status getDualSol(VectorBase< R > &vector) const
get current solution VectorBase<R> for dual variables.
void computeDualfarkas4Row(R direction, SPxId enterId)
virtual void perturbMinEnter(void)
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
Definition: spxid.h:36
void setRedCost(VectorBase< R > &p_vector)
virtual void getEnterVals2(int leaveIdx, R enterMax, R &leaveBound, StableSum< R > &objChange)
void setTiming(Timer::TYPE ttype)
set timing type
Definition: spxsolver.h:856
virtual R value()
current objective value.
bool leave(int i, bool polish=false)
VectorBase< R > theCoTest
Definition: spxsolver.h:394
virtual void changeMaxObj(const VectorBase< R > &newObj, bool scale=false)
virtual void changeCol(SPxColId p_id, const LPColBase< R > &p_newCol, bool scale=false)
Definition: spxsolver.h:1100
const VectorBase< R > & ubBound() const
upper bound for fVec.
Definition: spxsolver.h:1386
Pricing thePricing
full or partial pricing.
Definition: spxsolver.h:255
R objLimit
< the number of calls to the method isTimeLimitReached()
Definition: spxsolver.h:265
SPxStatus status() const
returns current SPxStatus.
Definition: spxbasis.h:428
SolutionPolish polishObj
objective of solution polishing
Definition: spxsolver.h:257
Sparse Linear Solver virtual base class.Class SLinSolver provides a class for solving sparse linear s...
Definition: dsvectorbase.h:30
VectorBase< R > up
vector of upper bounds.
Definition: lpcolsetbase.h:54
R entertol() const
feasibility tolerance maintained by ratio test during ENTER algorithm.
Definition: spxsolver.h:812
virtual void doRemoveCol(int i)
void clearDualBounds(typename SPxBasisBase< R >::Desc::Status, R &, R &) const
TimerFactory class.
don&#39;t perform modifications on optimal basis
Definition: spxsolver.h:241
void shiftLBbound(int i, R to)
shift i &#39;th lbBound to to.
Definition: spxsolver.h:1629
virtual const SVectorBase< R > * enterVector(const SPxId &p_id)
Get pointer to the id &#39;th vector.
Definition: spxsolver.h:1941
R theShift
sum of all shifts applied to any bound.
Definition: spxsolver.h:281
virtual void unInit()
uninitialize data structures.
Definition: spxsolver.h:1904
bool fullPerturbation
whether to perturb the entire problem or just the bounds relevant for the current pivot ...
Definition: spxsolver.h:338
No Problem has been loaded.
Definition: spxsolver.h:227
SSVectorBase< R > * solveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:294
Random random
The random number generator used throughout the whole computation. Its seed can be modified...
Definition: spxsolver.h:437
SPxColId cId(int n) const
Returns the column identifier for column n.
Definition: spxlpbase.h:591
Saving LPs in a form suitable for SoPlex.
nothing known on loaded problem.
Definition: spxsolver.h:230
bool isInitialized() const
has the internal data been initialized?
Definition: spxsolver.h:1895
bool m_pricingViolCoUpToDate
true, if the stored violation in coDim is up to date
Definition: spxsolver.h:276
SSVectorBase< R > * solveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:290
LP has been solved to optimality.
Definition: spxsolver.h:231
void setSparsePricingFactor(R fac)
Definition: spxsolver.h:896
Semi sparse vector.This class implements semi-sparse vectors. Such are VectorBases where the indices ...
Definition: dsvectorbase.h:29
SSVectorBase< R > & delta()
update VectorBase<R> , writeable
Definition: updatevector.h:113
an error occured.
Definition: spxsolver.h:215
int numCycle() const
actual number of degenerate simplex steps encountered so far.
Definition: spxsolver.h:919
void shiftUCbound(int i, R to)
shift i &#39;th ucBound to to.
Definition: spxsolver.h:1653
SPxBasisBase< R >::Desc::Status varStatusToBasisStatusCol(int col, VarStatus stat) const
converts VarStatus to basis status for columns
bool hyperPricingLeave
true if hyper sparse pricing is turned on in the leaving Simplex
Definition: spxsolver.h:464
DecompStatus getDecompStatus() const
returns whether a basis needs to be found for the improved dual simplex
Definition: spxsolver.h:2270
const SPxPricer< R > * pricer() const
return loaded SPxPricer.
Definition: spxsolver.h:1816
void updateFtest()
update basis feasibility test vector.
bool sparsePricingEnter
true if sparsePricing is turned on in the entering Simplex for slack variables
Definition: spxsolver.h:462
virtual void setStarter(SPxStarter< R > *starter, const bool destroy=false)
setup starting basis generator to use. If destroy is true, starter will be freed in destructor...
void setDelta(R d)
set parameter delta, i.e., set feastol and opttol to same value.
const VectorBase< R > & fRhs() const
right-hand side vector for fVec
Definition: spxsolver.h:1381
void setSolverStatus(typename SPxSolverBase< R >::Status stat)
setting the solver status external from the solve loop.
Definition: spxsolver.h:2106
SPxSolverBase< R > & operator=(const SPxSolverBase< R > &base)
assignment operator
virtual void loadBasis(const typename SPxBasisBase< R >::Desc &)
set a start basis.
int degenCompIterOffset
the number of iterations performed before the degeneracy level is computed
Definition: spxsolver.h:333
virtual void getLeaveVals2(R leaveMax, SPxId enterId, R &enterBound, R &newUBbound, R &newLBbound, R &newCoPrhs, StableSum< R > &objChange)
SPxStatus
basis status.
Definition: spxbasis.h:92
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
Fast shifting ratio test.Class SPxFastRT is an implementation class of SPxRatioTester providing fast ...
Definition: spxfastrt.h:42
SPxBasisBase< R >::Desc::Status varStatusToBasisStatusRow(int row, VarStatus stat) const
converts VarStatus to basis status for rows
R lastShift
for forcing feasibility.
Definition: spxsolver.h:282
bool isConsistent() const
check consistency.
solve() aborted due to detection of cycling.
Definition: spxsolver.h:222
SPxSense
Optimization sense.
Definition: spxlpbase.h:115
SPxStarter< R > * thestarter
Definition: spxsolver.h:417
int getDegenCompOffset() const
gets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2300
const Desc & desc() const
Definition: spxbasis.h:467
void setDual(VectorBase< R > &p_vector)
void computePrimalray4Col(R direction, SPxId enterId)
double Real
Definition: spxdefines.h:227
VarStatus basisStatusToVarStatus(typename SPxBasisBase< R >::Desc::Status stat) const
converts basis status to VarStatus
solve() aborted due to objective limit.
Definition: spxsolver.h:225
DataArray< int > integerVariables
supplementary variable information, 0: continous variable, 1: integer variable
Definition: spxsolver.h:489
LP is primal infeasible or unbounded.
Definition: spxsolver.h:234
#define MAXIMUM(x, y)
Definition: spxdefines.h:255
bool weightsAreSetup
are the dual norms already set up?
Definition: spxsolver.h:474
Status getResult(R *value=0, VectorBase< R > *primal=0, VectorBase< R > *slacks=0, VectorBase< R > *dual=0, VectorBase< R > *reduCost=0)
get all results of last solve.
virtual void doPupdate(void)
virtual Status getPrimalray(VectorBase< R > &vector) const
get primal ray in case of unboundedness.
int leaveCount
number of LEAVE iterations
Definition: spxsolver.h:400
R m_pricingViolCo
maximal feasibility violation of current solution in coDim
Definition: spxsolver.h:275
Status & coStatus(int i)
Definition: spxbasis.h:287
virtual void reDim()
reset dimensions of vectors according to loaded LP.
SPxBasisBase< R >::Desc::Status covarStatus(int i) const
Status of i &#39;th covariable.
Definition: spxsolver.h:1302
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1162
const VectorBase< R > & fTest() const
Violations of fVec.
Definition: spxsolver.h:1430
void setMetricInformation(int type)
print basis metric within the usual output
Definition: spxsolver.h:890
int m_maxCycle
maximum steps before cycling is detected.
Definition: spxsolver.h:283
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:533
void useFullPerturbation(bool full)
perturb entire problem or only the bounds relevant to the current pivot
Definition: spxsolver.h:925
const SPxBasisBase< R > & basis() const
Return current basis.
Definition: spxsolver.h:1806
Dense VectorBase<R> with semi-sparse VectorBase<R> for updates.
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
Definition: basevectors.h:1134
virtual R objValue()
get objective value of current solution.
Definition: spxsolver.h:2048
solve() aborted to exit decomposition simplex
Definition: spxsolver.h:220
Timer::TYPE getTiming()
set timing type
Definition: spxsolver.h:867
void computeCoTest()
compute coTest vector.
void shiftLPbound(int i, R to)
shift i &#39;th lpBound to to.
Definition: spxsolver.h:1645
const VectorBase< R > & coTest() const
violations of coPvec.
Definition: spxsolver.h:1510
virtual void changeRhs(SPxRowId p_id, const R &p_newRhs, bool scale=false)
Definition: spxsolver.h:1073
void localAddRows(int start)
int totalboundflips
total number of bound flips
Definition: spxsolver.h:406
virtual void reinitializeVecs()
setup all vecs fresh
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition: spxout.h:63
virtual void changeCol(int i, const LPColBase< R > &newCol, bool scale=false)
std::string statistics() const
returns statistical information in form of a string.
Definition: spxsolver.h:2258
int polishIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2183
void computeEnterCoPrhs4Row(int i, int n)
int version() const
return the version of SPxSolverBase as number like 123 for 1.2.3
Definition: spxsolver.h:519
UpdateVector< R > primVec
primal vector
Definition: spxsolver.h:354
R sumPrimalDegeneracy()
get the sum of primal degeneracy
Definition: spxsolver.h:2158
int multColwiseCalls
number of products, columnwise multiplication
Definition: spxsolver.h:483
const VectorBase< R > & lpBound() const
Definition: spxsolver.h:1549
virtual bool readBasisFile(const char *filename, const NameSet *rowNames, const NameSet *colNames)
SSVectorBase< R > * coSolveVector2rhs
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:298
int nClckSkipsLeft
remaining number of times the clock can be safely skipped
Definition: spxsolver.h:263
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
get number of dual norms
R leavetol() const
feasibility tolerance maintained by ratio test during LEAVE algorithm.
Definition: spxsolver.h:819
LP has been proven to be primal unbounded.
Definition: spxsolver.h:232
int info
user information to store values -1, 0, +1
Definition: datakey.h:55
virtual void doRemoveRows(int perm[])
int polishCount
number of solution polishing iterations
Definition: spxsolver.h:403
int multFullCalls
number of products ignoring sparsity
Definition: spxsolver.h:482
virtual void changeElement(SPxRowId rid, SPxColId cid, const R &val, bool scale=false)
Definition: spxsolver.h:1108
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:273
static Timer * switchTimer(Timer *timer, Timer::TYPE ttype)
Definition: timerfactory.h:72
bool isColBasic(int i) const
is the i &#39;th column vector basic ?
Definition: spxsolver.h:1341
void forceRecompNonbasicValue()
Definition: spxsolver.h:693
void setBasis(const VarStatus rows[], const VarStatus cols[])
set the lp solver&#39;s basis.
void perturbMax(const UpdateVector< R > &vec, VectorBase< R > &low, VectorBase< R > &up, R eps, R delta, int start=0, int incr=1)
Abstract pricer base class.Class SPxPricer is a pure virtual class defining the interface for pricer ...
Definition: spxpricer.h:47
Dense Vector with semi-sparse Vector for updatesIn many algorithms vectors are updated in every itera...
Definition: updatevector.h:53
bool isBasic(const SPxRowId &rid) const
is the rid &#39;th vector basic ?
Definition: spxsolver.h:1323
variable set to its upper bound.
Definition: spxsolver.h:202
Basis descriptor.
Definition: spxbasis.h:106
VectorBase< R > * theFrhs
Definition: spxsolver.h:373
R boundrange
absolute range of all bounds in the problem
Definition: spxsolver.h:419
UpdateVector< R > * theRPvec
row pricing vector
Definition: spxsolver.h:383
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
R getDegeneracyLevel(VectorBase< R > degenvec)
get level of dual degeneracy
VectorBase< R > theTest
Definition: spxsolver.h:395
const SVSetBase< R > * thecovectors
the LP coVectors according to representation
Definition: spxsolver.h:351
void setup4coSolve2(SSVectorBase< R > *p_z, SSVectorBase< R > *p_rhs)
Setup vectors to be cosolved within Simplex loop.
Definition: spxsolver.h:1779
virtual Real time() const =0
UpdateVector< R > & pVec() const
pricing vector.
Definition: spxsolver.h:1523
void setDecompStatus(DecompStatus decomp_stat)
turn on or off the improved dual simplex.
virtual void changeRhsStatus(int i, R newRhs, R oldRhs=0.0)
void setMemFactor(R f)
set refactor threshold for memory growth in current factor update compared to the last factorization ...
Definition: spxsolver.h:511
R opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:834
DSVectorBase< R > dualFarkas
stores dual farkas proof in case of infeasibility
Definition: spxsolver.h:398
virtual void addedRows(int n)
R siderange
absolute range of all side in the problem
Definition: spxsolver.h:420
bool sparsePricingLeave
These values enable or disable sparse pricing.
Definition: spxsolver.h:461
void initRep(Representation p_rep)
initialize ROW or COLUMN representation.
virtual void changeObj(const VectorBase< R > &newObj, bool scale=false)
scale determines whether the new data needs to be scaled according to the existing LP (persistent sca...
variable is basic.
Definition: spxsolver.h:206
bool initialized
true, if all vectors are setup.
Definition: spxsolver.h:285
bool hyperPricingEnter
true if hyper sparse pricing is turned on in the entering Simplex
Definition: spxsolver.h:465
virtual bool writeBasisFile(const char *filename, const NameSet *rowNames, const NameSet *colNames, const bool cpxFormat=false) const
SPxSolverBase(Type type=LEAVE, Representation rep=ROW, Timer::TYPE ttype=Timer::USER_TIME)
default constructor.
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
Definition: lprowbase.h:45
bool freeRatioTester
true iff theratiotester should be freed inside of object
Definition: spxsolver.h:305
virtual void clearRowObjs()
Definition: spxsolver.h:1012
void setStatus(SPxStatus stat)
sets basis SPxStatus to stat.
Definition: spxbasis.h:434
SSVectorBase< R > * solveVector3
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:292
UpdateVector< R > * theCPvec
column pricing vector
Definition: spxsolver.h:384
void setOutstream(SPxOut &newOutstream)
Definition: spxsolver.h:492
void setEnterBound4Row(int, int)
virtual Status getDualfarkas(VectorBase< R > &vector) const
get dual farkas proof of infeasibility.
Type type() const
return current Type.
Definition: spxsolver.h:535
Pricing pricing() const
return current Pricing.
Definition: spxsolver.h:541
R m_nonbasicValue
nonbasic part of current objective value
Definition: spxsolver.h:268
virtual R getBasisMetric(int type)
Definition: spxsolver.h:930
Debugging, floating point type and parameter definitions.
virtual void factorize()
Factorize basis matrix.
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
Simplex basis.
virtual void setTester(SPxRatioTester< R > *tester, const bool destroy=false)
setup ratio-tester to use. If destroy is true, tester will be freed in destructor.
bool getDualNorms(int &nnormsRow, int &nnormsCol, R *norms) const
get dual norms
int maxCycle() const
maximum number of degenerate simplex steps before we detect cycling.
Definition: spxsolver.h:914
virtual Status solve()
solve loaded LP.
VectorBase< R > weights
dual pricing norms
Definition: spxsolver.h:472
rowwise representation.
Definition: spxsolver.h:118
int boundFlips() const
get number of bound flips.
Definition: spxsolver.h:2134
virtual void changeRowObj(const VectorBase< R > &newObj, bool scale=false)
void computeFrhs()
compute feasibility vector from scratch.
bool isRowBasic(int i) const
is the i &#39;th row vector basic ?
Definition: spxsolver.h:1335
VectorBase< R > * theCoPrhs
Definition: spxsolver.h:378
VectorBase< R > * theUbound
Upper bound for vars.
Definition: spxsolver.h:388
virtual Status getRedCostSol(VectorBase< R > &vector) const
get vector of reduced costs.
void setOpttol(R d)
set parameter opttol.
virtual void changeBounds(const VectorBase< R > &newLower, const VectorBase< R > &newUpper, bool scale=false)
virtual void setTerminationTime(Real time=infinity)
set time limit.
UpdateVector< R > addVec
storage for thePvec = &addVec
Definition: spxsolver.h:357
bool isCoId(const SPxId &p_id) const
Is p_id a CoId.
Definition: spxsolver.h:1189
R delta() const
guaranteed primal and dual bound violation for optimal solution, returning the maximum of feastol() a...
Definition: spxsolver.h:842
const LPColSet & cols() const
return const lp&#39;s cols if available.
Definition: spxsolver.h:2223
Everything should be within this namespace.
virtual void doRemoveCols(int perm[])
Timer class.
Basis is singular, numerical troubles?
Definition: spxsolver.h:226
SPxRowId rowId(int i) const
RowId of i &#39;th inequality.
Definition: spxsolver.h:2322
int m_numViol
number of violations of current solution
Definition: spxsolver.h:277
const VectorBase< R > & lbBound() const
lower bound for fVec.
Definition: spxsolver.h:1404
Array< UnitVectorBase< R > > unitVecs
array of unit vectors
Definition: spxsolver.h:349
virtual void setLeaveBounds()
TYPE
types of timers
Definition: timer.h:99
void setLeaveBound4Col(int i, int n)
virtual void ungetEnterVal(SPxId enterId, typename SPxBasisBase< R >::Desc::Status enterStat, R leaveVal, const SVectorBase< R > &vec, StableSum< R > &objChange)
int maxIters
maximum allowed iterations.
Definition: spxsolver.h:261
void computeEnterCoPrhs4Col(int i, int n)
VectorBase< R > theLRbound
Lower Row Feasibility bound.
Definition: spxsolver.h:360
void setPrimalBounds()
setup feasibility bounds for entering algorithm
columnwise representation.
Definition: spxsolver.h:119
virtual void changeUpper(const VectorBase< R > &newUpper, bool scale=false)
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
Definition: spxlpbase.h:56
void computeTest()
compute test VectorBase<R> in ENTERing Simplex.
Entering Simplex.
Definition: spxsolver.h:145
virtual void setTerminationIter(int iteration=-1)
set iteration limit.
virtual bool writeState(const char *filename, const NameSet *rowNames=NULL, const NameSet *colNames=NULL, const bool cpxFormat=false) const
Set of LP columns.Class LPColSetBase implements a set of LPColBase%s. Unless for memory limitations...
Definition: lpcolsetbase.h:43
void setNonzeroFactor(R f)
set refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix ...
Definition: spxsolver.h:499
virtual void changeSense(typename SPxLPBase< R >::SPxSense sns)
virtual void clearUpdateVecs(void)
int multSparseCalls
number of products exploiting sparsity
Definition: spxsolver.h:481
virtual void clearRowObjs()
Clears row objective function values for all rows.
Definition: spxlpbase.h:1664
void setDegenCompOffset(int iterOffset)
sets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2293
DataArray< int > isInfeasible
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:456
void localAddCols(int start)
UpdateVector< R > dualVec
dual vector
Definition: spxsolver.h:356
virtual void changeRange(SPxRowId p_id, const R &p_newLhs, const R &p_newRhs, bool scale=false)
Definition: spxsolver.h:1084
Save arrays of arbitrary types.
bool isCoBasic(int i) const
is the i &#39;th covector basic ?
Definition: spxsolver.h:1353
bool isBasic(int i) const
is the i &#39;th vector basic ?
Definition: spxsolver.h:1347
void shiftFvec()
Perform initial shifting to optain an feasible or pricable basis.
void setFeastol(R d)
set parameter feastol.
virtual R terminationValue() const
return objective limit.
virtual void changeRowObj(SPxRowId p_id, const R &p_newVal, bool scale=false)
Definition: spxsolver.h:1007
virtual bool precisionReached(R &newpricertol) const
is the solution precise enough, or should we increase delta() ?
Sparse vector .
void getUpper(VectorBase< R > &p_up) const
copy upper bound VectorBase<R> to p_up.
Definition: spxsolver.h:2234
bool sparsePricingEnterCo
true if sparsePricing is turned on in the entering Simplex
Definition: spxsolver.h:463
DSVectorBase< R > primalRay
stores primal ray in case of unboundedness
Definition: spxsolver.h:397
Saving LPs in a form suitable for SoPlex.
const LPColSetBase< R > * lpcolset() const
Returns the LP as an LPColSetBase.
Definition: spxlpbase.h:2059
No linear solver loaded.
Definition: spxsolver.h:218
R feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:826
void updateTest()
recompute test vector.
Real getMaxTime()
the maximum runtime
Definition: spxsolver.h:2199
void perturbMin(const UpdateVector< R > &vec, VectorBase< R > &low, VectorBase< R > &up, R eps, R delta, int start=0, int incr=1)
void unscaleLPandReloadBasis()
unscales the LP and reloads the basis
virtual void changeElement(int i, int j, const R &val, bool scale=false)
virtual void changeObj(SPxColId p_id, const R &p_newVal, bool scale=false)
overloading a virtual function
Definition: spxsolver.h:987
bool isTimeLimitReached(const bool forceCheck=false)
returns whether current time limit is reached; call to time() may be skipped unless forceCheck is tru...
virtual void changeUpperStatus(int i, R newUpper, R oldLower=0.0)
void hyperPricing(bool h)
enable or disable hyper sparse pricing
Status m_status
status of algorithm.
Definition: spxsolver.h:266
Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize=-1, const int colsSize=-1) const
get current basis, and return solver status.
SPxBasisBase< R >::Desc::Status varStatus(int i) const
Status of i &#39;th variable.
Definition: spxsolver.h:1296
Timer * theTime
time spent in last call to method solve()
Definition: spxsolver.h:258
void setFillFactor(R f)
set refactor threshold for fill-in in current factor update compared to fill-in in last factorization...
Definition: spxsolver.h:505
void getLower(VectorBase< R > &p_low) const
copy lower bound VectorBase<R> to p_low.
Definition: spxsolver.h:2229
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:161
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
Definition: lprowsetbase.h:44
virtual int terminationIter() const
return iteration limit.
int coDim() const
codimension.
Definition: spxsolver.h:1125
int getMaxIters()
the maximum number of iterations
Definition: spxsolver.h:2211
SolutionPolish getSolutionPolishing()
return objective of solution polishing
Definition: spxsolver.h:673
virtual void changeUpper(SPxColId p_id, const R &p_newUpper, bool scale=false)
overloading virtual function
Definition: spxsolver.h:1037
virtual void printDisplayLine(const bool force=false, const bool forceHead=false)
print display line of flying table
void getLhs(VectorBase< R > &p_lhs) const
copy lhs value VectorBase<R> to p_lhs.
Definition: spxsolver.h:2240
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:151
void setDisplayFreq(int freq)
set display frequency
Definition: spxsolver.h:878
virtual void changeRhs(const VectorBase< R > &newRhs, bool scale=false)
virtual void reLoad()
reload LP.
R m_pricingViol
maximal feasibility violation of current solution
Definition: spxsolver.h:271
void setPrimal(VectorBase< R > &p_vector)
int primalIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2170
SPxLPBase< R >::SPxSense sense() const
optimization sense.
Definition: spxsolver.h:2252
Type theType
entering or leaving algortihm.
Definition: spxsolver.h:254
virtual void setEnterBounds()
Leaving Simplex.
Definition: spxsolver.h:154
UpdateVector< R > * theFvec
Definition: spxsolver.h:375
int iterations() const
get number of iterations of current solution.
Definition: spxsolver.h:2164
void updateCoTest()
recompute coTest vector.
virtual void changeLhs(SPxRowId p_id, const R &p_newLhs, bool scale=false)
Definition: spxsolver.h:1061
Starting basis has not been found yet.
Definition: spxsolver.h:195
VectorBase< R > theUCbound
Upper Column Feasibility bound.
Definition: spxsolver.h:361
void testBounds() const
void setComputeDegenFlag(bool computeDegen)
sets whether the degeneracy is computed at each iteration
Definition: spxsolver.h:2279
void setSlacks(VectorBase< R > &p_vector)
int iteration() const
returns number of basis changes since last load().
Definition: spxbasis.h:549
VectorBase< R > dualRhs
rhs VectorBase<R> for computing the dual vector
Definition: spxsolver.h:355
virtual void loadLP(const SPxLPBase< R > &LP, bool initSlackBasis=true)
copy LP.
VectorBase< R > * theLbound
Lower bound for vars.
Definition: spxsolver.h:389
virtual void setPricer(SPxPricer< R > *pricer, const bool destroy=false)
setup pricer to use. If destroy is true, pricer will be freed in destructor.
R nonbasicValue()
Compute part of objective value.
Status status() const
Status of solution process.
VectorBase< R > theUBbound
Upper Basic Feasibility bound.
Definition: spxsolver.h:369
#define SOPLEX_SUBVERSION
Definition: spxdefines.h:55
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
Definition: ssvectorbase.h:34
UpdateVector< R > * thePvec
Definition: spxsolver.h:381
virtual void computeFrhsXtra()
int boundflips
number of performed bound flips
Definition: spxsolver.h:405
R sparsePricingFactor
enable sparse pricing when viols < factor * dim()
Definition: spxsolver.h:327
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
Definition: spxid.h:55
virtual void rejectLeave(int leaveNum, SPxId leaveId, typename SPxBasisBase< R >::Desc::Status leaveStat, const SVectorBase< R > *newVec=0)
UpdateVector< R > * theCoPvec
Definition: spxsolver.h:379
virtual void getEnterVals(SPxId id, R &enterTest, R &enterUB, R &enterLB, R &enterVal, R &enterMax, R &enterPric, typename SPxBasisBase< R >::Desc::Status &enterStat, R &enterRO, StableSum< R > &objChange)
virtual void changeMaxObj(SPxColId p_id, const R &p_newVal, bool scale=false)
overloading a virtual function
Definition: spxsolver.h:997
virtual void unShift(void)
remove shift as much as possible.
SPxBasisBase< R >::SPxStatus getBasisStatus() const
gets basis status
Definition: spxsolver.h:2085
SPxOut * spxout
message handler
Definition: spxsolver.h:486
void setBasisStatus(typename SPxBasisBase< R >::SPxStatus stat)
set the lp solver&#39;s basis status.
Definition: spxsolver.h:2097
VarStatus getBasisColStatus(int col) const
gets basis status for a single column
void shiftPvec()
Perform initial shifting to optain an feasible or pricable basis.
virtual void qualSlackViolation(R &maxviol, R &sumviol) const
get the residuum |Ax-b|.
solve() aborted due to iteration limit.
Definition: spxsolver.h:224
int getDisplayFreq()
get display frequency
Definition: spxsolver.h:884
const SLinSolver< R > * slinSolver() const
return loaded SLinSolver.
Definition: spxsolver.h:1821
VectorBase< R > primRhs
rhs VectorBase<R> for computing the primal vector
Definition: spxsolver.h:353
virtual void qualBoundViolation(R &maxviol, R &sumviol) const
get violations of bounds.
algorithm is running
Definition: spxsolver.h:229
Pricing
Pricing type.
Definition: spxsolver.h:163
virtual void perturbMaxLeave(void)
perturb nonbasic bounds.
virtual Status getSlacks(VectorBase< R > &vector) const
get VectorBase<R> of slack variables.
VectorBase< R > theLCbound
Lower Column Feasibility bound.
Definition: spxsolver.h:362
SPxStarter< R > * starter() const
return current starter.
Definition: spxsolver.h:547
virtual void doRemoveRow(int i)
bool freeStarter
true iff thestarter should be freed inside of object
Definition: spxsolver.h:306
const VectorBase< R > & upBound() const
Definition: spxsolver.h:1528
bool recomputedVectors
flag to perform clean up step to reduce numerical errors only once
Definition: spxsolver.h:323
SolutionPolish
objective for solution polishing
Definition: spxsolver.h:239
int enterCount
number of ENTER iterations
Definition: spxsolver.h:401
int getDecompIterationLimit() const
returns the iteration limit for the decomposition simplex initialisation
Definition: spxsolver.h:2312
DIdxSet infeasibilitiesCo
Definition: spxsolver.h:445
Representation theRep
row or column representation.
Definition: spxsolver.h:256
void setup4coSolve(SSVectorBase< R > *p_y, SSVectorBase< R > *p_rhs)
Setup vectors to be cosolved within Simplex loop.
Definition: spxsolver.h:1767
virtual void rejectEnter(SPxId enterId, R enterTest, typename SPxBasisBase< R >::Desc::Status enterStat)
virtual void clear()
clear all data in solver.
DataArray< int > isInfeasibleCo
0: index not violated, 1: index violated, 2: index violated and among candidate list ...
Definition: spxsolver.h:458
R primalDegenSum
the sum of the primal degeneracy percentage
Definition: spxsolver.h:412
void computeFrhs2(VectorBase< R > &, VectorBase< R > &)
LP has a usable Basis (maybe LP is changed).
Definition: spxsolver.h:228
SSVectorBase< R > * coSolveVector3rhs
when 3 systems are to be solved at a time; typically reserved for bound flipping ratio test (basic so...
Definition: spxsolver.h:302
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1120
not initialised error
Definition: spxsolver.h:219
SSVectorBase< R > * coSolveVector2
when 2 systems are to be solved at a time; typically for speepest edge weights
Definition: spxsolver.h:296
bool isBasisValid(DataArray< VarStatus > rows, DataArray< VarStatus > cols)
check a given basis for validity.
Type
Algorithmic type.
Definition: spxsolver.h:135
int m_numCycle
actual number of degenerate steps so far.
Definition: spxsolver.h:284
const SVectorBase< R > & unitVector(int i) const
return i &#39;th unit vector.
Definition: spxsolver.h:1281
void shiftLCbound(int i, R to)
shift i &#39;th lcBound to to.
Definition: spxsolver.h:1661
void setSolutionPolishing(SolutionPolish _polishObj)
set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack) ...
Definition: spxsolver.h:667
Wrapper for the system time query methods.
Definition: timer.h:76
void setPricing(Pricing pr)
set FULL or PARTIAL pricing.
int num() const
Current number of SVectorBases.
Definition: svsetbase.h:759
virtual bool noViols(R tol) const
check for violations above tol and immediately return false w/o checking the remaining values ...
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:506
bool isBasic(const SPxColId &cid) const
is the cid &#39;th vector basic ?
Definition: spxsolver.h:1329
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
Definition: lpcolbase.h:45
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
Definition: ssvectorbase.h:35
virtual void changeLhsStatus(int i, R newLhs, R oldLhs=0.0)
int leaveCycles
the number of degenerate steps during the leaving algorithm
Definition: spxsolver.h:409
int multUnsetupCalls
number of products w/o sparsity information
Definition: spxsolver.h:484
virtual bool read(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
read LP from input stream.
virtual void changeLowerStatus(int i, R newLower, R oldLower=0.0)
bool setDualNorms(int nnormsRow, int nnormsCol, R *norms)
set dual norms
void computeDualfarkas4Col(R direction)
LP has been proven to be primal infeasible.
Definition: spxsolver.h:233
void computePvec()
compute entire pVec().
int leaveDegenCand
the number of degenerate candidates in the leaving algorithm
Definition: spxsolver.h:411
const SVectorBase< R > & coVector(int i) const
i &#39;th covector of LP.
Definition: spxsolver.h:1246
virtual void setTerminationValue(R value=R(infinity))
set objective limit.
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1143
int decompIterationLimit
the maximum number of iterations before the decomposition simplex is aborted.
Definition: spxsolver.h:335
virtual TYPE type()=0
return type of timer
VectorBase< R > * theCoUbound
Upper bound for covars.
Definition: spxsolver.h:390
bool isValid() const
returns TRUE, iff the DataKey is valid.
Definition: datakey.h:107
virtual void computeFrhs1(const VectorBase< R > &, const VectorBase< R > &)
Real cumulativeTime() const
cumulative time spent in all calls to method solve().
Definition: spxsolver.h:2205
LP has beed solved to optimality but unscaled solution contains violations.
Definition: spxsolver.h:235