Scippy

SoPlex

Sequential object-oriented simPlex

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