SoPlex
Loading...
Searching...
No Matches
soplex.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the class library */
4/* SoPlex --- the Sequential object-oriented simPlex. */
5/* */
6/* Copyright (c) 1996-2026 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file soplex.h
26 * @brief Preconfigured SoPlex LP solver
27 */
28
29#ifndef _SOPLEX_H_
30#define _SOPLEX_H_
31
32#include <string.h>
33
34#include "soplex/spxgithash.h"
35#include "soplex/spxdefines.h"
36#include "soplex/basevectors.h"
37#include "soplex/spxsolver.h"
38#include "soplex/slufactor.h"
40
41///@todo try to move to cpp file by forward declaration
43#include "soplex/spxmainsm.h"
44
45#include "soplex/spxscaler.h"
46#include "soplex/spxequilisc.h"
47#include "soplex/spxleastsqsc.h"
48#include "soplex/spxgeometsc.h"
49
50#include "soplex/spxstarter.h"
51#include "soplex/spxweightst.h"
52#include "soplex/spxsumst.h"
53#include "soplex/spxvectorst.h"
54
55#include "soplex/spxpricer.h"
56#include "soplex/spxautopr.h"
57#include "soplex/spxdantzigpr.h"
58#include "soplex/spxparmultpr.h"
59#include "soplex/spxdevexpr.h"
60#include "soplex/spxsteeppr.h"
61#include "soplex/spxsteepexpr.h"
62#include "soplex/spxhybridpr.h"
63
65#include "soplex/spxdefaultrt.h"
66#include "soplex/spxharrisrt.h"
67#include "soplex/spxfastrt.h"
69
70#include "soplex/solbase.h"
71#include "soplex/sol.h"
72
73#include "soplex/spxlpbase.h"
74
75#include "soplex/spxpapilo.h"
76
77#ifdef SOPLEX_WITH_GMP
78#include <gmp.h>
79#endif
80
81#ifdef SOPLEX_WITH_BOOST
82#ifdef SOPLEX_WITH_MPFR
83// For multiple precision
84#include <boost/multiprecision/mpfr.hpp>
85#endif
86#ifdef SOPLEX_WITH_CPPMPF
87#include <boost/multiprecision/cpp_dec_float.hpp>
88#endif
89
90// An alias for boost multiprecision
91namespace mpf = boost::multiprecision;
92#endif
93
94#define SOPLEX_DEFAULT_RANDOM_SEED 0 // used to suppress output when the seed was not changed
95
96///@todo implement automatic rep switch, based on row/col dim
97///@todo introduce status codes for SoPlex, especially for rational solving
98
99///@todo record and return "best" solutions found during IR (Ambros)
100///@todo implement main IR loop for primal and dual feasible case with fail otherwise (Ambros)
101///@todo implement statistical info (time, factor time, iters, ...) since last call to solveReal() or solveRational() (Ambros?)
102///@todo implement performInfeasibilityIR (Ambros?)
103///@todo extend IR loop to infeasible case (Dan?)
104///@todo extend IR loop to unbounded case (Dan?)
105
106///@todo interface rational reconstruction code for rational vectors
107///@todo integrate rational reconstruction into IR loop
108///@todo integrate rational SPxSolver and distinguish between original and transformed rational LP
109///@todo rational scalers
110///@todo rational simplifier
111
112namespace soplex
113{
114
115/**@class SoPlex
116 * @brief Preconfigured SoPlex LP-solver.
117 * @ingroup Algo
118 */
119template <class R>
121{
122public:
123
124 ///@name Construction and destruction
125 ///@{
126
127 /// default constructor
129
130 /// assignment operator
132
133 /// copy constructor
135
136 /// destructor
137 virtual ~SoPlexBase();
138
139 ///@}
140
141
142 ///@name Access to the real LP
143 ///@{
144
145 /// returns number of rows
146 int numRows() const;
147 int numRowsReal() const; /* For SCIP compatibility */
148 int numRowsRational() const;
149
150 /// Templated function that
151 /// returns number of columns
152 int numCols() const;
153 int numColsReal() const; /* For SCIP compatibility */
154 int numColsRational() const;
155
156 /// returns number of nonzeros
157 int numNonzeros() const;
158
160
161 /// returns smallest non-zero element in absolute value
163
164 /// returns biggest non-zero element in absolute value
166
167 /// returns (unscaled) coefficient
168 R coefReal(int row, int col) const;
169
170 /// returns vector of row \p i, ignoring scaling
172
173 /// gets vector of row \p i
174 void getRowVectorReal(int i, DSVectorBase<R>& row) const;
175
176 /// returns right-hand side vector, ignoring scaling
178
179 /// gets right-hand side vector
180 void getRhsReal(VectorBase<R>& rhs) const;
181
182 /// returns right-hand side of row \p i
183 R rhsReal(int i) const;
184
185 /// returns left-hand side vector, ignoring scaling
187
188 /// gets left-hand side vector
189 void getLhsReal(VectorBase<R>& lhs) const;
190
191 /// returns left-hand side of row \p i
192 R lhsReal(int i) const;
193
194 /// returns inequality type of row \p i
195 typename LPRowBase<R>::Type rowTypeReal(int i) const;
196
197 /// returns vector of col \p i, ignoring scaling
199
200 /// gets vector of col \p i
201 void getColVectorReal(int i, DSVectorBase<R>& col) const;
202
203 /// returns upper bound vector
205
206 /// returns upper bound of column \p i
207 R upperReal(int i) const;
208
209 /// gets upper bound vector
210 void getUpperReal(VectorBase<R>& upper) const;
211
212 /// returns lower bound vector
214
215 /// returns lower bound of column \p i
216 R lowerReal(int i) const;
217
218 /// gets lower bound vector
219 void getLowerReal(VectorBase<R>& lower) const;
220
221 /// gets objective function vector
222 void getObjReal(VectorBase<R>& obj) const;
223
224 /// returns objective value of column \p i
225 R objReal(int i) const;
226
227 /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
228 /// internally, this is generally faster
230
231 /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
232 /// stored internally, this is generally faster
233 R maxObjReal(int i) const;
234
235 /// gets number of available dual norms
236 void getNdualNorms(int& nnormsRow, int& nnormsCol) const;
237
238 /// gets steepest edge norms and returns false if they are not available
239 bool getDualNorms(int& nnormsRow, int& nnormsCol, R* norms) const;
240
241 /// sets steepest edge norms and returns false if that's not possible
242 bool setDualNorms(int nnormsRow, int nnormsCol, R* norms);
243
244 /// pass integrality information about the variables to the solver
245 void setIntegralityInformation(int ncols, int* intInfo);
246
247 ///@}
248
249
250 ///@name Access to the rational LP
251 ///@{
252
253 /// returns smallest non-zero element in absolute value
255
256 /// returns biggest non-zero element in absolute value
258
259 /// gets row \p i
260 void getRowRational(int i, LPRowRational& lprow) const;
261
262 /// gets rows \p start, ..., \p end.
263 void getRowsRational(int start, int end, LPRowSetRational& lprowset) const;
264
265 /// returns vector of row \p i
267
268 /// returns right-hand side vector
270
271 /// returns right-hand side of row \p i
272 const Rational& rhsRational(int i) const;
273
274 /// returns left-hand side vector
276
277 /// returns left-hand side of row \p i
278 const Rational& lhsRational(int i) const;
279
280 /// returns inequality type of row \p i
282
283 /// gets column \p i
284 void getColRational(int i, LPColRational& lpcol) const;
285
286 /// gets columns \p start, ..., \p end
287 void getColsRational(int start, int end, LPColSetRational& lpcolset) const;
288
289 /// returns vector of column \p i
291
292 /// returns upper bound vector
294
295 /// returns upper bound of column \p i
296 const Rational& upperRational(int i) const;
297
298 /// returns lower bound vector
300
301 /// returns lower bound of column \p i
302 const Rational& lowerRational(int i) const;
303
304 /// gets objective function vector
306
307 /// gets objective value of column \p i
308 void getObjRational(int i, Rational& obj) const;
309
310 /// returns objective value of column \p i
311 Rational objRational(int i) const;
312
313 /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
314 /// internally, this is generally faster
316
317 /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
318 /// stored internally, this is generally faster
319 const Rational& maxObjRational(int i) const;
320
321 ///@}
322
323
324 ///@name Modification of the real LP
325 ///@{
326
327 /// adds a single row
328 void addRowReal(const LPRowBase<R>& lprow);
329
330 /// adds multiple rows
331 void addRowsReal(const LPRowSetBase<R>& lprowset);
332
333 /// adds a single column
334 void addColReal(const LPColBase<R>& lpcol);
335
336 /// adds multiple columns
337 void addColsReal(const LPColSetBase<R>& lpcolset);
338
339 /// replaces row \p i with \p lprow
340 void changeRowReal(int i, const LPRowBase<R>& lprow);
341
342 /// changes left-hand side vector for constraints to \p lhs
343 void changeLhsReal(const VectorBase<R>& lhs);
344
345 /// changes left-hand side of row \p i to \p lhs
346 void changeLhsReal(int i, const R& lhs);
347
348 /// changes right-hand side vector to \p rhs
349 void changeRhsReal(const VectorBase<R>& rhs);
350
351 /// changes right-hand side of row \p i to \p rhs
352 void changeRhsReal(int i, const R& rhs);
353
354 /// changes left- and right-hand side vectors
355 void changeRangeReal(const VectorBase<R>& lhs, const VectorBase<R>& rhs);
356
357 /// changes left- and right-hand side of row \p i
358 void changeRangeReal(int i, const R& lhs, const R& rhs);
359
360 /// replaces column \p i with \p lpcol
361 void changeColReal(int i, const LPColReal& lpcol);
362
363 /// changes vector of lower bounds to \p lower
364 void changeLowerReal(const VectorBase<R>& lower);
365
366 /// changes lower bound of column i to \p lower
367 void changeLowerReal(int i, const R& lower);
368
369 /// changes vector of upper bounds to \p upper
370 void changeUpperReal(const VectorBase<R>& upper);
371
372 /// changes \p i 'th upper bound to \p upper
373 void changeUpperReal(int i, const R& upper);
374
375 /// changes vectors of column bounds to \p lower and \p upper
376 void changeBoundsReal(const VectorBase<R>& lower, const VectorBase<R>& upper);
377
378 /// changes bounds of column \p i to \p lower and \p upper
379 void changeBoundsReal(int i, const R& lower, const R& upper);
380
381 /// changes objective function vector to \p obj
382 void changeObjReal(const VectorBase<R>& obj);
383
384 /// changes objective coefficient of column i to \p obj
385 void changeObjReal(int i, const R& obj);
386
387 /// changes matrix entry in row \p i and column \p j to \p val
388 void changeElementReal(int i, int j, const R& val);
389
390 /// removes row \p i
391 void removeRowReal(int i);
392
393 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
394 /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
395 /// #numRows()
396 void removeRowsReal(int perm[]);
397
398 /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRows() may be passed
399 /// as buffer memory
400 void removeRowsReal(int idx[], int n, int perm[] = nullptr);
401
402 /// removes rows \p start to \p end including both; an array \p perm of size #numRows() may be passed as buffer
403 /// memory
404 void removeRowRangeReal(int start, int end, int perm[] = nullptr);
405
406 /// removes column i
407 void removeColReal(int i);
408
409 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
410 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
411 /// #numColsReal()
412 void removeColsReal(int perm[]);
413
414 /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsReal() may be
415 /// passed as buffer memory
416 void removeColsReal(int idx[], int n, int perm[] = nullptr);
417
418 /// removes columns \p start to \p end including both; an array \p perm of size #numColsReal() may be passed as
419 /// buffer memory
420 void removeColRangeReal(int start, int end, int perm[] = nullptr);
421
422 /// clears the LP
424
425 /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, if sync mode is manual
427
428 ///@}
429
430
431 ///@name Modification of the rational LP
432 ///@{
433
434 /// adds a single row
435 void addRowRational(const LPRowRational& lprow);
436
437#ifdef SOPLEX_WITH_GMP
438 /// adds a single row (GMP only method)
439 void addRowRational(const mpq_t* lhs, const mpq_t* rowValues, const int* rowIndices,
440 const int rowSize, const mpq_t* rhs);
441
442 /// adds a set of rows (GMP only method)
443 void addRowsRational(const mpq_t* lhs, const mpq_t* rowValues, const int* rowIndices,
444 const int* rowStarts, const int* rowLengths, const int numRows, const int numValues,
445 const mpq_t* rhs);
446#endif
447
448 /// adds multiple rows
449 void addRowsRational(const LPRowSetRational& lprowset);
450
451 /// adds a single column
452 void addColRational(const LPColRational& lpcol);
453
454#ifdef SOPLEX_WITH_GMP
455 /// adds a single column (GMP only method)
456 void addColRational(const mpq_t* obj, const mpq_t* lower, const mpq_t* colValues,
457 const int* colIndices, const int colSize, const mpq_t* upper);
458
459 /// adds a set of columns (GMP only method)
460 void addColsRational(const mpq_t* obj, const mpq_t* lower, const mpq_t* colValues,
461 const int* colIndices, const int* colStarts, const int* colLengths, const int numCols,
462 const int numValues, const mpq_t* upper);
463#endif
464
465 /// adds multiple columns
466 void addColsRational(const LPColSetRational& lpcolset);
467
468 /// replaces row \p i with \p lprow
469 void changeRowRational(int i, const LPRowRational& lprow);
470
471 /// changes left-hand side vector for constraints to \p lhs
473
474 /// changes left-hand side of row \p i to \p lhs
475 void changeLhsRational(int i, const Rational& lhs);
476
477#ifdef SOPLEX_WITH_GMP
478 /// changes left-hand side of row \p i to \p lhs (GMP only method)
479 void changeLhsRational(int i, const mpq_t* lhs);
480#endif
481
482 /// changes right-hand side vector to \p rhs
484
485#ifdef SOPLEX_WITH_GMP
486 /// changes right-hand side vector to \p rhs (GMP only method)
487 void changeRhsRational(const mpq_t* rhs, int rhsSize);
488#endif
489
490 /// changes right-hand side of row \p i to \p rhs
491 void changeRhsRational(int i, const Rational& rhs);
492
493 /// changes left- and right-hand side vectors
495
496 /// changes left- and right-hand side of row \p i
497 void changeRangeRational(int i, const Rational& lhs, const Rational& rhs);
498
499#ifdef SOPLEX_WITH_GMP
500 /// changes left- and right-hand side of row \p i (GMP only method)
501 void changeRangeRational(int i, const mpq_t* lhs, const mpq_t* rhs);
502#endif
503
504 /// replaces column \p i with \p lpcol
505 void changeColRational(int i, const LPColRational& lpcol);
506
507 /// changes vector of lower bounds to \p lower
509
510 /// changes lower bound of column i to \p lower
511 void changeLowerRational(int i, const Rational& lower);
512
513#ifdef SOPLEX_WITH_GMP
514 /// changes lower bound of column i to \p lower (GMP only method)
515 void changeLowerRational(int i, const mpq_t* lower);
516#endif
517
518 /// changes vector of upper bounds to \p upper
520
521 /// changes \p i 'th upper bound to \p upper
522 void changeUpperRational(int i, const Rational& upper);
523
524#ifdef SOPLEX_WITH_GMP
525 /// changes upper bound of column i to \p upper (GMP only method)
526 void changeUpperRational(int i, const mpq_t* upper);
527#endif
528
529 /// changes vectors of column bounds to \p lower and \p upper
530 void changeBoundsRational(const VectorRational& lower, const VectorRational& upper);
531
532 /// changes bounds of column \p i to \p lower and \p upper
533 void changeBoundsRational(int i, const Rational& lower, const Rational& upper);
534
535#ifdef SOPLEX_WITH_GMP
536 /// changes bounds of column \p i to \p lower and \p upper (GMP only method)
537 void changeBoundsRational(int i, const mpq_t* lower, const mpq_t* upper);
538#endif
539
540 /// changes objective function vector to \p obj
542
543 /// changes objective coefficient of column i to \p obj
544 void changeObjRational(int i, const Rational& obj);
545
546#ifdef SOPLEX_WITH_GMP
547 /// changes objective coefficient of column i to \p obj (GMP only method)
548 void changeObjRational(int i, const mpq_t* obj);
549#endif
550
551 /// changes matrix entry in row \p i and column \p j to \p val
552 void changeElementRational(int i, int j, const Rational& val);
553
554#ifdef SOPLEX_WITH_GMP
555 /// changes matrix entry in row \p i and column \p j to \p val (GMP only method)
556 void changeElementRational(int i, int j, const mpq_t* val);
557#endif
558
559 /// removes row \p i
560 void removeRowRational(int i);
561
562 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the new
563 /// index where row \p i has been moved to; note that \p perm must point to an array of size at least
564 /// #numRowsRational()
565 void removeRowsRational(int perm[]);
566
567 /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsRational() may be
568 /// passed as buffer memory
569 void removeRowsRational(int idx[], int n, int perm[] = nullptr);
570
571 /// removes rows \p start to \p end including both; an array \p perm of size #numRowsRational() may be passed as
572 /// buffer memory
573 void removeRowRangeRational(int start, int end, int perm[] = nullptr);
574
575 /// removes column i
576 void removeColRational(int i);
577
578 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
579 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
580 /// #numColsRational()
581 void removeColsRational(int perm[]);
582
583 /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsRational() may be
584 /// passed as buffer memory
585 void removeColsRational(int idx[], int n, int perm[] = nullptr);
586
587 /// removes columns \p start to \p end including both; an array \p perm of size #numColsRational() may be passed as
588 /// buffer memory
589 void removeColRangeRational(int start, int end, int perm[] = nullptr);
590
591 /// clears the LP
593
594 /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, if sync mode is manual
596
597 ///@}
598
599 ///@name Solving and general solution query
600 ///@{
601
602 /// optimize the given LP
603 typename SPxSolverBase<R>::Status optimize(volatile bool* interrupt = nullptr);
604
605 // old name for backwards compatibility
606 typename SPxSolverBase<R>::Status solve(volatile bool* interrupt = nullptr)
607 {
608 return optimize(interrupt);
609 }
610
611 /// returns the current solver status
613
614 /// is stored primal solution feasible?
615 bool isPrimalFeasible() const;
616
617 /// is a solution available (not neccessarily feasible)?
618 bool hasSol() const;
619
620 /// deprecated: use #hasSol() instead
621 bool hasPrimal() const
622 {
623 return hasSol();
624 }
625
626 /// deprecated: use #hasSol() instead
627 bool hasDual() const
628 {
629 return hasSol();
630 }
631
632 /// is a primal unbounded ray available?
633 bool hasPrimalRay() const;
634
635 /// is stored dual solution feasible?
636 bool isDualFeasible() const;
637
638 /// is Farkas proof of infeasibility available?
639 bool hasDualFarkas() const;
640
641 /// sets the status to OPTIMAL in case the LP has been solved with unscaled violations
643 {
645 {
647 return true;
648 }
649 else
650 return false;
651 }
652 ///@}
653
654
655 ///@name Query for the real solution data
656 ///@{
657
658 /// returns the objective value if a primal solution is available
660
661 /// gets the primal solution vector if available; returns true on success
663 bool getPrimalReal(R* p_vector, int size); // For SCIP compatibility
665
666 /// gets the activity for the \p i 'th row given the current primal solution
667 bool getRowActivity(int i, R& value);
668 bool getRowActivityRational(int i, Rational& value);
669
670 /// gets the activities for the rows in \p indices given the current primal solution;
671 /// all other elements of \p vector are left unchanged;
672 /// \p vector must have the same size as the total number of rows
673 bool getRowsActivity(const std::vector<int>& indices, VectorBase<R>& vector);
674 bool getRowsActivityReal(const std::vector<int>& indices, R* p_vector, int dim);
675 bool getRowsActivityRational(const std::vector<int>& indices, VectorRational& vector);
676
677 /// gets the activities for all rows given the current primal solution;
678 /// \p vector must have the same size as the total number of rows
680 bool getRowsActivityReal(R* p_vector, int dim);
682
683 /// gets the vector of slack values if available; returns true on success
685 bool getSlacksReal(R* p_vector, int dim);
686
687 /// gets the primal ray if available; returns true on success
689 bool getPrimalRayReal(R* vector, int dim); /* For SCIP compatibility */
691
692 /// gets the dual solution vector if available; returns true on success
693 bool getDual(VectorBase<R>& vector);
694 bool getDualReal(R* p_vector, int dim); /* For SCIP compatibility */
696
697 /// gets the activity for the \p i 'th column given the current dual solution
698 bool getColActivity(const int i, R& value);
699 bool getColActivityRational(const int i, Rational& value);
700
701 /// gets the activities for the columns in \p indices given the current dual solution;
702 /// all other elements of \p vector are left unchanged;
703 /// \p vector must have the same size as the total number of columns
704 bool getColsActivity(const std::vector<int>& indices, VectorBase<R>& vector);
705 bool getColsActivityReal(const std::vector<int>& indices, R* p_vector, const int dim);
706 bool getColsActivityRational(const std::vector<int>& indices, VectorRational& vector);
707
708 /// gets the activities for all columns given the current dual solution;
709 /// \p vector must have the same size as the total number of columns
711 bool getColsActivityReal(R* p_vector, const int dim);
713
714 /// gets the vector of reduced cost values if available; returns true on success
716 bool getRedCostReal(R* vector, int dim); /* For SCIP compatibility */
718
719 /// gets the Farkas proof if available; returns true on success
721 bool getDualFarkasReal(R* vector, int dim);
723
724 /// gets violation of bounds; returns true on success
725 bool getBoundViolation(R& maxviol, R& sumviol);
727
728 /// gets violation of constraints; returns true on success
729 bool getRowViolation(R& maxviol, R& sumviol);
730 bool getRowViolationRational(Rational& maxviol, Rational& sumviol);
731
732 /// gets violation of reduced costs; returns true on success
733 bool getRedCostViolation(R& maxviol, R& sumviol);
735
736 /// gets violation of dual multipliers; returns true on success
737 bool getDualViolation(R& maxviol, R& sumviol);
739
740 ///@}
741
742
743 ///@name Query for the rational solution data
744 ///@{
745
746 /// returns the objective value if a primal solution is available
748
749 /// gets the vector of slack values if available; returns true on success
751
752#ifdef SOPLEX_WITH_GMP
753 /// gets the primal solution vector if available; returns true on success (GMP only method)
754 bool getPrimalRational(mpq_t* vector, const int size);
755
756 /// gets the vector of slack values if available; returns true on success (GMP only method)
757 bool getSlacksRational(mpq_t* vector, const int size);
758
759 /// gets the primal ray if LP is unbounded; returns true on success (GMP only method)
760 bool getPrimalRayRational(mpq_t* vector, const int size);
761
762 /// gets the dual solution vector if available; returns true on success (GMP only method)
763 bool getDualRational(mpq_t* vector, const int size);
764
765 /// gets the vector of reduced cost values if available; returns true on success (GMP only method)
766 bool getRedCostRational(mpq_t* vector, const int size);
767
768 /// gets the Farkas proof if LP is infeasible; returns true on success (GMP only method)
769 bool getDualFarkasRational(mpq_t* vector, const int size);
770#endif
771
772 /// get size of primal solution
773 int totalSizePrimalRational(const int base = 2);
774
775 /// get size of dual solution
776 int totalSizeDualRational(const int base = 2);
777
778 /// get size of least common multiple of denominators in primal solution
779 int dlcmSizePrimalRational(const int base = 2);
780
781 /// get size of least common multiple of denominators in dual solution
782 int dlcmSizeDualRational(const int base = 2);
783
784 /// get size of largest denominator in primal solution
785 int dmaxSizePrimalRational(const int base = 2);
786
787 /// get size of largest denominator in dual solution
788 int dmaxSizeDualRational(const int base = 2);
789
790 ///@}
791
792
793 ///@name Access and modification of basis information
794 ///@{
795
796 /// is an advanced starting basis available?
797 bool hasBasis() const;
798
799 /// returns the current basis status
801
802 /// returns basis status for a single row
804
805 /// returns basis status for a single column
807
808 /// gets current basis via arrays of statuses
810 typename SPxSolverBase<R>::VarStatus cols[]) const;
811
812 /// gets the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m
813 void getBasisInd(int* bind) const;
814
815 /** compute one of several matrix metrics based on the diagonal of the LU factorization
816 * type = 0: max/min ratio
817 * type = 1: trace of U (sum of diagonal elements)
818 * type = 2: determinant (product of diagonal elements)
819 */
820 bool getBasisMetric(R& metric, int type = 0);
821
822 /// computes an estimated condition number for the current basis matrix using the power method; returns true on success
823 bool getEstimatedCondition(R& condition);
824
825 /// computes the exact condition number for the current basis matrix using the power method; returns true on success
826 bool getExactCondition(R& condition);
827
828 /// computes row \p r of basis inverse; returns true on success
829 /// @param r which row of the basis inverse is computed
830 /// @param coef values of result vector (not packed but scattered)
831 /// @param inds indices of result vector (nullptr if not to be used)
832 /// @param ninds number of nonzeros in result vector
833 /// @param unscale determines whether the result should be unscaled according to the original LP data
834 bool getBasisInverseRowReal(int r, R* coef, int* inds = nullptr, int* ninds = nullptr,
835 bool unscale = true);
836
837 /// computes column \p c of basis inverse; returns true on success
838 /// @param c which column of the basis inverse is computed
839 /// @param coef values of result vector (not packed but scattered)
840 /// @param inds indices of result vector (nullptr if not to be used)
841 /// @param ninds number of nonzeros in result vector
842 /// @param unscale determines whether the result should be unscaled according to the original LP data
843 bool getBasisInverseColReal(int c, R* coef, int* inds = nullptr, int* ninds = nullptr,
844 bool unscale = true);
845
846 /// computes dense solution of basis matrix B * \p sol = \p rhs; returns true on success
847 bool getBasisInverseTimesVecReal(R* rhs, R* sol, bool unscale = true);
848
849 /// multiply with basis matrix; B * \p vec (inplace)
850 /// @param vec (dense) vector to be multiplied with
851 /// @param unscale determines whether the result should be unscaled according to the original LP data
852 bool multBasis(R* vec, bool unscale = true);
853
854 /// multiply with transpose of basis matrix; \p vec * B^T (inplace)
855 /// @param vec (dense) vector to be multiplied with
856 /// @param unscale determines whether the result should be unscaled according to the original LP data
857 bool multBasisTranspose(R* vec, bool unscale = true);
858
859 /// compute rational basis inverse; returns true on success
861
862 /// gets an array of indices for the columns of the rational basis matrix; bind[i] >= 0 means that the i-th column of
863 /// the basis matrix contains variable bind[i]; bind[i] < 0 means that the i-th column of the basis matrix contains
864 /// the slack variable for row -bind[i]-1; performs rational factorization if not available; returns true on success
866
867 /// computes row r of basis inverse; performs rational factorization if not available; returns true on success
869
870 /// computes column c of basis inverse; performs rational factorization if not available; returns true on success
872
873 /// computes solution of basis matrix B * sol = rhs; performs rational factorization if not available; returns true
874 /// on success
876
877 /// sets starting basis via arrays of statuses
878 void setBasis(const typename SPxSolverBase<R>::VarStatus rows[],
879 const typename SPxSolverBase<R>::VarStatus cols[]);
880
881 /// clears starting basis
883
884 ///@}
885
886
887 ///@name Statistical information
888 ///@{
889
890 /// number of iterations since last call to solve
891 int numIterations() const;
892
893 /// number of iterative refinements
894 int numRefinements() const;
895
896 /// number of precision boosts since last call to solve
898
899 /// number of iterations in higher precision since last call to solve
901
902 /// time spen in higher precision since last call to solve
904
905 /// time spent in last call to solve
907
908 /// statistical information in form of a string
909 std::string statisticString() const;
910
911 /// name of starter
912 const char* getStarterName();
913
914 /// name of simplifier
915 const char* getSimplifierName();
916
917 /// name of scaling method
918 const char* getScalerName();
919
920 /// name of currently loaded pricer
921 const char* getPricerName();
922
923 /// name of currently loaded ratiotester
924 const char* getRatiotesterName();
925
926 ///@}
927
928
929 ///@name File I/O
930 ///@{
931
932 /// reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and
933 /// integer variables if desired; returns true on success
934 bool readFile(const char* filename, NameSet* rowNames = nullptr, NameSet* colNames = nullptr,
935 DIdxSet* intVars = nullptr);
936
937 /// Templated write function
938 /// Real
939 /// writes real LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
940 /// colNames are \c nullptr, default names are used; if \p intVars is not \c nullptr, the variables contained in it are
941 /// marked as integer; returns true on success
942 /// Rational
943 /// writes rational LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
944 /// colNames are \c nullptr, default names are used; if \p intVars is not \c nullptr, the variables contained in it are
945 /// marked as integer; returns true on success
946 bool writeFile(const char* filename, const NameSet* rowNames = nullptr,
947 const NameSet* colNames = nullptr,
948 const DIdxSet* intvars = nullptr, const bool unscale = true,
949 const bool writeZeroObjective = false) const;
950
951 bool writeFileRational(const char* filename, const NameSet* rowNames = nullptr,
952 const NameSet* colNames = nullptr, const DIdxSet* intvars = nullptr,
953 const bool writeZeroObjective = false) const;
954
955 /* For SCIP compatibility */
956 bool writeFileReal(const char* filename, const NameSet* rowNames = nullptr,
957 const NameSet* colNames = nullptr,
958 const DIdxSet* intvars = nullptr, const bool unscale = true,
959 const bool writeZeroObjective = false) const;
960
961 /// writes the dual of the real LP to file; LP or MPS format is chosen from the extension in \p filename;
962 /// if \p rowNames and \p colNames are \c nullptr, default names are used; if \p intVars is not \c nullptr,
963 /// the variables contained in it are marked as integer; returns true on success
964 bool writeDualFileReal(const char* filename, const NameSet* rowNames = nullptr,
965 const NameSet* colNames = nullptr, const DIdxSet* intvars = nullptr,
966 const bool writeZeroObjective = false) const;
967
968 /// reads basis information from \p filename and returns true on success; if \p rowNames and \p colNames are \c nullptr,
969 /// default names are assumed; returns true on success
970 bool readBasisFile(const char* filename, const NameSet* rowNames = nullptr,
971 const NameSet* colNames = nullptr);
972
973 /// writes basis information to \p filename; if \p rowNames and \p colNames are \c nullptr, default names are used;
974 /// returns true on success
975 bool writeBasisFile(const char* filename, const NameSet* rowNames = nullptr,
976 const NameSet* colNames = nullptr,
977 const bool cpxFormat = false) const;
978
979 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c nullptr,
980 /// default names are used
981 void writeStateReal(const char* filename, const NameSet* rowNames = nullptr,
982 const NameSet* colNames = nullptr,
983 const bool cpxFormat = false, const bool writeZeroObjective = false) const;
984
985 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c nullptr,
986 /// default names are used
987 void writeStateRational(const char* filename, const NameSet* rowNames = nullptr,
988 const NameSet* colNames = nullptr, const bool cpxFormat = false,
989 const bool writeZeroObjective = false) const;
990
991 ///@}
992
993
994 ///@name Parameters
995 ///@{
996
997 /// boolean parameters
998 typedef enum
999 {
1000 /// should lifting be used to reduce range of nonzero matrix coefficients?
1002
1003 /// should LP be transformed to equality form before a rational solve?
1005
1006 /// should dual infeasibility be tested in order to try to return a dual solution even if primal infeasible?
1008
1009 /// should a rational factorization be performed after iterative refinement?
1011
1012 /// should cycling solutions be accepted during iterative refinement?
1014
1015 /// apply rational reconstruction after each iterative refinement?
1017
1018 /// round scaling factors for iterative refinement to powers of two?
1020
1021 /// continue iterative refinement with exact basic solution if not optimal?
1023
1024 /// use bound flipping also for row representation?
1026
1027 /// use persistent scaling?
1029
1030 /// perturb the entire problem or only the relevant bounds of s single pivot?
1032
1033 /// re-optimize the original problem to get a proof (ray) of infeasibility/unboundedness?
1035
1036 /// try to enforce that the optimal solution is a basic solution
1038
1039 // enable presolver SingletonCols in PaPILO?
1041
1042 // enable presolver ConstraintPropagation in PaPILO?
1044
1045 // enable presolver ParallelRowDetection in PaPILO?
1047
1048 // enable presolver ParallelColDetection in PaPILO?
1050
1051 // enable presolver SingletonStuffing in PaPILO?
1053
1054 // enable presolver DualFix in PaPILO?
1056
1057 // enable presolver FixContinuous in PaPILO?
1059
1060 // enable presolver DominatedCols in PaPILO?
1062
1063 // enable iterative refinement ?
1065
1066 /// adapt tolerances to the multiprecision used
1068
1069 /// enable precision boosting ?
1071
1072 /// boosted solver start from last basis
1074
1075 /// try different settings when solve fails
1077
1078 /// number of boolean parameters
1080 } BoolParam;
1081
1082 /// integer parameters
1083 typedef enum
1084 {
1085 /// objective sense
1087
1088 /// type of computational form, i.e., column or row representation
1090
1091 /// type of algorithm, i.e., primal or dual
1093
1094 /// type of LU update
1096
1097 /// maximum number of updates without fresh factorization
1099
1100 /// iteration limit (-1 if unlimited)
1102
1103 /// refinement limit (-1 if unlimited)
1105
1106 /// stalling refinement limit (-1 if unlimited)
1108
1109 /// display frequency
1111
1112 /// verbosity level
1114
1115 /// type of simplifier
1117
1118 /// type of scaler
1120
1121 /// type of starter used to create crash basis
1123
1124 /// type of pricer
1126
1127 /// type of ratio test
1129
1130 /// mode for synchronizing real and rational LP
1132
1133 /// mode for reading LP files
1135
1136 /// mode for iterative refinement strategy
1138
1139 /// mode for a posteriori feasibility checks
1141
1142 /// type of timer
1143 TIMER = 19,
1144
1145 /// mode for hyper sparse pricing
1147
1148 /// minimum number of stalling refinements since last pivot to trigger rational factorization
1150
1151 /// maximum number of conjugate gradient iterations in least square scaling
1153
1154 /// mode for solution polishing
1156
1157 /// print condition number during the solve
1159
1160 /// type of timer for statistics
1162
1163 // maximum number of digits for the multiprecision type
1165
1166 ///@todo precision-boosting find better parameter name
1167 /// after how many simplex pivots do we store the advanced and stable basis, 1 = every iterations
1169
1170 /// number of integer parameters
1172 } IntParam;
1173
1174 /// values for parameter OBJSENSE
1175 enum
1176 {
1177 /// minimization
1179
1180 /// maximization
1182 };
1183
1184 /// values for parameter REPRESENTATION
1185 enum
1186 {
1187 /// automatic choice according to number of rows and columns
1189
1190 /// column representation Ax - s = 0, lower <= x <= upper, lhs <= s <= rhs
1192
1193 /// row representation (lower,lhs) <= (x,Ax) <= (upper,rhs)
1195 };
1196
1197 /// values for parameter ALGORITHM
1198 enum
1199 {
1200 /// primal simplex algorithm, i.e., entering for column and leaving for row representation
1202
1203 /// dual simplex algorithm, i.e., leaving for column and entering for row representation
1205 };
1206
1207 /// values for parameter FACTOR_UPDATE_TYPE
1208 enum
1209 {
1210 /// product form update
1212
1213 /// Forrest-Tomlin type update
1215 };
1216
1217 /// values for parameter VERBOSITY
1218 enum
1219 {
1220 /// only error output
1222
1223 /// only error and warning output
1225
1226 /// only error, warning, and debug output
1228
1229 /// standard verbosity level
1231
1232 /// high verbosity level
1234
1235 /// full verbosity level
1237 };
1238
1239 /// values for parameter SIMPLIFIER
1240 enum
1241 {
1242 /// disabling presolving
1244
1245 /// using internal presolving methods
1247
1248 /// using the presolve lib papilo
1250
1251 /// SoPlex chooses automatically (currently always "internal")
1253 };
1254
1255 /// values for parameter SCALER
1256 enum
1257 {
1258 /// no scaler
1260
1261 /// equilibrium scaling on rows or columns
1263
1264 /// equilibrium scaling on rows and columns
1266
1267 /// geometric mean scaling on rows and columns, max 1 round
1269
1270 /// geometric mean scaling on rows and columns, max 8 rounds
1272
1273 /// least square scaling
1275
1276 /// geometric mean scaling (max 8 rounds) followed by equilibrium scaling (rows and columns)
1278 };
1279
1280 /// values for parameter STARTER
1281 enum
1282 {
1283 /// slack basis
1285
1286 /// greedy crash basis weighted by objective, bounds, and sides
1288
1289 /// crash basis from a greedy solution
1291
1292 /// generic solution-based crash basis
1294 };
1295
1296 /// values for parameter PRICER
1297 enum
1298 {
1299 /// automatic pricer
1301
1302 /// Dantzig pricer
1304
1305 /// partial multiple pricer based on Dantzig pricing
1307
1308 /// devex pricer
1310
1311 /// steepest edge pricer with initialization to unit norms
1313
1314 /// steepest edge pricer with exact initialization of norms
1316 };
1317
1318 /// values for parameter RATIOTESTER
1319 enum
1320 {
1321 /// textbook ratio test without stabilization
1323
1324 /// standard Harris ratio test
1326
1327 /// modified Harris ratio test
1329
1330 /// bound flipping ratio test for long steps in the dual simplex
1332 };
1333
1334 /// values for parameter SYNCMODE
1335 enum
1336 {
1337 /// store only real LP
1339
1340 /// automatic sync of real and rational LP
1342
1343 /// user sync of real and rational LP
1345 };
1346
1347 /// values for parameter READMODE
1348 enum
1349 {
1350 /// standard floating-point parsing
1352
1353 /// rational parsing
1355 };
1356
1357 /// values for parameter SOLVEMODE
1358 enum
1359 {
1360 /// apply standard floating-point algorithm
1362
1363 /// decide depending on tolerances whether to apply iterative refinement
1365
1366 /// force iterative refinement
1368 };
1369
1370 /// values for parameter CHECKMODE
1371 enum
1372 {
1373 /// floating-point check
1375
1376 /// decide according to READMODE
1378
1379 /// rational check
1381 };
1382
1383 /// values for parameter TIMER
1384 enum
1385 {
1386 /// disable timing
1388
1389 /// cpu or user time
1391
1392 /// wallclock time
1394 };
1395
1396 /// values for parameter HYPER_PRICING
1397 enum
1398 {
1399 /// never
1401
1402 /// decide according to problem size
1404
1405 /// always
1407 };
1408
1409 /// values for parameter SOLUTION_POLISHING
1410 enum
1411 {
1412 /// no solution polishing
1414
1415 /// maximize number of basic slack variables, i.e. more variables on bounds
1417
1418 /// minimize number of basic slack variables, i.e. more variables between bounds
1420 };
1421
1422 /// real parameters
1423 typedef enum
1424 {
1425 /// primal feasibility tolerance
1427
1428 /// dual feasibility tolerance
1430
1431 /// general zero tolerance
1433
1434 /// zero tolerance used in factorization
1436
1437 /// zero tolerance used in update of the factorization
1439
1440 /// pivot zero tolerance used in factorization
1442
1443 /// infinity threshold
1445
1446 /// time limit in seconds (INFTY if unlimited)
1448
1449 /// lower limit on objective value
1451
1452 /// upper limit on objective value
1454
1455 /// working tolerance for feasibility in floating-point solver during iterative refinement
1457
1458 /// working tolerance for optimality in floating-point solver during iterative refinement
1460
1461 /// maximum increase of scaling factors between refinements
1463
1464 /// lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)
1466
1467 /// upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulated)
1469
1470 /// sparse pricing threshold (\#violations < dimension * SPARSITY_THRESHOLD activates sparse pricing)
1472
1473 /// threshold on number of rows vs. number of columns for switching from column to row representations in auto mode
1475
1476 /// geometric frequency at which to apply rational reconstruction
1478
1479 /// minimal reduction (sum of removed rows/cols) to continue simplification
1481
1482 /// refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix
1484
1485 /// refactor threshold for fill-in in current factor update compared to fill-in in last factorization
1487
1488 /// refactor threshold for memory growth in factorization since last refactorization
1490
1491 /// accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations)
1493
1494 /// objective offset
1496
1497 /// minimal Markowitz threshold to control sparsity/stability in LU factorization
1499
1500 /// minimal modification threshold to apply presolve reductions
1502
1503 /// factor by which the precision of the floating-point solver is multiplied
1505
1506 /// number of real parameters
1508 } RealParam;
1509
1510#ifdef SOPLEX_WITH_RATIONALPARAM
1511 /// rational parameters
1512 typedef enum
1513 {
1514 /// number of rational parameters
1515 RATIONALPARAM_COUNT = 0
1516 } RationalParam;
1517#endif
1518
1519 /// class of parameter settings
1521 {
1522 public:
1523 static struct BoolParam
1524 {
1525 /// constructor
1527 /// array of names for boolean parameters
1529 /// array of descriptions for boolean parameters
1531 /// array of default values for boolean parameters
1534
1535 static struct IntParam
1536 {
1537 /// constructor
1539 /// array of names for integer parameters
1541 /// array of descriptions for integer parameters
1543 /// array of default values for integer parameters
1545 /// array of lower bounds for int parameter values
1547 /// array of upper bounds for int parameter values
1550
1551 static struct RealParam
1552 {
1553 /// constructor
1555 /// array of names for real parameters
1557 /// array of descriptions for real parameters
1559 /// array of default values for real parameters
1561 /// array of lower bounds for real parameter values
1563 /// array of upper bounds for real parameter values
1566
1567#ifdef SOPLEX_WITH_RATIONALPARAM
1568 static struct RationalParam
1569 {
1570 /// constructor
1571 RationalParam();
1572 /// array of names for rational parameters
1573 std::string name[SoPlexBase<R>::RATIONALPARAM_COUNT];
1574 /// array of descriptions for rational parameters
1575 std::string description[SoPlexBase<R>::RATIONALPARAM_COUNT];
1576 /// array of default values for rational parameters
1578 /// array of lower bounds for rational parameter values
1580 /// array of upper bounds for rational parameter values
1582 } rationalParam;
1583#endif
1584
1585 /// array of current boolean parameter values
1587
1588 /// array of current integer parameter values
1590
1591 /// array of current real parameter values
1593
1594#ifdef SOPLEX_WITH_RATIONALPARAM
1595 /// array of current rational parameter values
1596 Rational _rationalParamValues[SoPlexBase<R>::RATIONALPARAM_COUNT];
1597#endif
1598
1599 /// default constructor initializing default settings
1601
1602 /// copy constructor
1604
1605 /// assignment operator
1607 };
1608
1610
1611 /// returns boolean parameter value
1612 bool boolParam(const BoolParam param) const;
1613
1614 /// returns integer parameter value
1615 int intParam(const IntParam param) const;
1616
1617 /// returns real parameter value
1618 Real realParam(const RealParam param) const;
1619
1620#ifdef SOPLEX_WITH_RATIONALPARAM
1621 /// returns rational parameter value
1622 Rational rationalParam(const RationalParam param) const;
1623#endif
1624
1625 /// returns current parameter settings
1626 const Settings& settings() const;
1627
1628 /// returns current tolerances
1629 const std::shared_ptr<Tolerances> tolerances() const;
1630
1631 /// sets boolean parameter value; returns true on success
1632 bool setBoolParam(const BoolParam param, const bool value, const bool init = true);
1633
1634 /// sets integer parameter value; returns true on success
1635 bool setIntParam(const IntParam param, const int value, const bool init = true);
1636
1637 /// sets real parameter value; returns true on success
1638 bool setRealParam(const RealParam param, const Real value, const bool init = true);
1639
1640#ifdef SOPLEX_WITH_RATIONALPARAM
1641 /// sets rational parameter value; returns true on success
1642 bool setRationalParam(const RationalParam param, const Rational value, const bool init = true);
1643#endif
1644
1645 /// sets parameter settings; returns true on success
1646 bool setSettings(const Settings& newSettings, const bool init = true);
1647
1648 /// resets default parameter settings
1649 void resetSettings(const bool quiet = false, const bool init = true);
1650
1651 /// print non-default parameter values
1653
1654 /// writes settings file; returns true on success
1655 bool saveSettingsFile(const char* filename, const bool onlyChanged = false,
1656 int solvemode = 1) const;
1657
1658 /// reads settings file; returns true on success
1659 bool loadSettingsFile(const char* filename);
1660
1661 /// parses one setting string and returns true on success; note that string is modified
1662 bool parseSettingsString(char* str);
1663
1664 ///@}
1665
1666
1667 ///@name Statistics
1668 ///@{
1669
1670 /// set statistic timers to a certain type
1671 void setTimings(const Timer::TYPE ttype);
1672
1673 /// prints solution statistics
1674 void printSolutionStatistics(std::ostream& os);
1675
1676 /// prints statistics on solving process
1677 void printSolvingStatistics(std::ostream& os);
1678
1679 /// prints short statistics
1680 void printShortStatistics(std::ostream& os);
1681
1682 /// prints complete statistics
1683 void printStatistics(std::ostream& os);
1684
1685 /// prints status
1686
1687 void printStatus(std::ostream& os, typename SPxSolverBase<R>::Status status);
1688
1689 ///@}
1690
1691
1692 ///@name Miscellaneous
1693 ///@{
1694
1695 /// prints version and compilation options
1696 void printVersion() const;
1697
1698 /// prints external libraries
1700
1701 /// checks if real LP and rational LP are in sync; dimensions will always be compared,
1702 /// vector and matrix values only if the respective parameter is set to true.
1703 /// If quiet is set to true the function will only display which vectors are different.
1704 bool areLPsInSync(const bool checkVecVals = true, const bool checkMatVals = false,
1705 const bool quiet = false) const;
1706
1707 /// set the random seeds of the solver instance
1708 void setRandomSeed(unsigned int seed);
1709
1710 /// returns the current random seed of the solver instance
1711 unsigned int randomSeed() const;
1712
1713 ///@}
1714
1715private:
1716
1717 ///@name Statistics on solving process
1718 ///@{
1719
1720 /// class of statistics
1721 class Statistics;
1722
1723 /// statistics since last call to solveReal() or solveRational()
1724 Statistics* _statistics;
1725
1726 ///@}
1727
1728
1729 ///@name Parameter settings
1730 ///@{
1731
1733
1734 std::shared_ptr<Tolerances> _tolerances;
1735
1741
1742 ///@}
1743
1744
1745 ///@name Data for the real LP
1746 ///@{
1747
1771
1776
1777#ifdef SOPLEX_WITH_BOOST
1778#ifdef SOPLEX_WITH_MPFR
1779 //----------------------------- BOOSTED SOLVER -----------------------------
1780 // multiprecision type used for the boosted solver
1781 using BP = number<mpfr_float_backend<0>, et_off>;
1782#else
1783#ifdef SOPLEX_WITH_GMP
1784 using BP = number<gmp_float<50>, et_off>;
1785#else
1786 using BP = number<cpp_dec_float<50>, et_off>;
1787#endif
1788#endif
1789#else
1790 using BP = double;
1791#endif
1792
1793 // boosted solver object
1795
1796 // ------------- Main attributes for precision boosting
1797
1798 int _initialPrecision = 50; // initial number of digits for multiprecision
1799 bool _boostingLimitReached; // true if BP::default_precision() > max authorized number of digits
1800 bool _switchedToBoosted; // true if _boostedSolver is used instead of _solver to cope with the numerical failure of _solver
1801 // this attribute remembers wether we are testing feasibility (1), unboundedness (2) or neither (0)
1802 // it is used when storing/loading the right basis in precision boosting.
1803 // example: if _certificateMode == 1, it is the basis for the feasibility LP that should be stored/loaded.
1805
1806 // ------------- Buffers for statistics of precision boosting
1807
1808 // ideally these four attributes would be local variables, however the precision boosting loop
1809 // wraps the solve in a way that it is complicated to declare these variables locally.
1810 int _lastStallPrecBoosts; // number of previous stalling precision boosts
1811 bool _factorSolNewBasisPrecBoost; // false if the current basis has already been factorized (no new iterations have been done)
1812 int _nextRatrecPrecBoost; // the iteration during or after which rational reconstruction can be performed
1813 // buffer storing the number of iterations before a given precision boost
1814 // used to detect stalling (_prevIterations < _statistics->iterations)
1816
1817 // ------------- Tolerances Ratios
1818
1819 /// ratios for computing the tolerances for precision boosting
1820 /// ratio denotes the proportion of precision used by the tolerance
1821 /// e.g. ratio = 0.65, precision = 100 digits, new tol = 10^(0.65*100)
1827
1828 // ------------- [Boosted] SLUFactor, Pricers, RatioTesters, Scalers, Simplifiers
1829
1831
1838
1843
1846
1853
1856
1857 //--------------------------------------------------------------------------
1858
1859 bool _isRealLPLoaded; // true indicates that the original LP is loaded in the _solver variable, hence all actions
1860 // are performed on the original LP.
1863
1870
1871 ///@}
1872
1873
1874 ///@name Data for the rational LP
1875 ///@{
1876
1880
1904
1905 /// type of bounds and sides
1906 typedef enum
1907 {
1908 /// both bounds are infinite
1910
1911 /// lower bound is finite, upper bound is infinite
1913
1914 /// upper bound is finite, lower bound is infinite
1916
1917 /// lower and upper bound finite, but different
1919
1920 /// lower bound equals upper bound
1922 } RangeType;
1923
1926
1927 ///@}
1928
1929
1930 ///@name Solution data
1931 ///@{
1932
1935
1938
1939 // indicates wether an old basis is currently stored for warm start
1941 bool _hasOldFeasBasis; // basis for testing feasibility
1942 bool _hasOldUnbdBasis; // basis for testing unboundedness
1943
1944 // these vectors store the last basis met in precision boosting when not testing feasibility or unboundedness.
1947
1948 // these vectors store the last basis met when testing feasibility in precision boosting.
1951
1952 // these vectors store the last basis met when testing unboundedness in precision boosting.
1955
1956 // these vectors don't replace _basisStatusRows and _basisStatusCols
1957 // they aim to overcome the issue of having the enum VarStatus inside SPxSolverBase.
1958 // When calling setBasis or getBasis (from SPxSolverBase class), a specific conversion is needed.
1959 // Function: SPxSolverBase<BP>::setBasis(...)
1960 // Usage: copy _basisStatusRows(Cols) to _tmpBasisStatusRows(Cols) before calling
1961 // mysolver.setBasis(_tmpBasisStatusRows, _tmpBasisStatusCols)
1962 // Function: SPxSolverBase<BP>::getBasis(...)
1963 // Usage: copy _tmpBasisStatusRows(Cols) to _basisStatusRows(Cols) after calling
1964 // mysolver.getBasis(_tmpBasisStatusRows, _tmpBasisStatusCols, _basisStatusRows.size(), _basisStatusCols.size())
1967
1971
1975
1976 ///@}
1977
1978 ///@name Miscellaneous
1979 ///@{
1980
1983
1987
1988 ///@}
1989
1990 ///@name Constant helper methods
1991 ///@{
1992
1993 /// extends sparse vector to hold newmax entries if and only if it holds no more free entries
1994 void _ensureDSVectorRationalMemory(DSVectorRational& vec, const int newmax) const;
1995
1996 /// creates a permutation for removing rows/columns from an array of indices
1997 void _idxToPerm(int* idx, int idxSize, int* perm, int permSize) const;
1998
1999 /// creates a permutation for removing rows/columns from a range of indices
2000 void _rangeToPerm(int start, int end, int* perm, int permSize) const;
2001
2002 /// checks consistency for the boosted solver
2004
2005 /// checks consistency
2006 bool _isConsistent() const;
2007
2008 /// should solving process be stopped?
2009 bool _isSolveStopped(bool& stoppedTime, bool& stoppedIter) const;
2010
2011 /// determines RangeType from real bounds
2012 RangeType _rangeTypeReal(const R& lower, const R& upper) const;
2013
2014 /// determines RangeType from rational bounds
2015 RangeType _rangeTypeRational(const Rational& lower, const Rational& upper) const;
2016
2017 /// switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
2018 RangeType _switchRangeType(const RangeType& rangeType) const;
2019
2020 /// checks whether RangeType corresponds to finite lower bound
2021 bool _lowerFinite(const RangeType& rangeType) const;
2022
2023 /// checks whether RangeType corresponds to finite upper bound
2024 bool _upperFinite(const RangeType& rangeType) const;
2025
2026 ///@}
2027
2028
2029 ///@name Non-constant helper methods
2030 ///@{
2031
2032 /// adds a single row to the real LP and adjusts basis
2033 void _addRowReal(const LPRowBase<R>& lprow);
2034
2035 /// adds a single row to the real LP and adjusts basis
2036 void _addRowReal(R lhs, const SVectorBase<R>& lprow, R rhs);
2037
2038 /// adds multiple rows to the real LP and adjusts basis
2039 void _addRowsReal(const LPRowSetBase<R>& lprowset);
2040
2041 /// adds a single column to the real LP and adjusts basis
2042 void _addColReal(const LPColReal& lpcol);
2043
2044 /// adds a single column to the real LP and adjusts basis
2045 void _addColReal(R obj, R lower, const SVectorBase<R>& lpcol, R upper);
2046
2047 /// adds multiple columns to the real LP and adjusts basis
2048 void _addColsReal(const LPColSetReal& lpcolset);
2049
2050 /// replaces row \p i with \p lprow and adjusts basis
2051 void _changeRowReal(int i, const LPRowBase<R>& lprow);
2052
2053 /// changes left-hand side vector for constraints to \p lhs and adjusts basis
2055
2056 /// changes left-hand side of row \p i to \p lhs and adjusts basis
2057 void _changeLhsReal(int i, const R& lhs);
2058
2059 /// changes right-hand side vector to \p rhs and adjusts basis
2061
2062 /// changes right-hand side of row \p i to \p rhs and adjusts basis
2063 void _changeRhsReal(int i, const R& rhs);
2064
2065 /// changes left- and right-hand side vectors and adjusts basis
2066 void _changeRangeReal(const VectorBase<R>& lhs, const VectorBase<R>& rhs);
2067
2068 /// changes left- and right-hand side of row \p i and adjusts basis
2069 void _changeRangeReal(int i, const R& lhs, const R& rhs);
2070
2071 /// replaces column \p i with \p lpcol and adjusts basis
2072 void _changeColReal(int i, const LPColReal& lpcol);
2073
2074 /// changes vector of lower bounds to \p lower and adjusts basis
2076
2077 /// changes lower bound of column i to \p lower and adjusts basis
2078 void _changeLowerReal(int i, const R& lower);
2079
2080 /// changes vector of upper bounds to \p upper and adjusts basis
2082
2083 /// changes \p i 'th upper bound to \p upper and adjusts basis
2084 void _changeUpperReal(int i, const R& upper);
2085
2086 /// changes vectors of column bounds to \p lower and \p upper and adjusts basis
2087 void _changeBoundsReal(const VectorBase<R>& lower, const VectorBase<R>& upper);
2088
2089 /// changes bounds of column \p i to \p lower and \p upper and adjusts basis
2090 void _changeBoundsReal(int i, const R& lower, const R& upper);
2091
2092 /// changes matrix entry in row \p i and column \p j to \p val and adjusts basis
2093 void _changeElementReal(int i, int j, const R& val);
2094
2095 /// removes row \p i and adjusts basis
2096 void _removeRowReal(int i);
2097
2098 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
2099 /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
2100 /// #numRows()
2101 void _removeRowsReal(int perm[]);
2102
2103 /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRows() may be passed
2104 /// as buffer memory
2105 void _removeRowsReal(int idx[], int n, int perm[]);
2106
2107 /// removes rows \p start to \p end including both; an array \p perm of size #numRows() may be passed as buffer
2108 /// memory
2109 void _removeRowRangeReal(int start, int end, int perm[]);
2110
2111 /// removes column i
2112 void _removeColReal(int i);
2113
2114 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
2115 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
2116 /// #numColsReal()
2117 void _removeColsReal(int perm[]);
2118
2119 /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsReal() may be
2120 /// passed as buffer memory
2121 void _removeColsReal(int idx[], int n, int perm[]);
2122
2123 /// removes columns \p start to \p end including both; an array \p perm of size #numColsReal() may be passed as
2124 /// buffer memory
2125 void _removeColRangeReal(int start, int end, int perm[]);
2126
2127 /// invalidates solution
2129
2130 /// enables simplifier and scaler according to current parameters
2132
2133 /// disables simplifier and scaler
2135
2136 /// ensures that the rational LP is available; performs no sync
2138
2139 /// ensures that the real LP and the basis are loaded in the solver; performs no sync
2141
2142 /// call floating-point solver and update statistics on iterations etc.
2143 void _solveBoostedRealLPAndRecordStatistics(volatile bool* interrupt = nullptr);
2144
2145 /// call floating-point solver and update statistics on iterations etc.
2146 void _solveRealLPAndRecordStatistics(volatile bool* interrupt = nullptr);
2147
2148 /// reads real LP in LP or MPS format from file and returns true on success; gets row names, column names, and
2149 /// integer variables if desired
2150 bool _readFileReal(const char* filename, NameSet* rowNames = nullptr, NameSet* colNames = nullptr,
2151 DIdxSet* intVars = nullptr);
2152
2153 /// reads rational LP in LP or MPS format from file and returns true on success; gets row names, column names, and
2154 /// integer variables if desired
2155 bool _readFileRational(const char* filename, NameSet* rowNames = nullptr,
2156 NameSet* colNames = nullptr,
2157 DIdxSet* intVars = nullptr);
2158
2159 /// completes range type arrays after adding columns and/or rows
2161
2162 /// recomputes range types from scratch using real LP
2164
2165 /// recomputes range types from scratch using rational LP
2167
2168 /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, without looking at the sync mode
2169 void _syncLPReal(bool time = true);
2170
2171 /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sync mode
2172 void _syncLPRational(bool time = true);
2173
2174 /// synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real solution
2176
2177 /// synchronizes real solution with rational solution, i.e., copies real solution to rational solution
2179
2180 /// returns pointer to a constant unit vector available until destruction of the SoPlexBase class
2182
2183 /// parses one line in a settings file and returns true on success; note that the string is modified
2184 bool _parseSettingsLine(char* line, const int lineNumber);
2185
2186 ///@}
2187
2188
2189 //**@name Private solving methods implemented in solverational.hpp */
2190 ///@{
2191
2192 /// stores floating-point solution of original LP as current rational solution and ensure that solution vectors have right dimension; ensure that solution is aligned with basis
2193 template <typename T>
2195 SolRational& sol,
2196 VectorBase<T>& primalReal,
2197 VectorBase<T>& dualReal,
2198 int& dualSize);
2199
2200 /// computes violation of bounds during the refinement loop
2201 void _computeBoundsViolation(SolRational& sol, Rational& boundsViolation);
2202
2203 /// computes violation of sides during the refinement loop
2204 void _computeSidesViolation(SolRational& sol, Rational& sideViolation);
2205
2206 /// computes violation of reduced costs during the refinement loop
2208 SolRational& sol,
2209 Rational& redCostViolation,
2210 const bool& maximizing);
2211
2212 /// computes dual violation during the refinement loop
2214 SolRational& sol,
2215 Rational& dualViolation,
2216 const bool& maximizing);
2217
2218 /// checks termination criteria for refinement loop
2220 bool& primalFeasible,
2221 bool& dualFeasible,
2222 Rational& boundsViolation,
2223 Rational& sideViolation,
2224 Rational& redCostViolation,
2225 Rational& dualViolation,
2226 int minIRRoundsRemaining,
2227 bool& stoppedTime,
2228 bool& stoppedIter,
2229 int numFailedRefinements);
2230
2231 /// checks refinement loop progress
2233 Rational& boundsViolation,
2234 Rational& sideViolation,
2235 Rational& redCostViolation,
2236 Rational& dualViolation,
2237 Rational& maxViolation,
2238 Rational& bestViolation,
2239 const Rational& violationImprovementFactor,
2240 int& numFailedRefinements);
2241
2242 /// performs rational reconstruction and/or factorizationd
2244 int& minIRRoundsRemaining,
2245 int& lastStallIterations,
2246 int& numberOfIterations,
2247 bool& factorSolNewBasis,
2248 int& nextRatrec,
2249 const Rational& errorCorrectionFactor,
2250 Rational& errorCorrection,
2251 Rational& maxViolation,
2252 SolRational& sol,
2253 bool& primalFeasible,
2254 bool& dualFeasible,
2255 bool& stoppedTime,
2256 bool& stoppedIter,
2257 bool& error,
2258 bool& breakAfter,
2259 bool& continueAfter);
2260
2261 /// forces value of given nonbasic variable to bound
2263 SolRational& sol,
2264 int& c,
2265 const int& maxDimRational,
2266 bool toLower);
2267
2268 /// computes primal scaling factor; limit increase in scaling by tolerance used in floating point solve
2270 Rational& maxScale,
2271 Rational& primalScale,
2272 Rational& boundsViolation,
2273 Rational& sideViolation,
2274 Rational& redCostViolation);
2275
2276 /// computes dual scaling factor; limit increase in scaling by tolerance used in floating point solve
2278 Rational& maxScale,
2279 Rational& primalScale,
2280 Rational& dualScale,
2281 Rational& redCostViolation,
2282 Rational& dualViolation);
2283
2284 /// applies scaled bounds
2285 template <typename T>
2286 void _applyScaledBounds(SPxSolverBase<T>& solver, Rational& primalScale);
2287
2288 /// applies scaled sides
2289 template <typename T>
2290 void _applyScaledSides(SPxSolverBase<T>& solver, Rational& primalScale);
2291
2292 /// applies scaled objective function
2293 template <typename T>
2294 void _applyScaledObj(SPxSolverBase<T>& solver, Rational& dualScale, SolRational& sol);
2295
2296 /// evaluates result of solve. Return true if the algorithm must to stopped, false otherwise.
2297 template <typename T>
2299 SPxSolverBase<T>& solver,
2300 typename SPxSolverBase<T>::Status result,
2301 bool usingRefinedLP,
2302 SolRational& sol,
2303 VectorBase<T>& dualReal,
2304 bool& infeasible,
2305 bool& unbounded,
2306 bool& stoppedTime,
2307 bool& stoppedIter,
2308 bool& error);
2309
2310 /// corrects primal solution and aligns with basis
2311 template <typename T>
2313 SolRational& sol,
2314 Rational& primalScale,
2315 int& primalSize,
2316 const int& maxDimRational,
2317 VectorBase<T>& primalReal);
2318
2319 /// updates or recomputes slacks depending on which looks faster
2320 void _updateSlacks(SolRational& sol, int& primalSize);
2321
2322 /// corrects dual solution and aligns with basis
2323 template <typename T>
2325 SPxSolverBase<T>& solver,
2326 SolRational& sol,
2327 const bool& maximizing,
2328 VectorBase<T>& dualReal,
2329 Rational& dualScale,
2330 int& dualSize,
2331 const int& maxDimRational);
2332
2333 /// updates or recomputes reduced cost values depending on which looks faster; adding one to the length of the
2334 /// dual vector accounts for the objective function vector
2335 void _updateReducedCosts(SolRational& sol, int& dualSize, const int& numCorrectedPrimals);
2336
2337 ///@todo precision-boosting move some place else
2338 /// converts the given DataArray of VarStatus to boostedPrecision
2340 DataArray< typename SPxSolverBase<R>::VarStatus >& base,
2341 DataArray< typename SPxSolverBase<BP>::VarStatus >& copy);
2342
2343 ///@todo precision-boosting move some place else
2344 /// converts the given DataArray of VarStatus to R precision
2346 DataArray< typename SPxSolverBase<BP>::VarStatus >& base,
2347 DataArray< typename SPxSolverBase<R>::VarStatus >& copy);
2348
2349 /// disable initial precision solver and switch to boosted solver
2351
2352 /// setup boosted solver before launching iteration
2354
2355 /// increase the multiprecision, return false if maximum precision is reached, true otherwise
2357
2358 /// reset the boosted precision to the default value
2360
2361 /// setup recovery mecanism using multiprecision, return false if maximum precision reached, true otherwise
2363
2364 /// return true if slack basis has to be loaded for boosted solver
2365 bool _isBoostedStartingFromSlack(bool initialSolve = true);
2366
2367 /// indicate if we are testing feasibility, unboundedness or neither
2371
2372 /// check if we are testing feasibility, unboundedness or neither
2376
2377 // stores given basis in old basis attributes: _oldBasisStatusRows, _oldFeasBasisStatusRows, _oldUnbdBasisStatusRows (and ...Cols)
2379 DataArray< typename SPxSolverBase<R>::VarStatus >& cols);
2380
2381 // stores given basis in old basis attributes: _oldBasisStatusRows, _oldFeasBasisStatusRows, _oldUnbdBasisStatusRows (and ...Cols)
2383 DataArray< typename SPxSolverBase<BP>::VarStatus >& cols);
2384
2385 // get the last advanced and stable basis stored by the initial solver and store it as old basis, unsimplify basis if simplifier activated
2386 void _storeLastStableBasis(bool vanished);
2387
2388 // get the last advanced and stable basis stored by the boosted solver and store it as old basis, unsimplify basis if simplifier activated
2389 void _storeLastStableBasisBoosted(bool vanished);
2390
2391 // load old basis in solver. The old basis loaded depends on the certificate mode (feasibility, unboundedness, or neither)
2392 bool _loadBasisFromOldBasis(bool boosted);
2393
2394 // update statistics for precision boosting
2396
2397 /// solves current problem using multiprecision floating-point solver
2398 /// return false if a new boosted iteration is necessary, true otherwise
2400 SolRational& sol,
2401 bool& primalFeasible,
2402 bool& dualFeasible,
2403 bool& infeasible,
2404 bool& unbounded,
2405 bool& stoppedTime,
2406 bool& stoppedIter,
2407 bool& error,
2408 bool& needNewBoostedIt);
2409
2410 /// solves current problem with iterative refinement and recovery mechanism using boosted solver
2412 SolRational& sol,
2413 bool acceptUnbounded,
2414 bool acceptInfeasible,
2415 int minIRRoundsRemaining,
2416 bool& primalFeasible,
2417 bool& dualFeasible,
2418 bool& infeasible,
2419 bool& unbounded,
2420 bool& stoppedTime,
2421 bool& stoppedIter,
2422 bool& error,
2423 bool& needNewBoostedIt);
2424
2425 /// perform iterative refinement using the right precision
2427 SolRational& sol,
2428 bool acceptUnbounded,
2429 bool acceptInfeasible,
2430 int minIRRoundsRemaining,
2431 bool& primalFeasible,
2432 bool& dualFeasible,
2433 bool& infeasible,
2434 bool& unbounded,
2435 bool& stoppedTime,
2436 bool& stoppedIter,
2437 bool& error
2438 );
2439
2440 /// solves current problem using double floating-point solver
2442 SolRational& sol,
2443 bool& primalFeasible,
2444 bool& dualFeasible,
2445 bool& infeasible,
2446 bool& unbounded,
2447 bool& stoppedTime,
2448 bool& stoppedIter,
2449 bool& error);
2450
2451 /// solves current problem with iterative refinement and recovery mechanism
2453 bool acceptUnbounded,
2454 bool acceptInfeasible,
2455 int minIRRoundsRemaining,
2456 bool& primalFeasible,
2457 bool& dualFeasible,
2458 bool& infeasible,
2459 bool& unbounded,
2460 bool& stoppedTime,
2461 bool& stoppedIter,
2462 bool& error);
2463
2464 /// performs iterative refinement on the auxiliary problem for testing unboundedness
2465 void _performUnboundedIRStable(SolRational& sol, bool& hasUnboundedRay, bool& stoppedTime,
2466 bool& stoppedIter, bool& error);
2467
2468 /// performs iterative refinement on the auxiliary problem for testing feasibility
2469 void _performFeasIRStable(SolRational& sol, bool& withDualFarkas, bool& stoppedTime,
2470 bool& stoppedIter, bool& error);
2471
2472 /// reduces matrix coefficient in absolute value by the lifting procedure of Thiele et al. 2013
2473 void _lift();
2474
2475 /// undoes lifting
2477
2478 /// store basis
2480
2481 /// restore basis
2483
2484 /// stores objective, bounds, and sides of real LP
2486
2487 /// restores objective, bounds, and sides of real LP
2489
2490 /// introduces slack variables to transform inequality constraints into equations for both rational and real LP,
2491 /// which should be in sync
2493
2494 /// undoes transformation to equality form
2496
2497 /// transforms LP to unboundedness problem by moving the objective function to the constraints, changing right-hand
2498 /// side and bounds to zero, and adding an auxiliary variable for the decrease in the objective function
2500
2501 /// undoes transformation to unboundedness problem
2502 void _untransformUnbounded(SolRational& sol, bool unbounded);
2503
2504 /// transforms LP to feasibility problem by removing the objective function, shifting variables, and homogenizing the
2505 /// right-hand side
2507
2508 /// undoes transformation to feasibility problem
2509 void _untransformFeasibility(SolRational& sol, bool infeasible);
2510
2511 /** computes radius of infeasibility box implied by an approximate Farkas' proof
2512
2513 Given constraints of the form \f$ lhs <= Ax <= rhs \f$, a farkas proof y should satisfy \f$ y^T A = 0 \f$ and
2514 \f$ y_+^T lhs - y_-^T rhs > 0 \f$, where \f$ y_+, y_- \f$ denote the positive and negative parts of \f$ y \f$.
2515 If \f$ y \f$ is approximate, it may not satisfy \f$ y^T A = 0 \f$ exactly, but the proof is still valid as long
2516 as the following holds for all potentially feasible \f$ x \f$:
2517
2518 \f[
2519 y^T Ax < (y_+^T lhs - y_-^T rhs) (*)
2520 \f]
2521
2522 we may therefore calculate \f$ y^T A \f$ and \f$ y_+^T lhs - y_-^T rhs \f$ exactly and check if the upper and lower
2523 bounds on \f$ x \f$ imply that all feasible \f$ x \f$ satisfy (*), and if not then compute bounds on \f$ x \f$ to
2524 guarantee (*). The simplest way to do this is to compute
2525
2526 \f[
2527 B = (y_+^T lhs - y_-^T rhs) / \sum_i(|(y^T A)_i|)
2528 \f]
2529
2530 noting that if every component of \f$ x \f$ has \f$ |x_i| < B \f$, then (*) holds.
2531
2532 \f$ B \f$ can be increased by iteratively including variable bounds smaller than \f$ B \f$. The speed of this
2533 method can be further improved by using interval arithmetic for all computations. For related information see
2534 Sec. 4 of Neumaier and Shcherbina, Mathematical Programming A, 2004.
2535
2536 Set transformed to true if this method is called after _transformFeasibility().
2537 */
2538 void _computeInfeasBox(SolRational& sol, bool transformed);
2539
2540 /// solves real LP during iterative refinement
2542 VectorBase<R>& dual,
2543 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2544 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols);
2545
2546 /// solves real LP with recovery mechanism
2547 typename SPxSolverBase<R>::Status _solveRealStable(bool acceptUnbounded, bool acceptInfeasible,
2548 VectorBase<R>& primal, VectorBase<R>& dual,
2549 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2550 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols,
2551 const bool forceNoSimplifier = false);
2552
2553 /// solves real LP during iterative refinement
2555 VectorBase<BP>& primal, VectorBase<BP>& dual,
2556 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2557 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols,
2558 typename SPxSolverBase<BP>::Status& boostedResult, bool initialSolve);
2559
2560 /// computes rational inverse of basis matrix as defined by _rationalLUSolverBind
2562
2563public:
2564
2565 /// factorizes rational basis matrix in column representation
2567 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2568 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols, bool& stoppedTime,
2569 bool& stoppedIter, bool& error, bool& optimal);
2570
2571 /// factorizes rational basis matrix in column representation
2573 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2574 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols, bool& stoppedTime,
2575 bool& stoppedIter, bool& error, bool& optimal, bool forceSolutionUpdate);
2576
2577private:
2578
2579 /// attempts rational reconstruction of primal-dual solution
2581 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusRows,
2582 DataArray< typename SPxSolverBase<R>::VarStatus >& basisStatusCols,
2583 const Rational& denomBoundSquared);
2584 ///@}
2585
2586 ///@name Private solving methods implemented in solvereal.cpp
2587 ///@{
2588
2589 /// solves the templated LP
2590 void _optimize(volatile bool* interrupt = nullptr);
2591
2592 /// temporary fix for Rational
2593 void _optimizeRational(volatile bool* interrupt = nullptr);
2594
2595 /// checks result of the solving process and solves again without preprocessing if necessary
2596 void _evaluateSolutionReal(typename SPxSimplifier<R>::Result simplificationStatus);
2597
2598 /// solves real LP with/without preprocessing
2599 void _preprocessAndSolveReal(bool applyPreprocessing, volatile bool* interrupt = nullptr);
2600
2601 /// loads original problem into solver and solves again after it has been solved to optimality with preprocessing
2602 void _resolveWithoutPreprocessing(typename SPxSimplifier<R>::Result simplificationStatus);
2603
2604 /// verify computed solution and resolve if necessary
2606
2607 /// verify computed obj stop and resolve if necessary
2609
2610 /// stores solution of the real LP; before calling this, the real LP must be loaded in the solver and solved (again)
2611 void _storeSolutionReal(bool verify = true);
2612
2613 /// stores solution from the simplifier because problem vanished in presolving step
2615
2616 /// unscales stored solution to remove internal or external scaling of LP
2617 void _unscaleSolutionReal(SPxLPBase<R>& LP, bool persistent = true);
2618
2619 /// load original LP and possibly setup a slack basis
2620 void _loadRealLP(bool initBasis);
2621
2622 /// check scaling of LP
2623 void _checkScaling(SPxLPBase<R>* origLP) const;
2624
2625 /// check correctness of (un)scaled basis matrix operations
2627
2628 /// check whether persistent scaling is supposed to be reapplied again after unscaling
2630
2631 /// checks the dual feasibility of the current basis
2633 ///@}
2634};
2635
2636/* Backwards compatibility */
2638// A header file containing all the general templated functions
2639
2640} // namespace soplex
2641
2642// General templated function
2643#include "soplex.hpp"
2644#include "soplex/solverational.hpp"
2645#include "soplex/testsoplex.hpp"
2646#include "soplex/solvereal.hpp"
2647
2648#endif // _SOPLEX_H_
Collection of dense, sparse, and semi-sparse vectors.
Safe arrays of arbitrary types.
Definition array.h:73
Dynamic index set.
Definition didxset.h:52
Dynamic sparse vectors.
Safe arrays of data objects.
Definition dataarray.h:75
LP column.
Definition lpcolbase.h:55
Set of LP columns.
(In)equality for LPs.
Definition lprowbase.h:55
Type
(In)Equality type of an LP row.
Definition lprowbase.h:82
Set of LP rows.
Set of strings.
Definition nameset.h:71
Implementation of Sparse Linear Solver with Rational precision.
Implementation of Sparse Linear Solver.
Definition slufactor.h:51
Auto pricer.
Definition spxautopr.h:52
SPxStatus
basis status.
Definition spxbasis.h:102
Bound flipping ratio test ("long step dual") for SoPlex.
Dantzig pricer.
Devex pricer.
Definition spxdevexpr.h:54
Equilibrium row/column scaling.
Definition spxequilisc.h:46
Fast shifting ratio test.
Definition spxfastrt.h:54
Geometric mean row/column scaling.
Definition spxgeometsc.h:46
Harris pricing with shifting.
Definition spxharrisrt.h:51
Saving LPs in a form suitable for SoPlex.
Definition spxlpbase.h:108
Least squares scaling.
LP simplifier for removing uneccessary row/columns.
Definition spxmainsm.h:72
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition spxout.h:78
Partial multiple pricing.
LP scaler abstract base class.
Definition spxscaler.h:87
LP simplification abstract base class.
Result
Result of the simplification.
Sequential object-oriented SimPlex.
Definition spxsolver.h:104
@ OPTIMAL
LP has been solved to optimality.
Definition spxsolver.h:224
@ OPTIMAL_UNSCALED_VIOLATIONS
LP has beed solved to optimality but unscaled solution contains violations.
Definition spxsolver.h:228
SoPlex start basis generation base class.
Definition spxstarter.h:52
Steepest edge pricer.
Steepest edge pricer.
Definition spxsteeppr.h:52
Simple heuristic SPxStarter.
Definition spxsumst.h:48
Solution vector based start basis.
Definition spxvectorst.h:55
Weighted start basis.
Definition spxweightst.h:67
Sparse vectors.
int _intParamValues[SoPlexBase< R >::INTPARAM_COUNT]
array of current integer parameter values
Definition soplex.h:1589
bool _boolParamValues[SoPlexBase< R >::BOOLPARAM_COUNT]
array of current boolean parameter values
Definition soplex.h:1586
Settings(const Settings &settings)
copy constructor
Settings & operator=(const Settings &settings)
assignment operator
Real _realParamValues[SoPlexBase< R >::REALPARAM_COUNT]
array of current real parameter values
Definition soplex.h:1592
Settings()
default constructor initializing default settings
void printExternalCodes() const
prints external libraries
int numRows() const
returns number of rows
void _performOptIRStableBoosted(SolRational &sol, bool acceptUnbounded, bool acceptInfeasible, int minIRRoundsRemaining, bool &primalFeasible, bool &dualFeasible, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error, bool &needNewBoostedIt)
solves current problem with iterative refinement and recovery mechanism using boosted solver
bool getBasisInverseTimesVecRational(const SVectorRational &rhs, SSVectorRational &sol)
computes solution of basis matrix B * sol = rhs; performs rational factorization if not available; re...
bool _isSolveStopped(bool &stoppedTime, bool &stoppedIter) const
should solving process be stopped?
SPxLeastSqSC< BP > _boostedScalerLeastsq
Definition soplex.h:1852
bool getDualNorms(int &nnormsRow, int &nnormsCol, R *norms) const
gets steepest edge norms and returns false if they are not available
VectorRational _modObj
Definition soplex.h:1896
void _changeColReal(int i, const LPColReal &lpcol)
replaces column i with lpcol and adjusts basis
SPxSolverBase< R >::Status _solveRealForRational(bool fromscratch, VectorBase< R > &primal, VectorBase< R > &dual, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols)
solves real LP during iterative refinement
void _untransformFeasibility(SolRational &sol, bool infeasible)
undoes transformation to feasibility problem
void _computeDualViolation(SolRational &sol, Rational &dualViolation, const bool &maximizing)
computes dual violation during the refinement loop
bool getRowViolation(R &maxviol, R &sumviol)
gets violation of constraints; returns true on success
bool getColActivity(const int i, R &value)
gets the activity for the i 'th column given the current dual solution
void _resolveWithoutPreprocessing(typename SPxSimplifier< R >::Result simplificationStatus)
loads original problem into solver and solves again after it has been solved to optimality with prepr...
R objValueReal()
returns the objective value if a primal solution is available
void _removeRowsReal(int idx[], int n, int perm[])
remove all rows with indices in array idx of size n; an array perm of size numRows() may be passed as...
bool _setupBoostedSolverAfterRecovery()
setup recovery mecanism using multiprecision, return false if maximum precision reached,...
VectorRational _modUpper
Definition soplex.h:1893
void _storeSolutionReal(bool verify=true)
stores solution of the real LP; before calling this, the real LP must be loaded in the solver and sol...
void getObjReal(VectorBase< R > &obj) const
gets objective function vector
void _updateBoostingStatistics()
bool getRowsActivityReal(R *p_vector, int dim)
void _storeLPReal()
stores objective, bounds, and sides of real LP
Real solveTime() const
time spent in last call to solve
void _storeRealSolutionAsRational(SolRational &sol, VectorBase< T > &primalReal, VectorBase< T > &dualReal, int &dualSize)
stores floating-point solution of original LP as current rational solution and ensure that solution v...
VectorBase< Real > _manualRhs
Definition soplex.h:1867
bool multBasisTranspose(R *vec, bool unscale=true)
multiply with transpose of basis matrix; vec * B^T (inplace)
void _removeRowReal(int i)
removes row i and adjusts basis
void _rangeToPerm(int start, int end, int *perm, int permSize) const
creates a permutation for removing rows/columns from a range of indices
void changeColRational(int i, const LPColRational &lpcol)
replaces column i with lpcol
void setTimings(const Timer::TYPE ttype)
set statistic timers to a certain type
SPxWeightST< Real > _starterWeight
Definition soplex.h:1758
const VectorBase< R > & lhsRealInternal() const
returns left-hand side vector, ignoring scaling
bool _isBoostedConsistent() const
checks consistency for the boosted solver
R coefReal(int row, int col) const
returns (unscaled) coefficient
VectorRational _unboundedLhs
Definition soplex.h:1884
bool getSlacksReal(VectorBase< R > &vector)
gets the vector of slack values if available; returns true on success
DataArray< typename SPxSolverBase< BP >::VarStatus > _tmpBasisStatusRows
Definition soplex.h:1965
SPxDantzigPR< BP > _boostedPricerDantzig
Definition soplex.h:1833
void _removeColsReal(int idx[], int n, int perm[])
remove all columns with indices in array idx of size n; an array perm of size numColsReal() may be pa...
SPxEquiliSC< Real > _scalerBiequi
Definition soplex.h:1753
RealParam
real parameters
Definition soplex.h:1424
bool getDualViolation(R &maxviol, R &sumviol)
gets violation of dual multipliers; returns true on success
void _enableSimplifierAndScaler()
enables simplifier and scaler according to current parameters
void _verifyObjLimitReal()
verify computed obj stop and resolve if necessary
bool getSlacksReal(R *p_vector, int dim)
DataArray< typename SPxSolverBase< Real >::VarStatus > _basisStatusRows
Definition soplex.h:1936
SoPlexBase()
default constructor
void changeLhsReal(const VectorBase< R > &lhs)
changes left-hand side vector for constraints to lhs
void addRowsRational(const LPRowSetRational &lprowset)
adds multiple rows
VectorRational _feasObj
Definition soplex.h:1887
void changeRhsRational(const VectorRational &rhs)
changes right-hand side vector to rhs
IntParam
integer parameters
Definition soplex.h:1084
DSVectorRational _tauColVector
Definition soplex.h:1886
int numRefinements() const
number of iterative refinements
void _removeColReal(int i)
removes column i
void changeUpperRational(const VectorRational &upper)
changes vector of upper bounds to upper
bool getColsActivityReal(const std::vector< int > &indices, R *p_vector, const int dim)
void _convertDataArrayVarStatusToRPrecision(DataArray< typename SPxSolverBase< BP >::VarStatus > &base, DataArray< typename SPxSolverBase< R >::VarStatus > &copy)
void _addColReal(const LPColReal &lpcol)
adds a single column to the real LP and adjusts basis
DataArray< typename SPxSolverBase< Real >::VarStatus > _storedBasisStatusRows
Definition soplex.h:1898
bool getDualRational(mpq_t *vector, const int size)
gets the dual solution vector if available; returns true on success (GMP only method)
void changeElementRational(int i, int j, const Rational &val)
changes matrix entry in row i and column j to val
LPRowRational::Type rowTypeRational(int i) const
returns inequality type of row i
void getObjRational(int i, Rational &obj) const
gets objective value of column i
const char * getStarterName()
name of starter
void _storeBasis()
store basis
void _ensureRealLPLoaded()
ensures that the real LP and the basis are loaded in the solver; performs no sync
void changeLhsRational(int i, const mpq_t *lhs)
changes left-hand side of row i to lhs (GMP only method)
const Rational & upperRational(int i) const
returns upper bound of column i
bool getSlacksRational(mpq_t *vector, const int size)
gets the vector of slack values if available; returns true on success (GMP only method)
VectorRational _unboundedLower
Definition soplex.h:1882
bool getBasisInverseRowReal(int r, R *coef, int *inds=nullptr, int *ninds=nullptr, bool unscale=true)
computes row r of basis inverse; returns true on success
void printSolvingStatistics(std::ostream &os)
prints statistics on solving process
const VectorBase< R > & maxObjRealInternal() const
returns objective function vector after transformation to a maximization problem; since this is how i...
void _updateReducedCosts(SolRational &sol, int &dualSize, const int &numCorrectedPrimals)
updates or recomputes reduced cost values depending on which looks faster; adding one to the length o...
int numRowsRational() const
bool checkBasisDualFeasibility(VectorBase< R > feasVec)
checks the dual feasibility of the current basis
void _updateSlacks(SolRational &sol, int &primalSize)
updates or recomputes slacks depending on which looks faster
bool getSlacksRational(VectorRational &vector)
gets the vector of slack values if available; returns true on success
const SVectorBase< R > & rowVectorRealInternal(int i) const
returns vector of row i, ignoring scaling
const VectorBase< R > & lowerRealInternal() const
returns lower bound vector
bool getBasisIndRational(DataArray< int > &bind)
gets an array of indices for the columns of the rational basis matrix; bind[i] >= 0 means that the i-...
bool getBasisInverseTimesVecReal(R *rhs, R *sol, bool unscale=true)
computes dense solution of basis matrix B * sol = rhs; returns true on success
void _applyScaledObj(SPxSolverBase< T > &solver, Rational &dualScale, SolRational &sol)
applies scaled objective function
void _syncLPReal(bool time=true)
synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP,...
void _recomputeRangeTypesRational()
recomputes range types from scratch using rational LP
int numIterations() const
number of iterations since last call to solve
const SVectorBase< R > & colVectorRealInternal(int i) const
returns vector of col i, ignoring scaling
bool setDualNorms(int nnormsRow, int nnormsCol, R *norms)
sets steepest edge norms and returns false if that's not possible
SPxGeometSC< Real > _scalerGeo1
Definition soplex.h:1754
void addRowsReal(const LPRowSetBase< R > &lprowset)
adds multiple rows
void changeBoundsReal(int i, const R &lower, const R &upper)
changes bounds of column i to lower and upper
bool getPrimalRayReal(R *vector, int dim)
void _solveRealForRationalStable(SolRational &sol, bool &primalFeasible, bool &dualFeasible, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error)
solves current problem using double floating-point solver
bool parseSettingsString(char *str)
parses one setting string and returns true on success; note that string is modified
int numNonzerosRational() const
const SVectorRational & rowVectorRational(int i) const
returns vector of row i
SPxLPBase< Real > _manualRealLP
Definition soplex.h:1869
void changeColReal(int i, const LPColReal &lpcol)
replaces column i with lpcol
void changeObjRational(int i, const Rational &obj)
changes objective coefficient of column i to obj
void _changeBoundsReal(int i, const R &lower, const R &upper)
changes bounds of column i to lower and upper and adjusts basis
void getBasisInd(int *bind) const
gets the indices of the basic columns and rows; basic column n gives value n, basic row m gives value...
SPxHarrisRT< BP > _boostedRatiotesterHarris
Definition soplex.h:1840
void clearLPRational()
clears the LP
void printStatus(std::ostream &os, typename SPxSolverBase< R >::Status status)
prints status
void changeRhsRational(const mpq_t *rhs, int rhsSize)
changes right-hand side vector to rhs (GMP only method)
bool getBasisInverseColReal(int c, R *coef, int *inds=nullptr, int *ninds=nullptr, bool unscale=true)
computes column c of basis inverse; returns true on success
void removeColRational(int i)
removes column i
void getBasis(typename SPxSolverBase< R >::VarStatus rows[], typename SPxSolverBase< R >::VarStatus cols[]) const
gets current basis via arrays of statuses
void _syncRealSolution()
synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real s...
int numColsRational() const
void addColReal(const LPColBase< R > &lpcol)
adds a single column
void getRowRational(int i, LPRowRational &lprow) const
gets row i
SPxLPBase< Real > * _realLP
Definition soplex.h:1772
void _changeLhsReal(const VectorBase< R > &lhs)
changes left-hand side vector for constraints to lhs and adjusts basis
bool boolParam(const BoolParam param) const
returns boolean parameter value
const Rational & lowerRational(int i) const
returns lower bound of column i
int dmaxSizeDualRational(const int base=2)
get size of largest denominator in dual solution
SPxParMultPR< Real > _pricerParMult
Definition soplex.h:1763
const char * getPricerName()
name of currently loaded pricer
void addColsRational(const LPColSetRational &lpcolset)
adds multiple columns
VectorRational _feasLhs
Definition soplex.h:1888
void changeElementReal(int i, int j, const R &val)
changes matrix entry in row i and column j to val
void changeRangeReal(int i, const R &lhs, const R &rhs)
changes left- and right-hand side of row i
void getColRational(int i, LPColRational &lpcol) const
gets column i
void printUserSettings()
print non-default parameter values
bool _loadBasisFromOldBasis(bool boosted)
void _computePrimalScalingFactor(Rational &maxScale, Rational &primalScale, Rational &boundsViolation, Rational &sideViolation, Rational &redCostViolation)
computes primal scaling factor; limit increase in scaling by tolerance used in floating point solve
VectorRational _feasRhs
Definition soplex.h:1889
VectorRational _feasLower
Definition soplex.h:1890
void _correctDualSolution(SPxSolverBase< T > &solver, SolRational &sol, const bool &maximizing, VectorBase< T > &dualReal, Rational &dualScale, int &dualSize, const int &maxDimRational)
corrects dual solution and aligns with basis
SPxAutoPR< BP > _boostedPricerAuto
Definition soplex.h:1832
int numColsReal() const
bool areLPsInSync(const bool checkVecVals=true, const bool checkMatVals=false, const bool quiet=false) const
checks if real LP and rational LP are in sync; dimensions will always be compared,...
void _loadRealLP(bool initBasis)
load original LP and possibly setup a slack basis
const std::shared_ptr< Tolerances > tolerances() const
returns current tolerances
bool hasDual() const
deprecated: use hasSol() instead
Definition soplex.h:627
bool getDualFarkasReal(R *vector, int dim)
void changeUpperRational(int i, const mpq_t *upper)
changes upper bound of column i to upper (GMP only method)
void addRowsRational(const mpq_t *lhs, const mpq_t *rowValues, const int *rowIndices, const int *rowStarts, const int *rowLengths, const int numRows, const int numValues, const mpq_t *rhs)
adds a set of rows (GMP only method)
void _solveRealLPAndRecordStatistics(volatile bool *interrupt=nullptr)
call floating-point solver and update statistics on iterations etc.
void _changeBoundsReal(const VectorBase< R > &lower, const VectorBase< R > &upper)
changes vectors of column bounds to lower and upper and adjusts basis
void _completeRangeTypesRational()
completes range type arrays after adding columns and/or rows
void changeUpperReal(const VectorBase< R > &upper)
changes vector of upper bounds to upper
void _invalidateSolution()
invalidates solution
void removeRowRangeRational(int start, int end, int perm[]=nullptr)
removes rows start to end including both; an array perm of size numRowsRational() may be passed as bu...
void _optimizeRational(volatile bool *interrupt=nullptr)
temporary fix for Rational
DataArray< RangeType > _colTypes
Definition soplex.h:1924
bool isDualFeasible() const
is stored dual solution feasible?
DataArray< typename SPxSolverBase< Real >::VarStatus > _basisStatusCols
Definition soplex.h:1937
void _transformFeasibility()
transforms LP to feasibility problem by removing the objective function, shifting variables,...
bool getBasisMetric(R &metric, int type=0)
SPxDantzigPR< Real > _pricerDantzig
Definition soplex.h:1762
Presol< Real > _simplifierPaPILO
Definition soplex.h:1751
SPxGeometSC< BP > _boostedScalerGeo8
Definition soplex.h:1850
bool getEstimatedCondition(R &condition)
computes an estimated condition number for the current basis matrix using the power method; returns t...
R lowerReal(int i) const
returns lower bound of column i
void removeRowRational(int i)
removes row i
void _optimize(volatile bool *interrupt=nullptr)
solves the templated LP
SPxParMultPR< BP > _boostedPricerParMult
Definition soplex.h:1834
bool getPrimalRational(VectorRational &vector)
int totalSizeDualRational(const int base=2)
get size of dual solution
int dlcmSizeDualRational(const int base=2)
get size of least common multiple of denominators in dual solution
SPxSteepPR< Real > _pricerQuickSteep
Definition soplex.h:1765
void _project(SolRational &sol)
undoes lifting
bool getRedCostViolation(R &maxviol, R &sumviol)
gets violation of reduced costs; returns true on success
SPxSolverBase< R >::Status optimize(volatile bool *interrupt=nullptr)
optimize the given LP
SPxSolverBase< R >::Status solve(volatile bool *interrupt=nullptr)
Definition soplex.h:606
void addColRational(const LPColRational &lpcol)
adds a single column
DSVectorRational _primalDualDiff
Definition soplex.h:1897
DataArray< typename SPxSolverBase< Real >::VarStatus > _storedBasisStatusCols
Definition soplex.h:1899
void _computeDualScalingFactor(Rational &maxScale, Rational &primalScale, Rational &dualScale, Rational &redCostViolation, Rational &dualViolation)
computes dual scaling factor; limit increase in scaling by tolerance used in floating point solve
SPxSumST< Real > _starterSum
Definition soplex.h:1759
bool ignoreUnscaledViolations()
sets the status to OPTIMAL in case the LP has been solved with unscaled violations
Definition soplex.h:642
bool getDualFarkas(VectorBase< R > &vector)
gets the Farkas proof if available; returns true on success
bool getDualFarkasRational(mpq_t *vector, const int size)
gets the Farkas proof if LP is infeasible; returns true on success (GMP only method)
bool readBasisFile(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr)
reads basis information from filename and returns true on success; if rowNames and colNames are nullp...
SLUFactor< Real > _slufactor
Definition soplex.h:1749
int numCols() const
Templated function that returns number of columns.
void _applyScaledBounds(SPxSolverBase< T > &solver, Rational &primalScale)
applies scaled bounds
bool _lowerFinite(const RangeType &rangeType) const
checks whether RangeType corresponds to finite lower bound
SPxDevexPR< Real > _pricerDevex
Definition soplex.h:1764
void _checkRefinementProgress(Rational &boundsViolation, Rational &sideViolation, Rational &redCostViolation, Rational &dualViolation, Rational &maxViolation, Rational &bestViolation, const Rational &violationImprovementFactor, int &numFailedRefinements)
checks refinement loop progress
void changeObjReal(int i, const R &obj)
changes objective coefficient of column i to obj
bool readFile(const char *filename, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
reads LP file in LP or MPS format according to READMODE parameter; gets row names,...
Rational objRational(int i) const
returns objective value of column i
VectorBase< Real > _manualObj
Definition soplex.h:1868
SLUFactorRational _rationalLUSolver
Definition soplex.h:1878
void setRandomSeed(unsigned int seed)
set the random seeds of the solver instance
void _computeInfeasBox(SolRational &sol, bool transformed)
void printStatistics(std::ostream &os)
prints complete statistics
void writeStateReal(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const bool cpxFormat=false, const bool writeZeroObjective=false) const
writes internal LP, basis information, and parameter settings; if rowNames and colNames are nullptr,...
void _applyScaledSides(SPxSolverBase< T > &solver, Rational &primalScale)
applies scaled sides
int intParam(const IntParam param) const
returns integer parameter value
bool getRowsActivity(VectorBase< R > &vector)
gets the activities for all rows given the current primal solution; vector must have the same size as...
void changeBoundsRational(const VectorRational &lower, const VectorRational &upper)
changes vectors of column bounds to lower and upper
void _untransformEquality(SolRational &sol)
undoes transformation to equality form
void removeRowsReal(int idx[], int n, int perm[]=nullptr)
remove all rows with indices in array idx of size n; an array perm of size numRows() may be passed as...
const char * getRatiotesterName()
name of currently loaded ratiotester
Rational objValueRational()
returns the objective value if a primal solution is available
void _solveRealForRationalBoosted(VectorBase< BP > &primal, VectorBase< BP > &dual, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols, typename SPxSolverBase< BP >::Status &boostedResult, bool initialSolve)
solves real LP during iterative refinement
bool getRowsActivityRational(const std::vector< int > &indices, VectorRational &vector)
Real realParam(const RealParam param) const
returns real parameter value
int totalSizePrimalRational(const int base=2)
get size of primal solution
bool getBoundViolation(R &maxviol, R &sumviol)
gets violation of bounds; returns true on success
bool getBoundViolationRational(Rational &maxviol, Rational &sumviol)
void changeRangeRational(int i, const mpq_t *lhs, const mpq_t *rhs)
changes left- and right-hand side of row i (GMP only method)
void changeObjRational(int i, const mpq_t *obj)
changes objective coefficient of column i to obj (GMP only method)
bool _upperFinite(const RangeType &rangeType) const
checks whether RangeType corresponds to finite upper bound
bool saveSettingsFile(const char *filename, const bool onlyChanged=false, int solvemode=1) const
writes settings file; returns true on success
SPxEquiliSC< BP > _boostedScalerBiequi
Definition soplex.h:1848
void changeRhsRational(int i, const Rational &rhs)
changes right-hand side of row i to rhs
SPxVectorST< Real > _starterVector
Definition soplex.h:1760
void _convertDataArrayVarStatusToBoosted(DataArray< typename SPxSolverBase< R >::VarStatus > &base, DataArray< typename SPxSolverBase< BP >::VarStatus > &copy)
SPxBoundFlippingRT< BP > _boostedRatiotesterBoundFlipping
Definition soplex.h:1842
void removeRowsRational(int idx[], int n, int perm[]=nullptr)
remove all rows with indices in array idx of size n; an array perm of size numRowsRational() may be p...
void _performOptIRStable(SolRational &sol, bool acceptUnbounded, bool acceptInfeasible, int minIRRoundsRemaining, bool &primalFeasible, bool &dualFeasible, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error)
solves current problem with iterative refinement and recovery mechanism
void _forceNonbasicToBound(SolRational &sol, int &c, const int &maxDimRational, bool toLower)
forces value of given nonbasic variable to bound
void _changeRangeReal(const VectorBase< R > &lhs, const VectorBase< R > &rhs)
changes left- and right-hand side vectors and adjusts basis
void _transformUnbounded()
transforms LP to unboundedness problem by moving the objective function to the constraints,...
void setBasis(const typename SPxSolverBase< R >::VarStatus rows[], const typename SPxSolverBase< R >::VarStatus cols[])
sets starting basis via arrays of statuses
std::shared_ptr< Tolerances > _tolerances
Definition soplex.h:1734
void _changeLowerReal(const VectorBase< R > &lower)
changes vector of lower bounds to lower and adjusts basis
void _changeUpperReal(const VectorBase< R > &upper)
changes vector of upper bounds to upper and adjusts basis
void removeColReal(int i)
removes column i
int dlcmSizePrimalRational(const int base=2)
get size of least common multiple of denominators in primal solution
void _computeBasisInverseRational()
computes rational inverse of basis matrix as defined by _rationalLUSolverBind
void _computeSidesViolation(SolRational &sol, Rational &sideViolation)
computes violation of sides during the refinement loop
R objReal(int i) const
returns objective value of column i
VectorRational _unboundedRhs
Definition soplex.h:1885
SolBase< Real > _solReal
Definition soplex.h:1968
SLUFactor< BP > _boostedSlufactor
Definition soplex.h:1830
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldFeasBasisStatusRows
Definition soplex.h:1949
void _performUnboundedIRStable(SolRational &sol, bool &hasUnboundedRay, bool &stoppedTime, bool &stoppedIter, bool &error)
performs iterative refinement on the auxiliary problem for testing unboundedness
bool getPrimal(VectorBase< R > &vector)
gets the primal solution vector if available; returns true on success
bool _readFileReal(const char *filename, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
reads real LP in LP or MPS format from file and returns true on success; gets row names,...
Settings * _currentSettings
Definition soplex.h:1732
void _switchToBoosted()
disable initial precision solver and switch to boosted solver
Presol< BP > _boostedSimplifierPaPILO
Definition soplex.h:1855
unsigned int randomSeed() const
returns the current random seed of the solver instance
SPxAutoPR< Real > _pricerAuto
Definition soplex.h:1761
bool getExactCondition(R &condition)
computes the exact condition number for the current basis matrix using the power method; returns true...
void writeStateRational(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const bool cpxFormat=false, const bool writeZeroObjective=false) const
writes internal LP, basis information, and parameter settings; if rowNames and colNames are nullptr,...
int numRowsReal() const
void _changeUpperReal(int i, const R &upper)
changes i 'th upper bound to upper and adjusts basis
void changeLowerRational(const VectorRational &lower)
changes vector of lower bounds to lower
void _solveBoostedRealLPAndRecordStatistics(volatile bool *interrupt=nullptr)
call floating-point solver and update statistics on iterations etc.
void changeRowReal(int i, const LPRowBase< R > &lprow)
replaces row i with lprow
void _recomputeRangeTypesReal()
recomputes range types from scratch using real LP
int numIterationsBoosted() const
number of iterations in higher precision since last call to solve
SPxSteepExPR< Real > _pricerSteep
Definition soplex.h:1766
bool getBasisInverseColRational(const int c, SSVectorRational &vec)
computes column c of basis inverse; performs rational factorization if not available; returns true on...
void _checkScaling(SPxLPBase< R > *origLP) const
check scaling of LP
void _solveRealForRationalBoostedStable(SolRational &sol, bool &primalFeasible, bool &dualFeasible, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error, bool &needNewBoostedIt)
solves current problem using multiprecision floating-point solver return false if a new boosted itera...
void removeRowReal(int i)
removes row i
DataArray< RangeType > _rowTypes
Definition soplex.h:1925
SPxDefaultRT< Real > _ratiotesterTextbook
Definition soplex.h:1767
void _storeLastStableBasisBoosted(bool vanished)
SPxSolverBase< R >::VarStatus basisRowStatus(int row) const
returns basis status for a single row
void _restoreLPReal()
restores objective, bounds, and sides of real LP
SPxMainSM< BP > _boostedSimplifierMainSM
Definition soplex.h:1854
bool setBoolParam(const BoolParam param, const bool value, const bool init=true)
sets boolean parameter value; returns true on success
void changeLowerReal(const VectorBase< R > &lower)
changes vector of lower bounds to lower
void printSolutionStatistics(std::ostream &os)
prints solution statistics
void changeUpperReal(int i, const R &upper)
changes i 'th upper bound to upper
bool getRowsActivity(const std::vector< int > &indices, VectorBase< R > &vector)
gets the activities for the rows in indices given the current primal solution; all other elements of ...
const Rational & maxObjRational(int i) const
returns objective value of column i after transformation to a maximization problem; since this is how...
void printShortStatistics(std::ostream &os)
prints short statistics
const Rational & lhsRational(int i) const
returns left-hand side of row i
int dmaxSizePrimalRational(const int base=2)
get size of largest denominator in primal solution
VectorRational _modLower
Definition soplex.h:1892
void changeUpperRational(int i, const Rational &upper)
changes i 'th upper bound to upper
bool getRedCost(VectorBase< R > &vector)
gets the vector of reduced cost values if available; returns true on success
SPxBoundFlippingRT< Real > _ratiotesterBoundFlipping
Definition soplex.h:1770
bool getRedCostReal(R *vector, int dim)
void _syncLPRational(bool time=true)
synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sy...
bool _isBoostedStartingFromSlack(bool initialSolve=true)
return true if slack basis has to be loaded for boosted solver
bool _parseSettingsLine(char *line, const int lineNumber)
parses one line in a settings file and returns true on success; note that the string is modified
void removeColRangeReal(int start, int end, int perm[]=nullptr)
removes columns start to end including both; an array perm of size numColsReal() may be passed as buf...
const char * getSimplifierName()
name of simplifier
const SVectorRational & colVectorRational(int i) const
returns vector of column i
void factorizeColumnRational(SolRational &sol, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols, bool &stoppedTime, bool &stoppedIter, bool &error, bool &optimal)
factorizes rational basis matrix in column representation
void _syncRationalSolution()
synchronizes real solution with rational solution, i.e., copies real solution to rational solution
void _storeLastStableBasis(bool vanished)
void _changeLhsReal(int i, const R &lhs)
changes left-hand side of row i to lhs and adjusts basis
SPxSteepExPR< BP > _boostedPricerSteep
Definition soplex.h:1837
VectorRational _unboundedUpper
Definition soplex.h:1883
SPxSolverBase< Real >::Status _status
Definition soplex.h:1933
void changeElementRational(int i, int j, const mpq_t *val)
changes matrix entry in row i and column j to val (GMP only method)
bool getRowActivityRational(int i, Rational &value)
void _removeRowRangeReal(int start, int end, int perm[])
removes rows start to end including both; an array perm of size numRows() may be passed as buffer mem...
void changeBoundsRational(int i, const Rational &lower, const Rational &upper)
changes bounds of column i to lower and upper
RangeType _switchRangeType(const RangeType &rangeType) const
switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
void _ensureDSVectorRationalMemory(DSVectorRational &vec, const int newmax) const
extends sparse vector to hold newmax entries if and only if it holds no more free entries
bool _evaluateResult(SPxSolverBase< T > &solver, typename SPxSolverBase< T >::Status result, bool usingRefinedLP, SolRational &sol, VectorBase< T > &dualReal, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error)
evaluates result of solve. Return true if the algorithm must to stopped, false otherwise.
void syncLPReal()
synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP,...
void _transformEquality()
introduces slack variables to transform inequality constraints into equations for both rational and r...
void clearBasis()
clears starting basis
SPxScaler< BP > * _boostedScaler
Definition soplex.h:1844
DataArray< int > _rationalLUSolverBind
Definition soplex.h:1879
SPxGeometSC< Real > _scalerGeo8
Definition soplex.h:1755
void _ratrecAndOrRatfac(int &minIRRoundsRemaining, int &lastStallIterations, int &numberOfIterations, bool &factorSolNewBasis, int &nextRatrec, const Rational &errorCorrectionFactor, Rational &errorCorrection, Rational &maxViolation, SolRational &sol, bool &primalFeasible, bool &dualFeasible, bool &stoppedTime, bool &stoppedIter, bool &error, bool &breakAfter, bool &continueAfter)
performs rational reconstruction and/or factorizationd
std::string statisticString() const
statistical information in form of a string
void _ensureRationalLP()
ensures that the rational LP is available; performs no sync
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldBasisStatusRows
Definition soplex.h:1945
VectorRational _modRhs
Definition soplex.h:1895
VectorBase< Real > _manualLhs
Definition soplex.h:1866
void changeBoundsReal(const VectorBase< R > &lower, const VectorBase< R > &upper)
changes vectors of column bounds to lower and upper
void changeBoundsRational(int i, const mpq_t *lower, const mpq_t *upper)
changes bounds of column i to lower and upper (GMP only method)
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
gets number of available dual norms
SPxSolverBase< BP > _boostedSolver
Definition soplex.h:1794
void changeLhsRational(const VectorRational &lhs)
changes left-hand side vector for constraints to lhs
bool _isConsistent() const
checks consistency
void changeRowRational(int i, const LPRowRational &lprow)
replaces row i with lprow
void _addRowReal(const LPRowBase< R > &lprow)
adds a single row to the real LP and adjusts basis
void getUpperReal(VectorBase< R > &upper) const
gets upper bound vector
VectorBase< Real > _manualLower
Definition soplex.h:1864
SoPlexBase< R > & operator=(const SoPlexBase< R > &rhs)
assignment operator
const VectorRational & maxObjRational() const
returns objective function vector after transformation to a maximization problem; since this is how i...
bool getColActivityRational(const int i, Rational &value)
bool hasPrimalRay() const
is a primal unbounded ray available?
bool getDual(VectorBase< R > &vector)
gets the dual solution vector if available; returns true on success
SPxSimplifier< BP > * _boostedSimplifier
Definition soplex.h:1845
void resetSettings(const bool quiet=false, const bool init=true)
resets default parameter settings
bool hasPrimal() const
deprecated: use hasSol() instead
Definition soplex.h:621
bool getColsActivity(const std::vector< int > &indices, VectorBase< R > &vector)
gets the activities for the columns in indices given the current dual solution; all other elements of...
void changeObjReal(const VectorBase< R > &obj)
changes objective function vector to obj
bool writeFile(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const DIdxSet *intvars=nullptr, const bool unscale=true, const bool writeZeroObjective=false) const
Templated write function Real writes real LP to file; LP or MPS format is chosen from the extension i...
bool getColsActivityReal(R *p_vector, const int dim)
Rational maxAbsNonzeroRational() const
returns biggest non-zero element in absolute value
bool getRowActivity(int i, R &value)
gets the activity for the i 'th row given the current primal solution
void _correctPrimalSolution(SolRational &sol, Rational &primalScale, int &primalSize, const int &maxDimRational, VectorBase< T > &primalReal)
corrects primal solution and aligns with basis
Array< UnitVectorRational * > _unitMatrixRational
Definition soplex.h:1900
void _switchToStandardMode()
indicate if we are testing feasibility, unboundedness or neither
void _preprocessAndSolveReal(bool applyPreprocessing, volatile bool *interrupt=nullptr)
solves real LP with/without preprocessing
VectorBase< Real > _manualUpper
Definition soplex.h:1865
R maxObjReal(int i) const
returns objective value of column i after transformation to a maximization problem; since this is how...
void _unscaleSolutionReal(SPxLPBase< R > &LP, bool persistent=true)
unscales stored solution to remove internal or external scaling of LP
bool _reapplyPersistentScaling() const
check whether persistent scaling is supposed to be reapplied again after unscaling
void removeRowsReal(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
bool _inStandardMode()
check if we are testing feasibility, unboundedness or neither
int numNonzeros() const
returns number of nonzeros
void _changeRhsReal(const VectorBase< R > &rhs)
changes right-hand side vector to rhs and adjusts basis
bool _readFileRational(const char *filename, NameSet *rowNames=nullptr, NameSet *colNames=nullptr, DIdxSet *intVars=nullptr)
reads rational LP in LP or MPS format from file and returns true on success; gets row names,...
SoPlexBase(const SoPlexBase< R > &rhs)
copy constructor
const VectorBase< R > & rhsRealInternal() const
returns right-hand side vector, ignoring scaling
void changeLowerRational(int i, const mpq_t *lower)
changes lower bound of column i to lower (GMP only method)
void _removeRowsReal(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
void _addRowReal(R lhs, const SVectorBase< R > &lprow, R rhs)
adds a single row to the real LP and adjusts basis
bool getBasisInverseRowRational(const int r, SSVectorRational &vec)
computes row r of basis inverse; performs rational factorization if not available; returns true on su...
SPxLeastSqSC< Real > _scalerLeastsq
Definition soplex.h:1757
bool getColsActivityRational(const std::vector< int > &indices, VectorRational &vector)
bool getPrimalRayRational(mpq_t *vector, const int size)
gets the primal ray if LP is unbounded; returns true on success (GMP only method)
bool getPrimalRayRational(VectorRational &vector)
void _storeBasisAsOldBasisBoosted(DataArray< typename SPxSolverBase< BP >::VarStatus > &rows, DataArray< typename SPxSolverBase< BP >::VarStatus > &cols)
SPxGeometSC< BP > _boostedScalerGeo1
Definition soplex.h:1849
void printVersion() const
prints version and compilation options
Statistics * _statistics
Definition soplex.h:1724
SPxSolverBase< Real > _solver
Definition soplex.h:1748
bool _boostPrecision()
increase the multiprecision, return false if maximum precision is reached, true otherwise
SPxDevexPR< BP > _boostedPricerDevex
Definition soplex.h:1835
void syncLPRational()
synchronizes rational LP with real LP, i.e., copies real LP to rational LP, if sync mode is manual
bool writeFileReal(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const DIdxSet *intvars=nullptr, const bool unscale=true, const bool writeZeroObjective=false) const
bool writeFileRational(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const DIdxSet *intvars=nullptr, const bool writeZeroObjective=false) const
void clearLPReal()
clears the LP
void getColVectorReal(int i, DSVectorBase< R > &col) const
gets vector of col i
bool hasDualFarkas() const
is Farkas proof of infeasibility available?
SPxLPRational * _rationalLP
Definition soplex.h:1877
void _changeRangeReal(int i, const R &lhs, const R &rhs)
changes left- and right-hand side of row i and adjusts basis
VectorRational _feasUpper
Definition soplex.h:1891
void getColsRational(int start, int end, LPColSetRational &lpcolset) const
gets columns start, ..., end
bool setSettings(const Settings &newSettings, const bool init=true)
sets parameter settings; returns true on success
bool getRedCostRational(mpq_t *vector, const int size)
gets the vector of reduced cost values if available; returns true on success (GMP only method)
void _addColsReal(const LPColSetReal &lpcolset)
adds multiple columns to the real LP and adjusts basis
void _changeRhsReal(int i, const R &rhs)
changes right-hand side of row i to rhs and adjusts basis
SPxSimplifier< Real > * _simplifier
Definition soplex.h:1773
void getRowVectorReal(int i, DSVectorBase< R > &row) const
gets vector of row i
void _storeBasisAsOldBasis(DataArray< typename SPxSolverBase< R >::VarStatus > &rows, DataArray< typename SPxSolverBase< R >::VarStatus > &cols)
void changeLhsReal(int i, const R &lhs)
changes left-hand side of row i to lhs
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldUnbdBasisStatusCols
Definition soplex.h:1954
void removeRowsRational(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
const Settings & settings() const
returns current parameter settings
LPRowBase< R >::Type rowTypeReal(int i) const
returns inequality type of row i
SPxFastRT< Real > _ratiotesterFast
Definition soplex.h:1769
SPxDefaultRT< BP > _boostedRatiotesterTextbook
Definition soplex.h:1839
SPxFastRT< BP > _boostedRatiotesterFast
Definition soplex.h:1841
void _resetBoostedPrecision()
reset the boosted precision to the default value
bool getColsActivityRational(VectorRational &vector)
const VectorRational & lhsRational() const
returns left-hand side vector
void changeObjRational(const VectorRational &obj)
changes objective function vector to obj
void getLhsReal(VectorBase< R > &lhs) const
gets left-hand side vector
SPxSolverBase< R >::Status status() const
returns the current solver status
bool getDualFarkasRational(VectorRational &vector)
R maxAbsNonzeroReal() const
returns biggest non-zero element in absolute value
SPxBasisBase< R >::SPxStatus basisStatus() const
returns the current basis status
bool isPrimalFeasible() const
is stored primal solution feasible?
void getLowerReal(VectorBase< R > &lower) const
gets lower bound vector
bool getColsActivity(VectorBase< R > &vector)
gets the activities for all columns given the current dual solution; vector must have the same size a...
void _performFeasIRStable(SolRational &sol, bool &withDualFarkas, bool &stoppedTime, bool &stoppedIter, bool &error)
performs iterative refinement on the auxiliary problem for testing feasibility
SPxStarter< Real > * _starter
Definition soplex.h:1775
void _restoreBasis()
restore basis
SPxSteepPR< BP > _boostedPricerQuickSteep
Definition soplex.h:1836
RangeType _rangeTypeReal(const R &lower, const R &upper) const
determines RangeType from real bounds
bool getPrimalReal(R *p_vector, int size)
bool writeDualFileReal(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const DIdxSet *intvars=nullptr, const bool writeZeroObjective=false) const
writes the dual of the real LP to file; LP or MPS format is chosen from the extension in filename; if...
bool getDualRational(VectorRational &vector)
bool hasBasis() const
is an advanced starting basis available?
SPxScaler< Real > * _scaler
Definition soplex.h:1774
void _untransformUnbounded(SolRational &sol, bool unbounded)
undoes transformation to unboundedness problem
void _verifySolutionReal()
verify computed solution and resolve if necessary
void removeColsReal(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldFeasBasisStatusCols
Definition soplex.h:1950
Real precisionBoostTime() const
time spen in higher precision since last call to solve
virtual ~SoPlexBase()
destructor
SPxSolverBase< R >::Status _solveRealStable(bool acceptUnbounded, bool acceptInfeasible, VectorBase< R > &primal, VectorBase< R > &dual, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols, const bool forceNoSimplifier=false)
solves real LP with recovery mechanism
void changeLowerReal(int i, const R &lower)
changes lower bound of column i to lower
void _evaluateSolutionReal(typename SPxSimplifier< R >::Result simplificationStatus)
checks result of the solving process and solves again without preprocessing if necessary
void removeColRangeRational(int start, int end, int perm[]=nullptr)
removes columns start to end including both; an array perm of size numColsRational() may be passed as...
R upperReal(int i) const
returns upper bound of column i
bool setRealParam(const RealParam param, const Real value, const bool init=true)
sets real parameter value; returns true on success
const VectorRational & lowerRational() const
returns lower bound vector
void _removeColRangeReal(int start, int end, int perm[])
removes columns start to end including both; an array perm of size numColsReal() may be passed as buf...
void _changeElementReal(int i, int j, const R &val)
changes matrix entry in row i and column j to val and adjusts basis
void addRowReal(const LPRowBase< R > &lprow)
adds a single row
void _removeColsReal(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
bool writeBasisFile(const char *filename, const NameSet *rowNames=nullptr, const NameSet *colNames=nullptr, const bool cpxFormat=false) const
writes basis information to filename; if rowNames and colNames are nullptr, default names are used; r...
SPxSolverBase< R >::VarStatus basisColStatus(int col) const
returns basis status for a single column
Rational minAbsNonzeroRational() const
returns smallest non-zero element in absolute value
bool setIntParam(const IntParam param, const int value, const bool init=true)
sets integer parameter value; returns true on success
bool getDualReal(R *p_vector, int dim)
void getRowsRational(int start, int end, LPRowSetRational &lprowset) const
gets rows start, ..., end.
SPxMainSM< Real > _simplifierMainSM
Definition soplex.h:1750
bool getRowsActivityReal(const std::vector< int > &indices, R *p_vector, int dim)
bool getDualViolationRational(Rational &maxviol, Rational &sumviol)
void _addRowsReal(const LPRowSetBase< R > &lprowset)
adds multiple rows to the real LP and adjusts basis
int numPrecisionBoosts() const
number of precision boosts since last call to solve
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldUnbdBasisStatusRows
Definition soplex.h:1953
void addColsReal(const LPColSetBase< R > &lpcolset)
adds multiple columns
void changeRhsReal(const VectorBase< R > &rhs)
changes right-hand side vector to rhs
const VectorRational & rhsRational() const
returns right-hand side vector
void changeRangeReal(const VectorBase< R > &lhs, const VectorBase< R > &rhs)
changes left- and right-hand side vectors
void addRowRational(const mpq_t *lhs, const mpq_t *rowValues, const int *rowIndices, const int rowSize, const mpq_t *rhs)
adds a single row (GMP only method)
bool computeBasisInverseRational()
compute rational basis inverse; returns true on success
bool loadSettingsFile(const char *filename)
reads settings file; returns true on success
void _storeSolutionRealFromPresol()
stores solution from the simplifier because problem vanished in presolving step
const char * getScalerName()
name of scaling method
SPxGeometSC< Real > _scalerGeoequi
Definition soplex.h:1756
void addColRational(const mpq_t *obj, const mpq_t *lower, const mpq_t *colValues, const int *colIndices, const int colSize, const mpq_t *upper)
adds a single column (GMP only method)
bool multBasis(R *vec, bool unscale=true)
multiply with basis matrix; B * vec (inplace)
VectorRational _modLhs
Definition soplex.h:1894
bool _reconstructSolutionRational(SolRational &sol, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols, const Rational &denomBoundSquared)
attempts rational reconstruction of primal-dual solution
void _changeLowerReal(int i, const R &lower)
changes lower bound of column i to lower and adjusts basis
void changeRangeRational(const VectorRational &lhs, const VectorRational &rhs)
changes left- and right-hand side vectors
void removeColsReal(int idx[], int n, int perm[]=nullptr)
remove all columns with indices in array idx of size n; an array perm of size numColsReal() may be pa...
void _addColReal(R obj, R lower, const SVectorBase< R > &lpcol, R upper)
adds a single column to the real LP and adjusts basis
void changeLhsRational(int i, const Rational &lhs)
changes left-hand side of row i to lhs
void _performOptIRWrapper(SolRational &sol, bool acceptUnbounded, bool acceptInfeasible, int minIRRoundsRemaining, bool &primalFeasible, bool &dualFeasible, bool &infeasible, bool &unbounded, bool &stoppedTime, bool &stoppedIter, bool &error)
perform iterative refinement using the right precision
void factorizeColumnRational(SolRational &sol, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusRows, DataArray< typename SPxSolverBase< R >::VarStatus > &basisStatusCols, bool &stoppedTime, bool &stoppedIter, bool &error, bool &optimal, bool forceSolutionUpdate)
factorizes rational basis matrix in column representation
DataArray< typename SPxSolverBase< Real >::VarStatus > _oldBasisStatusCols
Definition soplex.h:1946
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
void _computeReducedCostViolation(SolRational &sol, Rational &redCostViolation, const bool &maximizing)
computes violation of reduced costs during the refinement loop
R lhsReal(int i) const
returns left-hand side of row i
void addColsRational(const mpq_t *obj, const mpq_t *lower, const mpq_t *colValues, const int *colIndices, const int *colStarts, const int *colLengths, const int numCols, const int numValues, const mpq_t *upper)
adds a set of columns (GMP only method)
bool getPrimalRational(mpq_t *vector, const int size)
gets the primal solution vector if available; returns true on success (GMP only method)
void _computeBoundsViolation(SolRational &sol, Rational &boundsViolation)
computes violation of bounds during the refinement loop
void _disableSimplifierAndScaler()
disables simplifier and scaler
R minAbsNonzeroReal() const
returns smallest non-zero element in absolute value
void getObjRational(VectorRational &obj) const
gets objective function vector
SPxGeometSC< BP > _boostedScalerGeoequi
Definition soplex.h:1851
bool getPrimalRay(VectorBase< R > &vector)
gets the primal ray if available; returns true on success
void removeRowRangeReal(int start, int end, int perm[]=nullptr)
removes rows start to end including both; an array perm of size numRows() may be passed as buffer mem...
SPxHarrisRT< Real > _ratiotesterHarris
Definition soplex.h:1768
const Rational & rhsRational(int i) const
returns right-hand side of row i
const UnitVectorRational * _unitVectorRational(const int i)
returns pointer to a constant unit vector available until destruction of the SoPlexBase class
void _changeRowReal(int i, const LPRowBase< R > &lprow)
replaces row i with lprow and adjusts basis
bool getRedCostRational(VectorRational &vector)
bool getRowsActivityRational(VectorRational &vector)
void _setupBoostedSolver()
setup boosted solver before launching iteration
R rhsReal(int i) const
returns right-hand side of row i
bool _isRefinementOver(bool &primalFeasible, bool &dualFeasible, Rational &boundsViolation, Rational &sideViolation, Rational &redCostViolation, Rational &dualViolation, int minIRRoundsRemaining, bool &stoppedTime, bool &stoppedIter, int numFailedRefinements)
checks termination criteria for refinement loop
const VectorBase< R > & upperRealInternal() const
returns upper bound vector
bool getRedCostViolationRational(Rational &maxviol, Rational &sumviol)
bool hasSol() const
is a solution available (not neccessarily feasible)?
SPxEquiliSC< BP > _boostedScalerUniequi
Definition soplex.h:1847
LPColSetRational _slackCols
Definition soplex.h:1881
void changeRhsReal(int i, const R &rhs)
changes right-hand side of row i to rhs
void _idxToPerm(int *idx, int idxSize, int *perm, int permSize) const
creates a permutation for removing rows/columns from an array of indices
void changeRangeRational(int i, const Rational &lhs, const Rational &rhs)
changes left- and right-hand side of row i
void _lift()
reduces matrix coefficient in absolute value by the lifting procedure of Thiele et al....
void removeColsRational(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
const VectorRational & upperRational() const
returns upper bound vector
BoolParam
boolean parameters
Definition soplex.h:999
RangeType
type of bounds and sides
Definition soplex.h:1907
void changeLowerRational(int i, const Rational &lower)
changes lower bound of column i to lower
void addRowRational(const LPRowRational &lprow)
adds a single row
void removeColsRational(int idx[], int n, int perm[]=nullptr)
remove all columns with indices in array idx of size n; an array perm of size numColsRational() may b...
void _checkBasisScaling()
check correctness of (un)scaled basis matrix operations
RangeType _rangeTypeRational(const Rational &lower, const Rational &upper) const
determines RangeType from rational bounds
SPxEquiliSC< Real > _scalerUniequi
Definition soplex.h:1752
void getRhsReal(VectorBase< R > &rhs) const
gets right-hand side vector
DataArray< typename SPxSolverBase< BP >::VarStatus > _tmpBasisStatusCols
Definition soplex.h:1966
bool getRowViolationRational(Rational &maxviol, Rational &sumviol)
Class for storing a primal-dual solution with basis information.
Definition solbase.h:53
TYPE
types of timers
Definition timer.h:109
Dense vector.
Definition vectorbase.h:86
Everything should be within this namespace.
VectorBase< Rational > VectorRational
Definition vector.h:40
SoPlexBase< Real > SoPlex
Definition soplex.h:2637
LPColSetBase< Rational > LPColSetRational
Definition lpcolset.h:38
double Real
Definition spxdefines.h:269
LPColBase< Rational > LPColRational
Definition lpcol.h:40
SolBase< Rational > SolRational
Definition sol.h:37
LPColBase< Real > LPColReal
Definition lpcol.h:39
SVectorBase< Rational > SVectorRational
Definition svector.h:40
LPColSetBase< Real > LPColSetReal
Definition lpcolset.h:37
SPxLPBase< Rational > SPxLPRational
Definition spxlp.h:46
UnitVectorBase< Rational > UnitVectorRational
Definition unitvector.h:40
LPRowBase< Rational > LPRowRational
Definition lprow.h:38
SSVectorBase< Rational > SSVectorRational
Definition ssvector.h:39
DSVectorBase< Rational > DSVectorRational
Definition dsvector.h:39
SPxDefaultRT()
default constructor
LPRowSetBase< Rational > LPRowSetRational
Definition lprowset.h:38
Implementation of Sparse Linear Solver.
Implementation of Sparse Linear Solver with Rational precision.
Types of solution classes.
Class for storing a primal-dual solution with basis information.
Auto pricer.
Bound flipping ratio test (long step dual) for SoPlex.
Dantzig pricer.
Textbook ratio test for SoPlex.
Debugging, floating point type and parameter definitions.
Devex pricer.
LP equilibrium scaling.
Fast shifting ratio test.
LP geometric mean scaling.
returns the current git hash of SoPlex
Harris pricing with shifting.
Hybrid pricer.
LP least squares scaling.
Saving LPs in a form suitable for SoPlex.
General methods in LP preprocessing.
Partial multiple pricing.
Abstract pricer base class.
Abstract ratio test base class.
LP scaling base class.
LP simplification base class.
main LP solver class
SoPlex start basis generation base class.
Steepest edge pricer with exact initialization of weights.
Steepest edge pricer.
Simple heuristic SPxStarter.
Solution vector based start basis.
Weighted start basis.
std::string name[SoPlexBase< R >::BOOLPARAM_COUNT]
array of names for boolean parameters
Definition soplex.h:1528
std::string description[SoPlexBase< R >::BOOLPARAM_COUNT]
array of descriptions for boolean parameters
Definition soplex.h:1530
bool defaultValue[SoPlexBase< R >::BOOLPARAM_COUNT]
array of default values for boolean parameters
Definition soplex.h:1532
std::string name[SoPlexBase< R >::INTPARAM_COUNT]
array of names for integer parameters
Definition soplex.h:1540
int lower[SoPlexBase< R >::INTPARAM_COUNT]
array of lower bounds for int parameter values
Definition soplex.h:1546
int upper[SoPlexBase< R >::INTPARAM_COUNT]
array of upper bounds for int parameter values
Definition soplex.h:1548
int defaultValue[SoPlexBase< R >::INTPARAM_COUNT]
array of default values for integer parameters
Definition soplex.h:1544
std::string description[SoPlexBase< R >::INTPARAM_COUNT]
array of descriptions for integer parameters
Definition soplex.h:1542
Real upper[SoPlexBase< R >::REALPARAM_COUNT]
array of upper bounds for real parameter values
Definition soplex.h:1564
Real defaultValue[SoPlexBase< R >::REALPARAM_COUNT]
array of default values for real parameters
Definition soplex.h:1560
Real lower[SoPlexBase< R >::REALPARAM_COUNT]
array of lower bounds for real parameter values
Definition soplex.h:1562
std::string description[SoPlexBase< R >::REALPARAM_COUNT]
array of descriptions for real parameters
Definition soplex.h:1558
std::string name[SoPlexBase< R >::REALPARAM_COUNT]
array of names for real parameters
Definition soplex.h:1556