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