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