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-2025 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 // set tolerances for all the UpdateVectors
497 this->primVec.setTolerances(newTolerances);
498 this->dualVec.setTolerances(newTolerances);
499 this->addVec.setTolerances(newTolerances);
500 this->theFvec->setTolerances(newTolerances);
501 this->theCoPvec->setTolerances(newTolerances);
502 this->thePvec->setTolerances(newTolerances);
503 this->theRPvec->setTolerances(newTolerances);
504 this->theCPvec->setTolerances(newTolerances);
505 }
506
507 /// returns current tolerances
508 const std::shared_ptr<Tolerances>& tolerances() const
509 {
510 return this->_tolerances;
511 }
512
513 /// set refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix
515 {
517 }
518
519 /// set refactor threshold for fill-in in current factor update compared to fill-in in last factorization
521 {
523 }
524
525 /// set refactor threshold for memory growth in current factor update compared to the last factorization
526 void setMemFactor(R f)
527 {
529 }
530
531 /**@name Access */
532 ///@{
533 /// return the version of SPxSolverBase as number like 123 for 1.2.3
534 int version() const
535 {
536 return SOPLEX_VERSION;
537 }
538 /// return the internal subversion of SPxSolverBase as number
539 /// @deprecated Always 0 and will be removed in a future release.
540 int subversion() const
541 {
542 return SOPLEX_SUBVERSION;
543 }
544 /// return the current basis representation.
546 {
547 return theRep;
548 }
549
550 /// return current Type.
551 Type type() const
552 {
553 return theType;
554 }
555
556 /// return current Pricing.
558 {
559 return thePricing;
560 }
561
562 /// return current starter.
564 {
565 return thestarter;
566 }
567 ///@}
568
569 //-----------------------------
570 /**@name Setup
571 * Before solving an LP with an instance of SPxSolverBase,
572 * the following steps must be performed:
573 *
574 * -# Load the LP by copying an external LP or reading it from an
575 * input stream.
576 * -# Setup the pricer to use by loading an \ref soplex::SPxPricer
577 * "SPxPricer" object (if not already done in a previous call).
578 * -# Setup the ratio test method to use by loading an
579 * \ref soplex::SPxRatioTester "SPxRatioTester" object
580 * (if not already done in a previous call).
581 * -# Setup the linear system solver to use by loading an
582 * \ref soplex::SLinSolver "SLinSolver" object
583 * (if not already done in a previous call).
584 * -# Optionally setup an start basis generation method by loading an
585 * \ref soplex::SPxStarter "SPxStarter" object.
586 * -# Optionally setup a start basis by loading a
587 * \ref soplex::SPxBasisBase<R>::Desc "SPxBasisBase<R>::Desc" object.
588 * -# Optionally switch to another basis
589 * \ref soplex::SPxSolverBase<R>::Representation "Representation"
590 * by calling method \ref soplex::SPxSolverBase<R>::setRep() "setRep()".
591 * -# Optionally switch to another algorithm
592 * \ref soplex::SPxSolverBase<R>::Type "Type"
593 * by calling method \ref soplex::SPxSolverBase<R>::setType() "setType()".
594 *
595 * Now the solver is ready for execution. If the loaded LP is to be solved
596 * again from scratch, this can be done with method
597 * \ref soplex::SPxSolverBase<R>::reLoad() "reLoad()". Finally,
598 * \ref soplex::SPxSolverBase<R>::clear() "clear()" removes the LP from the solver.
599 */
600 ///@{
601 /// read LP from input stream.
602 virtual bool read(std::istream& in, NameSet* rowNames = nullptr,
603 NameSet* colNames = nullptr, DIdxSet* intVars = nullptr);
604
605 /// copy LP.
606 virtual void loadLP(const SPxLPBase<R>& LP, bool initSlackBasis = true);
607 /// setup linear solver to use. If \p destroy is true, \p slusolver will be freed in destructor.
608 virtual void setBasisSolver(SLinSolver<R>* slu, const bool destroy = false);
609 /// setup pricer to use. If \p destroy is true, \p pricer will be freed in destructor.
610 virtual void setPricer(SPxPricer<R>* pricer, const bool destroy = false);
611 /// setup ratio-tester to use. If \p destroy is true, \p tester will be freed in destructor.
612 virtual void setTester(SPxRatioTester<R>* tester, const bool destroy = false);
613 /// setup starting basis generator to use. If \p destroy is true, \p starter will be freed in destructor.
614 virtual void setStarter(SPxStarter<R>* starter, const bool destroy = false);
615 /// set a start basis.
616 virtual void loadBasis(const typename SPxBasisBase<R>::Desc&);
617
618 /// initialize #ROW or #COLUMN representation.
620 /// switch to #ROW or #COLUMN representation if not already used.
622 /// set \ref soplex::SPxSolverBase<R>::LEAVE "LEAVE" or \ref soplex::SPxSolverBase<R>::ENTER "ENTER" algorithm.
623 void setType(Type tp);
624 /// set \ref soplex::SPxSolverBase<R>::FULL "FULL" or \ref soplex::SPxSolverBase<R>::PARTIAL "PARTIAL" pricing.
626
627 /// reload LP.
628 virtual void reLoad();
629
630 /// clear all data in solver.
631 virtual void clear();
632
633 /// unscales the LP and reloads the basis
635
636 /// invalidates the basis, triggers refactorization
638
639 /** Load basis from \p filename in MPS format. If \p rowNames and \p
640 * colNames are \c nullptr, default names are used for the constraints and
641 * variables.
642 */
643 virtual bool readBasisFile(const char* filename,
644 const NameSet* rowNames, const NameSet* colNames);
645
646 /** Write basis to \p filename in MPS format. If \p rowNames and \p
647 * colNames are \c nullptr, default names are used for the constraints and
648 * variables.
649 */
650 virtual bool writeBasisFile(const char* filename,
651 const NameSet* rowNames, const NameSet* colNames, const bool cpxFormat = false) const;
652
653 /** Write current LP, basis, and parameter settings.
654 * LP is written in MPS format to "\p filename".mps, basis is written in "\p filename".bas, and parameters
655 * are written to "\p filename".set. If \p rowNames and \p colNames are \c nullptr, default names are used for
656 * the constraints and variables.
657 */
658 virtual bool writeState(const char* filename, const NameSet* rowNames = nullptr,
659 const NameSet* colNames = nullptr, const bool cpxFormat = false,
660 const bool writeZeroObjective = false) const;
661
662 ///@}
663
664 /**@name Solving LPs */
665 ///@{
666 /// solve loaded LP.
667 /** Solves the loaded LP by processing the Simplex iteration until
668 * the termination criteria is fullfilled (see #terminate()).
669 * The SPxStatus of the solver will indicate the reason for termination.
670 * @param interrupt can be set externally to interrupt the solve
671 * @param polish should solution polishing be considered
672 *
673 * @throw SPxStatusException if either no problem, solver, pricer
674 * or ratiotester loaded or if solve is still running when it shouldn't be
675 */
676 virtual Status solve(volatile bool* interrupt = nullptr, bool polish = true);
677
678 /** Identify primal basic variables that have zero reduced costs and
679 * try to pivot them out of the basis to make them tight.
680 * This is supposed to decrease the number of fractional variables
681 * when solving LP relaxations of (mixed) integer programs.
682 * The objective must not be modified during this procedure.
683 * @return true, if objective was modified (due to numerics) and resolving is necessary
684 */
686
687 /// set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack)
689 {
690 polishObj = _polishObj;
691 }
692
693 /// return objective of solution polishing
695 {
696 return polishObj;
697 }
698
699 /// true if objective limit should be used in the next solve
701 {
702 return useTerminationValue;
703 }
704
705 /// toggle objective limit for next solve
706 void toggleTerminationValue(bool enable)
707 {
708 useTerminationValue = enable;
709 }
710
711 /// Status of solution process.
712 Status status() const;
713
714 /// current objective value.
715 /**@return Objective value of the current solution vector
716 * (see #getPrimalSol()).
717 */
718 virtual R value();
719
720 // update nonbasic part of the objective value by the given amount
721 /**@return whether nonbasic part of objective is reliable
722 */
723 bool updateNonbasicValue(R objChange);
724
725 // trigger a recomputation of the nonbasic part of the objective value
727 {
728 m_nonbasicValue = 0.0;
730 }
731
732 /** helper method that computes a fresh factorization of the basis matrix
733 * (if at least one update has been performed)
734 * and recomputes Frhs, Fvec, CoPrhs, Pvec, and the nonbasic values.
735 * In LEAVE the Ftest is recomputed, in ENTER the CoTest and Test are recomputed.
736 *
737 * This method is called to eliminate accumulated errors from LU updates
738 * especially required before checking if the solver can terminate
739 * (optimality or objective limit)
740 */
741 virtual void factorizeAndRecompute();
742
743 /// get solution vector for primal variables.
744 /** This method returns the Status of the basis.
745 * If it is #REGULAR or better,
746 * the primal solution vector of the current basis will be copied
747 * to the argument \p vector. Hence, \p vector must be of dimension
748 * #nCols().
749 *
750 * @throw SPxStatusException if not initialized
751 */
753
754 /// get VectorBase<R> of slack variables.
755 /** This method returns the Status of the basis.
756 * If it is #REGULAR or better,
757 * the slack variables of the current basis will be copied
758 * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
759 * #nRows().
760 *
761 * @warning Because SPxSolverBase supports range constraints as its
762 * default, slack variables are defined in a nonstandard way:
763 * Let \em x be the current solution vector and \em A the constraint
764 * matrix. Then the vector of slack variables is defined as
765 * \f$s = Ax\f$.
766 *
767 * @throw SPxStatusException if no problem loaded
768 */
770
771 /// get current solution VectorBase<R> for dual variables.
772 /** This method returns the Status of the basis.
773 * If it is #REGULAR or better,
774 * the VectorBase<R> of dual variables of the current basis will be copied
775 * to the argument \p vector. Hence, \p VectorBase<R> must be of dimension
776 * #nRows().
777 *
778 * @warning Even though mathematically, each range constraint would
779 * account for two dual variables (one for each inequaility), only
780 * #nRows() dual variables are setup via the following
781 * construction: Given a range constraint, there are three possible
782 * situations:
783 * - None of its inequalities is tight: The dual variables
784 * for both are 0. However, when shifting (see below)
785 * occurs, it may be set to a value other than 0, which
786 * models a perturbed objective vector.
787 * - Both of its inequalities are tight: In this case the
788 * range constraint models an equality and we adopt the
789 * standard definition.
790 * - One of its inequalities is tight while the other is not:
791 * In this case only the dual variable for the tight
792 * constraint is given with the standard definition, while
793 * the other constraint is implicitely set to 0.
794 *
795 * @throw SPxStatusException if no problem loaded
796 */
798
799 /// get vector of reduced costs.
800 /** This method returns the Status of the basis.
801 * If it is #REGULAR or better,
802 * the vector of reduced costs of the current basis will be copied
803 * to the argument \p vector. Hence, \p vector must be of dimension
804 * #nCols().
805 *
806 * Let \em d denote the vector of dual variables, as defined above,
807 * and \em A the LPs constraint matrix. Then the reduced cost vector
808 * \em r is defined as \f$r^T = c^T - d^TA\f$.
809 *
810 * @throw SPxStatusException if no problem loaded
811 */
813
814 /// get primal ray in case of unboundedness.
815 /// @throw SPxStatusException if no problem loaded
817
818 /// get dual farkas proof of infeasibility.
819 /// @throw SPxStatusException if no problem loaded
821
822 /// print display line of flying table
823 virtual void printDisplayLine(const bool force = false, const bool forceHead = false);
824
825 /// Termination criterion.
826 /** This method is called in each Simplex iteration to determine, if
827 * the algorithm is to terminate. In this case a nonzero value is
828 * returned.
829 *
830 * This method is declared virtual to allow for implementation of
831 * other stopping criteria or using it as callback method within the
832 * Simplex loop, by overriding the method in a derived class.
833 * However, all implementations must terminate with the
834 * statement \c return SPxSolverBase<R>::#terminate(), if no own termination
835 * criteria is encountered.
836 *
837 * Note, that the Simplex loop stopped even when #terminate()
838 * returns 0, if the LP has been solved to optimality (i.e. no
839 * further pricing succeeds and no shift is present).
840 */
841 virtual bool terminate();
842 ///@}
843
844 //-----------------------------
845 /**@name Control Parameters */
846 ///@{
847 /// values \f$|x| < \epsilon\f$ are considered to be 0.
848 /** if you want another value for epsilon, use
849 * \ref soplex::Tolerances::setEpsilon() "Tolerances::setEpsilon()".
850 */
851 R epsilon() const
852 {
853 return this->tolerances()->epsilon();
854 }
855 /// feasibility tolerance maintained by ratio test during ENTER algorithm.
856 R entertol() const
857 {
858 if(theRep == COLUMN)
859 return this->tolerances()->floatingPointFeastol() * this->entertolscale;
860 else
861 return this->tolerances()->floatingPointOpttol() * this->entertolscale;
862 }
863 /// feasibility tolerance maintained by ratio test during LEAVE algorithm.
864 R leavetol() const
865 {
866 if(theRep == COLUMN)
867 return this->tolerances()->floatingPointOpttol() * this->leavetolscale;
868 else
869 return this->tolerances()->floatingPointFeastol() * this->leavetolscale;
870 }
871 /// scale the entering tolerance
873 {
874 this->entertolscale = d;
875 }
876 /// scale the leaving tolerance
878 {
879 this->leavetolscale = d;
880 }
882 {
883 this->scaleEntertol(d);
884 this->scaleLeavetol(d);
885 }
886 /// guaranteed primal and dual bound violation for optimal solution, returning the maximum of floatingPointFeastol() and floatingPointOpttol().
887 R delta() const
888 {
889 return SOPLEX_MAX(this->tolerances()->floatingPointFeastol(),
890 this->tolerances()->floatingPointOpttol());
891 }
892
893 /// set timing type
895 {
901 timerType = ttype;
902 }
903
904 /// set timing type
906 {
907 assert(timerType == theTime->type());
908 assert(timerType == multTimeSparse->type());
909 assert(timerType == multTimeFull->type());
910 assert(timerType == multTimeColwise->type());
911 assert(timerType == multTimeUnsetup->type());
912 return timerType;
913 }
914
915 /// set display frequency
916 void setDisplayFreq(int freq)
917 {
918 displayFreq = freq;
919 }
920
921 /// get display frequency
923 {
924 return displayFreq;
925 }
926
927 /// print basis metric within the usual output
929 {
931 }
932
933 // enable sparse pricing when viols < fac * dim()
935 {
937 }
938 /// enable or disable hyper sparse pricing
939 void hyperPricing(bool h);
940
941 // get old basis status rows
943 {
944 return oldBasisStatusRows;
945 }
946
947 // get old basis status cols
949 {
950 return oldBasisStatusCols;
951 }
952
953 // should the basis be stored for use in precision boosting?
955 {
957 }
958
959 // set frequency of storing the basis for use in precision boosting
961 {
963 }
964
965 /** SPxSolverBase considers a Simplex step as degenerate if the
966 * steplength does not exceed #epsilon(). Cycling occurs if only
967 * degenerate steps are taken. To prevent this situation, SPxSolverBase
968 * perturbs the problem such that nondegenerate steps are ensured.
969 *
970 * maxCycle() controls how agressive such perturbation is
971 * performed, since no more than maxCycle() degenerate steps are
972 * accepted before perturbing the LP. The current number of consecutive
973 * degenerate steps is counted by numCycle().
974 */
975 /// maximum number of degenerate simplex steps before we detect cycling.
976 int maxCycle() const
977 {
978 return m_maxCycle;
979 }
980 /// actual number of degenerate simplex steps encountered so far.
981 int numCycle() const
982 {
983 return m_numCycle;
984 }
985
986 /// perturb entire problem or only the bounds relevant to the current pivot
987 void useFullPerturbation(bool full)
988 {
989 fullPerturbation = full;
990 }
991
992 virtual R getBasisMetric(int type)
993 {
994 return basis().getMatrixMetric(type);
995 }
996
997 ///@}
998
999private:
1000
1001 //-----------------------------
1002 /**@name Private helpers */
1003 ///@{
1004 ///
1005 void localAddRows(int start);
1006 ///
1007 void localAddCols(int start);
1008 ///
1009 void setPrimal(VectorBase<R>& p_vector);
1010 ///
1011 void setSlacks(VectorBase<R>& p_vector);
1012 ///
1013 void setDual(VectorBase<R>& p_vector);
1014 ///
1015 void setRedCost(VectorBase<R>& p_vector);
1016 ///@}
1017
1018protected:
1019
1020 //-----------------------------
1021 /**@name Protected helpers */
1022 ///@{
1023 ///
1024 virtual void addedRows(int n);
1025 ///
1026 virtual void addedCols(int n);
1027 ///
1028 virtual void doRemoveRow(int i);
1029 ///
1030 virtual void doRemoveRows(int perm[]);
1031 ///
1032 virtual void doRemoveCol(int i);
1033 ///
1034 virtual void doRemoveCols(int perm[]);
1035 ///@}
1036
1037public:
1038
1039 //-----------------------------
1040 /**@name Modification */
1041 /// \p scale determines whether the new data needs to be scaled according to the existing LP (persistent scaling)
1042 ///@{
1043 ///
1044 virtual void changeObj(const VectorBase<R>& newObj, bool scale = false);
1045 ///
1046 virtual void changeObj(int i, const R& newVal, bool scale = false);
1047 ///
1048 using SPxLPBase<R>::changeObj; /// overloading a virtual function
1049 virtual void changeObj(SPxColId p_id, const R& p_newVal, bool scale = false)
1050 {
1051 changeObj(this->number(p_id), p_newVal, scale);
1052 }
1053 ///
1054 virtual void changeMaxObj(const VectorBase<R>& newObj, bool scale = false);
1055 ///
1056 virtual void changeMaxObj(int i, const R& newVal, bool scale = false);
1057 ///
1058 using SPxLPBase<R>::changeMaxObj; /// overloading a virtual function
1059 virtual void changeMaxObj(SPxColId p_id, const R& p_newVal, bool scale = false)
1060 {
1061 changeMaxObj(this->number(p_id), p_newVal, scale);
1062 }
1063 ///
1064 virtual void changeRowObj(const VectorBase<R>& newObj, bool scale = false);
1065 ///
1066 virtual void changeRowObj(int i, const R& newVal, bool scale = false);
1067 ///
1069 virtual void changeRowObj(SPxRowId p_id, const R& p_newVal, bool scale = false)
1070 {
1071 changeRowObj(this->number(p_id), p_newVal);
1072 }
1073 ///
1074 virtual void clearRowObjs()
1075 {
1077 unInit();
1078 }
1079 ///
1080 virtual void changeLowerStatus(int i, R newLower, R oldLower = 0.0);
1081 ///
1082 virtual void changeLower(const VectorBase<R>& newLower, bool scale = false);
1083 ///
1084 virtual void changeLower(int i, const R& newLower, bool scale = false);
1085 ///
1087 virtual void changeLower(SPxColId p_id, const R& p_newLower, bool scale = false)
1088 {
1089 changeLower(this->number(p_id), p_newLower, scale);
1090 }
1091 ///
1092 virtual void changeUpperStatus(int i, R newUpper, R oldLower = 0.0);
1093 ///
1094 virtual void changeUpper(const VectorBase<R>& newUpper, bool scale = false);
1095 ///
1096 virtual void changeUpper(int i, const R& newUpper, bool scale = false);
1097 ///
1098 using SPxLPBase<R>::changeUpper; /// overloading virtual function
1099 virtual void changeUpper(SPxColId p_id, const R& p_newUpper, bool scale = false)
1100 {
1101 changeUpper(this->number(p_id), p_newUpper, scale);
1102 }
1103 ///
1104 virtual void changeBounds(const VectorBase<R>& newLower, const VectorBase<R>& newUpper,
1105 bool scale = false);
1106 ///
1107 virtual void changeBounds(int i, const R& newLower, const R& newUpper, bool scale = false);
1108 ///
1110 virtual void changeBounds(SPxColId p_id, const R& p_newLower, const R& p_newUpper,
1111 bool scale = false)
1112 {
1113 changeBounds(this->number(p_id), p_newLower, p_newUpper, scale);
1114 }
1115 ///
1116 virtual void changeLhsStatus(int i, R newLhs, R oldLhs = 0.0);
1117 ///
1118 virtual void changeLhs(const VectorBase<R>& newLhs, bool scale = false);
1119 ///
1120 virtual void changeLhs(int i, const R& newLhs, bool scale = false);
1121 ///
1123 virtual void changeLhs(SPxRowId p_id, const R& p_newLhs, bool scale = false)
1124 {
1125 changeLhs(this->number(p_id), p_newLhs, scale);
1126 }
1127 ///
1128 virtual void changeRhsStatus(int i, R newRhs, R oldRhs = 0.0);
1129 ///
1130 virtual void changeRhs(const VectorBase<R>& newRhs, bool scale = false);
1131 ///
1132 virtual void changeRhs(int i, const R& newRhs, bool scale = false);
1133 ///
1135 virtual void changeRhs(SPxRowId p_id, const R& p_newRhs, bool scale = false)
1136 {
1137 changeRhs(this->number(p_id), p_newRhs, scale);
1138 }
1139 ///
1140 virtual void changeRange(const VectorBase<R>& newLhs, const VectorBase<R>& newRhs,
1141 bool scale = false);
1142 ///
1143 virtual void changeRange(int i, const R& newLhs, const R& newRhs, bool scale = false);
1144 ///
1146 virtual void changeRange(SPxRowId p_id, const R& p_newLhs, const R& p_newRhs, bool scale = false)
1147 {
1148 changeRange(this->number(p_id), p_newLhs, p_newRhs, scale);
1149 }
1150 ///
1151 virtual void changeRow(int i, const LPRowBase<R>& newRow, bool scale = false);
1152 ///
1154 virtual void changeRow(SPxRowId p_id, const LPRowBase<R>& p_newRow, bool scale = false)
1155 {
1156 changeRow(this->number(p_id), p_newRow, scale);
1157 }
1158 ///
1159 virtual void changeCol(int i, const LPColBase<R>& newCol, bool scale = false);
1160 ///
1162 virtual void changeCol(SPxColId p_id, const LPColBase<R>& p_newCol, bool scale = false)
1163 {
1164 changeCol(this->number(p_id), p_newCol, scale);
1165 }
1166 ///
1167 virtual void changeElement(int i, int j, const R& val, bool scale = false);
1168 ///
1170 virtual void changeElement(SPxRowId rid, SPxColId cid, const R& val, bool scale = false)
1171 {
1172 changeElement(this->number(rid), this->number(cid), val, scale);
1173 }
1174 ///
1175 virtual void changeSense(typename SPxLPBase<R>::SPxSense sns);
1176 ///@}
1177
1178 //------------------------------------
1179 /**@name Dimension and codimension */
1180 ///@{
1181 /// dimension of basis matrix.
1182 int dim() const
1183 {
1184 return thecovectors->num();
1185 }
1186 /// codimension.
1187 int coDim() const
1188 {
1189 return thevectors->num();
1190 }
1191 ///@}
1192
1193 //------------------------------------
1194 /**@name Variables and Covariables
1195 * Class SPxLPBase<R> introduces \ref soplex::SPxId "SPxIds" to identify
1196 * row or column data of an LP. SPxSolverBase uses this concept to
1197 * access data with respect to the chosen representation.
1198 */
1199 ///@{
1200 /// id of \p i 'th vector.
1201 /** The \p i 'th Id is the \p i 'th SPxRowId for a rowwise and the
1202 * \p i 'th SPxColId for a columnwise basis represenation. Hence,
1203 * 0 <= i < #coDim().
1204 */
1205 SPxId id(int i) const
1206 {
1207 if(rep() == ROW)
1208 {
1209 SPxRowId rid = SPxLPBase<R>::rId(i);
1210 return SPxId(rid);
1211 }
1212 else
1213 {
1214 SPxColId cid = SPxLPBase<R>::cId(i);
1215 return SPxId(cid);
1216 }
1217 }
1218
1219 /// id of \p i 'th covector.
1220 /** The \p i 'th #coId() is the \p i 'th SPxColId for a rowwise and the
1221 * \p i 'th SPxRowId for a columnwise basis represenation. Hence,
1222 * 0 <= i < #dim().
1223 */
1224 SPxId coId(int i) const
1225 {
1226 if(rep() == ROW)
1227 {
1228 SPxColId cid = SPxLPBase<R>::cId(i);
1229 return SPxId(cid);
1230 }
1231 else
1232 {
1233 SPxRowId rid = SPxLPBase<R>::rId(i);
1234 return SPxId(rid);
1235 }
1236 }
1237
1238 /// Is \p p_id an SPxId ?
1239 /** This method returns wheather or not \p p_id identifies a vector
1240 * with respect to the chosen representation.
1241 */
1242 bool isId(const SPxId& p_id) const
1243 {
1244 return p_id.info * theRep > 0;
1245 }
1246
1247 /// Is \p p_id a CoId.
1248 /** This method returns wheather or not \p p_id identifies a coVector
1249 * with respect to the chosen representation.
1250 */
1251 bool isCoId(const SPxId& p_id) const
1252 {
1253 return p_id.info * theRep < 0;
1254 }
1255 ///@}
1256
1257 //------------------------------------
1258 /**@name Vectors and Covectors */
1259 ///@{
1260 /// \p i 'th vector.
1261 /**@return a reference to the \p i 'th, 0 <= i < #coDim(), vector of
1262 * the loaded LP (with respect to the chosen representation).
1263 */
1264 const SVectorBase<R>& vector(int i) const
1265 {
1266 return (*thevectors)[i];
1267 }
1268
1269 ///
1270 const SVectorBase<R>& vector(const SPxRowId& rid) const
1271 {
1272 assert(rid.isValid());
1273 return (rep() == ROW)
1274 ? (*thevectors)[this->number(rid)]
1275 : static_cast<const SVectorBase<R>&>(unitVecs[this->number(rid)]);
1276 }
1277 ///
1278 const SVectorBase<R>& vector(const SPxColId& cid) const
1279 {
1280 assert(cid.isValid());
1281 return (rep() == COLUMN)
1282 ? (*thevectors)[this->number(cid)]
1283 : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1284 }
1285
1286 /// VectorBase<R> associated to \p p_id.
1287 /**@return Returns a reference to the VectorBase<R> of the loaded LP corresponding
1288 * to \p id (with respect to the chosen representation). If \p p_id is
1289 * an id, a vector of the constraint matrix is returned, otherwise
1290 * the corresponding unit vector (of the slack variable or bound
1291 * inequality) is returned.
1292 * @todo The implementation does not exactly look like it will do
1293 * what is promised in the describtion.
1294 */
1295 const SVectorBase<R>& vector(const SPxId& p_id) const
1296 {
1297 assert(p_id.isValid());
1298
1299 return p_id.isSPxRowId()
1300 ? vector(SPxRowId(p_id))
1301 : vector(SPxColId(p_id));
1302 }
1303
1304 /// \p i 'th covector of LP.
1305 /**@return a reference to the \p i 'th, 0 <= i < #dim(), covector of
1306 * the loaded LP (with respect to the chosen representation).
1307 */
1308 const SVectorBase<R>& coVector(int i) const
1309 {
1310 return (*thecovectors)[i];
1311 }
1312 ///
1313 const SVectorBase<R>& coVector(const SPxRowId& rid) const
1314 {
1315 assert(rid.isValid());
1316 return (rep() == COLUMN)
1317 ? (*thecovectors)[this->number(rid)]
1318 : static_cast<const SVector&>(unitVecs[this->number(rid)]);
1319 }
1320 ///
1321 const SVectorBase<R>& coVector(const SPxColId& cid) const
1322 {
1323 assert(cid.isValid());
1324 return (rep() == ROW)
1325 ? (*thecovectors)[this->number(cid)]
1326 : static_cast<const SVectorBase<R>&>(unitVecs[this->number(cid)]);
1327 }
1328 /// coVector associated to \p p_id.
1329 /**@return a reference to the covector of the loaded LP
1330 * corresponding to \p p_id (with respect to the chosen
1331 * representation). If \p p_id is a coid, a covector of the constraint
1332 * matrix is returned, otherwise the corresponding unit vector is
1333 * returned.
1334 */
1335 const SVectorBase<R>& coVector(const SPxId& p_id) const
1336 {
1337 assert(p_id.isValid());
1338 return p_id.isSPxRowId()
1339 ? coVector(SPxRowId(p_id))
1340 : coVector(SPxColId(p_id));
1341 }
1342 /// return \p i 'th unit vector.
1343 const SVectorBase<R>& unitVector(int i) const
1344 {
1345 return unitVecs[i];
1346 }
1347 ///@}
1348
1349 //------------------------------------
1350 /**@name Variable status
1351 * The Simplex basis assigns a \ref soplex::SPxBasisBase<R>::Desc::Status
1352 * "Status" to each variable and covariable. Depending on the
1353 * representation, the status indicates that the corresponding
1354 * vector is in the basis matrix or not.
1355 */
1356 ///@{
1357 /// Status of \p i 'th variable.
1359 {
1360 return this->desc().status(i);
1361 }
1362
1363 /// Status of \p i 'th covariable.
1365 {
1366 return this->desc().coStatus(i);
1367 }
1368
1369 /// does \p stat describe a basic index ?
1370 bool isBasic(typename SPxBasisBase<R>::Desc::Status stat) const
1371 {
1372 return (stat * rep() > 0);
1373 }
1374
1375 /// is the \p p_id 'th vector basic ?
1376 bool isBasic(const SPxId& p_id) const
1377 {
1378 assert(p_id.isValid());
1379 return p_id.isSPxRowId()
1380 ? isBasic(SPxRowId(p_id))
1381 : isBasic(SPxColId(p_id));
1382 }
1383
1384 /// is the \p rid 'th vector basic ?
1385 bool isBasic(const SPxRowId& rid) const
1386 {
1387 return isBasic(this->desc().rowStatus(this->number(rid)));
1388 }
1389
1390 /// is the \p cid 'th vector basic ?
1391 bool isBasic(const SPxColId& cid) const
1392 {
1393 return isBasic(this->desc().colStatus(this->number(cid)));
1394 }
1395
1396 /// is the \p i 'th row vector basic ?
1397 bool isRowBasic(int i) const
1398 {
1399 return isBasic(this->desc().rowStatus(i));
1400 }
1401
1402 /// is the \p i 'th column vector basic ?
1403 bool isColBasic(int i) const
1404 {
1405 return isBasic(this->desc().colStatus(i));
1406 }
1407
1408 /// is the \p i 'th vector basic ?
1409 bool isBasic(int i) const
1410 {
1411 return isBasic(this->desc().status(i));
1412 }
1413
1414 /// is the \p i 'th covector basic ?
1415 bool isCoBasic(int i) const
1416 {
1417 return isBasic(this->desc().coStatus(i));
1418 }
1419 ///@}
1420
1421 /// feasibility vector.
1422 /** This method return the \em feasibility vector. If it satisfies its
1423 * bound, the basis is called feasible (independently of the chosen
1424 * representation). The feasibility vector has dimension #dim().
1425 *
1426 * For the entering Simplex, #fVec is kept within its bounds. In
1427 * contrast to this, the pricing of the leaving Simplex selects an
1428 * element of #fVec, that violates its bounds.
1429 */
1431 {
1432 return *theFvec;
1433 }
1434 /// right-hand side vector for \ref soplex::SPxSolverBase<R>::fVec "fVec"
1435 /** The feasibility vector is computed by solving a linear system with the
1436 * basis matrix. The right-hand side vector of this system is referred
1437 * to as \em feasibility, \em right-hand \em side \em vector #fRhs().
1438 *
1439 * For a row basis, #fRhs() is the objective vector (ignoring shifts).
1440 * For a column basis, it is the sum of all nonbasic vectors scaled by
1441 * the factor of their bound.
1442 */
1443 const VectorBase<R>& fRhs() const
1444 {
1445 return *theFrhs;
1446 }
1447 /// upper bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1448 const VectorBase<R>& ubBound() const
1449 {
1450 return theUBbound;
1451 }
1452 /// upper bound for #fVec, writable.
1453 /** This method returns the upper bound for the feasibility vector.
1454 * It may only be called for the #ENTER%ing Simplex.
1455 *
1456 * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1457 * maintained to fullfill its bounds. As #fVec itself, also its
1458 * bounds depend on the chosen representation. Further, they may
1459 * need to be shifted (see below).
1460 */
1462 {
1463 return theUBbound;
1464 }
1465 /// lower bound for \ref soplex::SPxSolverBase<R>::fVec "fVec".
1466 const VectorBase<R>& lbBound() const
1467 {
1468 return theLBbound;
1469 }
1470 /// lower bound for #fVec, writable.
1471 /** This method returns the lower bound for the feasibility vector.
1472 * It may only be called for the #ENTER%ing Simplex.
1473 *
1474 * For the #ENTER%ing Simplex algorithms, the feasibility vector is
1475 * maintained to fullfill its bounds. As #fVec itself, also its
1476 * bound depend on the chosen representation. Further, they may
1477 * need to be shifted (see below).
1478 */
1480 {
1481 return theLBbound;
1482 }
1483
1484 /// Violations of \ref soplex::SPxSolverBase<R>::fVec "fVec"
1485 /** For the leaving Simplex algorithm, pricing involves selecting a
1486 * variable from #fVec that violates its bounds that is to leave
1487 * the basis. When a SPxPricer is called to select such a
1488 * leaving variable, #fTest() contains the vector of violations:
1489 * For #fTest()[i] < 0, the \c i 'th basic variable violates one of
1490 * its bounds by the given value. Otherwise no bound is violated.
1491 */
1492 const VectorBase<R>& fTest() const
1493 {
1494 assert(type() == LEAVE);
1495 return theCoTest;
1496 }
1497
1498 /// copricing vector.
1499 /** The copricing vector #coPvec along with the pricing vector
1500 * #pVec are used for pricing in the #ENTER%ing Simplex algorithm,
1501 * i.e. one variable is selected, that violates its bounds. In
1502 * contrast to this, the #LEAVE%ing Simplex algorithm keeps both
1503 * vectors within their bounds.
1504 */
1506 {
1507 return *theCoPvec;
1508 }
1509
1510 /// Right-hand side vector for \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1511 /** The vector #coPvec is computed by solving a linear system with the
1512 * basis matrix and #coPrhs as the right-hand side vector. For
1513 * column basis representation, #coPrhs is build up of the
1514 * objective vector elements of all basic variables. For a row
1515 * basis, it consists of the tight bounds of all basic
1516 * constraints.
1517 */
1518 const VectorBase<R>& coPrhs() const
1519 {
1520 return *theCoPrhs;
1521 }
1522
1523 ///
1524 const VectorBase<R>& ucBound() const
1525 {
1526 assert(theType == LEAVE);
1527 return *theCoUbound;
1528 }
1529 /// upper bound for #coPvec.
1530 /** This method returns the upper bound for #coPvec. It may only be
1531 * called for the leaving Simplex algorithm.
1532 *
1533 * For the leaving Simplex algorithms #coPvec is maintained to
1534 * fullfill its bounds. As #coPvec itself, also its bound depend
1535 * on the chosen representation. Further, they may need to be
1536 * shifted (see below).
1537 */
1539 {
1540 assert(theType == LEAVE);
1541 return *theCoUbound;
1542 }
1543
1544 ///
1545 const VectorBase<R>& lcBound() const
1546 {
1547 assert(theType == LEAVE);
1548 return *theCoLbound;
1549 }
1550 /// lower bound for #coPvec.
1551 /** This method returns the lower bound for #coPvec. It may only be
1552 * called for the leaving Simplex algorithm.
1553 *
1554 * For the leaving Simplex algorithms #coPvec is maintained to
1555 * fullfill its bounds. As #coPvec itself, also its bound depend
1556 * on the chosen representation. Further, they may need to be
1557 * shifted (see below).
1558 */
1560 {
1561 assert(theType == LEAVE);
1562 return *theCoLbound;
1563 }
1564
1565 /// violations of \ref soplex::SPxSolverBase<R>::coPvec "coPvec".
1566 /** In entering Simplex pricing selects checks vectors #coPvec()
1567 * and #pVec() for violation of its bounds. #coTest() contains
1568 * the violations for #coPvec() which are indicated by a negative
1569 * value. That is, if #coTest()[i] < 0, the \p i 'th element of #coPvec()
1570 * is violated by -#coTest()[i].
1571 */
1572 const VectorBase<R>& coTest() const
1573 {
1574 assert(type() == ENTER);
1575 return theCoTest;
1576 }
1577 /// pricing vector.
1578 /** The pricing vector #pVec is the product of #coPvec with the
1579 * constraint matrix. As #coPvec, also #pVec is maintained within
1580 * its bound for the leaving Simplex algorithm, while the bounds
1581 * are tested for the entering Simplex. #pVec is of dimension
1582 * #coDim(). Vector #pVec() is only up to date for #LEAVE%ing
1583 * Simplex or #FULL pricing in #ENTER%ing Simplex.
1584 */
1586 {
1587 return *thePvec;
1588 }
1589 ///
1590 const VectorBase<R>& upBound() const
1591 {
1592 assert(theType == LEAVE);
1593 return *theUbound;
1594 }
1595 /// upper bound for #pVec.
1596 /** This method returns the upper bound for #pVec. It may only be
1597 * called for the leaving Simplex algorithm.
1598 *
1599 * For the leaving Simplex algorithms #pVec is maintained to
1600 * fullfill its bounds. As #pVec itself, also its bound depend
1601 * on the chosen representation. Further, they may need to be
1602 * shifted (see below).
1603 */
1605 {
1606 assert(theType == LEAVE);
1607 return *theUbound;
1608 }
1609
1610 ///
1611 const VectorBase<R>& lpBound() const
1612 {
1613 assert(theType == LEAVE);
1614 return *theLbound;
1615 }
1616 /// lower bound for #pVec.
1617 /** This method returns the lower bound for #pVec. It may only be
1618 * called for the leaving Simplex algorithm.
1619 *
1620 * For the leaving Simplex algorithms #pVec is maintained to
1621 * fullfill its bounds. As #pVec itself, also its bound depend
1622 * on the chosen representation. Further, they may need to be
1623 * shifted (see below).
1624 */
1626 {
1627 assert(theType == LEAVE);
1628 return *theLbound;
1629 }
1630
1631 /// Violations of \ref soplex::SPxSolverBase<R>::pVec "pVec".
1632 /** In entering Simplex pricing selects checks vectors #coPvec()
1633 * and #pVec() for violation of its bounds. Vector #test()
1634 * contains the violations for #pVec(), i.e., if #test()[i] < 0,
1635 * the i'th element of #pVec() is violated by #test()[i].
1636 * Vector #test() is only up to date for #FULL pricing.
1637 */
1638 const VectorBase<R>& test() const
1639 {
1640 assert(type() == ENTER);
1641 return theTest;
1642 }
1643
1644 /// compute and return \ref soplex::SPxSolverBase<R>::pVec() "pVec()"[i].
1645 R computePvec(int i);
1646 /// compute entire \ref soplex::SPxSolverBase<R>::pVec() "pVec()".
1648 /// compute and return \ref soplex::SPxSolverBase<R>::test() "test()"[i] in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1649 R computeTest(int i);
1650 /// compute test VectorBase<R> in \ref soplex::SPxSolverBase<R>::ENTER "ENTER"ing Simplex.
1652
1653 //------------------------------------
1654 /**@name Shifting
1655 * The task of the ratio test (implemented in SPxRatioTester classes)
1656 * is to select a variable for the basis update, such that the basis
1657 * remains priced (i.e. both, the pricing and copricing vectors satisfy
1658 * their bounds) or feasible (i.e. the feasibility vector satisfies its
1659 * bounds). However, this can lead to numerically instable basis matrices
1660 * or -- after accumulation of various errors -- even to a singular basis
1661 * matrix.
1662 *
1663 * The key to overcome this problem is to allow the basis to become "a
1664 * bit" infeasible or unpriced, in order provide a better choice for the
1665 * ratio test to select a stable variable. This is equivalent to enlarging
1666 * the bounds by a small amount. This is referred to as \em shifting.
1667 *
1668 * These methods serve for shifting feasibility bounds, either in order
1669 * to maintain numerical stability or initially for computation of
1670 * phase 1. The sum of all shifts applied to any bound is stored in
1671 * \ref soplex::SPxSolverBase<R>::theShift "theShift".
1672 *
1673 * The following methods are used to shift individual bounds. They are
1674 * mainly intended for stable implenentations of SPxRatioTester.
1675 */
1676 ///@{
1677 /// Perform initial shifting to optain an feasible or pricable basis.
1679 /// Perform initial shifting to optain an feasible or pricable basis.
1681
1682 /// shift \p i 'th \ref soplex::SPxSolver::ubBound "ubBound" to \p to.
1683 void shiftUBbound(int i, R to)
1684 {
1685 assert(theType == ENTER);
1686 // use maximum to not count tightened bounds in case of equality shifts
1687 theShift += SOPLEX_MAX(to - theUBbound[i], 0.0);
1688 theUBbound[i] = to;
1689 }
1690 /// shift \p i 'th \ref soplex::SPxSolver::lbBound "lbBound" to \p to.
1691 void shiftLBbound(int i, R to)
1692 {
1693 assert(theType == ENTER);
1694 // use maximum to not count tightened bounds in case of equality shifts
1695 theShift += SOPLEX_MAX(theLBbound[i] - to, 0.0);
1696 theLBbound[i] = to;
1697 }
1698 /// shift \p i 'th \ref soplex::SPxSolver::upBound "upBound" to \p to.
1699 void shiftUPbound(int i, R to)
1700 {
1701 assert(theType == LEAVE);
1702 // use maximum to not count tightened bounds in case of equality shifts
1703 theShift += SOPLEX_MAX(to - (*theUbound)[i], 0.0);
1704 (*theUbound)[i] = to;
1705 }
1706 /// shift \p i 'th \ref soplex::SPxSolver::lpBound "lpBound" to \p to.
1707 void shiftLPbound(int i, R to)
1708 {
1709 assert(theType == LEAVE);
1710 // use maximum to not count tightened bounds in case of equality shifts
1711 theShift += SOPLEX_MAX((*theLbound)[i] - to, 0.0);
1712 (*theLbound)[i] = to;
1713 }
1714 /// shift \p i 'th \ref soplex::SPxSolver::ucBound "ucBound" to \p to.
1715 void shiftUCbound(int i, R to)
1716 {
1717 assert(theType == LEAVE);
1718 // use maximum to not count tightened bounds in case of equality shifts
1719 theShift += SOPLEX_MAX(to - (*theCoUbound)[i], 0.0);
1720 (*theCoUbound)[i] = to;
1721 }
1722 /// shift \p i 'th \ref soplex::SPxSolver::lcBound "lcBound" to \p to.
1723 void shiftLCbound(int i, R to)
1724 {
1725 assert(theType == LEAVE);
1726 // use maximum to not count tightened bounds in case of equality shifts
1727 theShift += SOPLEX_MAX((*theCoLbound)[i] - to, 0.0);
1728 (*theCoLbound)[i] = to;
1729 }
1730 ///
1731 void testBounds() const;
1732
1733 /// total current shift amount.
1734 virtual R shift() const
1735 {
1736 return theShift;
1737 }
1738 /// remove shift as much as possible.
1739 virtual void unShift(void);
1740
1741 /// get violation of constraints.
1742 virtual void qualConstraintViolation(R& maxviol, R& sumviol) const;
1743 /// get violations of bounds.
1744 virtual void qualBoundViolation(R& maxviol, R& sumviol) const;
1745 /// get the residuum |Ax-b|.
1746 virtual void qualSlackViolation(R& maxviol, R& sumviol) const;
1747 /// get violation of optimality criterion.
1748 virtual void qualRedCostViolation(R& maxviol, R& sumviol) const;
1749 ///@}
1750
1751private:
1752
1753 //------------------------------------
1754 /**@name Perturbation */
1755 ///@{
1756 ///
1758 const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1759 int start = 0, int incr = 1);
1760 ///
1762 const UpdateVector<R>& vec, VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1763 int start = 0, int incr = 1);
1764 ///
1766 VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1767 const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1768 ///
1770 VectorBase<R>& low, VectorBase<R>& up, R eps, R delta,
1771 const typename SPxBasisBase<R>::Desc::Status* stat, int start, int incr);
1772 ///@}
1773
1774 //------------------------------------
1775 /**@name The Simplex Loop
1776 * We now present a set of methods that may be usefull when implementing
1777 * own SPxPricer or SPxRatioTester classes. Here is, how
1778 * SPxSolverBase will call methods from its loaded SPxPricer and
1779 * SPxRatioTester.
1780 *
1781 * For the entering Simplex:
1782 * -# \ref soplex::SPxPricer::selectEnter() "SPxPricer::selectEnter()"
1783 * -# \ref soplex::SPxRatioTester::selectLeave() "SPxRatioTester::selectLeave()"
1784 * -# \ref soplex::SPxPricer::entered4() "SPxPricer::entered4()"
1785 *
1786 * For the leaving Simplex:
1787 * -# \ref soplex::SPxPricer::selectLeave() "SPxPricer::selectLeave()"
1788 * -# \ref soplex::SPxRatioTester::selectEnter() "SPxRatioTester::selectEnter()"
1789 * -# \ref soplex::SPxPricer::left4() "SPxPricer::left4()"
1790 */
1791 ///@{
1792public:
1793 /// Setup vectors to be solved within Simplex loop.
1794 /** Load vector \p y to be #solve%d with the basis matrix during the
1795 * #LEAVE Simplex. The system will be solved after #SPxSolverBase%'s call
1796 * to SPxRatioTester. The system will be solved along with
1797 * another system. Solving two linear system at a time has
1798 * performance advantages over solving the two linear systems
1799 * seperately.
1800 */
1802 {
1803 assert(type() == LEAVE);
1804 solveVector2 = p_y;
1805 solveVector2rhs = p_rhs;
1806 }
1807 /// Setup vectors to be solved within Simplex loop.
1808 /** Load a second additional vector \p y2 to be #solve%d with the
1809 * basis matrix during the #LEAVE Simplex. The system will be
1810 * solved after #SPxSolverBase%'s call to SPxRatioTester.
1811 * The system will be solved along with at least one
1812 * other system. Solving several linear system at a time has
1813 * performance advantages over solving them seperately.
1814 */
1816 {
1817 assert(type() == LEAVE);
1818 solveVector3 = p_y2;
1819 solveVector3rhs = p_rhs2;
1820 }
1821 /// Setup vectors to be cosolved within Simplex loop.
1822 /** Load vector \p y to be #coSolve%d with the basis matrix during
1823 * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1824 * call to SPxRatioTester. The system will be solved along
1825 * with another system. Solving two linear system at a time has
1826 * performance advantages over solving the two linear systems
1827 * seperately.
1828 */
1830 {
1831 assert(type() == ENTER);
1832 coSolveVector2 = p_y;
1833 coSolveVector2rhs = p_rhs;
1834 }
1835 /// Setup vectors to be cosolved within Simplex loop.
1836 /** Load a second vector \p z to be #coSolve%d with the basis matrix during
1837 * the #ENTER Simplex. The system will be solved after #SPxSolverBase%'s
1838 * call to SPxRatioTester. The system will be solved along
1839 * with two other systems.
1840 */
1842 {
1843 assert(type() == ENTER);
1844 coSolveVector3 = p_z;
1845 coSolveVector3rhs = p_rhs;
1846 }
1847
1848 /// maximal infeasibility of basis
1849 /** This method is called before concluding optimality. Since it is
1850 * possible that some stable implementation of class
1851 * SPxRatioTester yielded a slightly infeasible (or unpriced)
1852 * basis, this must be checked before terminating with an optimal
1853 * solution.
1854 */
1855 virtual R maxInfeas() const;
1856
1857 /// check for violations above tol and immediately return false w/o checking the remaining values
1858 /** This method is useful for verifying whether an objective limit can be used as termination criterion
1859 */
1860 virtual bool noViols(R tol) const;
1861
1862 /// Return current basis.
1863 /**@note The basis can be used to solve linear systems or use
1864 * any other of its (const) methods. It is, however, encuraged
1865 * to use methods #setup4solve() and #setup4coSolve() for solving
1866 * systems, since this is likely to have perfomance advantages.
1867 */
1868 const SPxBasisBase<R>& basis() const
1869 {
1870 return *this;
1871 }
1872 ///
1874 {
1875 return *this;
1876 }
1877 /// return loaded SPxPricer.
1878 const SPxPricer<R>* pricer() const
1879 {
1880 return thepricer;
1881 }
1882 /// return loaded SLinSolver.
1884 {
1886 }
1887 /// return loaded SPxRatioTester.
1889 {
1890 return theratiotester;
1891 }
1892
1893 /// Factorize basis matrix.
1894 /// @throw SPxStatusException if loaded matrix is singular
1895 virtual void factorize();
1896
1897private:
1898
1899 /** let index \p i leave the basis and manage entering of another one.
1900 @returns \c false if LP is unbounded/infeasible. */
1901 bool leave(int i, bool polish = false);
1902 /** let id enter the basis and manage leaving of another one.
1903 @returns \c false if LP is unbounded/infeasible. */
1904 bool enter(SPxId& id, bool polish = false);
1905
1906 /// test coVector \p i with status \p stat.
1907 R coTest(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1908 /// compute coTest vector.
1910 /// recompute coTest vector.
1912
1913 /// test VectorBase<R> \p i with status \p stat.
1914 R test(int i, typename SPxBasisBase<R>::Desc::Status stat) const;
1915 /// recompute test vector.
1917
1918 /// compute basis feasibility test vector.
1920 /// update basis feasibility test vector.
1922
1923 ///@}
1924
1925 //------------------------------------
1926 /**@name Parallelization
1927 * In this section we present the methods, that are provided in order to
1928 * allow a parallel version to be implemented as a derived class, thereby
1929 * inheriting most of the code of SPxSolverBase.
1930 *
1931 * @par Initialization
1932 * These methods are used to setup all the vectors used in the Simplex
1933 * loop, that where described in the previous sectios.
1934 */
1935 ///@{
1936public:
1937 /// intialize data structures.
1938 /** If SPxSolverBase is not \ref isInitialized() "initialized", the method
1939 * #solve() calls #init() to setup all vectors and internal data structures.
1940 * Most of the other methods within this section are called by #init().
1941 *
1942 * Derived classes should add the initialization of additional
1943 * data structures by overriding this method. Don't forget,
1944 * however, to call SPxSolverBase<R>::init().
1945 */
1946 virtual void init();
1947
1948protected:
1949
1950 /// has the internal data been initialized?
1951 /** As long as an instance of SPxSolverBase is not initialized, no member
1952 * contains setup data. Initialization is performed via method
1953 * #init(). Afterwards all data structures are kept up to date (even
1954 * for all manipulation methods), until #unInit() is called. However,
1955 * some manipulation methods call #unInit() themselfs.
1956 */
1957 bool isInitialized() const
1958 {
1959 return initialized;
1960 }
1961
1962 /// resets clock average statistics
1964
1965 /// uninitialize data structures.
1966 virtual void unInit()
1967 {
1968 initialized = false;
1969 }
1970 /// setup all vecs fresh
1971 virtual void reinitializeVecs();
1972 /// reset dimensions of vectors according to loaded LP.
1973 virtual void reDim();
1974 /// compute feasibility vector from scratch.
1976 ///
1977 virtual void computeFrhsXtra();
1978 ///
1979 virtual void computeFrhs1(const VectorBase<R>&, const VectorBase<R>&);
1980 ///
1982 /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for entering Simplex.
1983 virtual void computeEnterCoPrhs();
1984 ///
1985 void computeEnterCoPrhs4Row(int i, int n);
1986 ///
1987 void computeEnterCoPrhs4Col(int i, int n);
1988 /// compute \ref soplex::SPxSolverBase<R>::theCoPrhs "theCoPrhs" for leaving Simplex.
1989 virtual void computeLeaveCoPrhs();
1990 ///
1991 void computeLeaveCoPrhs4Row(int i, int n);
1992 ///
1993 void computeLeaveCoPrhs4Col(int i, int n);
1994
1995 /// Compute part of objective value.
1996 /** This method is called from #value() in order to compute the part of
1997 * the objective value resulting form nonbasic variables for #COLUMN
1998 * Representation.
1999 */
2001
2002 /// Get pointer to the \p id 'th vector
2003 virtual const SVectorBase<R>* enterVector(const SPxId& p_id)
2004 {
2005 assert(p_id.isValid());
2006 return p_id.isSPxRowId()
2007 ? &vector(SPxRowId(p_id)) : &vector(SPxColId(p_id));
2008 }
2009 ///
2010 virtual void getLeaveVals(int i,
2011 typename SPxBasisBase<R>::Desc::Status& leaveStat, SPxId& leaveId,
2012 R& leaveMax, R& leavebound, int& leaveNum, StableSum<R>& objChange);
2013 ///
2014 virtual void getLeaveVals2(R leaveMax, SPxId enterId,
2015 R& enterBound, R& newUBbound,
2016 R& newLBbound, R& newCoPrhs, StableSum<R>& objChange);
2017 ///
2018 virtual void getEnterVals(SPxId id, R& enterTest,
2019 R& enterUB, R& enterLB, R& enterVal, R& enterMax,
2020 R& enterPric, typename SPxBasisBase<R>::Desc::Status& enterStat, R& enterRO,
2021 StableSum<R>& objChange);
2022 ///
2023 virtual void getEnterVals2(int leaveIdx,
2024 R enterMax, R& leaveBound, StableSum<R>& objChange);
2025 ///
2026 virtual void ungetEnterVal(SPxId enterId, typename SPxBasisBase<R>::Desc::Status enterStat,
2027 R leaveVal, const SVectorBase<R>& vec, StableSum<R>& objChange);
2028 ///
2029 virtual void rejectEnter(SPxId enterId,
2030 R enterTest, typename SPxBasisBase<R>::Desc::Status enterStat);
2031 ///
2032 virtual void rejectLeave(int leaveNum, SPxId leaveId,
2033 typename SPxBasisBase<R>::Desc::Status leaveStat, const SVectorBase<R>* newVec = nullptr);
2034 ///
2035 virtual void setupPupdate(void);
2036 ///
2037 virtual void doPupdate(void);
2038 ///
2039 virtual void clearUpdateVecs(void);
2040 ///
2041 virtual void perturbMinEnter(void);
2042 /// perturb basis bounds.
2043 virtual void perturbMaxEnter(void);
2044 ///
2045 virtual void perturbMinLeave(void);
2046 /// perturb nonbasic bounds.
2047 virtual void perturbMaxLeave(void);
2048 ///@}
2049
2050 //------------------------------------
2051 /** The following methods serve for initializing the bounds for dual or
2052 * primal Simplex algorithm of entering or leaving type.
2053 */
2054 ///@{
2055 ///
2057 ///
2059 ///
2061 /// setup feasibility bounds for entering algorithm
2063 ///
2064 void setEnterBound4Col(int, int);
2065 ///
2066 void setEnterBound4Row(int, int);
2067 ///
2068 virtual void setEnterBounds();
2069 ///
2070 void setLeaveBound4Row(int i, int n);
2071 ///
2072 void setLeaveBound4Col(int i, int n);
2073 ///
2074 virtual void setLeaveBounds();
2075 ///@}
2076
2077 //------------------------------------
2078 /** Compute the primal ray or the farkas proof in case of unboundedness
2079 * or infeasibility.
2080 */
2081 ///@{
2082 ///
2083 void computePrimalray4Col(R direction, SPxId enterId);
2084 ///
2085 void computePrimalray4Row(R direction);
2086 ///
2087 void computeDualfarkas4Col(R direction);
2088 ///
2089 void computeDualfarkas4Row(R direction, SPxId enterId);
2090 ///@}
2091
2092public:
2093
2094 //------------------------------------
2095 /** Limits and status inquiry */
2096 ///@{
2097 /// set time limit.
2099 /// return time limit.
2100 virtual Real terminationTime() const;
2101 /// set iteration limit.
2102 virtual void setTerminationIter(int iteration = -1);
2103 /// return iteration limit.
2104 virtual int terminationIter() const;
2105 /// set objective limit.
2106 virtual void setTerminationValue(R value = R(infinity));
2107 /// return objective limit.
2108 virtual R terminationValue() const;
2109 /// get objective value of current solution.
2110 virtual R objValue()
2111 {
2112 return value();
2113 }
2114 /// get all results of last solve.
2115 Status
2116 getResult(R* value = 0, VectorBase<R>* primal = 0,
2117 VectorBase<R>* slacks = 0, VectorBase<R>* dual = 0,
2118 VectorBase<R>* reduCost = 0);
2119
2120protected:
2121
2122 /**@todo put the following basis methods near the variable status methods!*/
2123 /// converts basis status to VarStatus
2125
2126 /// converts VarStatus to basis status for rows
2128 const;
2129
2130 /// converts VarStatus to basis status for columns
2132 const;
2133
2134public:
2135
2136 /// gets basis status for a single row
2138
2139 /// gets basis status for a single column
2141
2142 /// get current basis, and return solver status.
2143 Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize = -1,
2144 const int colsSize = -1) const;
2145
2146 /// gets basis status
2148 {
2149 return SPxBasisBase<R>::status();
2150 }
2151
2152 /// check a given basis for validity.
2154
2155 /// set the lp solver's basis.
2156 void setBasis(const VarStatus rows[], const VarStatus cols[]);
2157
2158 /// set the lp solver's basis status.
2160 {
2161 if(m_status == OPTIMAL)
2162 m_status = UNKNOWN;
2163
2165 }
2166
2167 /// setting the solver status external from the solve loop.
2169 {
2170 m_status = stat;
2171 }
2172
2173 /// get level of dual degeneracy
2174 // this function is used for the improved dual simplex
2176
2177 /// get number of dual norms
2178 void getNdualNorms(int& nnormsRow, int& nnormsCol) const;
2179
2180 /// get dual norms
2181 bool getDualNorms(int& nnormsRow, int& nnormsCol, R* norms) const;
2182
2183 /// set dual norms
2184 bool setDualNorms(int nnormsRow, int nnormsCol, R* norms);
2185
2186 /// pass integrality information about the variables to the solver
2187 void setIntegralityInformation(int ncols, int* intInfo);
2188
2189 /// reset cumulative time counter to zero.
2191 {
2192 theCumulativeTime = 0.0;
2193 }
2194
2195 /// get number of bound flips.
2196 int boundFlips() const
2197 {
2198 return totalboundflips;
2199 }
2200
2201 /// get number of dual degenerate pivots
2203 {
2204 return (rep() == ROW) ? enterCycles : leaveCycles;
2205 }
2206
2207 /// get number of primal degenerate pivots
2209 {
2210 return (rep() == ROW) ? leaveCycles : enterCycles;
2211 }
2212
2213 /// get the sum of dual degeneracy
2215 {
2216 return dualDegenSum;
2217 }
2218
2219 /// get the sum of primal degeneracy
2221 {
2222 return primalDegenSum;
2223 }
2224
2225 /// get number of iterations of current solution.
2226 int iterations() const
2227 {
2228 return basis().iteration();
2229 }
2230
2231 /// return number of iterations done with primal algorithm
2233 {
2234 assert(iterations() == 0 || primalCount <= iterations());
2235 return (iterations() == 0) ? 0 : primalCount;
2236 }
2237
2238 /// return number of iterations done with primal algorithm
2240 {
2241 return iterations() - primalIterations();
2242 }
2243
2244 /// return number of iterations done with primal algorithm
2246 {
2247 return polishCount;
2248 }
2249
2250 /// time spent in last call to method solve().
2251 Real time() const
2252 {
2253 return theTime->time();
2254 }
2255
2256 /// returns whether current time limit is reached; call to time() may be skipped unless \p forceCheck is true
2257 ///
2258 bool isTimeLimitReached(const bool forceCheck = false);
2259
2260 /// the maximum runtime
2262 {
2263 return maxTime;
2264 }
2265
2266 /// cumulative time spent in all calls to method solve().
2268 {
2269 return theCumulativeTime;
2270 }
2271
2272 /// the maximum number of iterations
2274 {
2275 return maxIters;
2276 }
2277
2278 /// return const lp's rows if available.
2279 const LPRowSetBase<R>& rows() const
2280 {
2281 return *this->lprowset();
2282 }
2283
2284 /// return const lp's cols if available.
2285 const LPColSet& cols() const
2286 {
2287 return *this->lpcolset();
2288 }
2289
2290 /// copy lower bound VectorBase<R> to \p p_low.
2291 void getLower(VectorBase<R>& p_low) const
2292 {
2293 p_low = SPxLPBase<R>::lower();
2294 }
2295 /// copy upper bound VectorBase<R> to \p p_up.
2296 void getUpper(VectorBase<R>& p_up) const
2297 {
2298 p_up = SPxLPBase<R>::upper();
2299 }
2300
2301 /// copy lhs value VectorBase<R> to \p p_lhs.
2302 void getLhs(VectorBase<R>& p_lhs) const
2303 {
2304 p_lhs = SPxLPBase<R>::lhs();
2305 }
2306
2307 /// copy rhs value VectorBase<R> to \p p_rhs.
2308 void getRhs(VectorBase<R>& p_rhs) const
2309 {
2310 p_rhs = SPxLPBase<R>::rhs();
2311 }
2312
2313 /// optimization sense.
2315 {
2316 return this->spxSense();
2317 }
2318
2319 /// returns statistical information in form of a string.
2320 std::string statistics() const
2321 {
2322 std::stringstream s;
2323 s << basis().statistics()
2324 << "Solution time : " << std::setw(10) << std::fixed << std::setprecision(
2325 2) << time() << std::endl
2326 << "Iterations : " << std::setw(10) << iterations() << std::endl;
2327
2328 return s.str();
2329 }
2330
2331 ///@}
2332
2333 //------------------------------------
2334 /** Mapping between numbers and Ids */
2335 ///@{
2336 /// RowId of \p i 'th inequality.
2337 SPxRowId rowId(int i) const
2338 {
2339 return this->rId(i);
2340 }
2341 /// ColId of \p i 'th column.
2342 SPxColId colId(int i) const
2343 {
2344 return this->cId(i);
2345 }
2346 ///@}
2347
2348 //------------------------------------
2349 /** Constructors / destructors */
2350 ///@{
2351 /// default constructor.
2352 explicit
2356 // virtual destructor
2358 ///@}
2359
2360 //------------------------------------
2361 /** Miscellaneous */
2362 ///@{
2363 /// check consistency.
2364 bool isConsistent() const;
2365 ///@}
2366
2367 //------------------------------------
2368 /** assignment operator and copy constructor */
2369 ///@{
2370 /// assignment operator
2372 /// copy constructor
2374 ///@}
2375
2376 void testVecs();
2377};
2378
2379//
2380// Auxiliary functions.
2381//
2382
2383/// Pretty-printing of variable status.
2384template <class R>
2385std::ostream& operator<<(std::ostream& os,
2386 const typename SPxSolverBase<R>::VarStatus& status);
2387
2388/// Pretty-printing of solver status.
2389template <class R>
2390std::ostream& operator<<(std::ostream& os,
2391 const typename SPxSolverBase<R>::Status& status);
2392
2393/// Pretty-printing of algorithm.
2394template <class R>
2395std::ostream& operator<<(std::ostream& os,
2396 const typename SPxSolverBase<R>::Type& status);
2397
2398/// Pretty-printing of representation.
2399template <class R>
2400std::ostream& operator<<(std::ostream& os,
2401 const typename SPxSolverBase<R>::Representation& status);
2402
2403/* For Backwards compatibility */
2405
2406} // namespace soplex
2407
2408// For general templated functions
2409#include "spxsolver.hpp"
2410#include "spxsolve.hpp"
2411#include "changesoplex.hpp"
2412#include "leave.hpp"
2413#include "enter.hpp"
2414#include "spxshift.hpp"
2415#include "spxbounds.hpp"
2416#include "spxchangebasis.hpp"
2417#include "spxvecs.hpp"
2418#include "spxwritestate.hpp"
2419#include "spxfileio.hpp"
2420#include "spxquality.hpp"
2421
2422#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:1224
bool getDualNorms(int &nnormsRow, int &nnormsCol, R *norms) const
get dual norms
void scaleLeavetol(R d)
scale the leaving tolerance
Definition: spxsolver.h:877
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:2168
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:856
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:1707
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:1723
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:1251
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:1162
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:2226
virtual void changeElement(SPxRowId rid, SPxColId cid, const R &val, bool scale=false)
Definition: spxsolver.h:1170
VectorBase< R > & lcBound()
lower bound for coPvec.
Definition: spxsolver.h:1559
UpdateVector< R > * theFvec
Definition: spxsolver.h:369
int primalIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2232
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:1878
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:1957
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:1524
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:1385
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:1801
bool isCoBasic(int i) const
is the i 'th covector basic ?
Definition: spxsolver.h:1415
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:1391
SolutionPolish getSolutionPolishing()
return objective of solution polishing
Definition: spxsolver.h:694
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:887
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:2196
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:1492
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:557
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:987
virtual void changeMaxObj(SPxColId p_id, const R &p_newVal, bool scale=false)
overloading a virtual function
Definition: spxsolver.h:1059
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:1049
SPxStarter< R > * starter() const
return current starter.
Definition: spxsolver.h:563
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:1815
int getDisplayFreq()
get display frequency
Definition: spxsolver.h:922
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:2302
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:1829
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:1397
int coDim() const
codimension.
Definition: spxsolver.h:1187
bool isId(const SPxId &p_id) const
Is p_id an SPxId ?
Definition: spxsolver.h:1242
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:948
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:954
virtual void clearRowObjs()
Definition: spxsolver.h:1074
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:2190
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:1585
void setMemFactor(R f)
set refactor threshold for memory growth in current factor update compared to the last factorization
Definition: spxsolver.h:526
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:916
R leavetolscale
factor to temporarily decrease the leaving tolerance
Definition: spxsolver.h:274
void forceRecompNonbasicValue()
Definition: spxsolver.h:726
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:1123
int multColwiseCalls
number of products, columnwise multiplication
Definition: spxsolver.h:477
void setSparsePricingFactor(R fac)
Definition: spxsolver.h:934
const SVectorBase< R > & vector(const SPxRowId &rid) const
Definition: spxsolver.h:1270
void setup4coSolve2(SSVectorBase< R > *p_z, SSVectorBase< R > *p_rhs)
Setup vectors to be cosolved within Simplex loop.
Definition: spxsolver.h:1841
SPxBasisBase< R >::SPxStatus getBasisStatus() const
gets basis status
Definition: spxsolver.h:2147
const SVectorBase< R > & vector(const SPxId &p_id) const
VectorBase<R> associated to p_id.
Definition: spxsolver.h:1295
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:2337
const SVectorBase< R > & coVector(int i) const
i 'th covector of LP.
Definition: spxsolver.h:1308
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:942
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:928
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:2003
void computePvec()
compute entire pVec().
void computeTest()
compute test VectorBase<R> in ENTERing Simplex.
VectorBase< R > & ucBound()
upper bound for coPvec.
Definition: spxsolver.h:1538
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:1205
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:2110
void setDual(VectorBase< R > &p_vector)
SPxBasisBase< R >::Desc::Status covarStatus(int i) const
Status of i 'th covariable.
Definition: spxsolver.h:1364
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:1572
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:2308
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:545
Timer::TYPE getTiming()
set timing type
Definition: spxsolver.h:905
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:1403
Real time() const
time spent in last call to method solve().
Definition: spxsolver.h:2251
virtual void doRemoveCols(int perm[])
bool isTerminationValueEnabled() const
true if objective limit should be used in the next solve
Definition: spxsolver.h:700
virtual void changeUpper(SPxColId p_id, const R &p_newUpper, bool scale=false)
overloading virtual function
Definition: spxsolver.h:1099
R sumPrimalDegeneracy()
get the sum of primal degeneracy
Definition: spxsolver.h:2220
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:1883
void computeEnterCoPrhs4Row(int i, int n)
const VectorBase< R > & lpBound() const
Definition: spxsolver.h:1611
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:520
int numCycle() const
actual number of degenerate simplex steps encountered so far.
Definition: spxsolver.h:981
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:1087
SPxColId colId(int i) const
ColId of i 'th column.
Definition: spxsolver.h:2342
bool isBasic(int i) const
is the i 'th vector basic ?
Definition: spxsolver.h:1409
virtual void changeRange(SPxRowId p_id, const R &p_newLhs, const R &p_newRhs, bool scale=false)
Definition: spxsolver.h:1146
UpdateVector< R > & fVec() const
feasibility vector.
Definition: spxsolver.h:1430
VectorBase< R > & upBound()
upper bound for pVec.
Definition: spxsolver.h:1604
@ 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:540
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:1335
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:872
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:514
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:881
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:1683
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:1888
int dualIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2239
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:1321
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:1868
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:1278
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:534
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:851
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:1479
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:1966
void setLeaveBound4Row(int i, int n)
int maxCycle() const
maximum number of degenerate simplex steps before we detect cycling.
Definition: spxsolver.h:976
virtual void changeLower(int i, const R &newLower, bool scale=false)
void setStoreBasisFreqForBoosting(int freq)
Definition: spxsolver.h:960
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:2245
VectorBase< R > & lpBound()
lower bound for pVec.
Definition: spxsolver.h:1625
virtual void clear()
clear all data in solver.
int dim() const
dimension of basis matrix.
Definition: spxsolver.h:1182
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:1715
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:2279
SPxBasisBase< R >::Desc::Status varStatusToBasisStatusCol(int col, VarStatus stat) const
converts VarStatus to basis status for columns
SPxBasisBase< R > & basis()
Definition: spxsolver.h:1873
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:688
void toggleTerminationValue(bool enable)
toggle objective limit for next solve
Definition: spxsolver.h:706
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:2214
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:1313
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:1466
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:2296
UpdateVector< R > & coPvec() const
copricing vector.
Definition: spxsolver.h:1505
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:2202
Pricing thePricing
full or partial pricing.
Definition: spxsolver.h:248
const VectorBase< R > & ubBound() const
upper bound for fVec.
Definition: spxsolver.h:1448
int getMaxIters()
the maximum number of iterations
Definition: spxsolver.h:2273
std::string statistics() const
returns statistical information in form of a string.
Definition: spxsolver.h:2320
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:1691
SPxBasisBase< R >::Desc::Status varStatus(int i) const
Status of i 'th variable.
Definition: spxsolver.h:1358
SPxLPBase< R >::SPxSense sense() const
optimization sense.
Definition: spxsolver.h:2314
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:1545
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:1638
const VectorBase< R > & upBound() const
Definition: spxsolver.h:1590
Status status() const
Status of solution process.
const SVectorBase< R > & vector(int i) const
i 'th vector.
Definition: spxsolver.h:1264
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:2208
virtual void unShift(void)
remove shift as much as possible.
Type type() const
return current Type.
Definition: spxsolver.h:551
virtual R shift() const
total current shift amount.
Definition: spxsolver.h:1734
int multUnsetupCalls
number of products w/o sparsity information
Definition: spxsolver.h:478
VectorBase< R > & ubBound()
upper bound for fVec, writable.
Definition: spxsolver.h:1461
void getLower(VectorBase< R > &p_low) const
copy lower bound VectorBase<R> to p_low.
Definition: spxsolver.h:2291
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:1518
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:1370
bool isBasic(const SPxId &p_id) const
is the p_id 'th vector basic ?
Definition: spxsolver.h:1376
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:894
const SVectorBase< R > & unitVector(int i) const
return i 'th unit vector.
Definition: spxsolver.h:1343
const std::shared_ptr< Tolerances > & tolerances() const
returns current tolerances
Definition: spxsolver.h:508
virtual void changeBounds(SPxColId p_id, const R &p_newLower, const R &p_newUpper, bool scale=false)
Definition: spxsolver.h:1110
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:864
virtual void doRemoveCol(int i)
void setBasisStatus(typename SPxBasisBase< R >::SPxStatus stat)
set the lp solver's basis status.
Definition: spxsolver.h:2159
void shiftUPbound(int i, R to)
shift i 'th upBound to to.
Definition: spxsolver.h:1699
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:1154
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:2285
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:2267
virtual void doRemoveRow(int i)
void initRep(Representation p_rep)
initialize ROW or COLUMN representation.
virtual R getBasisMetric(int type)
Definition: spxsolver.h:992
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:1135
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:1443
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:2261
virtual void changeRowObj(SPxRowId p_id, const R &p_newVal, bool scale=false)
Definition: spxsolver.h:1069
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
void setTolerances(std::shared_ptr< Tolerances > &tolerances)
set tolerances
Definition: updatevector.h:174
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:1134
double Real
Definition: spxdefines.h:269
SPxSolverBase< Real > SPxSolver
Definition: spxsolver.h:2404
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.