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-2022 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  /// invalidates the basis, triggers refactorization
621  void invalidateBasis();
622 
623  /** Load basis from \p filename in MPS format. If \p rowNames and \p
624  * colNames are \c NULL, default names are used for the constraints and
625  * variables.
626  */
627  virtual bool readBasisFile(const char* filename,
628  const NameSet* rowNames, const NameSet* colNames);
629 
630  /** Write basis to \p filename in MPS format. If \p rowNames and \p
631  * colNames are \c NULL, default names are used for the constraints and
632  * variables.
633  */
634  virtual bool writeBasisFile(const char* filename,
635  const NameSet* rowNames, const NameSet* colNames, const bool cpxFormat = false) const;
636 
637  /** Write current LP, basis, and parameter settings.
638  * LP is written in MPS format to "\p filename".mps, basis is written in "\p filename".bas, and parameters
639  * are written to "\p filename".set. If \p rowNames and \p colNames are \c NULL, default names are used for
640  * the constraints and variables.
641  */
642  virtual bool writeState(const char* filename,
643  const NameSet* rowNames = NULL, const NameSet* colNames = NULL, const bool cpxFormat = false) const;
644 
645  ///@}
646 
647  /**@name Solving LPs */
648  ///@{
649  /// solve loaded LP.
650  /** Solves the loaded LP by processing the Simplex iteration until
651  * the termination criteria is fullfilled (see #terminate()).
652  * The SPxStatus of the solver will indicate the reason for termination.
653  *
654  * @throw SPxStatusException if either no problem, solver, pricer
655  * or ratiotester loaded or if solve is still running when it shouldn't be
656  */
657  virtual Status solve(volatile bool* interrupt = NULL);
658 
659  /** Identify primal basic variables that have zero reduced costs and
660  * try to pivot them out of the basis to make them tight.
661  * This is supposed to decrease the number of fractional variables
662  * when solving LP relaxations of (mixed) integer programs.
663  * The objective must not be modified during this procedure.
664  */
666 
667  /// set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack)
668  void setSolutionPolishing(SolutionPolish _polishObj)
669  {
670  polishObj = _polishObj;
671  }
672 
673  /// return objective of solution polishing
675  {
676  return polishObj;
677  }
678 
679  /// Status of solution process.
680  Status status() const;
681 
682  /// current objective value.
683  /**@return Objective value of the current solution vector
684  * (see #getPrimalSol()).
685  */
686  virtual R value();
687 
688  // update nonbasic part of the objective value by the given amount
689  /**@return whether nonbasic part of objective is reliable
690  */
691  bool updateNonbasicValue(R objChange);
692 
693  // trigger a recomputation of the nonbasic part of the objective value
695  {
696  m_nonbasicValue = 0.0;
697  m_nonbasicValueUpToDate = false;
698  }
699 
700  /// get solution vector for primal variables.
701  /** This method returns the Status of the basis.
702  * If it is #REGULAR or better,
703  * the primal solution vector of the current basis will be copied
704  * to the argument \p vector. Hence, \p vector must be of dimension
705  * #nCols().
706  *
707  * @throw SPxStatusException if not initialized
708  */
709  virtual Status getPrimalSol(VectorBase<R>& vector) const;
710 
711  /// get VectorBase<R> of slack variables.
712  /** This method returns the Status of the basis.
713  * If it is #REGULAR or better,
714  * the slack variables of the current basis will be copied
715  * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
716  * #nRows().
717  *
718  * @warning Because SPxSolverBase supports range constraints as its
719  * default, slack variables are defined in a nonstandard way:
720  * Let \em x be the current solution vector and \em A the constraint
721  * matrix. Then the vector of slack variables is defined as
722  * \f$s = Ax\f$.
723  *
724  * @throw SPxStatusException if no problem loaded
725  */
726  virtual Status getSlacks(VectorBase<R>& vector) const;
727 
728  /// get current solution VectorBase<R> for dual variables.
729  /** This method returns the Status of the basis.
730  * If it is #REGULAR or better,
731  * the VectorBase<R> of dual variables of the current basis will be copied
732  * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
733  * #nRows().
734  *
735  * @warning Even though mathematically, each range constraint would
736  * account for two dual variables (one for each inequaility), only
737  * #nRows() dual variables are setup via the following
738  * construction: Given a range constraint, there are three possible
739  * situations:
740  * - None of its inequalities is tight: The dual variables
741  * for both are 0. However, when shifting (see below)
742  * occurs, it may be set to a value other than 0, which
743  * models a perturbed objective vector.
744  * - Both of its inequalities are tight: In this case the
745  * range constraint models an equality and we adopt the
746  * standard definition.
747  * - One of its inequalities is tight while the other is not:
748  * In this case only the dual variable for the tight
749  * constraint is given with the standard definition, while
750  * the other constraint is implicitely set to 0.
751  *
752  * @throw SPxStatusException if no problem loaded
753  */
754  virtual Status getDualSol(VectorBase<R>& vector) const;
755 
756  /// get vector of reduced costs.
757  /** This method returns the Status of the basis.
758  * If it is #REGULAR or better,
759  * the vector of reduced costs of the current basis will be copied
760  * to the argument \p vector. Hence, \p vector must be of dimension
761  * #nCols().
762  *
763  * Let \em d denote the vector of dual variables, as defined above,
764  * and \em A the LPs constraint matrix. Then the reduced cost vector
765  * \em r is defined as \f$r^T = c^T - d^TA\f$.
766  *
767  * @throw SPxStatusException if no problem loaded
768  */
769  virtual Status getRedCostSol(VectorBase<R>& vector) const;
770 
771  /// get primal ray in case of unboundedness.
772  /// @throw SPxStatusException if no problem loaded
773  virtual Status getPrimalray(VectorBase<R>& vector) const;
774 
775  /// get dual farkas proof of infeasibility.
776  /// @throw SPxStatusException if no problem loaded
777  virtual Status getDualfarkas(VectorBase<R>& vector) const;
778 
779  /// print display line of flying table
780  virtual void printDisplayLine(const bool force = false, const bool forceHead = false);
781 
782  /// Termination criterion.
783  /** This method is called in each Simplex iteration to determine, if
784  * the algorithm is to terminate. In this case a nonzero value is
785  * returned.
786  *
787  * This method is declared virtual to allow for implementation of
788  * other stopping criteria or using it as callback method within the
789  * Simplex loop, by overriding the method in a derived class.
790  * However, all implementations must terminate with the
791  * statement \c return SPxSolverBase<R>::#terminate(), if no own termination
792  * criteria is encountered.
793  *
794  * Note, that the Simplex loop stopped even when #terminate()
795  * returns 0, if the LP has been solved to optimality (i.e. no
796  * further pricing succeeds and no shift is present).
797  */
798  virtual bool terminate();
799  ///@}
800 
801  //-----------------------------
802  /**@name Control Parameters */
803  ///@{
804  /// values \f$|x| < \epsilon\f$ are considered to be 0.
805  /** if you want another value for epsilon, use
806  * \ref soplex::Param::setEpsilon() "Param::setEpsilon()".
807  */
808  R epsilon() const
809  {
810  return primVec.delta().getEpsilon();
811  }
812  /// feasibility tolerance maintained by ratio test during ENTER algorithm.
813  R entertol() const
814  {
815  assert(m_entertol > 0.0);
816 
817  return m_entertol;
818  }
819  /// feasibility tolerance maintained by ratio test during LEAVE algorithm.
820  R leavetol() const
821  {
822  assert(m_leavetol > 0.0);
823 
824  return m_leavetol;
825  }
826  /// allowed primal feasibility tolerance.
827  R feastol() const
828  {
829  assert(m_entertol > 0.0);
830  assert(m_leavetol > 0.0);
831 
832  return theRep == COLUMN ? m_entertol : m_leavetol;
833  }
834  /// allowed optimality, i.e., dual feasibility tolerance.
835  R opttol() const
836  {
837  assert(m_entertol > 0.0);
838  assert(m_leavetol > 0.0);
839 
840  return theRep == COLUMN ? m_leavetol : m_entertol;
841  }
842  /// guaranteed primal and dual bound violation for optimal solution, returning the maximum of feastol() and opttol(), i.e., the less tight tolerance.
843  R delta() const
844  {
845  assert(m_entertol > 0.0);
846  assert(m_leavetol > 0.0);
847 
848  return m_entertol > m_leavetol ? m_entertol : m_leavetol;
849  }
850  /// set parameter \p feastol.
851  void setFeastol(R d);
852  /// set parameter \p opttol.
853  void setOpttol(R d);
854  /// set parameter \p delta, i.e., set \p feastol and \p opttol to same value.
855  void setDelta(R d);
856  /// set timing type
857  void setTiming(Timer::TYPE ttype)
858  {
859  theTime = TimerFactory::switchTimer(theTime, ttype);
860  multTimeSparse = TimerFactory::switchTimer(multTimeSparse, ttype);
861  multTimeFull = TimerFactory::switchTimer(multTimeFull, ttype);
862  multTimeColwise = TimerFactory::switchTimer(multTimeColwise, ttype);
863  multTimeUnsetup = TimerFactory::switchTimer(multTimeUnsetup, ttype);
864  timerType = ttype;
865  }
866 
867  /// set timing type
869  {
870  assert(timerType == theTime->type());
871  assert(timerType == multTimeSparse->type());
872  assert(timerType == multTimeFull->type());
873  assert(timerType == multTimeColwise->type());
874  assert(timerType == multTimeUnsetup->type());
875  return timerType;
876  }
877 
878  /// set display frequency
879  void setDisplayFreq(int freq)
880  {
881  displayFreq = freq;
882  }
883 
884  /// get display frequency
885  int getDisplayFreq()
886  {
887  return displayFreq;
888  }
889 
890  /// print basis metric within the usual output
891  void setMetricInformation(int type)
892  {
894  }
895 
896  // enable sparse pricing when viols < fac * dim()
897  void setSparsePricingFactor(R fac)
898  {
899  sparsePricingFactor = fac;
900  }
901  /// enable or disable hyper sparse pricing
902  void hyperPricing(bool h);
903 
904  /** SPxSolverBase considers a Simplex step as degenerate if the
905  * steplength does not exceed #epsilon(). Cycling occurs if only
906  * degenerate steps are taken. To prevent this situation, SPxSolverBase
907  * perturbs the problem such that nondegenerate steps are ensured.
908  *
909  * maxCycle() controls how agressive such perturbation is
910  * performed, since no more than maxCycle() degenerate steps are
911  * accepted before perturbing the LP. The current number of consecutive
912  * degenerate steps is counted by numCycle().
913  */
914  /// maximum number of degenerate simplex steps before we detect cycling.
915  int maxCycle() const
916  {
917  return m_maxCycle;
918  }
919  /// actual number of degenerate simplex steps encountered so far.
920  int numCycle() const
921  {
922  return m_numCycle;
923  }
924 
925  /// perturb entire problem or only the bounds relevant to the current pivot
926  void useFullPerturbation(bool full)
927  {
928  fullPerturbation = full;
929  }
930 
931  virtual R getBasisMetric(int type)
932  {
933  return basis().getMatrixMetric(type);
934  }
935 
936  ///@}
937 
938 private:
939 
940  //-----------------------------
941  /**@name Private helpers */
942  ///@{
943  ///
944  void localAddRows(int start);
945  ///
946  void localAddCols(int start);
947  ///
948  void setPrimal(VectorBase<R>& p_vector);
949  ///
950  void setSlacks(VectorBase<R>& p_vector);
951  ///
952  void setDual(VectorBase<R>& p_vector);
953  ///
954  void setRedCost(VectorBase<R>& p_vector);
955  ///@}
956 
957 protected:
958 
959  //-----------------------------
960  /**@name Protected helpers */
961  ///@{
962  ///
963  virtual void addedRows(int n);
964  ///
965  virtual void addedCols(int n);
966  ///
967  virtual void doRemoveRow(int i);
968  ///
969  virtual void doRemoveRows(int perm[]);
970  ///
971  virtual void doRemoveCol(int i);
972  ///
973  virtual void doRemoveCols(int perm[]);
974  ///@}
975 
976 public:
977 
978  //-----------------------------
979  /**@name Modification */
980  /// \p scale determines whether the new data needs to be scaled according to the existing LP (persistent scaling)
981  ///@{
982  ///
983  virtual void changeObj(const VectorBase<R>& newObj, bool scale = false);
984  ///
985  virtual void changeObj(int i, const R& newVal, bool scale = false);
986  ///
987  using SPxLPBase<R>::changeObj; /// overloading a virtual function
988  virtual void changeObj(SPxColId p_id, const R& p_newVal, bool scale = false)
989  {
990  changeObj(this->number(p_id), p_newVal, scale);
991  }
992  ///
993  virtual void changeMaxObj(const VectorBase<R>& newObj, bool scale = false);
994  ///
995  virtual void changeMaxObj(int i, const R& newVal, bool scale = false);
996  ///
997  using SPxLPBase<R>::changeMaxObj; /// overloading a virtual function
998  virtual void changeMaxObj(SPxColId p_id, const R& p_newVal, bool scale = false)
999  {
1000  changeMaxObj(this->number(p_id), p_newVal, scale);
1001  }
1002  ///
1003  virtual void changeRowObj(const VectorBase<R>& newObj, bool scale = false);
1004  ///
1005  virtual void changeRowObj(int i, const R& newVal, bool scale = false);
1006  ///
1008  virtual void changeRowObj(SPxRowId p_id, const R& p_newVal, bool scale = false)
1009  {
1010  changeRowObj(this->number(p_id), p_newVal);
1011  }
1012  ///
1013  virtual void clearRowObjs()
1014  {
1016  unInit();
1017  }
1018  ///
1019  virtual void changeLowerStatus(int i, R newLower, R oldLower = 0.0);
1020  ///
1021  virtual void changeLower(const VectorBase<R>& newLower, bool scale = false);
1022  ///
1023  virtual void changeLower(int i, const R& newLower, bool scale = false);
1024  ///
1026  virtual void changeLower(SPxColId p_id, const R& p_newLower, bool scale = false)
1027  {
1028  changeLower(this->number(p_id), p_newLower, scale);
1029  }
1030  ///
1031  virtual void changeUpperStatus(int i, R newUpper, R oldLower = 0.0);
1032  ///
1033  virtual void changeUpper(const VectorBase<R>& newUpper, bool scale = false);
1034  ///
1035  virtual void changeUpper(int i, const R& newUpper, bool scale = false);
1036  ///
1037  using SPxLPBase<R>::changeUpper; /// overloading virtual function
1038  virtual void changeUpper(SPxColId p_id, const R& p_newUpper, bool scale = false)
1039  {
1040  changeUpper(this->number(p_id), p_newUpper, scale);
1041  }
1042  ///
1043  virtual void changeBounds(const VectorBase<R>& newLower, const VectorBase<R>& newUpper,
1044  bool scale = false);
1045  ///
1046  virtual void changeBounds(int i, const R& newLower, const R& newUpper, bool scale = false);
1047  ///
1049  virtual void changeBounds(SPxColId p_id, const R& p_newLower, const R& p_newUpper,
1050  bool scale = false)
1051  {
1052  changeBounds(this->number(p_id), p_newLower, p_newUpper, scale);
1053  }
1054  ///
1055  virtual void changeLhsStatus(int i, R newLhs, R oldLhs = 0.0);
1056  ///
1057  virtual void changeLhs(const VectorBase<R>& newLhs, bool scale = false);
1058  ///
1059  virtual void changeLhs(int i, const R& newLhs, bool scale = false);
1060  ///
1062  virtual void changeLhs(SPxRowId p_id, const R& p_newLhs, bool scale = false)
1063  {
1064  changeLhs(this->number(p_id), p_newLhs, scale);
1065  }
1066  ///
1067  virtual void changeRhsStatus(int i, R newRhs, R oldRhs = 0.0);
1068  ///
1069  virtual void changeRhs(const VectorBase<R>& newRhs, bool scale = false);
1070  ///
1071  virtual void changeRhs(int i, const R& newRhs, bool scale = false);
1072  ///
1074  virtual void changeRhs(SPxRowId p_id, const R& p_newRhs, bool scale = false)
1075  {
1076  changeRhs(this->number(p_id), p_newRhs, scale);
1077  }
1078  ///
1079  virtual void changeRange(const VectorBase<R>& newLhs, const VectorBase<R>& newRhs,
1080  bool scale = false);
1081  ///
1082  virtual void changeRange(int i, const R& newLhs, const R& newRhs, bool scale = false);
1083  ///
1085  virtual void changeRange(SPxRowId p_id, const R& p_newLhs, const R& p_newRhs, bool scale = false)
1086  {
1087  changeRange(this->number(p_id), p_newLhs, p_newRhs, scale);
1088  }
1089  ///
1090  virtual void changeRow(int i, const LPRowBase<R>& newRow, bool scale = false);
1091  ///
1093  virtual void changeRow(SPxRowId p_id, const LPRowBase<R>& p_newRow, bool scale = false)
1094  {
1095  changeRow(this->number(p_id), p_newRow, scale);
1096  }
1097  ///
1098  virtual void changeCol(int i, const LPColBase<R>& newCol, bool scale = false);
1099  ///
1101  virtual void changeCol(SPxColId p_id, const LPColBase<R>& p_newCol, bool scale = false)
1102  {
1103  changeCol(this->number(p_id), p_newCol, scale);
1104  }
1105  ///
1106  virtual void changeElement(int i, int j, const R& val, bool scale = false);
1107  ///
1109  virtual void changeElement(SPxRowId rid, SPxColId cid, const R& val, bool scale = false)
1110  {
1111  changeElement(this->number(rid), this->number(cid), val, scale);
1112  }
1113  ///
1114  virtual void changeSense(typename SPxLPBase<R>::SPxSense sns);
1115  ///@}
1116 
1117  //------------------------------------
1118  /**@name Dimension and codimension */
1119  ///@{
1120  /// dimension of basis matrix.
1121  int dim() const
1122  {
1123  return thecovectors->num();
1124  }
1125  /// codimension.
1126  int coDim() const
1127  {
1128  return thevectors->num();
1129  }
1130  ///@}
1131 
1132  //------------------------------------
1133  /**@name Variables and Covariables
1134  * Class SPxLPBase<R> introduces \ref soplex::SPxId "SPxIds" to identify
1135  * row or column data of an LP. SPxSolverBase uses this concept to
1136  * access data with respect to the chosen representation.
1137  */
1138  ///@{
1139  /// id of \p i 'th vector.
1140  /** The \p i 'th Id is the \p i 'th SPxRowId for a rowwise and the
1141  * \p i 'th SPxColId for a columnwise basis represenation. Hence,
1142  * 0 <= i < #coDim().
1143  */
1144  SPxId id(int i) const
1145  {
1146  if(rep() == ROW)
1147  {
1148  SPxRowId rid = SPxLPBase<R>::rId(i);
1149  return SPxId(rid);
1150  }
1151  else
1152  {
1153  SPxColId cid = SPxLPBase<R>::cId(i);
1154  return SPxId(cid);
1155  }
1156  }
1157 
1158  /// id of \p i 'th covector.
1159  /** The \p i 'th #coId() is the \p i 'th SPxColId for a rowwise and the
1160  * \p i 'th SPxRowId for a columnwise basis represenation. Hence,
1161  * 0 <= i < #dim().
1162  */
1163  SPxId coId(int i) const
1164  {
1165  if(rep() == ROW)
1166  {
1167  SPxColId cid = SPxLPBase<R>::cId(i);
1168  return SPxId(cid);
1169  }
1170  else
1171  {
1172  SPxRowId rid = SPxLPBase<R>::rId(i);
1173  return SPxId(rid);
1174  }
1175  }
1176 
1177  /// Is \p p_id an SPxId ?
1178  /** This method returns wheather or not \p p_id identifies a vector
1179  * with respect to the chosen representation.
1180  */
1181  bool isId(const SPxId& p_id) const
1182  {
1183  return p_id.info * theRep > 0;
1184  }
1185 
1186  /// Is \p p_id a CoId.
1187  /** This method returns wheather or not \p p_id identifies a coVector
1188  * with respect to the chosen representation.
1189  */
1190  bool isCoId(const SPxId& p_id) const
1191  {
1192  return p_id.info * theRep < 0;
1193  }
1194  ///@}
1195 
1196  //------------------------------------
1197  /**@name Vectors and Covectors */
1198  ///@{
1199  /// \p i 'th vector.
1200  /**@return a reference to the \p i 'th, 0 <= i < #coDim(), vector of
1201  * the loaded LP (with respect to the chosen representation).
1202  */
1203  const SVectorBase<R>& vector(int i) const
1204  {
1205  return (*thevectors)[i];
1206  }
1207 
1208  ///
1209  const SVectorBase<R>& vector(const SPxRowId& rid) const
1210  {
1211  assert(rid.isValid());
1212  return (rep() == ROW)
1213  ? (*thevectors)[this->number(rid)]
1214  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(rid)]);
1215  }
1216  ///
1217  const SVectorBase<R>& vector(const SPxColId& cid) const
1218  {
1219  assert(cid.isValid());
1220  return (rep() == COLUMN)
1221  ? (*thevectors)[this->number(cid)]
1222  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1223  }
1224 
1225  /// VectorBase<R> associated to \p p_id.
1226  /**@return Returns a reference to the VectorBase<R> of the loaded LP corresponding
1227  * to \p id (with respect to the chosen representation). If \p p_id is
1228  * an id, a vector of the constraint matrix is returned, otherwise
1229  * the corresponding unit vector (of the slack variable or bound
1230  * inequality) is returned.
1231  * @todo The implementation does not exactly look like it will do
1232  * what is promised in the describtion.
1233  */
1234  const SVectorBase<R>& vector(const SPxId& p_id) const
1235  {
1236  assert(p_id.isValid());
1237 
1238  return p_id.isSPxRowId()
1239  ? vector(SPxRowId(p_id))
1240  : vector(SPxColId(p_id));
1241  }
1242 
1243  /// \p i 'th covector of LP.
1244  /**@return a reference to the \p i 'th, 0 <= i < #dim(), covector of
1245  * the loaded LP (with respect to the chosen representation).
1246  */
1247  const SVectorBase<R>& coVector(int i) const
1248  {
1249  return (*thecovectors)[i];
1250  }
1251  ///
1252  const SVectorBase<R>& coVector(const SPxRowId& rid) const
1253  {
1254  assert(rid.isValid());
1255  return (rep() == COLUMN)
1256  ? (*thecovectors)[this->number(rid)]
1257  : static_cast<const SVector&>(unitVecs[this->number(rid)]);
1258  }
1259  ///
1260  const SVectorBase<R>& coVector(const SPxColId& cid) const
1261  {
1262  assert(cid.isValid());
1263  return (rep() == ROW)
1264  ? (*thecovectors)[this->number(cid)]
1265  : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1266  }
1267  /// coVector associated to \p p_id.
1268  /**@return a reference to the covector of the loaded LP
1269  * corresponding to \p p_id (with respect to the chosen
1270  * representation). If \p p_id is a coid, a covector of the constraint
1271  * matrix is returned, otherwise the corresponding unit vector is
1272  * returned.
1273  */
1274  const SVectorBase<R>& coVector(const SPxId& p_id) const
1275  {
1276  assert(p_id.isValid());
1277  return p_id.isSPxRowId()
1278  ? coVector(SPxRowId(p_id))
1279  : coVector(SPxColId(p_id));
1280  }
1281  /// return \p i 'th unit vector.
1282  const SVectorBase<R>& unitVector(int i) const
1283  {
1284  return unitVecs[i];
1285  }
1286  ///@}
1287 
1288  //------------------------------------
1289  /**@name Variable status
1290  * The Simplex basis assigns a \ref soplex::SPxBasisBase<R>::Desc::Status
1291  * "Status" to each variable and covariable. Depending on the
1292  * representation, the status indicates that the corresponding
1293  * vector is in the basis matrix or not.
1294  */
1295  ///@{
1296  /// Status of \p i 'th variable.
1297  typename SPxBasisBase<R>::Desc::Status varStatus(int i) const
1298  {
1299  return this->desc().status(i);
1300  }
1301 
1302  /// Status of \p i 'th covariable.
1303  typename SPxBasisBase<R>::Desc::Status covarStatus(int i) const
1304  {
1305  return this->desc().coStatus(i);
1306  }
1307 
1308  /// does \p stat describe a basic index ?
1309  bool isBasic(typename SPxBasisBase<R>::Desc::Status stat) const
1310  {
1311  return (stat * rep() > 0);
1312  }
1313 
1314  /// is the \p p_id 'th vector basic ?
1315  bool isBasic(const SPxId& p_id) const
1316  {
1317  assert(p_id.isValid());
1318  return p_id.isSPxRowId()
1319  ? isBasic(SPxRowId(p_id))
1320  : isBasic(SPxColId(p_id));
1321  }
1322 
1323  /// is the \p rid 'th vector basic ?
1324  bool isBasic(const SPxRowId& rid) const
1325  {
1326  return isBasic(this->desc().rowStatus(this->number(rid)));
1327  }
1328 
1329  /// is the \p cid 'th vector basic ?
1330  bool isBasic(const SPxColId& cid) const
1331  {
1332  return isBasic(this->desc().colStatus(this->number(cid)));
1333  }
1334 
1335  /// is the \p i 'th row vector basic ?
1336  bool isRowBasic(int i) const
1337  {
1338  return isBasic(this->desc().rowStatus(i));
1339  }
1340 
1341  /// is the \p i 'th column vector basic ?
1342  bool isColBasic(int i) const
1343  {
1344  return isBasic(this->desc().colStatus(i));
1345  }
1346 
1347  /// is the \p i 'th vector basic ?
1348  bool isBasic(int i) const
1349  {
1350  return isBasic(this->desc().status(i));
1351  }
1352 
1353  /// is the \p i 'th covector basic ?
1354  bool isCoBasic(int i) const
1355  {
1356  return isBasic(this->desc().coStatus(i));
1357  }
1358  ///@}
1359 
1360  /// feasibility vector.
1361  /** This method return the \em feasibility vector. If it satisfies its
1362  * bound, the basis is called feasible (independently of the chosen
1363  * representation). The feasibility vector has dimension #dim().
1364  *
1365  * For the entering Simplex, #fVec is kept within its bounds. In
1366  * contrast to this, the pricing of the leaving Simplex selects an
1367  * element of #fVec, that violates its bounds.
1368  */
1369  UpdateVector<R>& fVec() const
1370  {
1371  return *theFvec;
1372  }
1373  /// right-hand side vector for \ref soplex::SPxSolverBase<R>::fVec "fVec"
1374  /** The feasibility vector is computed by solving a linear system with the
1375  * basis matrix. The right-hand side vector of this system is referred
1376  * to as \em feasibility, \em right-hand \em side \em vector #fRhs().
1377  *
1378  * For a row basis, #fRhs() is the objective vector (ignoring shifts).
1379  * For a column basis, it is the sum of all nonbasic vectors scaled by
1380  * the factor of their bound.
1381  */
1382  const VectorBase<R>& fRhs() const
1383  {
1384  return *theFrhs;
1385  }
1386  /// upper bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1387  const VectorBase<R>& ubBound() const
1388  {
1389  return theUBbound;
1390  }
1391  /// upper bound for #fVec, writable.
1392  /** This method returns the upper bound for the feasibility vector.
1393  * It may only be called for the #ENTER%ing Simplex.
1394  *
1395  * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1396  * maintained to fullfill its bounds. As #fVec itself, also its
1397  * bounds depend on the chosen representation. Further, they may
1398  * need to be shifted (see below).
1399  */
1401  {
1402  return theUBbound;
1403  }
1404  /// lower bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1405  const VectorBase<R>& lbBound() const
1406  {
1407  return theLBbound;
1408  }
1409  /// lower bound for #fVec, writable.
1410  /** This method returns the lower bound for the feasibility vector.
1411  * It may only be called for the #ENTER%ing Simplex.
1412  *
1413  * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1414  * maintained to fullfill its bounds. As #fVec itself, also its
1415  * bound depend on the chosen representation. Further, they may
1416  * need to be shifted (see below).
1417  */
1419  {
1420  return theLBbound;
1421  }
1422 
1423  /// Violations of \ref soplex::SPxSolverBase<R>::fVec "fVec"
1424  /** For the leaving Simplex algorithm, pricing involves selecting a
1425  * variable from #fVec that violates its bounds that is to leave
1426  * the basis. When a SPxPricer is called to select such a
1427  * leaving variable, #fTest() contains the vector of violations:
1428  * For #fTest()[i] < 0, the \c i 'th basic variable violates one of
1429  * its bounds by the given value. Otherwise no bound is violated.
1430  */
1431  const VectorBase<R>& fTest() const
1432  {
1433  assert(type() == LEAVE);
1434  return theCoTest;
1435  }
1436 
1437  /// copricing vector.
1438  /** The copricing vector #coPvec along with the pricing vector
1439  * #pVec are used for pricing in the #ENTER%ing Simplex algorithm,
1440  * i.e. one variable is selected, that violates its bounds. In
1441  * contrast to this, the #LEAVE%ing Simplex algorithm keeps both
1442  * vectors within their bounds.
1443  */
1444  UpdateVector<R>& coPvec() const
1445  {
1446  return *theCoPvec;
1447  }
1448 
1449  /// Right-hand side vector for \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1450  /** The vector #coPvec is computed by solving a linear system with the
1451  * basis matrix and #coPrhs as the right-hand side vector. For
1452  * column basis representation, #coPrhs is build up of the
1453  * objective vector elements of all basic variables. For a row
1454  * basis, it consists of the tight bounds of all basic
1455  * constraints.
1456  */
1457  const VectorBase<R>& coPrhs() const
1458  {
1459  return *theCoPrhs;
1460  }
1461 
1462  ///
1463  const VectorBase<R>& ucBound() const
1464  {
1465  assert(theType == LEAVE);
1466  return *theCoUbound;
1467  }
1468  /// upper bound for #coPvec.
1469  /** This method returns the upper bound for #coPvec. It may only be
1470  * called for the leaving Simplex algorithm.
1471  *
1472  * For the leaving Simplex algorithms #coPvec is maintained to
1473  * fullfill its bounds. As #coPvec itself, also its bound depend
1474  * on the chosen representation. Further, they may need to be
1475  * shifted (see below).
1476  */
1478  {
1479  assert(theType == LEAVE);
1480  return *theCoUbound;
1481  }
1482 
1483  ///
1484  const VectorBase<R>& lcBound() const
1485  {
1486  assert(theType == LEAVE);
1487  return *theCoLbound;
1488  }
1489  /// lower bound for #coPvec.
1490  /** This method returns the lower bound for #coPvec. It may only be
1491  * called for the leaving Simplex algorithm.
1492  *
1493  * For the leaving Simplex algorithms #coPvec is maintained to
1494  * fullfill its bounds. As #coPvec itself, also its bound depend
1495  * on the chosen representation. Further, they may need to be
1496  * shifted (see below).
1497  */
1499  {
1500  assert(theType == LEAVE);
1501  return *theCoLbound;
1502  }
1503 
1504  /// violations of \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1505  /** In entering Simplex pricing selects checks vectors #coPvec()
1506  * and #pVec() for violation of its bounds. #coTest() contains
1507  * the violations for #coPvec() which are indicated by a negative
1508  * value. That is, if #coTest()[i] < 0, the \p i 'th element of #coPvec()
1509  * is violated by -#coTest()[i].
1510  */
1511  const VectorBase<R>& coTest() const
1512  {
1513  assert(type() == ENTER);
1514  return theCoTest;
1515  }
1516  /// pricing vector.
1517  /** The pricing vector #pVec is the product of #coPvec with the
1518  * constraint matrix. As #coPvec, also #pVec is maintained within
1519  * its bound for the leaving Simplex algorithm, while the bounds
1520  * are tested for the entering Simplex. #pVec is of dimension
1521  * #coDim(). Vector #pVec() is only up to date for #LEAVE%ing
1522  * Simplex or #FULL pricing in #ENTER%ing Simplex.
1523  */
1524  UpdateVector<R>& pVec() const
1525  {
1526  return *thePvec;
1527  }
1528  ///
1529  const VectorBase<R>& upBound() const
1530  {
1531  assert(theType == LEAVE);
1532  return *theUbound;
1533  }
1534  /// upper bound for #pVec.
1535  /** This method returns the upper bound for #pVec. It may only be
1536  * called for the leaving Simplex algorithm.
1537  *
1538  * For the leaving Simplex algorithms #pVec is maintained to
1539  * fullfill its bounds. As #pVec itself, also its bound depend
1540  * on the chosen representation. Further, they may need to be
1541  * shifted (see below).
1542  */
1544  {
1545  assert(theType == LEAVE);
1546  return *theUbound;
1547  }
1548 
1549  ///
1550  const VectorBase<R>& lpBound() const
1551  {
1552  assert(theType == LEAVE);
1553  return *theLbound;
1554  }
1555  /// lower bound for #pVec.
1556  /** This method returns the lower bound for #pVec. It may only be
1557  * called for the leaving Simplex algorithm.
1558  *
1559  * For the leaving Simplex algorithms #pVec is maintained to
1560  * fullfill its bounds. As #pVec itself, also its bound depend
1561  * on the chosen representation. Further, they may need to be
1562  * shifted (see below).
1563  */
1565  {
1566  assert(theType == LEAVE);
1567  return *theLbound;
1568  }
1569 
1570  /// Violations of \ref soplex::SPxSolverBase<R>::pVec "pVec".
1571  /** In entering Simplex pricing selects checks vectors #coPvec()
1572  * and #pVec() for violation of its bounds. Vector #test()
1573  * contains the violations for #pVec(), i.e., if #test()[i] < 0,
1574  * the i'th element of #pVec() is violated by #test()[i].
1575  * Vector #test() is only up to date for #FULL pricing.
1576  */
1577  const VectorBase<R>& test() const
1578  {
1579  assert(type() == ENTER);
1580  return theTest;
1581  }
1582 
1583  /// compute and return \ref soplex::SPxSolverBase<R>::pVec() "pVec()"[i].
1584  R computePvec(int i);
1585  /// compute entire \ref soplex::SPxSolverBase<R>::pVec() "pVec()".
1586  void computePvec();
1587  /// compute and return \ref soplex::SPxSolverBase<R>::test() "test()"[i] in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1588  R computeTest(int i);
1589  /// compute test VectorBase<R> in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1590  void computeTest();
1591 
1592  //------------------------------------
1593  /**@name Shifting
1594  * The task of the ratio test (implemented in SPxRatioTester classes)
1595  * is to select a variable for the basis update, such that the basis
1596  * remains priced (i.e. both, the pricing and copricing vectors satisfy
1597  * their bounds) or feasible (i.e. the feasibility vector satisfies its
1598  * bounds). However, this can lead to numerically instable basis matrices
1599  * or -- after accumulation of various errors -- even to a singular basis
1600  * matrix.
1601  *
1602  * The key to overcome this problem is to allow the basis to become "a
1603  * bit" infeasible or unpriced, in order provide a better choice for the
1604  * ratio test to select a stable variable. This is equivalent to enlarging
1605  * the bounds by a small amount. This is referred to as \em shifting.
1606  *
1607  * These methods serve for shifting feasibility bounds, either in order
1608  * to maintain numerical stability or initially for computation of
1609  * phase 1. The sum of all shifts applied to any bound is stored in
1610  * \ref soplex::SPxSolverBase<R>::theShift "theShift".
1611  *
1612  * The following methods are used to shift individual bounds. They are
1613  * mainly intended for stable implenentations of SPxRatioTester.
1614  */
1615  ///@{
1616  /// Perform initial shifting to optain an feasible or pricable basis.
1617  void shiftFvec();
1618  /// Perform initial shifting to optain an feasible or pricable basis.
1619  void shiftPvec();
1620 
1621  /// shift \p i 'th \ref soplex::SPxSolver::ubBound "ubBound" to \p to.
1622  void shiftUBbound(int i, R to)
1623  {
1624  assert(theType == ENTER);
1625  // use maximum to not count tightened bounds in case of equality shifts
1626  theShift += MAXIMUM(to - theUBbound[i], 0.0);
1627  theUBbound[i] = to;
1628  }
1629  /// shift \p i 'th \ref soplex::SPxSolver::lbBound "lbBound" to \p to.
1630  void shiftLBbound(int i, R to)
1631  {
1632  assert(theType == ENTER);
1633  // use maximum to not count tightened bounds in case of equality shifts
1634  theShift += MAXIMUM(theLBbound[i] - to, 0.0);
1635  theLBbound[i] = to;
1636  }
1637  /// shift \p i 'th \ref soplex::SPxSolver::upBound "upBound" to \p to.
1638  void shiftUPbound(int i, R to)
1639  {
1640  assert(theType == LEAVE);
1641  // use maximum to not count tightened bounds in case of equality shifts
1642  theShift += MAXIMUM(to - (*theUbound)[i], 0.0);
1643  (*theUbound)[i] = to;
1644  }
1645  /// shift \p i 'th \ref soplex::SPxSolver::lpBound "lpBound" to \p to.
1646  void shiftLPbound(int i, R to)
1647  {
1648  assert(theType == LEAVE);
1649  // use maximum to not count tightened bounds in case of equality shifts
1650  theShift += MAXIMUM((*theLbound)[i] - to, 0.0);
1651  (*theLbound)[i] = to;
1652  }
1653  /// shift \p i 'th \ref soplex::SPxSolver::ucBound "ucBound" to \p to.
1654  void shiftUCbound(int i, R to)
1655  {
1656  assert(theType == LEAVE);
1657  // use maximum to not count tightened bounds in case of equality shifts
1658  theShift += MAXIMUM(to - (*theCoUbound)[i], 0.0);
1659  (*theCoUbound)[i] = to;
1660  }
1661  /// shift \p i 'th \ref soplex::SPxSolver::lcBound "lcBound" to \p to.
1662  void shiftLCbound(int i, R to)
1663  {
1664  assert(theType == LEAVE);
1665  // use maximum to not count tightened bounds in case of equality shifts
1666  theShift += MAXIMUM((*theCoLbound)[i] - to, 0.0);
1667  (*theCoLbound)[i] = to;
1668  }
1669  ///
1670  void testBounds() const;
1671 
1672  /// total current shift amount.
1673  virtual R shift() const
1674  {
1675  return theShift;
1676  }
1677  /// remove shift as much as possible.
1678  virtual void unShift(void);
1679 
1680  /// get violation of constraints.
1681  virtual void qualConstraintViolation(R& maxviol, R& sumviol) const;
1682  /// get violations of bounds.
1683  virtual void qualBoundViolation(R& maxviol, R& sumviol) const;
1684  /// get the residuum |Ax-b|.
1685  virtual void qualSlackViolation(R& maxviol, R& sumviol) const;
1686  /// get violation of optimality criterion.
1687  virtual void qualRedCostViolation(R& maxviol, R& sumviol) const;
1688  ///@}
1689 
1690 private:
1691 
1692  //------------------------------------
1693  /**@name Perturbation */
1694  ///@{
1695  ///
1696  void perturbMin(
1697  const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1698  int start = 0, int incr = 1);
1699  ///
1700  void perturbMax(
1701  const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1702  int start = 0, int incr = 1);
1703  ///
1704  R perturbMin(const UpdateVector<R>& uvec,
1705  VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1706  const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1707  ///
1708  R perturbMax(const UpdateVector<R>& uvec,
1709  VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1710  const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1711  ///@}
1712 
1713  //------------------------------------
1714  /**@name The Simplex Loop
1715  * We now present a set of methods that may be usefull when implementing
1716  * own SPxPricer or SPxRatioTester classes. Here is, how
1717  * SPxSolverBase will call methods from its loaded SPxPricer and
1718  * SPxRatioTester.
1719  *
1720  * For the entering Simplex:
1721  * -# \ref soplex::SPxPricer::selectEnter() "SPxPricer::selectEnter()"
1722  * -# \ref soplex::SPxRatioTester::selectLeave() "SPxRatioTester::selectLeave()"
1723  * -# \ref soplex::SPxPricer::entered4() "SPxPricer::entered4()"
1724  *
1725  * For the leaving Simplex:
1726  * -# \ref soplex::SPxPricer::selectLeave() "SPxPricer::selectLeave()"
1727  * -# \ref soplex::SPxRatioTester::selectEnter() "SPxRatioTester::selectEnter()"
1728  * -# \ref soplex::SPxPricer::left4() "SPxPricer::left4()"
1729  */
1730  ///@{
1731 public:
1732  /// Setup vectors to be solved within Simplex loop.
1733  /** Load vector \p y to be #solve%d with the basis matrix during the
1734  * #LEAVE Simplex. The system will be solved after #SPxSolverBase%'s call
1735  * to SPxRatioTester. The system will be solved along with
1736  * another system. Solving two linear system at a time has
1737  * performance advantages over solving the two linear systems
1738  * seperately.
1739  */
1740  void setup4solve(SSVectorBase<R>* p_y, SSVectorBase<R>* p_rhs)
1741  {
1742  assert(type() == LEAVE);
1743  solveVector2 = p_y;
1744  solveVector2rhs = p_rhs;
1745  }
1746  /// Setup vectors to be solved within Simplex loop.
1747  /** Load a second additional vector \p y2 to be #solve%d with the
1748  * basis matrix during the #LEAVE Simplex. The system will be
1749  * solved after #SPxSolverBase%'s call to SPxRatioTester.
1750  * The system will be solved along with at least one
1751  * other system. Solving several linear system at a time has
1752  * performance advantages over solving them seperately.
1753  */
1754  void setup4solve2(SSVectorBase<R>* p_y2, SSVectorBase<R>* p_rhs2)
1755  {
1756  assert(type() == LEAVE);
1757  solveVector3 = p_y2;
1758  solveVector3rhs = p_rhs2;
1759  }
1760  /// Setup vectors to be cosolved within Simplex loop.
1761  /** Load vector \p y to be #coSolve%d with the basis matrix during
1762  * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1763  * call to SPxRatioTester. The system will be solved along
1764  * with another system. Solving two linear system at a time has
1765  * performance advantages over solving the two linear systems
1766  * seperately.
1767  */
1768  void setup4coSolve(SSVectorBase<R>* p_y, SSVectorBase<R>* p_rhs)
1769  {
1770  assert(type() == ENTER);
1771  coSolveVector2 = p_y;
1772  coSolveVector2rhs = p_rhs;
1773  }
1774  /// Setup vectors to be cosolved within Simplex loop.
1775  /** Load a second vector \p z to be #coSolve%d with the basis matrix during
1776  * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1777  * call to SPxRatioTester. The system will be solved along
1778  * with two other systems.
1779  */
1781  {
1782  assert(type() == ENTER);
1783  coSolveVector3 = p_z;
1784  coSolveVector3rhs = p_rhs;
1785  }
1786 
1787  /// maximal infeasibility of basis
1788  /** This method is called before concluding optimality. Since it is
1789  * possible that some stable implementation of class
1790  * SPxRatioTester yielded a slightly infeasible (or unpriced)
1791  * basis, this must be checked before terminating with an optimal
1792  * solution.
1793  */
1794  virtual R maxInfeas() const;
1795 
1796  /// check for violations above tol and immediately return false w/o checking the remaining values
1797  /** This method is useful for verifying whether an objective limit can be used as termination criterion
1798  */
1799  virtual bool noViols(R tol) const;
1800 
1801  /// Return current basis.
1802  /**@note The basis can be used to solve linear systems or use
1803  * any other of its (const) methods. It is, however, encuraged
1804  * to use methods #setup4solve() and #setup4coSolve() for solving
1805  * systems, since this is likely to have perfomance advantages.
1806  */
1807  const SPxBasisBase<R>& basis() const
1808  {
1809  return *this;
1810  }
1811  ///
1813  {
1814  return *this;
1815  }
1816  /// return loaded SPxPricer.
1817  const SPxPricer<R>* pricer() const
1818  {
1819  return thepricer;
1820  }
1821  /// return loaded SLinSolver.
1822  const SLinSolver<R>* slinSolver() const
1823  {
1825  }
1826  /// return loaded SPxRatioTester.
1827  const SPxRatioTester<R>* ratiotester() const
1828  {
1830  }
1831 
1832  /// Factorize basis matrix.
1833  /// @throw SPxStatusException if loaded matrix is singular
1834  virtual void factorize();
1835 
1836 private:
1837 
1838  /** let index \p i leave the basis and manage entering of another one.
1839  @returns \c false if LP is unbounded/infeasible. */
1840  bool leave(int i, bool polish = false);
1841  /** let id enter the basis and manage leaving of another one.
1842  @returns \c false if LP is unbounded/infeasible. */
1843  bool enter(SPxId& id, bool polish = false);
1844 
1845  /// test coVector \p i with status \p stat.
1846  R coTest(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1847  /// compute coTest vector.
1848  void computeCoTest();
1849  /// recompute coTest vector.
1850  void updateCoTest();
1851 
1852  /// test VectorBase<R> \p i with status \p stat.
1853  R test(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1854  /// recompute test vector.
1855  void updateTest();
1856 
1857  /// compute basis feasibility test vector.
1858  void computeFtest();
1859  /// update basis feasibility test vector.
1860  void updateFtest();
1861 
1862  ///@}
1863 
1864  //------------------------------------
1865  /**@name Parallelization
1866  * In this section we present the methods, that are provided in order to
1867  * allow a parallel version to be implemented as a derived class, thereby
1868  * inheriting most of the code of SPxSolverBase.
1869  *
1870  * @par Initialization
1871  * These methods are used to setup all the vectors used in the Simplex
1872  * loop, that where described in the previous sectios.
1873  */
1874  ///@{
1875 public:
1876  /// intialize data structures.
1877  /** If SPxSolverBase is not \ref isInitialized() "initialized", the method
1878  * #solve() calls #init() to setup all vectors and internal data structures.
1879  * Most of the other methods within this section are called by #init().
1880  *
1881  * Derived classes should add the initialization of additional
1882  * data structures by overriding this method. Don't forget,
1883  * however, to call SPxSolverBase<R>::init().
1884  */
1885  virtual void init();
1886 
1887 protected:
1888 
1889  /// has the internal data been initialized?
1890  /** As long as an instance of SPxSolverBase is not initialized, no member
1891  * contains setup data. Initialization is performed via method
1892  * #init(). Afterwards all data structures are kept up to date (even
1893  * for all manipulation methods), until #unInit() is called. However,
1894  * some manipulation methods call #unInit() themselfs.
1895  */
1896  bool isInitialized() const
1897  {
1898  return initialized;
1899  }
1900 
1901  /// resets clock average statistics
1902  void resetClockStats();
1903 
1904  /// uninitialize data structures.
1905  virtual void unInit()
1906  {
1907  initialized = false;
1908  }
1909  /// setup all vecs fresh
1910  virtual void reinitializeVecs();
1911  /// reset dimensions of vectors according to loaded LP.
1912  virtual void reDim();
1913  /// compute feasibility vector from scratch.
1914  void computeFrhs();
1915  ///
1916  virtual void computeFrhsXtra();
1917  ///
1918  virtual void computeFrhs1(const VectorBase<R>&, const VectorBase<R>&);
1919  ///
1921  /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for entering Simplex.
1922  virtual void computeEnterCoPrhs();
1923  ///
1924  void computeEnterCoPrhs4Row(int i, int n);
1925  ///
1926  void computeEnterCoPrhs4Col(int i, int n);
1927  /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for leaving Simplex.
1928  virtual void computeLeaveCoPrhs();
1929  ///
1930  void computeLeaveCoPrhs4Row(int i, int n);
1931  ///
1932  void computeLeaveCoPrhs4Col(int i, int n);
1933 
1934  /// Compute part of objective value.
1935  /** This method is called from #value() in order to compute the part of
1936  * the objective value resulting form nonbasic variables for #COLUMN
1937  * Representation.
1938  */
1939  R nonbasicValue();
1940 
1941  /// Get pointer to the \p id 'th vector
1942  virtual const SVectorBase<R>* enterVector(const SPxId& p_id)
1943  {
1944  assert(p_id.isValid());
1945  return p_id.isSPxRowId()
1946  ? &vector(SPxRowId(p_id)) : &vector(SPxColId(p_id));
1947  }
1948  ///
1949  virtual void getLeaveVals(int i,
1950  typename SPxBasisBase<R>::Desc::Status& leaveStat, SPxId& leaveId,
1951  R& leaveMax, R& leavebound, int& leaveNum, StableSum<R>& objChange);
1952  ///
1953  virtual void getLeaveVals2(R leaveMax, SPxId enterId,
1954  R& enterBound, R& newUBbound,
1955  R& newLBbound, R& newCoPrhs, StableSum<R>& objChange);
1956  ///
1957  virtual void getEnterVals(SPxId id, R& enterTest,
1958  R& enterUB, R& enterLB, R& enterVal, R& enterMax,
1959  R& enterPric, typename SPxBasisBase<R>::Desc::Status& enterStat, R& enterRO,
1960  StableSum<R>& objChange);
1961  ///
1962  virtual void getEnterVals2(int leaveIdx,
1963  R enterMax, R& leaveBound, StableSum<R>& objChange);
1964  ///
1965  virtual void ungetEnterVal(SPxId enterId, typename SPxBasisBase<R>::Desc::Status enterStat,
1966  R leaveVal, const SVectorBase<R>& vec, StableSum<R>& objChange);
1967  ///
1968  virtual void rejectEnter(SPxId enterId,
1969  R enterTest, typename SPxBasisBase<R>::Desc::Status enterStat);
1970  ///
1971  virtual void rejectLeave(int leaveNum, SPxId leaveId,
1972  typename SPxBasisBase<R>::Desc::Status leaveStat, const SVectorBase<R>* newVec = 0);
1973  ///
1974  virtual void setupPupdate(void);
1975  ///
1976  virtual void doPupdate(void);
1977  ///
1978  virtual void clearUpdateVecs(void);
1979  ///
1980  virtual void perturbMinEnter(void);
1981  /// perturb basis bounds.
1982  virtual void perturbMaxEnter(void);
1983  ///
1984  virtual void perturbMinLeave(void);
1985  /// perturb nonbasic bounds.
1986  virtual void perturbMaxLeave(void);
1987  ///@}
1988 
1989  //------------------------------------
1990  /** The following methods serve for initializing the bounds for dual or
1991  * primal Simplex algorithm of entering or leaving type.
1992  */
1993  ///@{
1994  ///
1995  void clearDualBounds(typename SPxBasisBase<R>::Desc::Status, R&, R&) const;
1996  ///
1997  void setDualColBounds();
1998  ///
1999  void setDualRowBounds();
2000  /// setup feasibility bounds for entering algorithm
2001  void setPrimalBounds();
2002  ///
2003  void setEnterBound4Col(int, int);
2004  ///
2005  void setEnterBound4Row(int, int);
2006  ///
2007  virtual void setEnterBounds();
2008  ///
2009  void setLeaveBound4Row(int i, int n);
2010  ///
2011  void setLeaveBound4Col(int i, int n);
2012  ///
2013  virtual void setLeaveBounds();
2014  ///@}
2015 
2016  //------------------------------------
2017  /** Compute the primal ray or the farkas proof in case of unboundedness
2018  * or infeasibility.
2019  */
2020  ///@{
2021  ///
2022  void computePrimalray4Col(R direction, SPxId enterId);
2023  ///
2024  void computePrimalray4Row(R direction);
2025  ///
2026  void computeDualfarkas4Col(R direction);
2027  ///
2028  void computeDualfarkas4Row(R direction, SPxId enterId);
2029  ///@}
2030 
2031 public:
2032 
2033  //------------------------------------
2034  /** Limits and status inquiry */
2035  ///@{
2036  /// set time limit.
2037  virtual void setTerminationTime(Real time = infinity);
2038  /// return time limit.
2039  virtual Real terminationTime() const;
2040  /// set iteration limit.
2041  virtual void setTerminationIter(int iteration = -1);
2042  /// return iteration limit.
2043  virtual int terminationIter() const;
2044  /// set objective limit.
2045  virtual void setTerminationValue(R value = R(infinity));
2046  /// return objective limit.
2047  virtual R terminationValue() const;
2048  /// get objective value of current solution.
2049  virtual R objValue()
2050  {
2051  return value();
2052  }
2053  /// get all results of last solve.
2054  Status
2055  getResult(R* value = 0, VectorBase<R>* primal = 0,
2056  VectorBase<R>* slacks = 0, VectorBase<R>* dual = 0,
2057  VectorBase<R>* reduCost = 0);
2058 
2059 protected:
2060 
2061  /**@todo put the following basis methods near the variable status methods!*/
2062  /// converts basis status to VarStatus
2064 
2065  /// converts VarStatus to basis status for rows
2067  const;
2068 
2069  /// converts VarStatus to basis status for columns
2071  const;
2072 
2073 public:
2074 
2075  /// gets basis status for a single row
2076  VarStatus getBasisRowStatus(int row) const;
2077 
2078  /// gets basis status for a single column
2079  VarStatus getBasisColStatus(int col) const;
2080 
2081  /// get current basis, and return solver status.
2082  Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize = -1,
2083  const int colsSize = -1) const;
2084 
2085  /// gets basis status
2087  {
2089  }
2090 
2091  /// check a given basis for validity.
2093 
2094  /// set the lp solver's basis.
2095  void setBasis(const VarStatus rows[], const VarStatus cols[]);
2096 
2097  /// set the lp solver's basis status.
2098  void setBasisStatus(typename SPxBasisBase<R>::SPxStatus stat)
2099  {
2100  if(m_status == OPTIMAL)
2101  m_status = UNKNOWN;
2102 
2104  }
2105 
2106  /// setting the solver status external from the solve loop.
2107  void setSolverStatus(typename SPxSolverBase<R>::Status stat)
2108  {
2109  m_status = stat;
2110  }
2111 
2112  /// get level of dual degeneracy
2113  // this function is used for the improved dual simplex
2114  R getDegeneracyLevel(VectorBase<R> degenvec);
2115 
2116  /// get number of dual norms
2117  void getNdualNorms(int& nnormsRow, int& nnormsCol) const;
2118 
2119  /// get dual norms
2120  bool getDualNorms(int& nnormsRow, int& nnormsCol, R* norms) const;
2121 
2122  /// set dual norms
2123  bool setDualNorms(int nnormsRow, int nnormsCol, R* norms);
2124 
2125  /// pass integrality information about the variables to the solver
2126  void setIntegralityInformation(int ncols, int* intInfo);
2127 
2128  /// reset cumulative time counter to zero.
2129  void resetCumulativeTime()
2130  {
2131  theCumulativeTime = 0.0;
2132  }
2133 
2134  /// get number of bound flips.
2135  int boundFlips() const
2136  {
2138  }
2139 
2140  /// get number of dual degenerate pivots
2141  int dualDegeneratePivots()
2142  {
2143  return (rep() == ROW) ? enterCycles : leaveCycles;
2144  }
2145 
2146  /// get number of primal degenerate pivots
2148  {
2149  return (rep() == ROW) ? leaveCycles : enterCycles;
2150  }
2151 
2152  /// get the sum of dual degeneracy
2153  R sumDualDegeneracy()
2154  {
2156  }
2157 
2158  /// get the sum of primal degeneracy
2160  {
2162  }
2163 
2164  /// get number of iterations of current solution.
2165  int iterations() const
2166  {
2167  return basis().iteration();
2168  }
2169 
2170  /// return number of iterations done with primal algorithm
2171  int primalIterations()
2172  {
2173  assert(iterations() == 0 || primalCount <= iterations());
2174  return (iterations() == 0) ? 0 : primalCount;
2175  }
2176 
2177  /// return number of iterations done with primal algorithm
2178  int dualIterations()
2179  {
2181  }
2182 
2183  /// return number of iterations done with primal algorithm
2184  int polishIterations()
2185  {
2186  return polishCount;
2187  }
2188 
2189  /// time spent in last call to method solve().
2190  Real time() const
2191  {
2192  return theTime->time();
2193  }
2194 
2195  /// returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
2196  ///
2197  bool isTimeLimitReached(const bool forceCheck = false);
2198 
2199  /// the maximum runtime
2200  Real getMaxTime()
2201  {
2202  return maxTime;
2203  }
2204 
2205  /// cumulative time spent in all calls to method solve().
2206  Real cumulativeTime() const
2207  {
2209  }
2210 
2211  /// the maximum number of iterations
2212  int getMaxIters()
2213  {
2214  return maxIters;
2215  }
2216 
2217  /// return const lp's rows if available.
2218  const LPRowSetBase<R>& rows() const
2219  {
2220  return *this->lprowset();
2221  }
2222 
2223  /// return const lp's cols if available.
2224  const LPColSet& cols() const
2225  {
2226  return *this->lpcolset();
2227  }
2228 
2229  /// copy lower bound VectorBase<R> to \p p_low.
2230  void getLower(VectorBase<R>& p_low) const
2231  {
2233  }
2234  /// copy upper bound VectorBase<R> to \p p_up.
2235  void getUpper(VectorBase<R>& p_up) const
2236  {
2238  }
2239 
2240  /// copy lhs value VectorBase<R> to \p p_lhs.
2241  void getLhs(VectorBase<R>& p_lhs) const
2242  {
2244  }
2245 
2246  /// copy rhs value VectorBase<R> to \p p_rhs.
2247  void getRhs(VectorBase<R>& p_rhs) const
2248  {
2250  }
2251 
2252  /// optimization sense.
2253  typename SPxLPBase<R>::SPxSense sense() const
2254  {
2255  return this->spxSense();
2256  }
2257 
2258  /// returns statistical information in form of a string.
2259  std::string statistics() const
2260  {
2261  std::stringstream s;
2262  s << basis().statistics()
2263  << "Solution time : " << std::setw(10) << std::fixed << std::setprecision(
2264  2) << time() << std::endl
2265  << "Iterations : " << std::setw(10) << iterations() << std::endl;
2266 
2267  return s.str();
2268  }
2269 
2270  /// returns whether a basis needs to be found for the improved dual simplex
2272  {
2273  if(getStartingDecompBasis)
2274  return FINDSTARTBASIS;
2275  else
2276  return DONTFINDSTARTBASIS;
2277  }
2278 
2279  /// sets whether the degeneracy is computed at each iteration
2280  void setComputeDegenFlag(bool computeDegen)
2281  {
2282  computeDegeneracy = computeDegen;
2283  }
2284 
2285 
2286  /// returns whether the degeneracy is computed in each iteration
2287  bool getComputeDegeneracy() const
2288  {
2290  }
2291 
2292 
2293  /// sets the offset for the number of iterations before the degeneracy is computed
2294  void setDegenCompOffset(int iterOffset)
2295  {
2296  degenCompIterOffset = iterOffset;
2297  }
2298 
2299 
2300  /// gets the offset for the number of iterations before the degeneracy is computed
2301  int getDegenCompOffset() const
2302  {
2304  }
2305 
2306  /// sets the iteration limit for the decomposition simplex initialisation
2307  void setDecompIterationLimit(int iterationLimit)
2308  {
2309  decompIterationLimit = iterationLimit;
2310  }
2311 
2312  /// returns the iteration limit for the decomposition simplex initialisation
2313  int getDecompIterationLimit() const
2314  {
2316  }
2317  ///@}
2318 
2319  //------------------------------------
2320  /** Mapping between numbers and Ids */
2321  ///@{
2322  /// RowId of \p i 'th inequality.
2323  SPxRowId rowId(int i) const
2324  {
2325  return this->rId(i);
2326  }
2327  /// ColId of \p i 'th column.
2328  SPxColId colId(int i) const
2329  {
2330  return this->cId(i);
2331  }
2332  ///@}
2333 
2334  //------------------------------------
2335  /** Constructors / destructors */
2336  ///@{
2337  /// default constructor.
2338  explicit
2339  SPxSolverBase(Type type = LEAVE,
2341  Timer::TYPE ttype = Timer::USER_TIME);
2342  // virtual destructor
2343  virtual ~SPxSolverBase();
2344  ///@}
2345 
2346  //------------------------------------
2347  /** Miscellaneous */
2348  ///@{
2349  /// check consistency.
2350  bool isConsistent() const;
2351  ///@}
2352 
2353  //------------------------------------
2354  /** assignment operator and copy constructor */
2355  ///@{
2356  /// assignment operator
2358  /// copy constructor
2359  SPxSolverBase(const SPxSolverBase<R>& base);
2360  ///@}
2361 
2362  void testVecs();
2363 };
2364 
2365 //
2366 // Auxiliary functions.
2367 //
2368 
2369 /// Pretty-printing of variable status.
2370 template <class R>
2371 std::ostream& operator<<(std::ostream& os,
2372  const typename SPxSolverBase<R>::VarStatus& status);
2373 
2374 /// Pretty-printing of solver status.
2375 template <class R>
2376 std::ostream& operator<<(std::ostream& os,
2377  const typename SPxSolverBase<R>::Status& status);
2378 
2379 /// Pretty-printing of algorithm.
2380 template <class R>
2381 std::ostream& operator<<(std::ostream& os,
2382  const typename SPxSolverBase<R>::Type& status);
2383 
2384 /// Pretty-printing of representation.
2385 template <class R>
2386 std::ostream& operator<<(std::ostream& os,
2387  const typename SPxSolverBase<R>::Representation& status);
2388 
2389 /* For Backwards compatibility */
2391 
2392 } // namespace soplex
2393 
2394 // For general templated functions
2395 #include "spxsolver.hpp"
2396 #include "spxsolve.hpp"
2397 #include "changesoplex.hpp"
2398 #include "leave.hpp"
2399 #include "enter.hpp"
2400 #include "spxshift.hpp"
2401 #include "spxbounds.hpp"
2402 #include "spxchangebasis.hpp"
2403 #include "spxvecs.hpp"
2404 #include "spxwritestate.hpp"
2405 #include "spxfileio.hpp"
2406 #include "spxquality.hpp"
2407 
2408 #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:1028
R sumDualDegeneracy()
get the sum of dual degeneracy
Definition: spxsolver.h:2155
void setup4solve(SSVectorBase< R > *p_y, SSVectorBase< R > *p_rhs)
Setup vectors to be solved within Simplex loop.
Definition: spxsolver.h:1742
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:1205
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:2180
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:1183
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:2330
void resetCumulativeTime()
reset cumulative time counter to zero.
Definition: spxsolver.h:2131
R epsilon() const
values are considered to be 0.
Definition: spxsolver.h:810
const SPxRatioTester< R > * ratiotester() const
return loaded SPxRatioTester.
Definition: spxsolver.h:1829
SPxPricer< R > * thepricer
Definition: spxsolver.h:415
void shiftUPbound(int i, R to)
shift i &#39;th upBound to to.
Definition: spxsolver.h:1640
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:2289
const VectorBase< R > & coPrhs() const
Right-hand side vector for coPvec.
Definition: spxsolver.h:1459
UpdateVector< R > & fVec() const
feasibility vector.
Definition: spxsolver.h:1371
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:2192
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:1675
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:1465
void computeLeaveCoPrhs4Row(int i, int n)
virtual void changeRow(SPxRowId p_id, const LPRowBase< R > &p_newRow, bool scale=false)
Definition: spxsolver.h:1095
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:1624
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:1311
SPxSolverBase< Real > SPxSolver
Definition: spxsolver.h:2392
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:1446
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:2149
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:83
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:2249
const VectorBase< R > & lcBound() const
Definition: spxsolver.h:1486
SPxRatioTester< R > * theratiotester
Definition: spxsolver.h:416
void invalidateBasis()
invalidates the basis, triggers refactorization
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:1756
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:2220
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:2103
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:1579
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:2309
int dualDegeneratePivots()
get number of dual degenerate pivots
Definition: spxsolver.h:2143
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:859
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:1103
const VectorBase< R > & ubBound() const
upper bound for fVec.
Definition: spxsolver.h:1389
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:815
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:1632
virtual const SVectorBase< R > * enterVector(const SPxId &p_id)
Get pointer to the id &#39;th vector.
Definition: spxsolver.h:1944
R theShift
sum of all shifts applied to any bound.
Definition: spxsolver.h:281
virtual void unInit()
uninitialize data structures.
Definition: spxsolver.h:1907
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:1898
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:899
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:922
void shiftUCbound(int i, R to)
shift i &#39;th ucBound to to.
Definition: spxsolver.h:1656
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:2273
const SPxPricer< R > * pricer() const
return loaded SPxPricer.
Definition: spxsolver.h:1819
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:1384
void setSolverStatus(typename SPxSolverBase< R >::Status stat)
setting the solver status external from the solve loop.
Definition: spxsolver.h:2109
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:2303
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:256
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:284
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:1305
SPxId coId(int i) const
id of i &#39;th covector.
Definition: spxsolver.h:1165
const VectorBase< R > & fTest() const
Violations of fVec.
Definition: spxsolver.h:1433
void setMetricInformation(int type)
print basis metric within the usual output
Definition: spxsolver.h:893
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:928
const SPxBasisBase< R > & basis() const
Return current basis.
Definition: spxsolver.h:1809
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:2051
solve() aborted to exit decomposition simplex
Definition: spxsolver.h:220
Timer::TYPE getTiming()
set timing type
Definition: spxsolver.h:870
void computeCoTest()
compute coTest vector.
void shiftLPbound(int i, R to)
shift i &#39;th lpBound to to.
Definition: spxsolver.h:1648
const VectorBase< R > & coTest() const
violations of coPvec.
Definition: spxsolver.h:1513
virtual void changeRhs(SPxRowId p_id, const R &p_newRhs, bool scale=false)
Definition: spxsolver.h:1076
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:2261
int polishIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2186
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:2161
int multColwiseCalls
number of products, columnwise multiplication
Definition: spxsolver.h:483
const VectorBase< R > & lpBound() const
Definition: spxsolver.h:1552
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:822
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:1111
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:1344
void forceRecompNonbasicValue()
Definition: spxsolver.h:696
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:1326
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:1782
virtual Real time() const =0
UpdateVector< R > & pVec() const
pricing vector.
Definition: spxsolver.h:1526
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:837
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:1015
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:933
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:917
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:2137
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:1338
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:1192
R delta() const
guaranteed primal and dual bound violation for optimal solution, returning the maximum of feastol() a...
Definition: spxsolver.h:845
const LPColSet & cols() const
return const lp&#39;s cols if available.
Definition: spxsolver.h:2226
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:2325
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:1407
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:1714
void setDegenCompOffset(int iterOffset)
sets the offset for the number of iterations before the degeneracy is computed
Definition: spxsolver.h:2296
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:1087
Save arrays of arbitrary types.
bool isCoBasic(int i) const
is the i &#39;th covector basic ?
Definition: spxsolver.h:1356
bool isBasic(int i) const
is the i &#39;th vector basic ?
Definition: spxsolver.h:1350
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:1010
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:2237
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:2109
No linear solver loaded.
Definition: spxsolver.h:218
R feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:829
void updateTest()
recompute test vector.
Real getMaxTime()
the maximum runtime
Definition: spxsolver.h:2202
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:990
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:1299
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:2232
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:154
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:1128
int getMaxIters()
the maximum number of iterations
Definition: spxsolver.h:2214
SolutionPolish getSolutionPolishing()
return objective of solution polishing
Definition: spxsolver.h:676
virtual Status solve(volatile bool *interrupt=NULL)
solve loaded LP.
virtual void changeUpper(SPxColId p_id, const R &p_newUpper, bool scale=false)
overloading virtual function
Definition: spxsolver.h:1040
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:2243
bool isValid() const
returns TRUE iff the id is a valid column or row identifier.
Definition: spxid.h:144
void setDisplayFreq(int freq)
set display frequency
Definition: spxsolver.h:881
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:2173
SPxLPBase< R >::SPxSense sense() const
optimization sense.
Definition: spxsolver.h:2255
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:2167
void updateCoTest()
recompute coTest vector.
virtual void changeLhs(SPxRowId p_id, const R &p_newLhs, bool scale=false)
Definition: spxsolver.h:1064
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:2282
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:84
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:1000
virtual void unShift(void)
remove shift as much as possible.
SPxBasisBase< R >::SPxStatus getBasisStatus() const
gets basis status
Definition: spxsolver.h:2088
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:2100
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:887
const SLinSolver< R > * slinSolver() const
return loaded SLinSolver.
Definition: spxsolver.h:1824
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:1531
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:2315
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:1770
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:1123
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:1284
void shiftLCbound(int i, R to)
shift i &#39;th lcBound to to.
Definition: spxsolver.h:1664
void setSolutionPolishing(SolutionPolish _polishObj)
set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack) ...
Definition: spxsolver.h:670
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:771
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:1332
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:1249
virtual void setTerminationValue(R value=R(infinity))
set objective limit.
SPxId id(int i) const
id of i &#39;th vector.
Definition: spxsolver.h:1146
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:92
virtual void computeFrhs1(const VectorBase< R > &, const VectorBase< R > &)
Real cumulativeTime() const
cumulative time spent in all calls to method solve().
Definition: spxsolver.h:2208
LP has beed solved to optimality but unscaled solution contains violations.
Definition: spxsolver.h:235