Scippy

SoPlex

Sequential object-oriented simPlex

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-2015 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file soplex.h
17  * @brief Preconfigured SoPlex LP solver
18  */
19 
20 #ifndef _SOPLEX_H_
21 #define _SOPLEX_H_
22 
23 #ifndef SOPLEX_LEGACY
24 #include <string.h>
25 
26 ///@todo SoPlex should also have an spxout object to avoid using a global one
27 #include "spxdefines.h"
28 #include "basevectors.h"
29 #include "spxsolver.h"
30 #include "slufactor.h"
31 
32 ///@todo try to move to cpp file by forward declaration
33 #include "spxsimplifier.h"
34 #include "spxmainsm.h"
35 
36 #include "spxscaler.h"
37 #include "spxequilisc.h"
38 #include "spxgeometsc.h"
39 
40 #include "spxstarter.h"
41 #include "spxweightst.h"
42 #include "spxsumst.h"
43 #include "spxvectorst.h"
44 
45 #include "spxpricer.h"
46 #include "spxautopr.h"
47 #include "spxdantzigpr.h"
48 #include "spxparmultpr.h"
49 #include "spxdevexpr.h"
50 #include "spxsteeppr.h"
51 #include "spxsteepexpr.h"
52 #include "spxhybridpr.h"
53 
54 #include "spxratiotester.h"
55 #include "spxdefaultrt.h"
56 #include "spxharrisrt.h"
57 #include "spxfastrt.h"
58 #include "spxboundflippingrt.h"
59 
60 #include "sol.h"
61 
62 ///@todo implement automatic rep switch, based on row/col dim
63 ///@todo introduce status codes for SoPlex, especially for rational solving
64 
65 ///@todo record and return "best" solutions found during IR (Ambros)
66 ///@todo implement main IR loop for primal and dual feasible case with fail otherwise (Ambros)
67 ///@todo implement statistical info (time, factor time, iters, ...) since last call to solveReal() or solveRational() (Ambros?)
68 ///@todo implement performInfeasibilityIR (Ambros?)
69 ///@todo extend IR loop to infeasible case (Dan?)
70 ///@todo extend IR loop to unbounded case (Dan?)
71 
72 ///@todo interface rational reconstruction code for rational vectors
73 ///@todo integrate rational reconstruction into IR loop
74 ///@todo templatize SPxSolver and necessary components (SLUFactor, pricer, ratiotester)
75 ///@todo integrate rational SPxSolver and distinguish between original and transformed rational LP
76 ///@todo rational scalers
77 ///@todo rational simplifier
78 
79 namespace soplex
80 {
81 
82 /**@class SoPlex
83  * @brief Preconfigured SoPlex LP-solver.
84  * @ingroup Algo
85  */
86 class SoPlex
87 {
88 public:
89 
90  //**@name Construction and destruction */
91  //@{
92 
93  /// default constructor
94  SoPlex();
95 
96  /// assignment operator
97  SoPlex& operator=(const SoPlex& rhs);
98 
99  /// copy constructor
100  SoPlex(const SoPlex& rhs);
101 
102  /// destructor
103  virtual ~SoPlex();
104 
105  //@}
106 
107 
108  /// message handler
109 // SPxOut spxout;
110 
111 
112  //**@name Access to the real LP */
113  //@{
114 
115  /// returns number of rows
116  int numRowsReal() const;
117 
118  /// returns number of columns
119  int numColsReal() const;
120 
121  /// returns number of nonzeros
122  int numNonzerosReal() const;
123 
124  /// returns smallest non-zero element in absolute value
125  Real minAbsNonzeroReal() const;
126 
127  /// returns biggest non-zero element in absolute value
128  Real maxAbsNonzeroReal() const;
129 
130  /// gets row \p i
131  void getRowReal(int i, LPRowReal& lprow) const;
132 
133  /// gets rows \p start, ..., \p end.
134  void getRowsReal(int start, int end, LPRowSetReal& lprowset) const;
135 
136  /// returns vector of row \p i
137  const SVectorReal& rowVectorReal(int i) const;
138 
139  /// returns right-hand side vector
140  const VectorReal& rhsReal() const;
141 
142  /// returns right-hand side of row \p i
143  Real rhsReal(int i) const;
144 
145  /// returns left-hand side vector
146  const VectorReal& lhsReal() const;
147 
148  /// returns left-hand side of row \p i
149  Real lhsReal(int i) const;
150 
151  /// returns inequality type of row \p i
152  LPRowReal::Type rowTypeReal(int i) const;
153 
154  /// gets column \p i
155  void getColReal(int i, LPColReal& lpcol) const;
156 
157  /// gets columns \p start, ..., \p end
158  void getColsReal(int start, int end, LPColSetReal& lpcolset) const;
159 
160  /// returns vector of column \p i
161  const SVectorReal& colVectorReal(int i) const;
162 
163  /// returns upper bound vector
164  const VectorReal& upperReal() const;
165 
166  /// returns upper bound of column \p i
167  Real upperReal(int i) const;
168 
169  /// returns lower bound vector
170  const VectorReal& lowerReal() const;
171 
172  /// returns lower bound of column \p i
173  Real lowerReal(int i) const;
174 
175  /// gets objective function vector
176  void getObjReal(VectorReal& obj) const;
177 
178  /// returns objective value of column \p i
179  Real objReal(int i) const;
180 
181  /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
182  /// internally, this is generally faster
183  const VectorReal& maxObjReal() const;
184 
185  /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
186  /// stored internally, this is generally faster
187  Real maxObjReal(int i) const;
188 
189  /// gets number of available dual norms
190  void getNdualNorms(int& nnormsRow, int& nnormsCol) const;
191 
192  /// gets steepest edge norms and returns false if they are not available
193  bool getDualNorms(int& nnormsRow, int& nnormsCol, Real* norms) const;
194 
195  /// sets steepest edge norms and returns false if that's not possible
196  bool setDualNorms(int nnormsRow, int nnormsCol, Real* norms);
197 
198  //@}
199 
200 
201  //**@name Access to the rational LP */
202  //@{
203 
204  /// returns number of rows
205  int numRowsRational() const;
206 
207  /// returns number of columns
208  int numColsRational() const;
209 
210  /// returns number of nonzeros
211  int numNonzerosRational() const;
212 
213  /// returns smallest non-zero element in absolute value
215 
216  /// returns biggest non-zero element in absolute value
218 
219  /// gets row \p i
220  void getRowRational(int i, LPRowRational& lprow) const;
221 
222  /// gets rows \p start, ..., \p end.
223  void getRowsRational(int start, int end, LPRowSetRational& lprowset) const;
224 
225  /// returns vector of row \p i
226  const SVectorRational& rowVectorRational(int i) const;
227 
228  /// returns right-hand side vector
229  const VectorRational& rhsRational() const;
230 
231  /// returns right-hand side of row \p i
232  const Rational& rhsRational(int i) const;
233 
234  /// returns left-hand side vector
235  const VectorRational& lhsRational() const;
236 
237  /// returns left-hand side of row \p i
238  const Rational& lhsRational(int i) const;
239 
240  /// returns inequality type of row \p i
242 
243  /// gets column \p i
244  void getColRational(int i, LPColRational& lpcol) const;
245 
246  /// gets columns \p start, ..., \p end
247  void getColsRational(int start, int end, LPColSetRational& lpcolset) const;
248 
249  /// returns vector of column \p i
250  const SVectorRational& colVectorRational(int i) const;
251 
252  /// returns upper bound vector
253  const VectorRational& upperRational() const;
254 
255  /// returns upper bound of column \p i
256  const Rational& upperRational(int i) const;
257 
258  /// returns lower bound vector
259  const VectorRational& lowerRational() const;
260 
261  /// returns lower bound of column \p i
262  const Rational& lowerRational(int i) const;
263 
264  /// gets objective function vector
265  void getObjRational(VectorRational& obj) const;
266 
267  /// gets objective value of column \p i
268  void getObjRational(int i, Rational& obj) const;
269 
270  /// returns objective value of column \p i
271  Rational objRational(int i) const;
272 
273  /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
274  /// internally, this is generally faster
275  const VectorRational& maxObjRational() const;
276 
277  /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
278  /// stored internally, this is generally faster
279  const Rational& maxObjRational(int i) const;
280 
281  //@}
282 
283 
284  //**@name Modification of the real LP */
285  //@{
286 
287  /// adds a single row
288  void addRowReal(const LPRowReal& lprow);
289 
290  /// adds multiple rows
291  void addRowsReal(const LPRowSetReal& lprowset);
292 
293  /// adds a single column
294  void addColReal(const LPCol& lpcol);
295 
296  /// adds multiple columns
297  void addColsReal(const LPColSetReal& lpcolset);
298 
299  /// replaces row \p i with \p lprow
300  void changeRowReal(int i, const LPRowReal& lprow);
301 
302  /// changes left-hand side vector for constraints to \p lhs
303  void changeLhsReal(const VectorReal& lhs);
304 
305  /// changes left-hand side of row \p i to \p lhs
306  void changeLhsReal(int i, const Real& lhs);
307 
308  /// changes right-hand side vector to \p rhs
309  void changeRhsReal(const VectorReal& rhs);
310 
311  /// changes right-hand side of row \p i to \p rhs
312  void changeRhsReal(int i, const Real& rhs);
313 
314  /// changes left- and right-hand side vectors
315  void changeRangeReal(const VectorReal& lhs, const VectorReal& rhs);
316 
317  /// changes left- and right-hand side of row \p i
318  void changeRangeReal(int i, const Real& lhs, const Real& rhs);
319 
320  /// replaces column \p i with \p lpcol
321  void changeColReal(int i, const LPColReal& lpcol);
322 
323  /// changes vector of lower bounds to \p lower
324  void changeLowerReal(const VectorReal& lower);
325 
326  /// changes lower bound of column i to \p lower
327  void changeLowerReal(int i, const Real& lower);
328 
329  /// changes vector of upper bounds to \p upper
330  void changeUpperReal(const VectorReal& upper);
331 
332  /// changes \p i 'th upper bound to \p upper
333  void changeUpperReal(int i, const Real& upper);
334 
335  /// changes vectors of column bounds to \p lower and \p upper
336  void changeBoundsReal(const VectorReal& lower, const VectorReal& upper);
337 
338  /// changes bounds of column \p i to \p lower and \p upper
339  void changeBoundsReal(int i, const Real& lower, const Real& upper);
340 
341  /// changes objective function vector to \p obj
342  void changeObjReal(const VectorReal& obj);
343 
344  /// changes objective coefficient of column i to \p obj
345  void changeObjReal(int i, const Real& obj);
346 
347  /// changes matrix entry in row \p i and column \p j to \p val
348  void changeElementReal(int i, int j, const Real& val);
349 
350  /// removes row \p i
351  void removeRowReal(int i);
352 
353  /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
354  /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
355  /// #numRowsReal()
356  void removeRowsReal(int perm[]);
357 
358  /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsReal() may be passed
359  /// as buffer memory
360  void removeRowsReal(int idx[], int n, int perm[] = 0);
361 
362  /// removes rows \p start to \p end including both; an array \p perm of size #numRowsReal() may be passed as buffer
363  /// memory
364  void removeRowRangeReal(int start, int end, int perm[] = 0);
365 
366  /// removes column i
367  void removeColReal(int i);
368 
369  /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
370  /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
371  /// #numColsReal()
372  void removeColsReal(int perm[]);
373 
374  /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsReal() may be
375  /// passed as buffer memory
376  void removeColsReal(int idx[], int n, int perm[] = 0);
377 
378  /// removes columns \p start to \p end including both; an array \p perm of size #numColsReal() may be passed as
379  /// buffer memory
380  void removeColRangeReal(int start, int end, int perm[] = 0);
381 
382  /// clears the LP
383  void clearLPReal();
384 
385  /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, if sync mode is manual
386  void syncLPReal();
387 
388  //@}
389 
390 
391  //**@name Modification of the rational LP */
392  //@{
393 
394  /// adds a single row
395  void addRowRational(const LPRowRational& lprow);
396 
397 #ifdef SOPLEX_WITH_GMP
398  /// adds a single row
399  void addRowRational(const mpq_t* lhs, const mpq_t* rowValues, const int* rowIndices, const int rowSize, const mpq_t* rhs);
400 
401  /// adds a set of rows
402  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);
403 #endif
404 
405  /// adds multiple rows
406  void addRowsRational(const LPRowSetRational& lprowset);
407 
408  /// adds a single column
409  void addColRational(const LPColRational& lpcol);
410 
411 #ifdef SOPLEX_WITH_GMP
412  /// adds a single column
413  void addColRational(const mpq_t* obj, const mpq_t* lower, const mpq_t* colValues, const int* colIndices, const int colSize, const mpq_t* upper);
414 
415  /// adds a set of columns
416  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);
417 #endif
418 
419  /// adds multiple columns
420  void addColsRational(const LPColSetRational& lpcolset);
421 
422  /// replaces row \p i with \p lprow
423  void changeRowRational(int i, const LPRowRational& lprow);
424 
425  /// changes left-hand side vector for constraints to \p lhs
426  void changeLhsRational(const VectorRational& lhs);
427 
428  /// changes left-hand side of row \p i to \p lhs
429  void changeLhsRational(int i, const Rational& lhs);
430 
431 #ifdef SOPLEX_WITH_GMP
432  /// changes left-hand side of row \p i to \p lhs
433  void changeLhsRational(int i, const mpq_t* lhs);
434 #endif
435 
436  /// changes right-hand side vector to \p rhs
437  void changeRhsRational(const VectorRational& rhs);
438 
439 #ifdef SOPLEX_WITH_GMP
440  /// changes right-hand side vector to \p rhs
441  void changeRhsRational(const mpq_t* rhs, int rhsSize);
442 #endif
443 
444  /// changes right-hand side of row \p i to \p rhs
445  void changeRhsRational(int i, const Rational& rhs);
446 
447  /// changes left- and right-hand side vectors
448  void changeRangeRational(const VectorRational& lhs, const VectorRational& rhs);
449 
450  /// changes left- and right-hand side of row \p i
451  void changeRangeRational(int i, const Rational& lhs, const Rational& rhs);
452 
453 #ifdef SOPLEX_WITH_GMP
454  /// changes left- and right-hand side of row \p i
455  void changeRangeRational(int i, const mpq_t* lhs, const mpq_t* rhs);
456 #endif
457 
458  /// replaces column \p i with \p lpcol
459  void changeColRational(int i, const LPColRational& lpcol);
460 
461  /// changes vector of lower bounds to \p lower
462  void changeLowerRational(const VectorRational& lower);
463 
464  /// changes lower bound of column i to \p lower
465  void changeLowerRational(int i, const Rational& lower);
466 
467 #ifdef SOPLEX_WITH_GMP
468  /// changes lower bound of column i to \p lower
469  void changeLowerRational(int i, const mpq_t* lower);
470 #endif
471 
472  /// changes vector of upper bounds to \p upper
473  void changeUpperRational(const VectorRational& upper);
474 
475  /// changes \p i 'th upper bound to \p upper
476  void changeUpperRational(int i, const Rational& upper);
477 
478 #ifdef SOPLEX_WITH_GMP
479  /// changes upper bound of column i to \p upper
480  void changeUpperRational(int i, const mpq_t* upper);
481 #endif
482 
483  /// changes vectors of column bounds to \p lower and \p upper
484  void changeBoundsRational(const VectorRational& lower, const VectorRational& upper);
485 
486  /// changes bounds of column \p i to \p lower and \p upper
487  void changeBoundsRational(int i, const Rational& lower, const Rational& upper);
488 
489 #ifdef SOPLEX_WITH_GMP
490  /// changes bounds of column \p i to \p lower and \p upper
491  void changeBoundsRational(int i, const mpq_t* lower, const mpq_t* upper);
492 #endif
493 
494  /// changes objective function vector to \p obj
495  void changeObjRational(const VectorRational& obj);
496 
497  /// changes objective coefficient of column i to \p obj
498  void changeObjRational(int i, const Rational& obj);
499 
500 #ifdef SOPLEX_WITH_GMP
501  /// changes objective coefficient of column i to \p obj
502  void changeObjRational(int i, const mpq_t* obj);
503 #endif
504 
505  /// changes matrix entry in row \p i and column \p j to \p val
506  void changeElementRational(int i, int j, const Rational& val);
507 
508 #ifdef SOPLEX_WITH_GMP
509  /// changes matrix entry in row \p i and column \p j to \p val
510  void changeElementRational(int i, int j, const mpq_t* val);
511 #endif
512 
513  /// removes row \p i
514  void removeRowRational(int i);
515 
516  /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the new
517  /// index where row \p i has been moved to; note that \p perm must point to an array of size at least
518  /// #numRowsRational()
519  void removeRowsRational(int perm[]);
520 
521  /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsRational() may be
522  /// passed as buffer memory
523  void removeRowsRational(int idx[], int n, int perm[] = 0);
524 
525  /// removes rows \p start to \p end including both; an array \p perm of size #numRowsRational() may be passed as
526  /// buffer memory
527  void removeRowRangeRational(int start, int end, int perm[] = 0);
528 
529  /// removes column i
530  void removeColRational(int i);
531 
532  /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
533  /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
534  /// #numColsRational()
535  void removeColsRational(int perm[]);
536 
537  /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsRational() may be
538  /// passed as buffer memory
539  void removeColsRational(int idx[], int n, int perm[] = 0);
540 
541  /// removes columns \p start to \p end including both; an array \p perm of size #numColsRational() may be passed as
542  /// buffer memory
543  void removeColRangeRational(int start, int end, int perm[] = 0);
544 
545  /// clears the LP
546  void clearLPRational();
547 
548  /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, if sync mode is manual
549  void syncLPRational();
550 
551  //@}
552 
553 
554  //**@name Solving and general solution query */
555  //@{
556 
557  /// solves the LP
559 
560  /// returns the current solver status
561  SPxSolver::Status status() const;
562 
563  /// is a primal feasible solution available?
564  bool hasPrimal() const;
565 
566  /// is a primal unbounded ray available?
567  bool hasPrimalRay() const;
568 
569  /// is a dual feasible solution available?
570  bool hasDual() const;
571 
572  /// is Farkas proof of infeasibility available?
573  bool hasDualFarkas() const;
574 
575  //@}
576 
577 
578  //**@name Query for the real solution data */
579  //@{
580 
581  /// returns the objective value if a primal solution is available
582  Real objValueReal();
583 
584  /// gets the primal solution vector if available; returns true on success
585  bool getPrimalReal(VectorReal& vector);
586 
587  /// gets the vector of slack values if available; returns true on success
588  bool getSlacksReal(VectorReal& vector);
589 
590  /// gets the primal ray if available; returns true on success
591  bool getPrimalRayReal(VectorReal& vector);
592 
593  /// gets the dual solution vector if available; returns true on success
594  bool getDualReal(VectorReal& vector);
595 
596  /// gets the vector of reduced cost values if available; returns true on success
597  bool getRedCostReal(VectorReal& vector);
598 
599  /// gets the Farkas proof if available; returns true on success
600  bool getDualFarkasReal(VectorReal& vector);
601 
602  /// gets violation of bounds; returns true on success
603  bool getBoundViolationReal(Real& maxviol, Real& sumviol);
604 
605  /// gets violation of constraints; returns true on success
606  bool getRowViolationReal(Real& maxviol, Real& sumviol);
607 
608  /// gets violation of reduced costs; returns true on success
609  bool getRedCostViolationReal(Real& maxviol, Real& sumviol);
610 
611  /// gets violation of dual multipliers; returns true on success
612  bool getDualViolationReal(Real& maxviol, Real& sumviol);
613 
614  //@}
615 
616 
617  //**@name Query for the rational solution data */
618  //@{
619 
620  /// returns the objective value if a primal solution is available
622 
623  /// gets the primal solution vector if available; returns true on success
624  bool getPrimalRational(VectorRational& vector);
625 
626  /// gets the vector of slack values if available; returns true on success
627  bool getSlacksRational(VectorRational& vector);
628 
629  /// gets the primal ray if LP is unbounded; returns true on success
630  bool getPrimalRayRational(VectorRational& vector);
631 
632  /// gets the dual solution vector if available; returns true on success
633  bool getDualRational(VectorRational& vector);
634 
635  /// gets the vector of reduced cost values if available; returns true on success
636  bool getRedCostRational(VectorRational& vector);
637 
638  /// gets the Farkas proof if LP is infeasible; returns true on success
640 
641  /// gets violation of bounds; returns true on success
642  bool getBoundViolationRational(Rational& maxviol, Rational& sumviol);
643 
644  /// gets violation of constraints; returns true on success
645  bool getRowViolationRational(Rational& maxviol, Rational& sumviol);
646 
647  /// gets violation of reduced costs; returns true on success
648  bool getRedCostViolationRational(Rational& maxviol, Rational& sumviol);
649 
650  /// gets violation of dual multipliers; returns true on success
651  bool getDualViolationRational(Rational& maxviol, Rational& sumviol);
652 
653 #ifdef SOPLEX_WITH_GMP
654  /// gets the primal solution vector if available; returns true on success
655  bool getPrimalRational(mpq_t* vector, const int size);
656 
657  /// gets the vector of slack values if available; returns true on success
658  bool getSlacksRational(mpq_t* vector, const int size);
659 
660  /// gets the primal ray if LP is unbounded; returns true on success
661  bool getPrimalRayRational(mpq_t* vector, const int size);
662 
663  /// gets the dual solution vector if available; returns true on success
664  bool getDualRational(mpq_t* vector, const int size);
665 
666  /// gets the vector of reduced cost values if available; returns true on success
667  bool getRedCostRational(mpq_t* vector, const int size);
668 
669  /// gets the Farkas proof if LP is infeasible; returns true on success
670  bool getDualFarkasRational(mpq_t* vector, const int size);
671 #endif
672 
673  /// get size of primal solution
674  int totalSizePrimalRational(const int base = 2);
675 
676  /// get size of dual solution
677  int totalSizeDualRational(const int base = 2);
678 
679  /// get size of least common multiple of denominators in primal solution
680  int dlcmSizePrimalRational(const int base = 2);
681 
682  /// get size of least common multiple of denominators in dual solution
683  int dlcmSizeDualRational(const int base = 2);
684 
685  /// get size of largest denominator in primal solution
686  int dmaxSizePrimalRational(const int base = 2);
687 
688  /// get size of largest denominator in dual solution
689  int dmaxSizeDualRational(const int base = 2);
690 
691  //@}
692 
693 
694  //**@name Access and modification of basis information */
695  //@{
696 
697  /// is an advanced starting basis available?
698  bool hasBasis() const;
699 
700  /// returns the current basis status
702 
703  /// returns basis status for a single row
704  SPxSolver::VarStatus basisRowStatus(int row) const;
705 
706  /// returns basis status for a single column
707  SPxSolver::VarStatus basisColStatus(int col) const;
708 
709  /// gets current basis via arrays of statuses
710  void getBasis(SPxSolver::VarStatus rows[], SPxSolver::VarStatus cols[]) const;
711 
712  /// gets the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m
713  void getBasisInd(int* bind) const;
714 
715  /// computes an estimated condition number for the current basis matrix using the power method; returns true on success
716  bool getEstimatedCondition(Real& condition);
717 
718  /// computes the exact condition number for the current basis matrix using the power method; returns true on success
719  bool getExactCondition(Real& condition);
720 
721  /// computes row r of basis inverse; returns true on success
722  bool getBasisInverseRowReal(int r, Real* coef, int* inds = NULL, int* ninds = NULL);
723 
724  /// computes column c of basis inverse; returns true on success
725  bool getBasisInverseColReal(int c, Real* coef, int* inds = NULL, int* ninds = NULL);
726 
727  /// computes dense solution of basis matrix B * sol = rhs; returns true on success
728  bool getBasisInverseTimesVecReal(Real* rhs, Real* sol);
729 
730  /// sets starting basis via arrays of statuses
732 
733  /// clears starting basis
734  void clearBasis();
735 
736  //@}
737 
738 
739  //**@name Statistical information */
740  //@{
741 
742  /// number of iterations since last call to solve
743  int numIterations() const;
744 
745  /// time spent in last call to solve
746  Real solveTime() const;
747 
748  /// statistical information in form of a string
749  std::string statisticString() const;
750 
751  /// name of starter
752  const char* getStarterName();
753 
754  /// name of simplifier
755  const char* getSimplifierName();
756 
757  /// name of scaling method
758  const char* getScalerName();
759 
760  /// name of currently loaded pricer
761  const char* getPricerName();
762 
763  /// name of currently loaded ratiotester
764  const char* getRatiotesterName();
765 
766  //@}
767 
768 
769  //**@name File I/O */
770  //@{
771 
772  /// reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and
773  /// integer variables if desired; returns true on success
774  bool readFile(const char* filename, NameSet* rowNames = 0, NameSet* colNames = 0, DIdxSet* intVars = 0);
775 
776  /// writes real LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
777  /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
778  /// marked as integer; returns true on success
779  bool writeFileReal(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0, const DIdxSet* intvars = 0) const;
780 
781  /// writes rational LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
782  /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
783  /// marked as integer; returns true on success
784  bool writeFileRational(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0, const DIdxSet* intvars = 0) const;
785 
786  /// reads basis information from \p filename and returns true on success; if \p rowNames and \p colNames are \c NULL,
787  /// default names are assumed; returns true on success
788  bool readBasisFile(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0);
789 
790  /// writes basis information to \p filename; if \p rowNames and \p colNames are \c NULL, default names are used;
791  /// returns true on success
792  bool writeBasisFile(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0, const bool cpxFormat = false) const;
793 
794  /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
795  /// default names are used
796  void writeStateReal(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0, const bool cpxFormat = false) const;
797 
798  /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
799  /// default names are used
800  void writeStateRational(const char* filename, const NameSet* rowNames = 0, const NameSet* colNames = 0, const bool cpxFormat = false) const;
801 
802  //@}
803 
804 
805  //**@name Parameters */
806  //@{
807 
808  /// boolean parameters
809  typedef enum
810  {
811  /// should lifting be used to reduce range of nonzero matrix coefficients?
812  LIFTING = 0,
813 
814  /// should LP be transformed to equality form before a rational solve?
815  EQTRANS = 1,
816 
817  /// should dual infeasibility be tested in order to try to return a dual solution even if primal infeasible?
819 
820  /// should a rational factorization be performed after iterative refinement?
821  RATFAC = 3,
822 
823  /// should cycling solutions be accepted during iterative refinement?
825 
826  /// apply rational reconstruction after each iterative refinement?
827  RATREC = 5,
828 
829  /// round scaling factors for iterative refinement to powers of two?
831 
832  /// continue iterative refinement with exact basic solution if not optimal?
834 
835  /// should feasibility be tested with relaxed bounds and sides?
837 
838  /// use bound flipping also for row representation?
840 
841  /// number of boolean parameters
843  } BoolParam;
844 
845  /// integer parameters
846  typedef enum
847  {
848  /// objective sense
849  OBJSENSE = 0,
850 
851  /// type of computational form, i.e., column or row representation
853 
854  /// type of algorithm, i.e., primal or dual
856 
857  /// type of LU update
859 
860  /// maximum number of updates without fresh factorization
862 
863  /// iteration limit (-1 if unlimited)
865 
866  /// refinement limit (-1 if unlimited)
867  REFLIMIT = 6,
868 
869  /// stalling refinement limit (-1 if unlimited)
871 
872  /// display frequency
874 
875  /// verbosity level
877 
878  /// type of simplifier
880 
881  /// type of scaler
882  SCALER = 11,
883 
884  /// type of starter used to create crash basis
885  STARTER = 12,
886 
887  /// type of pricer
888  PRICER = 13,
889 
890  /// type of ratio test
892 
893  /// mode for synchronizing real and rational LP
894  SYNCMODE = 15,
895 
896  /// mode for reading LP files
897  READMODE = 16,
898 
899  /// mode for iterative refinement strategy
900  SOLVEMODE = 17,
901 
902  /// mode for a posteriori feasibility checks
903  CHECKMODE = 18,
904 
905  /// type of timer
906  TIMER = 19,
907 
908  /// mode for hyper sparse pricing
910 
911  /// minimum number of stalling refinements since last pivot to trigger rational factorization
913 
914  /// number of integer parameters
916  } IntParam;
917 
918  /// values for parameter OBJSENSE
919  enum
920  {
921  /// minimization
923 
924  /// maximization
926  };
927 
928  /// values for parameter REPRESENTATION
929  enum
930  {
931  /// automatic choice according to number of rows and columns
933 
934  /// column representation Ax - s = 0, lower <= x <= upper, lhs <= s <= rhs
936 
937  /// row representation (lower,lhs) <= (x,Ax) <= (upper,rhs)
939  };
940 
941  /// values for parameter ALGORITHM
942  enum
943  {
944  /// primal simplex algorithm, i.e., entering for column and leaving for row representation
946 
947  /// dual simplex algorithm, i.e., leaving for column and entering for row representation
949  };
950 
951  /// values for parameter FACTOR_UPDATE_TYPE
952  enum
953  {
954  /// product form update
956 
957  /// Forrest-Tomlin type update
959  };
960 
961  /// values for parameter VERBOSITY
962  enum
963  {
964  /// only error output
966 
967  /// only error and warning output
969 
970  /// only error, warning, and debug output
972 
973  /// standard verbosity level
975 
976  /// high verbosity level
978 
979  /// full verbosity level
981  };
982 
983  /// values for parameter SIMPLIFIER
984  enum
985  {
986  /// no simplifier
988 
989  /// automatic choice
991  };
992 
993  /// values for parameter SCALER
994  enum
995  {
996  /// no scaler
998 
999  /// equilibrium scaling on rows or columns
1001 
1002  /// equilibrium scaling on rows and columns
1004 
1005  /// geometric mean scaling on rows and columns, max 1 round
1007 
1008  /// geometric mean scaling on rows and columns, max 8 rounds
1010  };
1011 
1012  /// values for parameter STARTER
1013  enum
1014  {
1015  /// slack basis
1017 
1018  /// greedy crash basis weighted by objective, bounds, and sides
1020 
1021  /// crash basis from a greedy solution
1023 
1024  /// generic solution-based crash basis
1026  };
1027 
1028  /// values for parameter PRICER
1029  enum
1030  {
1031  /// automatic pricer
1033 
1034  /// Dantzig pricer
1036 
1037  /// partial multiple pricer based on Dantzig pricing
1039 
1040  /// devex pricer
1042 
1043  /// steepest edge pricer with initialization to unit norms
1045 
1046  /// steepest edge pricer with exact initialization of norms
1048  };
1049 
1050  /// values for parameter RATIOTESTER
1051  enum
1052  {
1053  /// textbook ratio test without stabilization
1055 
1056  /// standard Harris ratio test
1058 
1059  /// modified Harris ratio test
1061 
1062  /// bound flipping ratio test for long steps in the dual simplex
1064  };
1065 
1066  /// values for parameter SYNCMODE
1067  enum
1068  {
1069  /// store only real LP
1071 
1072  /// automatic sync of real and rational LP
1074 
1075  /// user sync of real and rational LP
1077  };
1078 
1079  /// values for parameter READMODE
1080  enum
1081  {
1082  /// standard floating-point parsing
1084 
1085  /// rational parsing
1087  };
1088 
1089  /// values for parameter SOLVEMODE
1090  enum
1091  {
1092  /// apply standard floating-point algorithm
1094 
1095  /// decide depending on tolerances whether to apply iterative refinement
1097 
1098  /// force iterative refinement
1100  };
1101 
1102  /// values for parameter CHECKMODE
1103  enum
1104  {
1105  /// floating-point check
1107 
1108  /// decide according to READMODE
1110 
1111  /// rational check
1113  };
1114 
1115  /// values for parameter TIMER
1116  enum
1117  {
1118  /// disable timing
1120 
1121  /// cpu or user time
1123 
1124  /// wallclock time
1126  };
1127 
1128  /// values for parameter HYPER_PRICING
1129  enum
1130  {
1131  /// never
1133 
1134  /// decide according to problem size
1136 
1137  /// always
1139  };
1140 
1141  /// real parameters
1142  typedef enum
1143  {
1144  /// primal feasibility tolerance
1145  FEASTOL = 0,
1146 
1147  /// dual feasibility tolerance
1148  OPTTOL = 1,
1149 
1150  /// general zero tolerance
1152 
1153  /// zero tolerance used in factorization
1155 
1156  /// zero tolerance used in update of the factorization
1158 
1159  /// pivot zero tolerance used in factorization
1161 
1162  /// infinity threshold
1163  INFTY = 6,
1164 
1165  /// time limit in seconds (INFTY if unlimited)
1167 
1168  /// lower limit on objective value
1170 
1171  /// upper limit on objective value
1173 
1174  /// working tolerance for feasibility in floating-point solver during iterative refinement
1176 
1177  /// working tolerance for optimality in floating-point solver during iterative refinement
1178  FPOPTTOL = 11,
1179 
1180  /// maximum increase of scaling factors between refinements
1182 
1183  /// lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)
1185 
1186  /// upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulated)
1188 
1189  /// sparse pricing threshold (\#violations < dimension * SPARSITY_THRESHOLD activates sparse pricing)
1191 
1192  /// threshold on number of rows vs. number of columns for switching from column to row representations in auto mode
1194 
1195  /// geometric frequency at which to apply rational reconstruction
1197 
1198  /// minimal reduction (sum of removed rows/cols) to continue simplification
1199  MINRED = 18,
1200 
1201  /// number of real parameters
1203  } RealParam;
1204 
1205 #ifdef SOPLEX_WITH_RATIONALPARAM
1206  /// rational parameters
1207  typedef enum
1208  {
1209  /// number of rational parameters
1210  RATIONALPARAM_COUNT = 0
1211  } RationalParam;
1212 #endif
1213 
1214  /// class of parameter settings
1215  class Settings;
1216 
1217  mutable SPxOut spxout;
1218 
1219  /// returns boolean parameter value
1220  bool boolParam(const BoolParam param) const;
1221 
1222  /// returns integer parameter value
1223  int intParam(const IntParam param) const;
1224 
1225  /// returns real parameter value
1226  Real realParam(const RealParam param) const;
1227 
1228 #ifdef SOPLEX_WITH_RATIONALPARAM
1229  /// returns rational parameter value
1230  Rational rationalParam(const RationalParam param) const;
1231 #endif
1232 
1233  /// returns current parameter settings
1234  const Settings& settings() const;
1235 
1236  /// sets boolean parameter value; returns true on success
1237  bool setBoolParam(const BoolParam param, const bool value, const bool quiet = false, const bool init = false);
1238 
1239  /// sets integer parameter value; returns true on success
1240  bool setIntParam(const IntParam param, const int value, const bool quiet = false, const bool init = false);
1241 
1242  /// sets real parameter value; returns true on success
1243  bool setRealParam(const RealParam param, const Real value, const bool quiet = false, const bool init = false);
1244 
1245 #ifdef SOPLEX_WITH_RATIONALPARAM
1246  /// sets rational parameter value; returns true on success
1247  bool setRationalParam(const RationalParam param, const Rational value, const bool quiet = false, const bool init = false);
1248 #endif
1249 
1250  /// sets parameter settings; returns true on success
1251  bool setSettings(const Settings& newSettings, const bool quiet = false, const bool init = false);
1252 
1253  /// print non-default parameter values
1254  void printUserSettings();
1255 
1256  /// writes settings file; returns true on success
1257  bool saveSettingsFile(const char* filename, const bool onlyChanged = false) const;
1258 
1259  /// reads settings file; returns true on success
1260  bool loadSettingsFile(const char* filename);
1261 
1262  /// parses one setting string and returns true on success; note that string is modified
1263  bool parseSettingsString(char* line);
1264 
1265  //@}
1266 
1267 
1268  //**@name Statistics */
1269  //@{
1270 
1271  /// prints solution statistics
1272  void printSolutionStatistics(std::ostream& os);
1273 
1274  /// prints statistics on solving process
1275  void printSolvingStatistics(std::ostream& os);
1276 
1277  /// prints short statistics
1278  void printShortStatistics(std::ostream& os);
1279 
1280  /// prints complete statistics
1281  void printStatistics(std::ostream& os);
1282 
1283  /// prints status
1284  void printStatus(std::ostream& os, SPxSolver::Status status);
1285 
1286  //@}
1287 
1288 
1289  //**@name Miscellaneous */
1290  //@{
1291 
1292  /// prints version and compilation options
1293  void printVersion() const;
1294 
1295  /// checks if real LP and rational LP are in sync; dimensions will always be compared,
1296  /// vector and matrix values only if the respective parameter is set to true.
1297  /// If quiet is set to true the function will only display which vectors are different.
1298  bool areLPsInSync(const bool checkVecVals = true, const bool checkMatVals = false, const bool quiet = false) const;
1299 
1300  //@}
1301 
1302 private:
1303 
1304  //**@name Statistics on solving process */
1305  //@{
1306 
1307  /// class of statistics
1308  class Statistics;
1309 
1310  /// statistics since last call to solveReal() or solveRational()
1312 
1313  //@}
1314 
1315 
1316  //**@name Parameter settings */
1317  //@{
1318 
1320 
1326 
1327  //@}
1328 
1329 
1330  //**@name Data for the real LP */
1331  //@{
1332 
1353 
1358 
1360 
1367 
1368  //@}
1369 
1370 
1371  //**@name Data for the rational LP */
1372  //@{
1373 
1375 
1399 
1400  /// type of bounds and sides
1401  typedef enum
1402  {
1403  /// both bounds are infinite
1405 
1406  /// lower bound is finite, upper bound is infinite
1408 
1409  /// upper bound is finite, lower bound is infinite
1411 
1412  /// lower and upper bound finite, but different
1414 
1415  /// lower bound equals upper bound
1417  } RangeType;
1418 
1421 
1422  //@}
1423 
1424 
1425  //**@name Solution data */
1426  //@{
1427 
1430 
1433 
1437 
1441 
1442  //@}
1443 
1444 
1445  //**@name Constant helper methods */
1446  //@{
1447 
1448  /// extends sparse vector to hold newmax entries if and only if it holds no more free entries
1449  void _ensureDSVectorRationalMemory(DSVectorRational& vec, const int newmax) const;
1450 
1451  /// creates a permutation for removing rows/columns from an array of indices
1452  void _idxToPerm(int* idx, int idxSize, int* perm, int permSize) const;
1453 
1454  /// creates a permutation for removing rows/columns from a range of indices
1455  void _rangeToPerm(int start, int end, int* perm, int permSize) const;
1456 
1457  /// checks consistency
1458  bool _isConsistent() const;
1459 
1460  /// should solving process be stopped?
1461  bool _isSolveStopped() const;
1462 
1463  /// determines RangeType from real bounds
1464  RangeType _rangeTypeReal(const Real& lower, const Real& upper) const;
1465 
1466  /// determines RangeType from rational bounds
1467  RangeType _rangeTypeRational(const Rational& lower, const Rational& upper) const;
1468 
1469  /// switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
1470  RangeType _switchRangeType(const RangeType& rangeType) const;
1471 
1472  /// checks whether RangeType corresponds to finite lower bound
1473  bool _lowerFinite(const RangeType& rangeType) const;
1474 
1475  /// checks whether RangeType corresponds to finite upper bound
1476  bool _upperFinite(const RangeType& rangeType) const;
1477 
1478  //@}
1479 
1480 
1481  //**@name Non-constant helper methods */
1482  //@{
1483 
1484  /// adds a single row to the real LP and adjusts basis
1485  void _addRowReal(const LPRowReal& lprow);
1486 
1487  /// adds a single row to the real LP and adjusts basis
1488  void _addRowReal(Real lhs, const SVectorReal& lprow, Real rhs);
1489 
1490  /// adds multiple rows to the real LP and adjusts basis
1491  void _addRowsReal(const LPRowSetReal& lprowset);
1492 
1493  /// adds a single column to the real LP and adjusts basis
1494  void _addColReal(const LPColReal& lpcol);
1495 
1496  /// adds a single column to the real LP and adjusts basis
1497  void _addColReal(Real obj, Real lower, const SVectorReal& lpcol, Real upper);
1498 
1499  /// adds multiple columns to the real LP and adjusts basis
1500  void _addColsReal(const LPColSetReal& lpcolset);
1501 
1502  /// replaces row \p i with \p lprow and adjusts basis
1503  void _changeRowReal(int i, const LPRowReal& lprow);
1504 
1505  /// changes left-hand side vector for constraints to \p lhs and adjusts basis
1506  void _changeLhsReal(const VectorReal& lhs);
1507 
1508  /// changes left-hand side of row \p i to \p lhs and adjusts basis
1509  void _changeLhsReal(int i, const Real& lhs);
1510 
1511  /// changes right-hand side vector to \p rhs and adjusts basis
1512  void _changeRhsReal(const VectorReal& rhs);
1513 
1514  /// changes right-hand side of row \p i to \p rhs and adjusts basis
1515  void _changeRhsReal(int i, const Real& rhs);
1516 
1517  /// changes left- and right-hand side vectors and adjusts basis
1518  void _changeRangeReal(const VectorReal& lhs, const VectorReal& rhs);
1519 
1520  /// changes left- and right-hand side of row \p i and adjusts basis
1521  void _changeRangeReal(int i, const Real& lhs, const Real& rhs);
1522 
1523  /// replaces column \p i with \p lpcol and adjusts basis
1524  void _changeColReal(int i, const LPColReal& lpcol);
1525 
1526  /// changes vector of lower bounds to \p lower and adjusts basis
1527  void _changeLowerReal(const VectorReal& lower);
1528 
1529  /// changes lower bound of column i to \p lower and adjusts basis
1530  void _changeLowerReal(int i, const Real& lower);
1531 
1532  /// changes vector of upper bounds to \p upper and adjusts basis
1533  void _changeUpperReal(const VectorReal& upper);
1534 
1535  /// changes \p i 'th upper bound to \p upper and adjusts basis
1536  void _changeUpperReal(int i, const Real& upper);
1537 
1538  /// changes vectors of column bounds to \p lower and \p upper and adjusts basis
1539  void _changeBoundsReal(const VectorReal& lower, const VectorReal& upper);
1540 
1541  /// changes bounds of column \p i to \p lower and \p upper and adjusts basis
1542  void _changeBoundsReal(int i, const Real& lower, const Real& upper);
1543 
1544  /// changes matrix entry in row \p i and column \p j to \p val and adjusts basis
1545  void _changeElementReal(int i, int j, const Real& val);
1546 
1547  /// removes row \p i and adjusts basis
1548  void _removeRowReal(int i);
1549 
1550  /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
1551  /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
1552  /// #numRowsReal()
1553  void _removeRowsReal(int perm[]);
1554 
1555  /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsReal() may be passed
1556  /// as buffer memory
1557  void _removeRowsReal(int idx[], int n, int perm[]);
1558 
1559  /// removes rows \p start to \p end including both; an array \p perm of size #numRowsReal() may be passed as buffer
1560  /// memory
1561  void _removeRowRangeReal(int start, int end, int perm[]);
1562 
1563  /// removes column i
1564  void _removeColReal(int i);
1565 
1566  /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
1567  /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
1568  /// #numColsReal()
1569  void _removeColsReal(int perm[]);
1570 
1571  /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsReal() may be
1572  /// passed as buffer memory
1573  void _removeColsReal(int idx[], int n, int perm[]);
1574 
1575  /// removes columns \p start to \p end including both; an array \p perm of size #numColsReal() may be passed as
1576  /// buffer memory
1577  void _removeColRangeReal(int start, int end, int perm[]);
1578 
1579  /// invalidates solution
1580  void _invalidateSolution();
1581 
1582  /// enables simplifier and scaler according to current parameters
1584 
1585  /// disables simplifier and scaler
1587 
1588  /// ensures that the rational LP is available; performs no sync
1589  void _ensureRationalLP();
1590 
1591  /// ensures that the real LP and the basis are loaded in the solver; performs no sync
1592  void _ensureRealLPLoaded();
1593 
1594  /// call floating-point solver and update statistics on iterations etc.
1596 
1597  /// reads real LP in LP or MPS format from file and returns true on success; gets row names, column names, and
1598  /// integer variables if desired
1599  bool _readFileReal(const char* filename, NameSet* rowNames = 0, NameSet* colNames = 0, DIdxSet* intVars = 0);
1600 
1601  /// reads rational LP in LP or MPS format from file and returns true on success; gets row names, column names, and
1602  /// integer variables if desired
1603  bool _readFileRational(const char* filename, NameSet* rowNames = 0, NameSet* colNames = 0, DIdxSet* intVars = 0);
1604 
1605  /// recomputes range types from scratch using real LP
1606  void _recomputeRangeTypesReal();
1607 
1608  /// recomputes range types from scratch using rational LP
1610 
1611  /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, without looking at the sync mode
1612  void _syncLPReal(bool time = true);
1613 
1614  /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sync mode
1615  void _syncLPRational(bool time = true);
1616 
1617  /// synchronizes real solution with rational solution, i.e., copies real solution to rational solution
1618  void _syncRealSolution();
1619 
1620  /// synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real solution
1621  void _syncRationalSolution();
1622 
1623  /// returns pointer to a constant unit vector available until destruction of the SoPlex class
1624  const UnitVectorRational* _unitVectorRational(const int i);
1625 
1626  /// parses one line in a settings file and returns true on success; note that the string is modified
1627  bool _parseSettingsLine(char* line, const int lineNumber);
1628 
1629  //@}
1630 
1631 
1632  //**@name Private solving methods implemented in solverational.cpp */
1633  //@{
1634 
1635  /// solves rational LP
1636  void _solveRational();
1637 
1638  /// solves current problem with iterative refinement and recovery mechanism
1639  void _performOptIRStable(SolRational& sol, bool acceptUnbounded, bool acceptInfeasible, int minRounds, bool& primalFeasible, bool& dualFeasible, bool& infeasible, bool& unbounded, bool& stopped, bool& error);
1640 
1641  /// performs iterative refinement on the auxiliary problem for testing unboundedness
1642  void _performUnboundedIRStable(SolRational& sol, bool& hasUnboundedRay, bool& stopped, bool& error);
1643 
1644  /// performs iterative refinement on the auxiliary problem for testing feasibility
1645  void _performFeasIRStable(SolRational& sol, bool& withDualFarkas, bool& stopped, bool& error);
1646 
1647  /// reduces matrix coefficient in absolute value by the lifting procedure of Thiele et al. 2013
1648  void _lift();
1649 
1650  /// undoes lifting
1651  void _project(SolRational& sol);
1652 
1653  /// store basis
1654  void _storeBasis();
1655 
1656  /// restore basis
1657  void _restoreBasis();
1658 
1659  /// stores objective, bounds, and sides of real LP
1660  void _storeLPReal();
1661 
1662  /// restores objective, bounds, and sides of real LP
1663  void _restoreLPReal();
1664 
1665  /// introduces slack variables to transform inequality constraints into equations for both rational and real LP,
1666  /// which should be in sync
1667  void _transformEquality();
1668 
1669  /// undoes transformation to equality form
1670  void _untransformEquality(SolRational& sol);
1671 
1672  /// transforms LP to unboundedness problem by moving the objective function to the constraints, changing right-hand
1673  /// side and bounds to zero, and adding an auxiliary variable for the decrease in the objective function
1674  void _transformUnbounded();
1675 
1676  /// undoes transformation to unboundedness problem
1677  void _untransformUnbounded(SolRational& sol, bool unbounded);
1678 
1679  /// transforms LP to feasibility problem by removing the objective function, shifting variables, and homogenizing the
1680  /// right-hand side
1681  void _transformFeasibility();
1682 
1683  /// undoes transformation to feasibility problem
1684  void _untransformFeasibility(SolRational& sol, bool infeasible);
1685 
1686  /** computes radius of infeasibility box implied by an approximate Farkas' proof
1687 
1688  Given constraints of the form \f$ lhs <= Ax <= rhs \f$, a farkas proof y should satisfy \f$ y^T A = 0 \f$ and
1689  \f$ y_+^T lhs - y_-^T rhs > 0 \f$, where \f$ y_+, y_- \f$ denote the positive and negative parts of \f$ y \f$.
1690  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
1691  as the following holds for all potentially feasible \f$ x \f$:
1692 
1693  \f[
1694  y^T Ax < (y_+^T lhs - y_-^T rhs) (*)
1695  \f]
1696 
1697  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
1698  bounds on \f$ x \f$ imply that all feasible \f$ x \f$ satisfy (*), and if not then compute bounds on \f$ x \f$ to
1699  guarantee (*). The simplest way to do this is to compute
1700 
1701  \f[
1702  B = (y_+^T lhs - y_-^T rhs) / \sum_i(|(y^T A)_i|)
1703  \f]
1704 
1705  noting that if every component of \f$ x \f$ has \f$ |x_i| < B \f$, then (*) holds.
1706 
1707  \f$ B \f$ can be increased by iteratively including variable bounds smaller than \f$ B \f$. The speed of this
1708  method can be further improved by using interval arithmetic for all computations. For related information see
1709  Sec. 4 of Neumaier and Shcherbina, Mathematical Programming A, 2004.
1710 
1711  Set transformed to true if this method is called after _transformFeasibility().
1712  */
1713  void _computeInfeasBox(SolRational& sol, bool transformed);
1714 
1715  /// solves real LP during iterative refinement
1716  SPxSolver::Status _solveRealForRational(bool fromscratch, VectorReal& primal, VectorReal& dual,
1717  DataArray< SPxSolver::VarStatus >& basisStatusRows,
1718  DataArray< SPxSolver::VarStatus >& basisStatusCols, bool& returnedBasis);
1719 
1720  /// solves real LP with recovery mechanism
1721  SPxSolver::Status _solveRealStable(bool acceptUnbounded, bool acceptInfeasible, VectorReal& primal, VectorReal& dual,
1722  DataArray< SPxSolver::VarStatus >& basisStatusRows,
1723  DataArray< SPxSolver::VarStatus >& basisStatusCols, bool& returnedBasis, const bool forceNoSimplifier = false);
1724 
1725  /// factorizes rational basis matrix in column representation
1726  void _factorizeColumnRational(SolRational& sol, DataArray< SPxSolver::VarStatus >& basisStatusRows, DataArray< SPxSolver::VarStatus >& basisStatusCols, bool& stopped, bool& error, bool& optimal);
1727 
1728  /// attempts rational reconstruction of primal-dual solution
1729  bool _reconstructSolutionRational(SolRational& sol, DataArray< SPxSolver::VarStatus >& basisStatusRows, DataArray< SPxSolver::VarStatus >& basisStatusCols, bool& stopped, bool& error, const Rational& denomBoundSquared);
1730  //@}
1731 
1732 
1733  //**@name Private solving methods implemented in solvereal.cpp */
1734  //@{
1735 
1736  /// solves real LP
1737  void _solveReal();
1738 
1739  /// checks result of the solving process and solves again without preprocessing if necessary
1740  void _evaluateSolutionReal(SPxSimplifier::Result simplificationStatus);
1741 
1742  /// solves real LP with/without preprocessing
1743  void _preprocessAndSolveReal(bool applyPreprocessing);
1744 
1745  /// loads original problem into solver and solves again after it has been solved to optimality with preprocessing
1746  void _resolveWithoutPreprocessing(SPxSimplifier::Result simplificationStatus);
1747 
1748  /// stores solution of the real LP; before calling this, the real LP must be loaded in the solver and solved (again)
1749  void _storeSolutionReal();
1750 
1751  //@}
1752 };
1753 }
1754 #else
1755 #include "soplexlegacy.h"
1756 
1757 namespace soplex
1758 {
1759  typedef SoPlexLegacy SoPlex;
1760 }
1761 #endif
1762 #endif // _SOPLEX_H_