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