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