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