Scippy

SoPlex

Sequential object-oriented simPlex

soplex.cpp
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-2019 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.cpp
17  * @brief Preconfigured SoPlex LP solver
18  */
19 
20 #include <assert.h>
21 #include "limits.h"
22 #include <iostream>
23 
24 #ifndef _MSC_VER
25 #include <strings.h>
26 #endif
27 
28 #include "soplex.h"
29 #include "soplex/spxfileio.h"
30 #include "soplex/statistics.h"
31 #include "soplex/mpsinput.h"
32 
33 /// maximum length of lines in settings file
34 #define SET_MAX_LINE_LEN 500
35 /// default setting for LU refactorization interval
36 #define DEFAULT_REFACTOR_INTERVAL 200
37 
38 #ifdef _MSC_VER
39 #define strncasecmp _strnicmp
40 #endif
41 
42 namespace soplex
43 {
45 {
46  // should lifting be used to reduce range of nonzero matrix coefficients?
47  name[SoPlex::LIFTING] = "lifting";
49  "should lifting be used to reduce range of nonzero matrix coefficients?";
51 
52  // should LP be transformed to equality form before a rational solve?
53  name[SoPlex::EQTRANS] = "eqtrans";
54  description[SoPlex::EQTRANS] = "should LP be transformed to equality form before a rational solve?";
56 
57  // should dual infeasibility be tested in order to try to return a dual solution even if primal infeasible?
58  name[SoPlex::TESTDUALINF] = "testdualinf";
60  "should dual infeasibility be tested in order to try to return a dual solution even if primal infeasible?";
62 
63  // should a rational factorization be performed after iterative refinement?
64  name[SoPlex::RATFAC] = "ratfac";
66  "should a rational factorization be performed after iterative refinement?";
68 
69  // should the decomposition based dual simplex be used to solve the LP? Setting this to true forces the solve mode to
70  // SOLVEMODE_REAL and the basis representation to REPRESENTATION_ROW
71  name[SoPlex::USEDECOMPDUALSIMPLEX] = "decompositiondualsimplex";
73  "should the decomposition based dual simplex be used to solve the LP?";
75 
76  // should the degeneracy be computed for each basis?
77  name[SoPlex::COMPUTEDEGEN] = "computedegen";
78  description[SoPlex::COMPUTEDEGEN] = "should the degeneracy be computed for each basis?";
80 
81  // should the dual of the complementary problem be used in the decomposition simplex?
82  name[SoPlex::USECOMPDUAL] = "usecompdual";
84  "should the dual of the complementary problem be used in the decomposition simplex?";
86 
87  /// should row and bound violations be computed explicitly in the update of reduced problem in the decomposition
88  // simplex
89  name[SoPlex::EXPLICITVIOL] = "explicitviol";
91  "Should violations of the original problem be explicitly computed in the decomposition simplex?";
93 
94  // should cycling solutions be accepted during iterative refinement?
95  name[SoPlex::ACCEPTCYCLING] = "acceptcycling";
97  "should cycling solutions be accepted during iterative refinement?";
99 
100  // apply rational reconstruction after each iterative refinement?
101  name[SoPlex::RATREC] = "ratrec";
102  description[SoPlex::RATREC] = "apply rational reconstruction after each iterative refinement?";
104 
105  // round scaling factors for iterative refinement to powers of two?
106  name[SoPlex::POWERSCALING] = "powerscaling";
108  "round scaling factors for iterative refinement to powers of two?";
110 
111  // continue iterative refinement with exact basic solution if not optimal?
112  name[SoPlex::RATFACJUMP] = "ratfacjump";
114  "continue iterative refinement with exact basic solution if not optimal?";
116 
117  // use bound flipping also for row representation?
118  name[SoPlex::ROWBOUNDFLIPS] = "rowboundflips";
119  description[SoPlex::ROWBOUNDFLIPS] = "use bound flipping also for row representation?";
121 
122  // use persistent scaling?
123  name[SoPlex::PERSISTENTSCALING] = "persistentscaling";
124  description[SoPlex::PERSISTENTSCALING] = "should persistent scaling be used?";
126 
127  // perturb the entire problem or only the relevant bounds of s single pivot?
128  name[SoPlex::FULLPERTURBATION] = "fullperturbation";
129  description[SoPlex::FULLPERTURBATION] = "should perturbation be applied to the entire problem?";
131 
132  /// re-optimize the original problem to get a proof of infeasibility/unboundedness?
133  name[SoPlex::ENSURERAY] = "ensureray";
135  "re-optimize the original problem to get a proof (ray) of infeasibility/unboundedness?";
137 }
138 
140 {
141  // objective sense
142  name[SoPlex::OBJSENSE] = "objsense";
143  description[SoPlex::OBJSENSE] = "objective sense (-1 - minimize, +1 - maximize)";
144  lower[SoPlex::OBJSENSE] = -1;
145  upper[SoPlex::OBJSENSE] = 1;
147 
148  // type of computational form, i.e., column or row representation
149  name[SoPlex::REPRESENTATION] = "representation";
151  "type of computational form (0 - auto, 1 - column representation, 2 - row representation)";
152  lower[SoPlex::REPRESENTATION] = 0;
153  upper[SoPlex::REPRESENTATION] = 2;
155 
156  // type of algorithm, i.e., primal or dual
157  name[SoPlex::ALGORITHM] = "algorithm";
158  description[SoPlex::ALGORITHM] = "type of algorithm (0 - primal, 1 - dual)";
159  lower[SoPlex::ALGORITHM] = 0;
160  upper[SoPlex::ALGORITHM] = 1;
162 
163  // type of LU update
164  name[SoPlex::FACTOR_UPDATE_TYPE] = "factor_update_type";
166  "type of LU update (0 - eta update, 1 - Forrest-Tomlin update)";
167  lower[SoPlex::FACTOR_UPDATE_TYPE] = 0;
168  upper[SoPlex::FACTOR_UPDATE_TYPE] = 1;
170 
171  // maximum number of updates without fresh factorization
172  name[SoPlex::FACTOR_UPDATE_MAX] = "factor_update_max";
174  "maximum number of LU updates without fresh factorization (0 - auto)";
175  lower[SoPlex::FACTOR_UPDATE_MAX] = 0;
176  upper[SoPlex::FACTOR_UPDATE_MAX] = INT_MAX;
178 
179  // iteration limit (-1 if unlimited)
180  name[SoPlex::ITERLIMIT] = "iterlimit";
181  description[SoPlex::ITERLIMIT] = "iteration limit (-1 - no limit)";
182  lower[SoPlex::ITERLIMIT] = -1;
183  upper[SoPlex::ITERLIMIT] = INT_MAX;
185 
186  // refinement limit (-1 if unlimited)
187  name[SoPlex::REFLIMIT] = "reflimit";
188  description[SoPlex::REFLIMIT] = "refinement limit (-1 - no limit)";
189  lower[SoPlex::REFLIMIT] = -1;
190  upper[SoPlex::REFLIMIT] = INT_MAX;
192 
193  // stalling refinement limit (-1 if unlimited)
194  name[SoPlex::STALLREFLIMIT] = "stallreflimit";
195  description[SoPlex::STALLREFLIMIT] = "stalling refinement limit (-1 - no limit)";
196  lower[SoPlex::STALLREFLIMIT] = -1;
197  upper[SoPlex::STALLREFLIMIT] = INT_MAX;
199 
200  // display frequency
201  name[SoPlex::DISPLAYFREQ] = "displayfreq";
202  description[SoPlex::DISPLAYFREQ] = "display frequency";
203  lower[SoPlex::DISPLAYFREQ] = 1;
204  upper[SoPlex::DISPLAYFREQ] = INT_MAX;
206 
207  // verbosity level
208  name[SoPlex::VERBOSITY] = "verbosity";
210  "verbosity level (0 - error, 1 - warning, 2 - debug, 3 - normal, 4 - high, 5 - full)";
211  lower[SoPlex::VERBOSITY] = 0;
212  upper[SoPlex::VERBOSITY] = 5;
214  //_intParamDefault[SoPlex::VERBOSITY] = SoPlex::VERBOSITY_FULL;
215 
216  // type of simplifier
217  name[SoPlex::SIMPLIFIER] = "simplifier";
218  description[SoPlex::SIMPLIFIER] = "simplifier (0 - off, 1 - auto)";
219  lower[SoPlex::SIMPLIFIER] = 0;
220  upper[SoPlex::SIMPLIFIER] = 1;
222 
223  // type of scaler
224  name[SoPlex::SCALER] = "scaler";
226  "scaling (0 - off, 1 - uni-equilibrium, 2 - bi-equilibrium, 3 - geometric, 4 - iterated geometric, 5 - least squares, 6 - geometric-equilibrium)";
227  lower[SoPlex::SCALER] = 0;
228  upper[SoPlex::SCALER] = 6;
230 
231  // type of starter used to create crash basis
232  name[SoPlex::STARTER] = "starter";
234  "crash basis generated when starting from scratch (0 - none, 1 - weight, 2 - sum, 3 - vector)";
235  lower[SoPlex::STARTER] = 0;
236  upper[SoPlex::STARTER] = 3;
238 
239  // type of pricer
240  name[SoPlex::PRICER] = "pricer";
242  "pricing method (0 - auto, 1 - dantzig, 2 - parmult, 3 - devex, 4 - quicksteep, 5 - steep)";
243  lower[SoPlex::PRICER] = 0;
244  upper[SoPlex::PRICER] = 5;
246 
247  // type of ratio test
248  name[SoPlex::RATIOTESTER] = "ratiotester";
250  "method for ratio test (0 - textbook, 1 - harris, 2 - fast, 3 - boundflipping)";
251  lower[SoPlex::RATIOTESTER] = 0;
252  upper[SoPlex::RATIOTESTER] = 3;
254 
255  // mode for synchronizing real and rational LP
256  name[SoPlex::SYNCMODE] = "syncmode";
258  "mode for synchronizing real and rational LP (0 - store only real LP, 1 - auto, 2 - manual)";
259  lower[SoPlex::SYNCMODE] = 0;
260  upper[SoPlex::SYNCMODE] = 2;
262 
263  // mode for reading LP files
264  name[SoPlex::READMODE] = "readmode";
265  description[SoPlex::READMODE] = "mode for reading LP files (0 - floating-point, 1 - rational)";
266  lower[SoPlex::READMODE] = 0;
267  upper[SoPlex::READMODE] = 1;
269 
270  // mode for iterative refinement strategy
271  name[SoPlex::SOLVEMODE] = "solvemode";
273  "mode for iterative refinement strategy (0 - floating-point solve, 1 - auto, 2 - exact rational solve)";
274  lower[SoPlex::SOLVEMODE] = 0;
275  upper[SoPlex::SOLVEMODE] = 2;
277 
278  // mode for iterative refinement strategy
279  name[SoPlex::CHECKMODE] = "checkmode";
281  "mode for a posteriori feasibility checks (0 - floating-point check, 1 - auto, 2 - exact rational check)";
282  lower[SoPlex::CHECKMODE] = 0;
283  upper[SoPlex::CHECKMODE] = 2;
285 
286  // type of timing
287  name[SoPlex::TIMER] = "timer";
289  "type of timer (1 - cputime, aka. usertime, 2 - wallclock time, 0 - no timing)";
290  lower[SoPlex::TIMER] = 0;
291  upper[SoPlex::TIMER] = 2;
293 
294  // mode for hyper sparse pricing
295  name[SoPlex::HYPER_PRICING] = "hyperpricing";
297  "mode for hyper sparse pricing (0 - off, 1 - auto, 2 - always)";
298  lower[SoPlex::HYPER_PRICING] = 0;
299  upper[SoPlex::HYPER_PRICING] = 2;
301 
302  // minimum number of stalling refinements since last pivot to trigger rational factorization
303  name[SoPlex::RATFAC_MINSTALLS] = "ratfac_minstalls";
305  "minimum number of stalling refinements since last pivot to trigger rational factorization";
306  lower[SoPlex::RATFAC_MINSTALLS] = 0;
307  upper[SoPlex::RATFAC_MINSTALLS] = INT_MAX;
309 
310  // maximum number of conjugate gradient iterations in least square scaling
311  name[SoPlex::LEASTSQ_MAXROUNDS] = "leastsq_maxrounds";
313  "maximum number of conjugate gradient iterations in least square scaling";
314  lower[SoPlex::LEASTSQ_MAXROUNDS] = 0;
315  upper[SoPlex::LEASTSQ_MAXROUNDS] = INT_MAX;
317 
318  // mode for solution polishing
319  name[SoPlex::SOLUTION_POLISHING] = "solution_polishing";
321  "mode for solution polishing (0 - off, 1 - max basic slack, 2 - min basic slack)";
322  lower[SoPlex::SOLUTION_POLISHING] = 0;
323  upper[SoPlex::SOLUTION_POLISHING] = 2;
325 
326  // the number of iterations before the decomposition simplex initialisation is terminated.
327  name[SoPlex::DECOMP_ITERLIMIT] = "decomp_iterlimit";
329  "the number of iterations before the decomposition simplex initialisation solve is terminated";
330  lower[SoPlex::DECOMP_ITERLIMIT] = 1;
331  upper[SoPlex::DECOMP_ITERLIMIT] = INT_MAX;
333 
334  // maximum number of violated rows added in each iteration of the decomposition simplex
335  name[SoPlex::DECOMP_MAXADDEDROWS] = "decomp_maxaddedrows";
337  "maximum number of rows that are added to the reduced problem when using the decomposition based simplex";
338  lower[SoPlex::DECOMP_MAXADDEDROWS] = 1;
339  upper[SoPlex::DECOMP_MAXADDEDROWS] = INT_MAX;
341 
342  // maximum number of violated rows added in each iteration of the decomposition simplex
343  name[SoPlex::DECOMP_DISPLAYFREQ] = "decomp_displayfreq";
345  "the frequency that the decomposition based simplex status output is displayed.";
346  lower[SoPlex::DECOMP_DISPLAYFREQ] = 1;
347  upper[SoPlex::DECOMP_DISPLAYFREQ] = INT_MAX;
349 
350  // the verbosity of the decomposition based simplex
351  name[SoPlex::DECOMP_VERBOSITY] = "decomp_verbosity";
353  "the verbosity of decomposition based simplex (0 - error, 1 - warning, 2 - debug, 3 - normal, 4 - high, 5 - full).";
354  lower[SoPlex::DECOMP_VERBOSITY] = 1;
355  upper[SoPlex::DECOMP_VERBOSITY] = 5;
357 
358  // printing condition number during the solve
359  name[SoPlex::PRINTCONDITION] = "printcondition";
361  "print condition number during the solve (0 - off, 1 - ratio estimate , 2 - sum estimate, 3 - product estimate, 4 - exact)";
362  lower[SoPlex::PRINTCONDITION] = 0;
363  upper[SoPlex::PRINTCONDITION] = 4;
365 }
366 
368 {
369  // primal feasibility tolerance
370  name[SoPlex::FEASTOL] = "feastol";
371  description[SoPlex::FEASTOL] = "primal feasibility tolerance";
372  lower[SoPlex::FEASTOL] = 0.0;
373  upper[SoPlex::FEASTOL] = 1.0;
375 
376  // dual feasibility tolerance
377  name[SoPlex::OPTTOL] = "opttol";
378  description[SoPlex::OPTTOL] = "dual feasibility tolerance";
379  lower[SoPlex::OPTTOL] = 0.0;
380  upper[SoPlex::OPTTOL] = 1.0;
382 
383  ///@todo define suitable values depending on Real type
384  // general zero tolerance
385  name[SoPlex::EPSILON_ZERO] = "epsilon_zero";
386  description[SoPlex::EPSILON_ZERO] = "general zero tolerance";
387  lower[SoPlex::EPSILON_ZERO] = 0.0;
388  upper[SoPlex::EPSILON_ZERO] = 1.0;
390 
391  ///@todo define suitable values depending on Real type
392  // zero tolerance used in factorization
393  name[SoPlex::EPSILON_FACTORIZATION] = "epsilon_factorization";
394  description[SoPlex::EPSILON_FACTORIZATION] = "zero tolerance used in factorization";
395  lower[SoPlex::EPSILON_FACTORIZATION] = 0.0;
396  upper[SoPlex::EPSILON_FACTORIZATION] = 1.0;
398 
399  ///@todo define suitable values depending on Real type
400  // zero tolerance used in update of the factorization
401  name[SoPlex::EPSILON_UPDATE] = "epsilon_update";
402  description[SoPlex::EPSILON_UPDATE] = "zero tolerance used in update of the factorization";
403  lower[SoPlex::EPSILON_UPDATE] = 0.0;
404  upper[SoPlex::EPSILON_UPDATE] = 1.0;
406 
407  ///@todo define suitable values depending on Real type
408  // pivot zero tolerance used in factorization
409  name[SoPlex::EPSILON_PIVOT] = "epsilon_pivot";
410  description[SoPlex::EPSILON_PIVOT] = "pivot zero tolerance used in factorization";
411  lower[SoPlex::EPSILON_PIVOT] = 0.0;
412  upper[SoPlex::EPSILON_PIVOT] = 1.0;
414 
415  ///@todo define suitable values depending on Real type
416  // infinity threshold
417  name[SoPlex::INFTY] = "infty";
418  description[SoPlex::INFTY] = "infinity threshold";
419  lower[SoPlex::INFTY] = 1e10;
420  upper[SoPlex::INFTY] = 1e100;
422 
423  // time limit in seconds (INFTY if unlimited)
424  name[SoPlex::TIMELIMIT] = "timelimit";
425  description[SoPlex::TIMELIMIT] = "time limit in seconds";
426  lower[SoPlex::TIMELIMIT] = 0.0;
429 
430  // lower limit on objective value
431  name[SoPlex::OBJLIMIT_LOWER] = "objlimit_lower";
432  description[SoPlex::OBJLIMIT_LOWER] = "lower limit on objective value";
436 
437  // upper limit on objective value
438  name[SoPlex::OBJLIMIT_UPPER] = "objlimit_upper";
439  description[SoPlex::OBJLIMIT_UPPER] = "upper limit on objective value";
443 
444  // working tolerance for feasibility in floating-point solver during iterative refinement
445  name[SoPlex::FPFEASTOL] = "fpfeastol";
447  "working tolerance for feasibility in floating-point solver during iterative refinement";
448  lower[SoPlex::FPFEASTOL] = 1e-12;
449  upper[SoPlex::FPFEASTOL] = 1.0;
451 
452  // working tolerance for optimality in floating-point solver during iterative refinement
453  name[SoPlex::FPOPTTOL] = "fpopttol";
455  "working tolerance for optimality in floating-point solver during iterative refinement";
456  lower[SoPlex::FPOPTTOL] = 1e-12;
457  upper[SoPlex::FPOPTTOL] = 1.0;
459 
460  // maximum increase of scaling factors between refinements
461  name[SoPlex::MAXSCALEINCR] = "maxscaleincr";
462  description[SoPlex::MAXSCALEINCR] = "maximum increase of scaling factors between refinements";
463  lower[SoPlex::MAXSCALEINCR] = 1.0;
466 
467  // lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)
468  name[SoPlex::LIFTMINVAL] = "liftminval";
470  "lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)";
471  lower[SoPlex::LIFTMINVAL] = 0.0;
472  upper[SoPlex::LIFTMINVAL] = 0.1;
473  defaultValue[SoPlex::LIFTMINVAL] = 0.000976562; // = 1/1024
474 
475  // upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulated)
476  name[SoPlex::LIFTMAXVAL] = "liftmaxval";
478  "lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)";
479  lower[SoPlex::LIFTMAXVAL] = 10.0;
482 
483  // threshold for using sparse pricing (no. of violations need to be smaller than threshold * dimension of problem)
484  name[SoPlex::SPARSITY_THRESHOLD] = "sparsity_threshold";
486  "sparse pricing threshold (#violations < dimension * SPARSITY_THRESHOLD activates sparse pricing)";
487  lower[SoPlex::SPARSITY_THRESHOLD] = 0.0;
488  upper[SoPlex::SPARSITY_THRESHOLD] = 1.0;
490 
491  // threshold on number of rows vs. number of columns for switching from column to row representations in auto mode
492  name[SoPlex::REPRESENTATION_SWITCH] = "representation_switch";
494  "threshold on number of rows vs. number of columns for switching from column to row representations in auto mode";
495  lower[SoPlex::REPRESENTATION_SWITCH] = 0.0;
498 
499  // geometric frequency at which to apply rational reconstruction
500  name[SoPlex::RATREC_FREQ] = "ratrec_freq";
501  description[SoPlex::RATREC_FREQ] = "geometric frequency at which to apply rational reconstruction";
502  lower[SoPlex::RATREC_FREQ] = 1.0;
505 
506  // minimal reduction (sum of removed rows/cols) to continue simplification
507  name[SoPlex::MINRED] = "minred";
509  "minimal reduction (sum of removed rows/cols) to continue simplification";
510  lower[SoPlex::MINRED] = 0.0;
511  upper[SoPlex::MINRED] = 1.0;
513 
514  // refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix
515  name[SoPlex::REFAC_BASIS_NNZ] = "refac_basis_nnz";
517  "refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix";
518  lower[SoPlex::REFAC_BASIS_NNZ] = 1.0;
519  upper[SoPlex::REFAC_BASIS_NNZ] = 100.0;
521 
522  // refactor threshold for fill-in in current factor update compared to fill-in in last factorization
523  name[SoPlex::REFAC_UPDATE_FILL] = "refac_update_fill";
525  "refactor threshold for fill-in in current factor update compared to fill-in in last factorization";
526  lower[SoPlex::REFAC_UPDATE_FILL] = 1.0;
527  upper[SoPlex::REFAC_UPDATE_FILL] = 100.0;
529 
530  // refactor threshold for memory growth in factorization since last refactorization
531  name[SoPlex::REFAC_MEM_FACTOR] = "refac_mem_factor";
533  "refactor threshold for memory growth in factorization since last refactorization";
534  lower[SoPlex::REFAC_MEM_FACTOR] = 1.0;
535  upper[SoPlex::REFAC_MEM_FACTOR] = 10.0;
537 
538  // accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations)
539  name[SoPlex::LEASTSQ_ACRCY] = "leastsq_acrcy";
541  "accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations)";
542  lower[SoPlex::LEASTSQ_ACRCY] = 1.0;
545 
546  // objective offset
547  name[SoPlex::OBJ_OFFSET] = "obj_offset";
548  description[SoPlex::OBJ_OFFSET] = "objective offset to be used";
552 }
553 
554 #ifdef SOPLEX_WITH_RATIONALPARAM
555 SoPlex::Settings::RationalParam::RationalParam() {}
556 #endif
557 
559 {
560  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
562 
563  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
565 
566  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
568 
569 #ifdef SOPLEX_WITH_RATIONALPARAM
570 
571  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
572  _rationalParamValues[i] = rationalParam.defaultValue[i];
573 
574 #endif
575 }
576 
578 {
579  *this = settings;
580 }
581 
583 {
584  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
585  _boolParamValues[i] = settings._boolParamValues[i];
586 
587  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
588  _intParamValues[i] = settings._intParamValues[i];
589 
590  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
591  _realParamValues[i] = settings._realParamValues[i];
592 
593 #ifdef SOPLEX_WITH_RATIONALPARAM
594 
595  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
596  _rationalParamValues[i] = settings._rationalParamValues[i];
597 
598 #endif
599 
600  return *this;
601 }
602 
606 #ifdef SOPLEX_WITH_RATIONALPARAM
607 SoPlex::Settings::RationalParam SoPlex::Settings::rationalParam;
608 #endif
609 
610 /// default constructor
612  : _statistics(0)
613  , _currentSettings(0)
614  , _scalerUniequi(false)
615  , _scalerBiequi(true)
616  , _scalerGeo1(false, 1)
617  , _scalerGeo8(false, 8)
618  , _scalerGeoequi(true)
619  , _scalerLeastsq()
620  , _simplifier(0)
621  , _scaler(0)
622  , _starter(0)
623  , _rationalLP(0)
625  , _status(SPxSolver::UNKNOWN)
626  , _hasBasis(false)
627  , _hasSolReal(false)
628  , _hasSolRational(false)
629  , _rationalPosone(1)
630  , _rationalNegone(-1)
631  , _rationalZero(0)
632 {
633  // transfer message handler
641 
642  // give lu factorization to solver
644 
645  // the real LP is initially stored in the solver; the rational LP is constructed, when the parameter SYNCMODE is
646  // initialized in setSettings() below
647  _realLP = &_solver;
648  _isRealLPLoaded = true;
649  _isRealLPScaled = false;
650  _applyPolishing = false;
651  _optimizeCalls = 0;
652  _unscaleCalls = 0;
655 
656  // initialize statistics
659 
660  // initialize parameter settings to default
664 
666 
667  assert(_isConsistent());
668 }
669 
670 
671 
672 /// assignment operator
674 {
675  if(this != &rhs)
676  {
677  // copy message handler
678  spxout = rhs.spxout;
679 
680  // copy statistics
681  *_statistics = *(rhs._statistics);
682 
683  // copy settings
685 
686  // copy solver components
687  _solver = rhs._solver;
688  _slufactor = rhs._slufactor;
692  _scalerGeo1 = rhs._scalerGeo1;
693  _scalerGeo8 = rhs._scalerGeo8;
697  _starterSum = rhs._starterSum;
699  _pricerAuto = rhs._pricerAuto;
709 
710  // copy solution data
711  _status = rhs._status;
715 
716  if(rhs._hasSolReal)
717  _solReal = rhs._solReal;
718 
719  if(rhs._hasSolRational)
721 
722  // set message handlers in members
730 
731  // transfer the lu solver
733 
734  // initialize pointers for simplifier, scaler, and starter
738 
739  // copy real LP if different from the LP in the solver
740  if(rhs._realLP != &(rhs._solver))
741  {
742  _realLP = 0;
744  _realLP = new(_realLP) SPxLPReal(*(rhs._realLP));
745  }
746  else
747  _realLP = &_solver;
748 
749  // copy rational LP
750  if(rhs._rationalLP == 0)
751  {
753  _rationalLP = 0;
754  }
755  else
756  {
758  _rationalLP = 0;
761  }
762 
763  // copy rational factorization
766 
767  // copy boolean flags
770  _hasSolReal = rhs._hasSolReal;
772  _hasBasis = rhs._hasBasis;
774 
775  // rational constants do not need to be assigned
776  _rationalPosone = 1;
777  _rationalNegone = -1;
778  _rationalZero = 0;
779  }
780 
781  assert(_isConsistent());
782 
783  return *this;
784 }
785 
786 
787 
788 /// copy constructor
789 ///@todo improve performance by implementing a separate copy constructor
791 {
792  // allocate memory as in default constructor
793  _statistics = 0;
796 
797  _currentSettings = 0;
800 
801  // call assignment operator
802  *this = rhs;
803 }
804 
805 
806 
807 /// destructor
809 {
810  assert(_isConsistent());
811 
812  // free settings
813  _currentSettings->~Settings();
815 
816  // free statistics
819 
820  // free real LP if different from the LP in the solver
821  assert(_realLP != 0);
822 
823  if(_realLP != &_solver)
824  {
825  _realLP->~SPxLPReal();
826  spx_free(_realLP);
827  }
828 
829  // free rational LP
830  if(_rationalLP != 0)
831  {
832  _rationalLP->~SPxLPRational();
834  }
835 
836  // free unit vectors
837  for(int i = 0; i < _unitMatrixRational.size(); i++)
838  {
839  if(_unitMatrixRational[i] != 0)
840  {
841  _unitMatrixRational[i]->~UnitVectorRational();
843  }
844  }
845 }
846 
847 
848 
849 /// returns number of rows
851 {
852  assert(_realLP != 0);
853  return _realLP->nRows();
854 }
855 
856 
857 
858 /// returns number of columns
860 {
861  assert(_realLP != 0);
862  return _realLP->nCols();
863 }
864 
865 
866 
867 /// returns number of nonzeros
869 {
870  assert(_realLP != 0);
871  return _realLP->nNzos();
872 }
873 
874 
875 
876 /// returns smallest non-zero element in absolute value
878 {
879  assert(_realLP != 0);
880  return _realLP->minAbsNzo();
881 }
882 
883 
884 
885 /// returns biggest non-zero element in absolute value
887 {
888  assert(_realLP != 0);
889  return _realLP->maxAbsNzo();
890 }
891 
892 
893 
894 /// returns (unscaled) coefficient
895 Real SoPlex::coefReal(int row, int col) const
896 {
897  if(_realLP->isScaled())
898  {
899  assert(_scaler);
900  return _scaler->getCoefUnscaled(*_realLP, row, col);
901  }
902  else
903  return colVectorRealInternal(col)[row];
904 }
905 
906 
907 
908 /// returns vector of row \p i, ignoring scaling
910 {
911  assert(_realLP != 0);
912  return _realLP->rowVector(i);
913 }
914 
915 
916 
917 /// gets vector of row \p i
918 void SoPlex::getRowVectorReal(int i, DSVectorReal& row) const
919 {
920  assert(_realLP);
921 
922  if(_realLP->isScaled())
923  {
924  assert(_scaler);
925  row.setMax(_realLP->rowVector(i).size());
926  _scaler->getRowUnscaled(*_realLP, i, row);
927  }
928  else
929  row = _realLP->rowVector(i);
930 }
931 
932 
933 
934 /// returns right-hand side vector, ignoring scaling
936 {
937  assert(_realLP != 0);
938  return _realLP->rhs();
939 }
940 
941 
942 
943 /// gets right-hand side vector
945 {
946  assert(_realLP);
947  _realLP->getRhsUnscaled(rhs);
948 }
949 
950 
951 
952 /// returns right-hand side of row \p i
953 Real SoPlex::rhsReal(int i) const
954 {
955  assert(_realLP != 0);
956  return _realLP->rhsUnscaled(i);
957 }
958 
959 
960 
961 /// returns left-hand side vector, ignoring scaling
963 {
964  assert(_realLP != 0);
965  return _realLP->lhs();
966 }
967 
968 
969 
970 /// gets left-hand side vector
972 {
973  assert(_realLP);
974  _realLP->getLhsUnscaled(lhs);
975 }
976 
977 
978 
979 /// returns left-hand side of row \p i
980 Real SoPlex::lhsReal(int i) const
981 {
982  assert(_realLP != 0);
983  return _realLP->lhsUnscaled(i);
984 }
985 
986 
987 
988 /// returns inequality type of row \p i
990 {
991  assert(_realLP != 0);
992  return _realLP->rowType(i);
993 }
994 
995 
996 
997 /// returns vector of col \p i, ignoring scaling
999 {
1000  assert(_realLP != 0);
1001  return _realLP->colVector(i);
1002 }
1003 
1004 
1005 
1006 /// gets vector of col \p i
1008 {
1009  assert(_realLP);
1010  _realLP->getColVectorUnscaled(i, col);
1011 }
1012 
1013 
1014 
1015 /// returns upper bound vector
1017 {
1018  assert(_realLP != 0);
1019  return _realLP->upper();
1020 }
1021 
1022 
1023 
1024 /// returns upper bound of column \p i
1026 {
1027  assert(_realLP != 0);
1028  return _realLP->upperUnscaled(i);
1029 }
1030 
1031 
1032 
1033 /// gets upper bound vector
1035 {
1036  assert(_realLP != 0);
1037  return _realLP->getUpperUnscaled(upper);
1038 }
1039 
1040 
1041 
1042 /// returns lower bound vector
1044 {
1045  assert(_realLP != 0);
1046  return _realLP->lower();
1047 }
1048 
1049 
1050 
1051 /// returns lower bound of column \p i
1053 {
1054  assert(_realLP != 0);
1055  return _realLP->lowerUnscaled(i);
1056 }
1057 
1058 
1059 
1060 /// gets lower bound vector
1062 {
1063  assert(_realLP != 0);
1064  return _realLP->getLowerUnscaled(lower);
1065 }
1066 
1067 
1068 
1069 
1070 /// gets objective function vector
1072 {
1073  assert(_realLP != 0);
1074  _realLP->getObjUnscaled(obj);
1075 }
1076 
1077 
1078 
1079 /// returns objective value of column \p i
1080 Real SoPlex::objReal(int i) const
1081 {
1082  assert(_realLP != 0);
1083  return _realLP->objUnscaled(i);
1084 }
1085 
1086 
1087 
1088 /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
1089 /// internally, this is generally faster
1091 {
1092  assert(_realLP != 0);
1093  return _realLP->maxObj();
1094 }
1095 
1096 
1097 
1098 /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
1099 /// stored internally, this is generally faster
1101 {
1102  assert(_realLP != 0);
1103  return _realLP->maxObjUnscaled(i);
1104 }
1105 
1106 
1107 
1108 /// gets number of available dual norms
1109 void SoPlex::getNdualNorms(int& nnormsRow, int& nnormsCol) const
1110 {
1111  _solver.getNdualNorms(nnormsRow, nnormsCol);
1112 }
1113 
1114 
1115 
1116 /// gets steepest edge norms and returns false if they are not available
1117 bool SoPlex::getDualNorms(int& nnormsRow, int& nnormsCol, Real* norms) const
1118 {
1119  return _solver.getDualNorms(nnormsRow, nnormsCol, norms);
1120 }
1121 
1122 
1123 
1124 /// sets steepest edge norms and returns false if that's not possible
1125 bool SoPlex::setDualNorms(int nnormsRow, int nnormsCol, Real* norms)
1126 {
1127  return _solver.setDualNorms(nnormsRow, nnormsCol, norms);
1128 }
1129 
1130 
1131 
1132 /// pass integrality information about the variables to the solver
1133 void SoPlex::setIntegralityInformation(int ncols, int* intInfo)
1134 {
1135  assert(ncols == _solver.nCols() || (ncols == 0 && intInfo == NULL));
1136  _solver.setIntegralityInformation(ncols, intInfo);
1137 }
1138 
1139 
1140 
1141 /// returns number of rows
1143 {
1144  assert(_rationalLP != 0);
1145  return _rationalLP->nRows();
1146 }
1147 
1148 
1149 
1150 /// returns number of columns
1152 {
1153  assert(_rationalLP != 0);
1154  return _rationalLP->nCols();
1155 }
1156 
1157 
1158 
1159 /// returns number of nonzeros
1161 {
1162  assert(_rationalLP != 0);
1163  return _rationalLP->nNzos();
1164 }
1165 
1166 
1167 
1168 /// returns smallest non-zero element in absolute value
1170 {
1171  assert(_rationalLP != 0);
1172  return _rationalLP->minAbsNzo();
1173 }
1174 
1175 
1176 
1177 /// returns biggest non-zero element in absolute value
1179 {
1180  assert(_rationalLP != 0);
1181  return _rationalLP->maxAbsNzo();
1182 }
1183 
1184 
1185 
1186 /// gets row \p i
1187 void SoPlex::getRowRational(int i, LPRowRational& lprow) const
1188 {
1189  assert(_rationalLP != 0);
1190  _rationalLP->getRow(i, lprow);
1191 }
1192 
1193 
1194 
1195 /// gets rows \p start, ..., \p end.
1196 void SoPlex::getRowsRational(int start, int end, LPRowSetRational& lprowset) const
1197 {
1198  assert(_rationalLP != 0);
1199  _rationalLP->getRows(start, end, lprowset);
1200 }
1201 
1202 
1203 
1204 /// returns vector of row \p i
1206 {
1207  assert(_rationalLP != 0);
1208  return _rationalLP->rowVector(i);
1209 }
1210 
1211 
1212 
1213 /// returns right-hand side vector
1215 {
1216  assert(_rationalLP != 0);
1217  return _rationalLP->rhs();
1218 }
1219 
1220 
1221 
1222 /// returns right-hand side of row \p i
1223 const Rational& SoPlex::rhsRational(int i) const
1224 {
1225  assert(_rationalLP != 0);
1226  return _rationalLP->rhs(i);
1227 }
1228 
1229 
1230 
1231 /// returns left-hand side vector
1233 {
1234  assert(_rationalLP != 0);
1235  return _rationalLP->lhs();
1236 }
1237 
1238 
1239 
1240 /// returns left-hand side of row \p i
1241 const Rational& SoPlex::lhsRational(int i) const
1242 {
1243  assert(_rationalLP != 0);
1244  return _rationalLP->lhs(i);
1245 }
1246 
1247 
1248 
1249 /// returns inequality type of row \p i
1251 {
1252  assert(_rationalLP != 0);
1253  return _rationalLP->rowType(i);
1254 }
1255 
1256 
1257 
1258 /// gets column \p i
1259 void SoPlex::getColRational(int i, LPColRational& lpcol) const
1260 {
1261  assert(_rationalLP != 0);
1262  return _rationalLP->getCol(i, lpcol);
1263 }
1264 
1265 
1266 
1267 /// gets columns \p start, ..., \p end
1268 void SoPlex::getColsRational(int start, int end, LPColSetRational& lpcolset) const
1269 {
1270  assert(_rationalLP != 0);
1271  return _rationalLP->getCols(start, end, lpcolset);
1272 }
1273 
1274 
1275 
1276 /// returns vector of column \p i
1278 {
1279  assert(_rationalLP != 0);
1280  return _rationalLP->colVector(i);
1281 }
1282 
1283 
1284 
1285 /// returns upper bound vector
1287 {
1288  assert(_rationalLP != 0);
1289  return _rationalLP->upper();
1290 }
1291 
1292 
1293 
1294 /// returns upper bound of column \p i
1295 const Rational& SoPlex::upperRational(int i) const
1296 {
1297  assert(_rationalLP != 0);
1298  return _rationalLP->upper(i);
1299 }
1300 
1301 
1302 
1303 /// returns lower bound vector
1305 {
1306  assert(_rationalLP != 0);
1307  return _rationalLP->lower();
1308 }
1309 
1310 
1311 
1312 /// returns lower bound of column \p i
1313 const Rational& SoPlex::lowerRational(int i) const
1314 {
1315  assert(_rationalLP != 0);
1316  return _rationalLP->lower(i);
1317 }
1318 
1319 
1320 
1321 /// gets objective function vector
1323 {
1324  assert(_rationalLP != 0);
1325  _rationalLP->getObj(obj);
1326 }
1327 
1328 
1329 
1330 /// gets objective value of column \p i
1331 void SoPlex::getObjRational(int i, Rational& obj) const
1332 {
1333  obj = maxObjRational(i);
1334 
1336  obj *= -1;
1337 }
1338 
1339 
1340 
1341 /// returns objective value of column \p i
1343 {
1344  assert(_rationalLP != 0);
1345  return _rationalLP->obj(i);
1346 }
1347 
1348 
1349 
1350 /// returns objective function vector after transformation to a maximization problem; since this is how it is stored
1351 /// internally, this is generally faster
1353 {
1354  assert(_rationalLP != 0);
1355  return _rationalLP->maxObj();
1356 }
1357 
1358 
1359 
1360 /// returns objective value of column \p i after transformation to a maximization problem; since this is how it is
1361 /// stored internally, this is generally faster
1363 {
1364  assert(_rationalLP != 0);
1365  return _rationalLP->maxObj(i);
1366 }
1367 
1368 
1369 
1370 /// adds a single row
1371 void SoPlex::addRowReal(const LPRowReal& lprow)
1372 {
1373  assert(_realLP != 0);
1374 
1375  _addRowReal(lprow);
1376 
1378  {
1379  _rationalLP->addRow(lprow);
1381  }
1382 
1384 }
1385 
1386 
1387 
1388 /// adds multiple rows
1389 void SoPlex::addRowsReal(const LPRowSetReal& lprowset)
1390 {
1391  assert(_realLP != 0);
1392 
1393  _addRowsReal(lprowset);
1394 
1396  {
1397  _rationalLP->addRows(lprowset);
1399  }
1400 
1402 }
1403 
1404 
1405 
1406 /// adds a single column
1407 void SoPlex::addColReal(const LPColReal& lpcol)
1408 {
1409  assert(_realLP != 0);
1410 
1411  _addColReal(lpcol);
1412 
1414  {
1415  _rationalLP->addCol(lpcol);
1417  }
1418 
1420 }
1421 
1422 
1423 
1424 /// adds multiple columns
1425 void SoPlex::addColsReal(const LPColSetReal& lpcolset)
1426 {
1427  assert(_realLP != 0);
1428 
1429  _addColsReal(lpcolset);
1430 
1432  {
1433  _rationalLP->addCols(lpcolset);
1435  }
1436 
1438 }
1439 
1440 
1441 
1442 /// replaces row \p i with \p lprow
1443 void SoPlex::changeRowReal(int i, const LPRowReal& lprow)
1444 {
1445  assert(_realLP != 0);
1446 
1447  _changeRowReal(i, lprow);
1448 
1450  {
1451  _rationalLP->changeRow(i, lprow);
1452  _rowTypes[i] = _rangeTypeReal(lprow.lhs(), lprow.rhs());
1454  }
1455 
1457 }
1458 
1459 
1460 
1461 /// changes left-hand side vector for constraints to \p lhs
1463 {
1464  assert(_realLP != 0);
1465 
1466  _changeLhsReal(lhs);
1467 
1469  {
1471 
1472  for(int i = 0; i < numRowsRational(); i++)
1474  }
1475 
1477 }
1478 
1479 
1480 
1481 /// changes left-hand side of row \p i to \p lhs
1482 void SoPlex::changeLhsReal(int i, const Real& lhs)
1483 {
1484  assert(_realLP != 0);
1485 
1486  _changeLhsReal(i, lhs);
1487 
1489  {
1490  _rationalLP->changeLhs(i, lhs);
1492  }
1493 
1495 }
1496 
1497 
1498 
1499 /// changes right-hand side vector to \p rhs
1501 {
1502  assert(_realLP != 0);
1503 
1504  _changeRhsReal(rhs);
1505 
1507  {
1509 
1510  for(int i = 0; i < numRowsRational(); i++)
1512  }
1513 
1515 }
1516 
1517 
1518 
1519 /// changes right-hand side of row \p i to \p rhs
1520 void SoPlex::changeRhsReal(int i, const Real& rhs)
1521 {
1522  assert(_realLP != 0);
1523 
1524  _changeRhsReal(i, rhs);
1525 
1527  {
1528  _rationalLP->changeRhs(i, rhs);
1530  }
1531 
1533 }
1534 
1535 
1536 
1537 /// changes left- and right-hand side vectors
1538 void SoPlex::changeRangeReal(const VectorReal& lhs, const VectorReal& rhs)
1539 {
1540  assert(_realLP != 0);
1541 
1542  _changeRangeReal(lhs, rhs);
1543 
1545  {
1547 
1548  for(int i = 0; i < numRowsRational(); i++)
1549  _rowTypes[i] = _rangeTypeReal(lhs[i], rhs[i]);
1550  }
1551 
1553 }
1554 
1555 
1556 
1557 /// changes left- and right-hand side of row \p i
1558 void SoPlex::changeRangeReal(int i, const Real& lhs, const Real& rhs)
1559 {
1560  assert(_realLP != 0);
1561 
1562  _changeRangeReal(i, lhs, rhs);
1563 
1565  {
1566  _rationalLP->changeRange(i, lhs, rhs);
1567  _rowTypes[i] = _rangeTypeReal(lhs, rhs);
1568  }
1569 
1571 }
1572 
1573 
1574 
1575 /// replaces column \p i with \p lpcol
1576 void SoPlex::changeColReal(int i, const LPColReal& lpcol)
1577 {
1578  assert(_realLP != 0);
1579 
1580  _changeColReal(i, lpcol);
1581 
1583  {
1584  _rationalLP->changeCol(i, lpcol);
1585  _colTypes[i] = _rangeTypeReal(lpcol.lower(), lpcol.upper());
1587  }
1588 
1590 }
1591 
1592 
1593 
1594 /// changes vector of lower bounds to \p lower
1596 {
1597  assert(_realLP != 0);
1598 
1599  _changeLowerReal(lower);
1600 
1602  {
1604 
1605  for(int i = 0; i < numColsRational(); i++)
1607  }
1608 
1609 
1611 }
1612 
1613 
1614 
1615 /// changes lower bound of column i to \p lower
1616 void SoPlex::changeLowerReal(int i, const Real& lower)
1617 {
1618  assert(_realLP != 0);
1619 
1620  _changeLowerReal(i, lower);
1621 
1623  {
1624  _rationalLP->changeLower(i, lower);
1626  }
1627 
1629 }
1630 
1631 
1632 
1633 /// changes vector of upper bounds to \p upper
1635 {
1636  assert(_realLP != 0);
1637 
1638  _changeUpperReal(upper);
1639 
1641  {
1643 
1644  for(int i = 0; i < numColsRational(); i++)
1646  }
1647 
1649 }
1650 
1651 
1652 
1653 /// changes \p i 'th upper bound to \p upper
1654 void SoPlex::changeUpperReal(int i, const Real& upper)
1655 {
1656  assert(_realLP != 0);
1657 
1658  _changeUpperReal(i, upper);
1659 
1661  {
1662  _rationalLP->changeUpper(i, upper);
1664  }
1665 
1667 }
1668 
1669 
1670 
1671 /// changes vectors of column bounds to \p lower and \p upper
1672 void SoPlex::changeBoundsReal(const VectorReal& lower, const VectorReal& upper)
1673 {
1674  assert(_realLP != 0);
1675 
1676  _changeBoundsReal(lower, upper);
1677 
1679  {
1681 
1682  for(int i = 0; i < numColsRational(); i++)
1683  _colTypes[i] = _rangeTypeReal(lower[i], upper[i]);
1684  }
1685 
1687 }
1688 
1689 
1690 
1691 /// changes bounds of column \p i to \p lower and \p upper
1692 void SoPlex::changeBoundsReal(int i, const Real& lower, const Real& upper)
1693 {
1694  assert(_realLP != 0);
1695 
1696  _changeBoundsReal(i, lower, upper);
1697 
1699  {
1700  _rationalLP->changeBounds(i, lower, upper);
1701  _colTypes[i] = _rangeTypeReal(lower, upper);
1702  }
1703 
1705 }
1706 
1707 
1708 
1709 /// changes objective function vector to \p obj
1711 {
1712  assert(_realLP != 0);
1713 
1714  bool scale = _realLP->isScaled();
1715  _realLP->changeObj(obj, scale);
1716 
1719 
1721 }
1722 
1723 
1724 
1725 /// changes objective coefficient of column i to \p obj
1726 void SoPlex::changeObjReal(int i, const Real& obj)
1727 {
1728  assert(_realLP != 0);
1729 
1730  bool scale = _realLP->isScaled();
1731  _realLP->changeObj(i, obj, scale);
1732 
1734  _rationalLP->changeObj(i, obj);
1735 
1737 }
1738 
1739 
1740 
1741 /// changes matrix entry in row \p i and column \p j to \p val
1742 void SoPlex::changeElementReal(int i, int j, const Real& val)
1743 {
1744  assert(_realLP != 0);
1745 
1746  _changeElementReal(i, j, val);
1747 
1749  _rationalLP->changeElement(i, j, val);
1750 
1752 }
1753 
1754 
1755 
1756 /// removes row \p i
1758 {
1759  assert(_realLP != 0);
1760 
1761  _removeRowReal(i);
1762 
1764  {
1765  _rationalLP->removeRow(i);
1766 
1767  // only swap elements if not the last one was removed
1768  if(i < _rationalLP->nRows())
1769  {
1771  assert(_rowTypes[i] == _rangeTypeRational(lhsRational(i), rhsRational(i)));
1772  }
1773 
1775  }
1776 
1778 }
1779 
1780 
1781 
1782 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
1783 /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
1784 /// #numRowsReal()
1785 void SoPlex::removeRowsReal(int perm[])
1786 {
1787  assert(_realLP != 0);
1788 
1789  const int oldsize = numRowsReal();
1790  _removeRowsReal(perm);
1791 
1793  {
1794  _rationalLP->removeRows(perm);
1795 
1796  for(int i = 0; i < oldsize; i++)
1797  {
1798  if(perm[i] >= 0)
1799  _rowTypes[perm[i]] = _rowTypes[i];
1800  }
1801 
1803 
1804  for(int i = 0; i < numRowsRational(); i++)
1805  {
1806  assert(_rowTypes[i] == _rangeTypeRational(lhsRational(i), rhsRational(i)));
1807  }
1808  }
1809 
1811 }
1812 
1813 
1814 
1815 /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsReal() may be passed
1816 /// as buffer memory
1817 void SoPlex::removeRowsReal(int idx[], int n, int perm[])
1818 {
1819  if(perm == 0)
1820  {
1822  _idxToPerm(idx, n, p.get_ptr(), numRowsReal());
1824  }
1825  else
1826  {
1827  _idxToPerm(idx, n, perm, numRowsReal());
1828  SoPlex::removeRowsReal(perm);
1829  }
1830 }
1831 
1832 
1833 
1834 /// removes rows \p start to \p end including both; an array \p perm of size #numRowsReal() may be passed as buffer
1835 /// memory
1836 void SoPlex::removeRowRangeReal(int start, int end, int perm[])
1837 {
1838  if(perm == 0)
1839  {
1841  _rangeToPerm(start, end, p.get_ptr(), numRowsReal());
1843  }
1844  else
1845  {
1846  _rangeToPerm(start, end, perm, numRowsReal());
1847  SoPlex::removeRowsReal(perm);
1848  }
1849 }
1850 
1851 
1852 
1853 /// removes column i
1855 {
1856  assert(_realLP != 0);
1857 
1858  _removeColReal(i);
1859 
1861  {
1862  _rationalLP->removeCol(i);
1863 
1864  // only swap elements if not the last one was removed
1865  if(i < _rationalLP->nCols())
1866  {
1869  }
1870 
1872  }
1873 
1875 }
1876 
1877 
1878 
1879 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
1880 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
1881 /// #numColsReal()
1882 void SoPlex::removeColsReal(int perm[])
1883 {
1884  assert(_realLP != 0);
1885 
1886  const int oldsize = numColsReal();
1887  _removeColsReal(perm);
1888 
1890  {
1891  _rationalLP->removeCols(perm);
1892 
1893  for(int i = 0; i < oldsize; i++)
1894  {
1895  if(perm[i] >= 0)
1896  _colTypes[perm[i]] = _colTypes[i];
1897  }
1898 
1900 
1901  for(int i = 0; i < numColsRational(); i++)
1902  {
1904  }
1905  }
1906 
1908 }
1909 
1910 
1911 
1912 /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsReal() may be
1913 /// passed as buffer memory
1914 void SoPlex::removeColsReal(int idx[], int n, int perm[])
1915 {
1916  if(perm == 0)
1917  {
1919  _idxToPerm(idx, n, p.get_ptr(), numColsReal());
1921  }
1922  else
1923  {
1924  _idxToPerm(idx, n, perm, numColsReal());
1925  SoPlex::removeColsReal(perm);
1926  }
1927 }
1928 
1929 
1930 
1931 /// removes columns \p start to \p end including both; an array \p perm of size #numColsReal() may be passed as
1932 /// buffer memory
1933 void SoPlex::removeColRangeReal(int start, int end, int perm[])
1934 {
1935  if(perm == 0)
1936  {
1938  _rangeToPerm(start, end, p.get_ptr(), numColsReal());
1940  }
1941  else
1942  {
1943  _rangeToPerm(start, end, perm, numColsReal());
1944  SoPlex::removeColsReal(perm);
1945  }
1946 }
1947 
1948 
1949 
1950 /// clears the LP
1952 {
1953  assert(_realLP != 0);
1954 
1955  _realLP->clear();
1956  _hasBasis = false;
1958 
1960  {
1961  _rationalLP->clear();
1962  _rowTypes.clear();
1963  _colTypes.clear();
1964  }
1965 
1967 }
1968 
1969 
1970 
1971 /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, if sync mode is manual
1973 {
1974  assert(_isConsistent());
1975 
1977  _syncLPReal();
1978 }
1979 
1980 
1981 
1982 /// adds a single row
1984 {
1985  assert(_rationalLP != 0);
1986 
1988  return;
1989 
1990  _rationalLP->addRow(lprow);
1992 
1994  _addRowReal(lprow);
1995 
1997 }
1998 
1999 
2000 
2001 #ifdef SOPLEX_WITH_GMP
2002 /// adds a single row (GMP only method)
2003 void SoPlex::addRowRational(const mpq_t* lhs, const mpq_t* rowValues, const int* rowIndices,
2004  const int rowSize, const mpq_t* rhs)
2005 {
2006  assert(_rationalLP != 0);
2007 
2009  return;
2010 
2011  _rationalLP->addRow(lhs, rowValues, rowIndices, rowSize, rhs);
2013 
2014  int i = numRowsRational() - 1;
2015 
2018 
2020 }
2021 
2022 
2023 
2024 /// adds a set of rows
2025 void SoPlex::addRowsRational(const mpq_t* lhs, const mpq_t* rowValues, const int* rowIndices,
2026  const int* rowStarts, const int* rowLengths, const int numRows, const int numValues,
2027  const mpq_t* rhs)
2028 {
2029  assert(_rationalLP != 0);
2030 
2032  return;
2033 
2034  _rationalLP->addRows(lhs, rowValues, rowIndices, rowStarts, rowLengths, numRows, numValues, rhs);
2036 
2038  {
2039  LPRowSetReal lprowset;
2040 
2041  for(int i = numRowsRational() - numRows; i < numRowsRational(); i++)
2043 
2044  _addRowsReal(lprowset);
2045  }
2046 
2048 }
2049 #endif
2050 
2051 
2052 
2053 /// adds multiple rows
2055 {
2056  assert(_rationalLP != 0);
2057 
2059  return;
2060 
2061  _rationalLP->addRows(lprowset);
2063 
2065  _addRowsReal(lprowset);
2066 
2068 }
2069 
2070 
2071 
2072 /// adds a single column
2074 {
2075  assert(_rationalLP != 0);
2076 
2078  return;
2079 
2080  _rationalLP->addCol(lpcol);
2082 
2084  _addColReal(lpcol);
2085 
2087 }
2088 
2089 
2090 
2091 #ifdef SOPLEX_WITH_GMP
2092 /// adds a single column (GMP only method)
2093 void SoPlex::addColRational(const mpq_t* obj, const mpq_t* lower, const mpq_t* colValues,
2094  const int* colIndices, const int colSize, const mpq_t* upper)
2095 {
2096  assert(_rationalLP != 0);
2097 
2099  return;
2100 
2101  _rationalLP->addCol(obj, lower, colValues, colIndices, colSize, upper);
2102  int i = numColsRational() - 1;
2104 
2107  1.0 : -1.0),
2109 
2111 }
2112 
2113 
2114 
2115 /// adds a set of columns
2116 void SoPlex::addColsRational(const mpq_t* obj, const mpq_t* lower, const mpq_t* colValues,
2117  const int* colIndices, const int* colStarts, const int* colLengths, const int numCols,
2118  const int numValues, const mpq_t* upper)
2119 {
2120  assert(_rationalLP != 0);
2121 
2123  return;
2124 
2125  _rationalLP->addCols(obj, lower, colValues, colIndices, colStarts, colLengths, numCols, numValues,
2126  upper);
2128 
2130  {
2131  LPColSetReal lpcolset;
2132 
2133  for(int i = numColsRational() - numCols; i < numColsRational(); i++)
2135  1.0 : -1.0),
2137 
2138  _addColsReal(lpcolset);
2139  }
2140 
2142 }
2143 #endif
2144 
2145 
2146 
2147 /// adds multiple columns
2149 {
2150  assert(_rationalLP != 0);
2151 
2153  return;
2154 
2155  _rationalLP->addCols(lpcolset);
2157 
2159  _addColsReal(lpcolset);
2160 
2162 }
2163 
2164 
2165 
2166 /// replaces row \p i with \p lprow
2167 void SoPlex::changeRowRational(int i, const LPRowRational& lprow)
2168 {
2169  assert(_rationalLP != 0);
2170 
2172  return;
2173 
2174  _rationalLP->changeRow(i, lprow);
2175  _rowTypes[i] = _rangeTypeRational(lprow.lhs(), lprow.rhs());
2177 
2179  _changeRowReal(i, lprow);
2180 
2182 }
2183 
2184 
2185 
2186 /// changes left-hand side vector for constraints to \p lhs
2188 {
2189  assert(_rationalLP != 0);
2190 
2192  return;
2193 
2194  _rationalLP->changeLhs(lhs);
2195 
2196  for(int i = 0; i < numRowsRational(); i++)
2197  _rowTypes[i] = _rangeTypeRational(lhs[i], _rationalLP->rhs(i));
2198 
2201 
2203 }
2204 
2205 
2206 
2207 /// changes left-hand side of row \p i to \p lhs
2208 void SoPlex::changeLhsRational(int i, const Rational& lhs)
2209 {
2210  assert(_rationalLP != 0);
2211 
2213  return;
2214 
2215  _rationalLP->changeLhs(i, lhs);
2217 
2219  _changeLhsReal(i, Real(lhs));
2220 
2222 }
2223 
2224 
2225 
2226 #ifdef SOPLEX_WITH_GMP
2227 /// changes left-hand side of row \p i to \p lhs (GMP only method)
2228 void SoPlex::changeLhsRational(int i, const mpq_t* lhs)
2229 {
2230  assert(_rationalLP != 0);
2231 
2233  return;
2234 
2235  _rationalLP->changeLhs(i, lhs);
2237 
2240 
2242 }
2243 #endif
2244 
2245 
2246 
2247 /// changes right-hand side vector to \p rhs
2249 {
2250  assert(_rationalLP != 0);
2251 
2253  return;
2254 
2255  _rationalLP->changeRhs(rhs);
2256 
2257  for(int i = 0; i < numRowsRational(); i++)
2258  _rowTypes[i] = _rangeTypeRational(_rationalLP->lhs(i), rhs[i]);
2259 
2262 
2264 }
2265 
2266 
2267 
2268 #ifdef SOPLEX_WITH_GMP
2269 /// changes right-hand side vector to \p rhs (GMP only method)
2270 void SoPlex::changeRhsRational(const mpq_t* rhs, int rhsSize)
2271 {
2272  assert(_rationalLP != 0);
2273 
2275  return;
2276 
2277  for(int i = 0; i < rhsSize; i++)
2278  {
2279  _rationalLP->changeRhs(i, rhs[i]);
2281  }
2282 
2285 
2287 }
2288 #endif
2289 
2290 
2291 
2292 /// changes right-hand side of row \p i to \p rhs
2293 void SoPlex::changeRhsRational(int i, const Rational& rhs)
2294 {
2295  assert(_rationalLP != 0);
2296 
2298  return;
2299 
2300  _rationalLP->changeRhs(i, rhs);
2302 
2304  _changeRhsReal(i, Real(rhs));
2305 
2307 }
2308 
2309 
2310 
2311 /// changes left- and right-hand side vectors
2313 {
2314  assert(_rationalLP != 0);
2315 
2317  return;
2318 
2319  _rationalLP->changeRange(lhs, rhs);
2320 
2321  for(int i = 0; i < numRowsRational(); i++)
2322  _rowTypes[i] = _rangeTypeRational(lhs[i], rhs[i]);
2323 
2326 
2328 }
2329 
2330 
2331 
2332 /// changes left- and right-hand side of row \p i
2333 void SoPlex::changeRangeRational(int i, const Rational& lhs, const Rational& rhs)
2334 {
2335  assert(_rationalLP != 0);
2336 
2338  return;
2339 
2340  _rationalLP->changeRange(i, lhs, rhs);
2341  _rowTypes[i] = _rangeTypeRational(lhs, rhs);
2342 
2344  _changeRangeReal(i, Real(lhs), Real(rhs));
2345 
2347 }
2348 
2349 
2350 
2351 #ifdef SOPLEX_WITH_GMP
2352 /// changes left-hand side of row \p i to \p lhs (GMP only method)
2353 void SoPlex::changeRangeRational(int i, const mpq_t* lhs, const mpq_t* rhs)
2354 {
2355  assert(_rationalLP != 0);
2356 
2358  return;
2359 
2360  _rationalLP->changeRange(i, lhs, rhs);
2362 
2365 
2367 }
2368 #endif
2369 
2370 
2371 
2372 /// replaces column \p i with \p lpcol
2373 void SoPlex::changeColRational(int i, const LPColRational& lpcol)
2374 {
2375  assert(_rationalLP != 0);
2376 
2378  return;
2379 
2380  _rationalLP->changeCol(i, lpcol);
2381  _colTypes[i] = _rangeTypeRational(lpcol.lower(), lpcol.upper());
2383 
2385  _changeColReal(i, lpcol);
2386 
2388 }
2389 
2390 
2391 
2392 /// changes vector of lower bounds to \p lower
2394 {
2395  assert(_rationalLP != 0);
2396 
2398  return;
2399 
2400  _rationalLP->changeLower(lower);
2401 
2402  for(int i = 0; i < numColsRational(); i++)
2403  _colTypes[i] = _rangeTypeRational(lower[i], _rationalLP->upper(i));
2404 
2406  _changeLowerReal(DVectorReal(lower));
2407 
2409 }
2410 
2411 
2412 
2413 /// changes lower bound of column i to \p lower
2414 void SoPlex::changeLowerRational(int i, const Rational& lower)
2415 {
2416  assert(_rationalLP != 0);
2417 
2419  return;
2420 
2421  _rationalLP->changeLower(i, lower);
2422  _colTypes[i] = _rangeTypeRational(lower, _rationalLP->upper(i));
2423 
2425  _changeLowerReal(i, Real(lower));
2426 
2428 }
2429 
2430 
2431 
2432 #ifdef SOPLEX_WITH_GMP
2433 /// changes lower bound of column i to \p lower (GMP only method)
2434 void SoPlex::changeLowerRational(int i, const mpq_t* lower)
2435 {
2436  assert(_rationalLP != 0);
2437 
2439  return;
2440 
2441  _rationalLP->changeLower(i, lower);
2443 
2446 
2448 }
2449 #endif
2450 
2451 
2452 
2453 /// changes vector of upper bounds to \p upper
2455 {
2456  assert(_rationalLP != 0);
2457 
2459  return;
2460 
2461  _rationalLP->changeUpper(upper);
2462 
2463  for(int i = 0; i < numColsRational(); i++)
2464  _colTypes[i] = _rangeTypeRational(_rationalLP->lower(i), upper[i]);
2465 
2467  _changeUpperReal(DVectorReal(upper));
2468 
2470 }
2471 
2472 
2473 
2474 /// changes \p i 'th upper bound to \p upper
2475 void SoPlex::changeUpperRational(int i, const Rational& upper)
2476 {
2477  assert(_rationalLP != 0);
2478 
2480  return;
2481 
2482  _rationalLP->changeUpper(i, upper);
2483  _colTypes[i] = _rangeTypeRational(_rationalLP->lower(i), upper);
2484 
2486  _changeUpperReal(i, Real(upper));
2487 
2489 }
2490 
2491 
2492 
2493 #ifdef SOPLEX_WITH_GMP
2494 /// changes upper bound of column i to \p upper (GMP only method)
2495 void SoPlex::changeUpperRational(int i, const mpq_t* upper)
2496 {
2497  assert(_rationalLP != 0);
2498 
2500  return;
2501 
2502  _rationalLP->changeUpper(i, upper);
2504 
2507 
2509 }
2510 #endif
2511 
2512 
2513 
2514 /// changes vectors of column bounds to \p lower and \p upper
2516 {
2517  assert(_rationalLP != 0);
2518 
2520  return;
2521 
2522  _rationalLP->changeBounds(lower, upper);
2523 
2524  for(int i = 0; i < numColsRational(); i++)
2525  _colTypes[i] = _rangeTypeRational(lower[i], upper[i]);
2526 
2528  _changeBoundsReal(DVectorReal(lower), DVectorReal(upper));
2529 
2531 }
2532 
2533 
2534 
2535 /// changes bounds of column \p i to \p lower and \p upper
2536 void SoPlex::changeBoundsRational(int i, const Rational& lower, const Rational& upper)
2537 {
2538  assert(_rationalLP != 0);
2539 
2541  return;
2542 
2543  _rationalLP->changeBounds(i, lower, upper);
2544  _colTypes[i] = _rangeTypeRational(lower, upper);
2545 
2547  _changeBoundsReal(i, Real(lower), Real(upper));
2548 
2550 }
2551 
2552 
2553 
2554 #ifdef SOPLEX_WITH_GMP
2555 /// changes bounds of column \p i to \p lower and \p upper (GMP only method)
2556 void SoPlex::changeBoundsRational(int i, const mpq_t* lower, const mpq_t* upper)
2557 {
2558  assert(_rationalLP != 0);
2559 
2561  return;
2562 
2563  _rationalLP->changeBounds(i, lower, upper);
2565 
2568 
2570 }
2571 #endif
2572 
2573 
2574 
2575 /// changes objective function vector to \p obj
2577 {
2578  assert(_rationalLP != 0);
2579 
2581  return;
2582 
2583  _rationalLP->changeObj(obj);
2584 
2586  _realLP->changeObj(DVectorReal(obj));
2587 
2589 }
2590 
2591 
2592 
2593 /// changes objective coefficient of column i to \p obj
2594 void SoPlex::changeObjRational(int i, const Rational& obj)
2595 {
2596  assert(_rationalLP != 0);
2597 
2599  return;
2600 
2601  _rationalLP->changeObj(i, obj);
2602 
2604  _realLP->changeObj(i, Real(obj));
2605 
2607 }
2608 
2609 
2610 
2611 #ifdef SOPLEX_WITH_GMP
2612 /// changes objective coefficient of column i to \p obj (GMP only method)
2613 void SoPlex::changeObjRational(int i, const mpq_t* obj)
2614 {
2615  assert(_rationalLP != 0);
2616 
2618  return;
2619 
2620  _rationalLP->changeObj(i, obj);
2621 
2623  _realLP->changeObj(i, Real(objRational(i)));
2624 
2626 }
2627 #endif
2628 
2629 
2630 
2631 /// changes matrix entry in row \p i and column \p j to \p val
2632 void SoPlex::changeElementRational(int i, int j, const Rational& val)
2633 {
2634  assert(_rationalLP != 0);
2635 
2637  return;
2638 
2639  _rationalLP->changeElement(i, j, val);
2640 
2642  _changeElementReal(i, j, Real(val));
2643 
2645 }
2646 
2647 
2648 #ifdef SOPLEX_WITH_GMP
2649 /// changes matrix entry in row \p i and column \p j to \p val (GMP only method)
2650 void SoPlex::changeElementRational(int i, int j, const mpq_t* val)
2651 {
2652  assert(_rationalLP != 0);
2653 
2655  return;
2656 
2657  _rationalLP->changeElement(i, j, val);
2658 
2660  _changeElementReal(i, j, mpq_get_d(*val));
2661 
2663 }
2664 #endif
2665 
2666 
2667 /// removes row \p i
2669 {
2670  assert(_rationalLP != 0);
2671 
2673  return;
2674 
2675  _rationalLP->removeRow(i);
2676 
2677  // only swap elements if not the last one was removed
2678  if(i < _rationalLP->nRows())
2679  {
2681  assert(_rowTypes[i] == _rangeTypeRational(lhsRational(i), rhsRational(i)));
2682  }
2683 
2685 
2687  _removeRowReal(i);
2688 
2690 }
2691 
2692 
2693 
2694 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the new
2695 /// index where row \p i has been moved to; note that \p perm must point to an array of size at least
2696 /// #numRowsRational()
2698 {
2699  assert(_rationalLP != 0);
2700 
2702  return;
2703 
2704  const int oldsize = numRowsRational();
2705  _rationalLP->removeRows(perm);
2706 
2707  for(int i = 0; i < oldsize; i++)
2708  {
2709  if(perm[i] >= 0)
2710  _rowTypes[perm[i]] = _rowTypes[i];
2711  }
2712 
2714 
2715  for(int i = 0; i < numRowsRational(); i++)
2716  {
2717  assert(_rowTypes[i] == _rangeTypeRational(lhsRational(i), rhsRational(i)));
2718  }
2719 
2720 
2722  _removeRowsReal(perm);
2723 
2725 }
2726 
2727 
2728 
2729 /// remove all rows with indices in array \p idx of size \p n; an array \p perm of size #numRowsRational() may be
2730 /// passed as buffer memory
2731 void SoPlex::removeRowsRational(int idx[], int n, int perm[])
2732 {
2733  if(perm == 0)
2734  {
2736  _idxToPerm(idx, n, p.get_ptr(), numRowsRational());
2738  }
2739  else
2740  {
2741  _idxToPerm(idx, n, perm, numRowsRational());
2743  }
2744 }
2745 
2746 
2747 
2748 /// removes rows \p start to \p end including both; an array \p perm of size #numRowsRational() may be passed as
2749 /// buffer memory
2750 void SoPlex::removeRowRangeRational(int start, int end, int perm[])
2751 {
2752  if(perm == 0)
2753  {
2755  _rangeToPerm(start, end, p.get_ptr(), numRowsRational());
2757  }
2758  else
2759  {
2760  _rangeToPerm(start, end, perm, numRowsRational());
2762  }
2763 }
2764 
2765 
2766 
2767 /// removes column i
2769 {
2770  assert(_rationalLP != 0);
2771 
2773  return;
2774 
2775  _rationalLP->removeCol(i);
2776 
2777  // only swap elements if not the last one was removed
2778  if(i < _rationalLP->nCols())
2779  {
2782  }
2783 
2785 
2787  _removeColReal(i);
2788 
2790 }
2791 
2792 
2793 
2794 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
2795 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
2796 /// #numColsRational()
2798 {
2799  assert(_rationalLP != 0);
2800 
2802  return;
2803 
2804  const int oldsize = numColsRational();
2805  _rationalLP->removeCols(perm);
2806 
2807  for(int i = 0; i < oldsize; i++)
2808  {
2809  if(perm[i] >= 0)
2810  _colTypes[perm[i]] = _colTypes[i];
2811  }
2812 
2814 
2815  for(int i = 0; i < numColsRational(); i++)
2816  {
2818  }
2819 
2821  _removeColsReal(perm);
2822 
2824 }
2825 
2826 
2827 
2828 /// remove all columns with indices in array \p idx of size \p n; an array \p perm of size #numColsRational() may be
2829 /// passed as buffer memory
2830 void SoPlex::removeColsRational(int idx[], int n, int perm[])
2831 {
2832  if(perm == 0)
2833  {
2835  _idxToPerm(idx, n, p.get_ptr(), numColsRational());
2837  }
2838  else
2839  {
2840  _idxToPerm(idx, n, perm, numColsRational());
2842  }
2843 }
2844 
2845 
2846 
2847 /// removes columns \p start to \p end including both; an array \p perm of size #numColsRational() may be passed as
2848 /// buffer memory
2849 void SoPlex::removeColRangeRational(int start, int end, int perm[])
2850 {
2851  if(perm == 0)
2852  {
2854  _rangeToPerm(start, end, p.get_ptr(), numColsRational());
2856  }
2857  else
2858  {
2859  _rangeToPerm(start, end, perm, numColsRational());
2861  }
2862 }
2863 
2864 
2865 
2866 /// clears the LP
2868 {
2869  assert(_rationalLP != 0);
2870 
2872  return;
2873 
2874  _rationalLP->clear();
2876  _rowTypes.clear();
2877  _colTypes.clear();
2878 
2880  {
2881  _realLP->clear();
2882  _hasBasis = false;
2883  }
2884 
2886 }
2887 
2888 
2889 
2890 /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, if sync mode is manual
2892 {
2893  assert(_isConsistent());
2894 
2896  _syncLPRational();
2897 }
2898 
2899 
2900 
2901 /// solves the LP
2903 {
2904  assert(_isConsistent());
2905 
2906  // clear statistics
2908 
2909  // the solution is no longer valid
2911 
2912  // if the decomposition based dual simplex flag is set to true
2914  {
2918  //setBoolParam(SoPlex::PERSISTENTSCALING, false);
2919 
2921 
2923  }
2924  // decide whether to solve the rational LP with iterative refinement or call the standard floating-point solver
2927  && GE(realParam(SoPlex::FEASTOL), 1e-9) && GE(realParam(SoPlex::OPTTOL), 1e-9)))
2928  {
2929  // ensure that tolerances are reasonable for the floating-point solver
2931  {
2932  MSG_WARNING(spxout, spxout << "Cannot call floating-point solver with feasibility tolerance below "
2933  << _currentSettings->realParam.lower[SoPlex::FPFEASTOL] << " - relaxing tolerance\n");
2935  }
2936  else
2938 
2940  {
2941  MSG_WARNING(spxout, spxout << "Cannot call floating-point solver with optimality tolerance below "
2942  << _currentSettings->realParam.lower[SoPlex::FPOPTTOL] << " - relaxing tolerance\n");
2944  }
2945  else
2947 
2949 
2950  _optimizeReal();
2951 #ifdef SOPLEX_DEBUG // this check will remove scaling of the realLP
2953 #endif
2954  }
2956  {
2957  _syncLPRational();
2959  }
2961  {
2962 #ifdef ENABLE_ADDITIONAL_CHECKS
2963  assert(areLPsInSync(true, true, false));
2964 #else
2965  assert(areLPsInSync(true, false, false));
2966 #endif
2967 
2969 
2970 #ifdef ENABLE_ADDITIONAL_CHECKS
2971  assert(areLPsInSync(true, true, false));
2972 #else
2973  assert(areLPsInSync(true, false, false));
2974 #endif
2975  }
2976  else
2977  {
2978 #ifdef ENABLE_ADDITIONAL_CHECKS
2979  assert(areLPsInSync(true, true, false));
2980 #else
2981  assert(areLPsInSync(true, false, false));
2982 #endif
2983 
2985  }
2986 
2987  MSG_INFO1(spxout, spxout << "\n";
2989  spxout << "\n");
2990 
2991 
2992  return status();
2993 }
2994 
2995 
2996 
2997 /// returns the current solver status
2999 {
3000  return _status;
3001 }
3002 
3003 
3004 
3005 /// is stored primal solution feasible?
3007 {
3010 }
3011 
3012 
3013 
3014 /// is a solution available (not necessarily feasible)?
3015 bool SoPlex::hasSol() const
3016 {
3017  return _hasSolReal || _hasSolRational;
3018 }
3019 
3020 
3021 
3022 /// is a primal unbounded ray available?
3024 {
3026 }
3027 
3028 
3029 
3030 /// is stored dual solution feasible?
3032 {
3035 }
3036 
3037 
3038 
3039 /// is Farkas proof of infeasibility available?
3041 {
3044 }
3045 
3046 
3047 
3048 /// returns the objective value if a primal or dual solution is available
3050 {
3051  assert(OBJSENSE_MAXIMIZE == 1);
3052  assert(OBJSENSE_MINIMIZE == -1);
3053 
3054  if(status() == SPxSolver::UNBOUNDED)
3056  else if(status() == SPxSolver::INFEASIBLE)
3058  else if(hasSol())
3059  {
3061  return _solReal._objVal;
3062  }
3063  else
3064  return 0.0;
3065 }
3066 
3067 
3068 
3069 /// gets the primal solution vector if available; returns true on success
3071 {
3072  if(hasSol() && vector.dim() >= numColsReal())
3073  {
3075  _solReal.getPrimal(vector);
3076  return true;
3077  }
3078  else
3079  return false;
3080 }
3081 
3082 
3083 
3084 /// gets the vector of slack values if available; returns true on success
3086 {
3087  if(hasSol() && vector.dim() >= numRowsReal())
3088  {
3090  _solReal.getSlacks(vector);
3091  return true;
3092  }
3093  else
3094  return false;
3095 }
3096 
3097 
3098 
3099 /// gets the primal ray if available; returns true on success
3101 {
3102  if(hasPrimalRay() && vector.dim() >= numColsReal())
3103  {
3105  _solReal.getPrimalRay(vector);
3106  return true;
3107  }
3108  else
3109  return false;
3110 }
3111 
3112 
3113 
3114 /// gets the dual solution vector if available; returns true on success
3116 {
3117  if(hasSol() && vector.dim() >= numRowsReal())
3118  {
3120  _solReal.getDual(vector);
3121  return true;
3122  }
3123  else
3124  return false;
3125 }
3126 
3127 
3128 
3129 /// gets the vector of reduced cost values if available; returns true on success
3131 {
3132  if(hasSol() && vector.dim() >= numColsReal())
3133  {
3135  _solReal.getRedCost(vector);
3136  return true;
3137  }
3138  else
3139  return false;
3140 }
3141 
3142 
3143 
3144 /// gets the Farkas proof if available; returns true on success
3146 {
3147  if(hasDualFarkas() && vector.dim() >= numRowsReal())
3148  {
3150  _solReal.getDualFarkas(vector);
3151  return true;
3152  }
3153  else
3154  return false;
3155 }
3156 
3157 
3158 
3159 /// gets violation of bounds; returns true on success
3160 bool SoPlex::getBoundViolationReal(Real& maxviol, Real& sumviol)
3161 {
3162  if(!hasSol())
3163  return false;
3164 
3166  VectorReal& primal = _solReal._primal;
3167  assert(primal.dim() == numColsReal());
3168 
3169  maxviol = 0.0;
3170  sumviol = 0.0;
3171 
3172  for(int i = numColsReal() - 1; i >= 0; i--)
3173  {
3174  Real lower = _realLP->lowerUnscaled(i);
3175  Real upper = _realLP->upperUnscaled(i);
3176  Real viol = lower - primal[i];
3177 
3178  if(viol > 0.0)
3179  {
3180  sumviol += viol;
3181 
3182  if(viol > maxviol)
3183  maxviol = viol;
3184  }
3185 
3186  viol = primal[i] - upper;
3187 
3188  if(viol > 0.0)
3189  {
3190  sumviol += viol;
3191 
3192  if(viol > maxviol)
3193  maxviol = viol;
3194  }
3195  }
3196 
3197  return true;
3198 }
3199 
3200 
3201 
3202 /// gets violation of constraints; returns true on success
3203 bool SoPlex::getRowViolationReal(Real& maxviol, Real& sumviol)
3204 {
3205  if(!hasSol())
3206  return false;
3207 
3209  VectorReal& primal = _solReal._primal;
3210  assert(primal.dim() == numColsReal());
3211 
3212  DVectorReal activity(numRowsReal());
3213  _realLP->computePrimalActivity(primal, activity, true);
3214  maxviol = 0.0;
3215  sumviol = 0.0;
3216 
3217  for(int i = numRowsReal() - 1; i >= 0; i--)
3218  {
3219  Real lhs = _realLP->lhsUnscaled(i);
3220  Real rhs = _realLP->rhsUnscaled(i);
3221 
3222  Real viol = lhs - activity[i];
3223 
3224  if(viol > 0.0)
3225  {
3226  sumviol += viol;
3227 
3228  if(viol > maxviol)
3229  maxviol = viol;
3230  }
3231 
3232  viol = activity[i] - rhs;
3233 
3234  if(viol > 0.0)
3235  {
3236  sumviol += viol;
3237 
3238  if(viol > maxviol)
3239  maxviol = viol;
3240  }
3241  }
3242 
3243  return true;
3244 }
3245 
3246 
3247 
3248 /// gets violation of reduced costs; returns true on success
3250 {
3251  if(!hasSol() || !hasBasis())
3252  return false;
3253 
3255  VectorReal& redcost = _solReal._redCost;
3256  assert(redcost.dim() == numColsReal());
3257 
3258  maxviol = 0.0;
3259  sumviol = 0.0;
3260 
3261  for(int c = numColsReal() - 1; c >= 0; c--)
3262  {
3263  SPxSolver::VarStatus colStatus = basisColStatus(c);
3264 
3266  {
3267  if(colStatus != SPxSolver::ON_UPPER && colStatus != SPxSolver::FIXED && redcost[c] < 0.0)
3268  {
3269  sumviol += -redcost[c];
3270 
3271  if(redcost[c] < -maxviol)
3272  maxviol = -redcost[c];
3273  }
3274 
3275  if(colStatus != SPxSolver::ON_LOWER && colStatus != SPxSolver::FIXED && redcost[c] > 0.0)
3276  {
3277  sumviol += redcost[c];
3278 
3279  if(redcost[c] > maxviol)
3280  maxviol = redcost[c];
3281  }
3282  }
3283  else
3284  {
3285  if(colStatus != SPxSolver::ON_UPPER && colStatus != SPxSolver::FIXED && redcost[c] > 0.0)
3286  {
3287  sumviol += redcost[c];
3288 
3289  if(redcost[c] > maxviol)
3290  maxviol = redcost[c];
3291  }
3292 
3293  if(colStatus != SPxSolver::ON_LOWER && colStatus != SPxSolver::FIXED && redcost[c] < 0.0)
3294  {
3295  sumviol += -redcost[c];
3296 
3297  if(redcost[c] < -maxviol)
3298  maxviol = -redcost[c];
3299  }
3300  }
3301  }
3302 
3303  return true;
3304 }
3305 
3306 
3307 
3308 /// gets violation of dual multipliers; returns true on success
3309 bool SoPlex::getDualViolationReal(Real& maxviol, Real& sumviol)
3310 {
3311  if(!hasSol() || !hasBasis())
3312  return false;
3313 
3315  VectorReal& dual = _solReal._dual;
3316  assert(dual.dim() == numRowsReal());
3317 
3318  maxviol = 0.0;
3319  sumviol = 0.0;
3320 
3321  for(int r = numRowsReal() - 1; r >= 0; r--)
3322  {
3323  SPxSolver::VarStatus rowStatus = basisRowStatus(r);
3324 
3326  {
3327  if(rowStatus != SPxSolver::ON_UPPER && rowStatus != SPxSolver::FIXED && dual[r] < 0.0)
3328  {
3329  sumviol += -dual[r];
3330 
3331  if(dual[r] < -maxviol)
3332  maxviol = -dual[r];
3333  }
3334 
3335  if(rowStatus != SPxSolver::ON_LOWER && rowStatus != SPxSolver::FIXED && dual[r] > 0.0)
3336  {
3337  sumviol += dual[r];
3338 
3339  if(dual[r] > maxviol)
3340  maxviol = dual[r];
3341  }
3342  }
3343  else
3344  {
3345  if(rowStatus != SPxSolver::ON_UPPER && rowStatus != SPxSolver::FIXED && dual[r] > 0.0)
3346  {
3347  sumviol += dual[r];
3348 
3349  if(dual[r] > maxviol)
3350  maxviol = dual[r];
3351  }
3352 
3353  if(rowStatus != SPxSolver::ON_LOWER && rowStatus != SPxSolver::FIXED && dual[r] < 0.0)
3354  {
3355  sumviol += -dual[r];
3356 
3357  if(dual[r] < -maxviol)
3358  maxviol = -dual[r];
3359  }
3360  }
3361  }
3362 
3363  return true;
3364 }
3365 
3366 
3367 
3368 /// returns the objective value if a primal or dual solution is available
3370 {
3371  assert(OBJSENSE_MAXIMIZE == 1);
3372  assert(OBJSENSE_MINIMIZE == -1);
3373 
3374  if(status() == SPxSolver::UNBOUNDED)
3375  {
3377  return _rationalPosInfty;
3378  else
3379  return _rationalNegInfty;
3380  }
3381  else if(status() == SPxSolver::INFEASIBLE)
3382  {
3384  return _rationalNegInfty;
3385  else
3386  return _rationalPosInfty;
3387  }
3388  else if(hasSol())
3389  {
3391  return _solRational._objVal;
3392  }
3393  else
3394  return _rationalZero;
3395 }
3396 
3397 
3398 
3399 /// gets the primal solution vector if available; returns true on success
3401 {
3402  if(_rationalLP != 0 && hasSol() && vector.dim() >= numColsRational())
3403  {
3405  _solRational.getPrimal(vector);
3406  return true;
3407  }
3408  else
3409  return false;
3410 }
3411 
3412 
3413 
3414 /// gets the vector of slack values if available; returns true on success
3416 {
3417  if(_rationalLP != 0 && hasSol() && vector.dim() >= numRowsRational())
3418  {
3420  _solRational.getSlacks(vector);
3421  return true;
3422  }
3423  else
3424  return false;
3425 }
3426 
3427 
3428 
3429 /// gets the primal ray if LP is unbounded; returns true on success
3431 {
3432  if(_rationalLP != 0 && hasPrimalRay() && vector.dim() >= numColsRational())
3433  {
3435  _solRational.getPrimalRay(vector);
3436  return true;
3437  }
3438  else
3439  return false;
3440 }
3441 
3442 
3443 
3444 /// gets the dual solution vector if available; returns true on success
3446 {
3447  if(_rationalLP != 0 && hasSol() && vector.dim() >= numRowsRational())
3448  {
3450  _solRational.getDual(vector);
3451  return true;
3452  }
3453  else
3454  return false;
3455 }
3456 
3457 
3458 
3459 /// gets the vector of reduced cost values if available; returns true on success
3461 {
3462  if(_rationalLP != 0 && hasSol() && vector.dim() >= numColsRational())
3463  {
3465  _solRational.getRedCost(vector);
3466  return true;
3467  }
3468  else
3469  return false;
3470 }
3471 
3472 
3473 
3474 /// gets the Farkas proof if LP is infeasible; returns true on success
3476 {
3477  if(_rationalLP != 0 && hasDualFarkas() && vector.dim() >= numRowsRational())
3478  {
3480  _solRational.getDualFarkas(vector);
3481  return true;
3482  }
3483  else
3484  return false;
3485 }
3486 
3487 
3488 
3489 /// gets violation of bounds; returns true on success
3491 {
3492  if(!isPrimalFeasible())
3493  return false;
3494 
3495  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3497  _syncLPRational(false);
3498 
3501  assert(primal.dim() == numColsRational());
3502 
3503  maxviol = 0;
3504  sumviol = 0;
3505 
3506  for(int i = numColsRational() - 1; i >= 0; i--)
3507  {
3508  Rational viol = lowerRational(i) - primal[i];
3509 
3510  if(viol > 0)
3511  {
3512  sumviol += viol;
3513 
3514  if(viol > maxviol)
3515  {
3516  maxviol = viol;
3517  MSG_DEBUG(std::cout << "increased bound violation for column " << i << ": " << rationalToString(
3518  viol)
3519  << " lower: " << rationalToString(lowerRational(i))
3520  << ", primal: " << rationalToString(primal[i]) << "\n");
3521  }
3522  }
3523 
3524  viol = primal[i] - upperRational(i);
3525 
3526  if(viol > 0)
3527  {
3528  sumviol += viol;
3529 
3530  if(viol > maxviol)
3531  {
3532  maxviol = viol;
3533  MSG_DEBUG(std::cout << "increased bound violation for column " << i << ": " << rationalToString(
3534  viol)
3535  << " upper: " << rationalToString(upperRational(i))
3536  << ", primal: " << rationalToString(primal[i]) << "\n");
3537  }
3538  }
3539  }
3540 
3541  return true;
3542 }
3543 
3544 
3545 
3546 /// gets violation of constraints; returns true on success
3548 {
3549  if(!isPrimalFeasible())
3550  return false;
3551 
3552  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3554  _syncLPRational(false);
3555 
3558  assert(primal.dim() == numColsRational());
3559 
3560  DVectorRational activity(numRowsRational());
3561  _rationalLP->computePrimalActivity(primal, activity);
3562  maxviol = 0;
3563  sumviol = 0;
3564 
3565  for(int i = numRowsRational() - 1; i >= 0; i--)
3566  {
3567  Rational viol = lhsRational(i) - activity[i];
3568 
3569  if(viol > 0)
3570  {
3571  sumviol += viol;
3572 
3573  if(viol > maxviol)
3574  {
3575  maxviol = viol;
3576  MSG_DEBUG(std::cout << "increased constraint violation for row " << i << ": " << rationalToString(
3577  viol)
3578  << " lhs: " << rationalToString(lhsRational(i))
3579  << ", activity: " << rationalToString(activity[i]) << "\n");
3580  }
3581  }
3582 
3583  viol = activity[i] - rhsRational(i);
3584 
3585  if(viol > 0)
3586  {
3587  sumviol += viol;
3588 
3589  if(viol > maxviol)
3590  {
3591  maxviol = viol;
3592  MSG_DEBUG(std::cout << "increased constraint violation for row " << i << ": " << rationalToString(
3593  viol)
3594  << " rhs: " << rationalToString(rhsRational(i))
3595  << ", activity: " << rationalToString(activity[i]) << "\n");
3596  }
3597  }
3598  }
3599 
3600  return true;
3601 }
3602 
3603 
3604 
3605 /// gets violation of reduced costs; returns true on success
3607 {
3608  if(!isPrimalFeasible() || !isDualFeasible())
3609  return false;
3610 
3611  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3613  _syncLPRational(false);
3614 
3617  assert(redcost.dim() == numColsRational());
3618 
3619  maxviol = 0;
3620  sumviol = 0;
3621 
3622  for(int c = numColsReal() - 1; c >= 0; c--)
3623  {
3624  assert(!_hasBasis || basisColStatus(c) != SPxSolver::UNDEFINED);
3625 
3626  if(_colTypes[c] == RANGETYPE_FIXED)
3627  {
3628  assert(lowerRational(c) == upperRational(c));
3629  continue;
3630  }
3631 
3633  || _solRational._primal[c] == lowerRational(c));
3635  || _solRational._primal[c] == upperRational(c));
3636  assert(!_hasBasis || basisColStatus(c) != SPxSolver::FIXED
3637  || _solRational._primal[c] == lowerRational(c));
3638  assert(!_hasBasis || basisColStatus(c) != SPxSolver::FIXED
3639  || _solRational._primal[c] == upperRational(c));
3640 
3642  {
3643  if(_solRational._primal[c] != upperRational(c) && redcost[c] < 0)
3644  {
3645  sumviol += -redcost[c];
3646 
3647  if(redcost[c] < -maxviol)
3648  {
3649  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3650  " not on upper bound: " << rationalToString(-redcost[c]) << "\n");
3651  maxviol = -redcost[c];
3652  }
3653  }
3654 
3655  if(_solRational._primal[c] != lowerRational(c) && redcost[c] > 0)
3656  {
3657  sumviol += redcost[c];
3658 
3659  if(redcost[c] > maxviol)
3660  {
3661  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3662  " not on lower bound: " << rationalToString(redcost[c]) << "\n");
3663  maxviol = redcost[c];
3664  }
3665  }
3666  }
3667  else
3668  {
3669  if(_solRational._primal[c] != upperRational(c) && redcost[c] > 0)
3670  {
3671  sumviol += redcost[c];
3672 
3673  if(redcost[c] > maxviol)
3674  {
3675  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3676  " not on upper bound: " << rationalToString(redcost[c]) << "\n");
3677  maxviol = redcost[c];
3678  }
3679  }
3680 
3681  if(_solRational._primal[c] != lowerRational(c) && redcost[c] < 0)
3682  {
3683  sumviol += -redcost[c];
3684 
3685  if(redcost[c] < -maxviol)
3686  {
3687  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3688  " not on lower bound: " << rationalToString(-redcost[c]) << "\n");
3689  maxviol = -redcost[c];
3690  }
3691  }
3692  }
3693  }
3694 
3695  return true;
3696 }
3697 
3698 
3699 
3700 /// gets violation of dual multipliers; returns true on success
3702 {
3703  if(!isDualFeasible() || !isPrimalFeasible())
3704  return false;
3705 
3706  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3708  _syncLPRational(false);
3709 
3712  assert(dual.dim() == numRowsRational());
3713 
3714  maxviol = 0;
3715  sumviol = 0;
3716 
3717  for(int r = numRowsReal() - 1; r >= 0; r--)
3718  {
3719  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::UNDEFINED);
3720 
3721  if(_rowTypes[r] == RANGETYPE_FIXED)
3722  {
3723  assert(lhsRational(r) == rhsRational(r));
3724  continue;
3725  }
3726 
3731  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::FIXED
3733  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::FIXED
3735 
3737  {
3738  if(_solRational._slacks[r] < rhsRational(r) - _rationalFeastol && dual[r] < 0)
3739  {
3740  sumviol += -dual[r];
3741 
3742  if(dual[r] < -maxviol)
3743  {
3744  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on upper bound: " <<
3745  rationalToString(-dual[r])
3746  << " (slack = " << rationalToString(_solRational._slacks[r])
3747  << ", status = " << basisRowStatus(r)
3748  << ", lhs = " << rationalToString(lhsRational(r))
3749  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3750  maxviol = -dual[r];
3751  }
3752  }
3753 
3754  if(_solRational._slacks[r] > lhsRational(r) + _rationalFeastol && dual[r] > 0)
3755  {
3756  sumviol += dual[r];
3757 
3758  if(dual[r] > maxviol)
3759  {
3760  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on lower bound: " <<
3761  rationalToString(dual[r])
3762  << " (slack = " << rationalToString(_solRational._slacks[r])
3763  << ", status = " << basisRowStatus(r)
3764  << ", lhs = " << rationalToString(lhsRational(r))
3765  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3766  maxviol = dual[r];
3767  }
3768  }
3769  }
3770  else
3771  {
3772  if(_solRational._slacks[r] < rhsRational(r) - _rationalFeastol && dual[r] > 0)
3773  {
3774  sumviol += dual[r];
3775 
3776  if(dual[r] > maxviol)
3777  {
3778  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on upper bound: " <<
3779  rationalToString(dual[r])
3780  << " (slack = " << rationalToString(_solRational._slacks[r])
3781  << ", status = " << basisRowStatus(r)
3782  << ", lhs = " << rationalToString(lhsRational(r))
3783  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3784  maxviol = dual[r];
3785  }
3786  }
3787 
3788  if(_solRational._slacks[r] > lhsRational(r) + _rationalFeastol && dual[r] < 0)
3789  {
3790  sumviol += -dual[r];
3791 
3792  if(dual[r] < -maxviol)
3793  {
3794  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on lower bound: " <<
3795  rationalToString(-dual[r])
3796  << " (slack = " << rationalToString(_solRational._slacks[r])
3797  << ", status = " << basisRowStatus(r)
3798  << ", lhs = " << rationalToString(lhsRational(r))
3799  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3800  maxviol = -dual[r];
3801  }
3802  }
3803  }
3804  }
3805 
3806  return true;
3807 }
3808 
3809 
3810 
3811 #ifdef SOPLEX_WITH_GMP
3812 /// gets the primal solution vector if available; returns true on success (GMP only method)
3813 bool SoPlex::getPrimalRational(mpq_t* vector, const int size)
3814 {
3815  assert(size >= numColsRational());
3816 
3817  if(hasSol())
3818  {
3820 
3821  for(int i = 0; i < numColsRational(); i++)
3822  mpq_set(vector[i], _solRational._primal[i].getMpqRef());
3823 
3824  return true;
3825  }
3826  else
3827  return false;
3828 }
3829 
3830 
3831 /// gets the vector of slack values if available; returns true on success
3832 bool SoPlex::getSlacksRational(mpq_t* vector, const int size)
3833 {
3834  assert(size >= numRowsRational());
3835 
3836  if(hasSol())
3837  {
3839 
3840  for(int i = 0; i < numRowsRational(); i++)
3841  mpq_set(vector[i], _solRational._slacks[i].getMpqRef());
3842 
3843  return true;
3844  }
3845  else
3846  return false;
3847 }
3848 
3849 
3850 
3851 /// gets the primal ray if LP is unbounded; returns true on success
3852 bool SoPlex::getPrimalRayRational(mpq_t* vector, const int size)
3853 {
3854  assert(size >= numColsRational());
3855 
3856  if(hasPrimalRay())
3857  {
3859 
3860  for(int i = 0; i < numColsRational(); i++)
3861  mpq_set(vector[i], _solRational._primalRay[i].getMpqRef());
3862 
3863  return true;
3864  }
3865  else
3866  return false;
3867 }
3868 
3869 
3870 
3871 /// gets the dual solution vector if available; returns true on success
3872 bool SoPlex::getDualRational(mpq_t* vector, const int size)
3873 {
3874  assert(size >= numRowsRational());
3875 
3876  if(hasSol())
3877  {
3879 
3880  for(int i = 0; i < numRowsRational(); i++)
3881  mpq_set(vector[i], _solRational._dual[i].getMpqRef());
3882 
3883  return true;
3884  }
3885  else
3886  return false;
3887 }
3888 
3889 
3890 
3891 /// gets the vector of reduced cost values if available; returns true on success
3892 bool SoPlex::getRedCostRational(mpq_t* vector, const int size)
3893 {
3894  assert(size >= numColsRational());
3895 
3896  if(hasSol())
3897  {
3899 
3900  for(int i = 0; i < numColsRational(); i++)
3901  mpq_set(vector[i], _solRational._redCost[i].getMpqRef());
3902 
3903  return true;
3904  }
3905  else
3906  return false;
3907 }
3908 
3909 
3910 
3911 /// gets the Farkas proof if LP is infeasible; returns true on success
3912 bool SoPlex::getDualFarkasRational(mpq_t* vector, const int size)
3913 {
3914  assert(size >= numRowsRational());
3915 
3916  if(hasDualFarkas())
3917  {
3919 
3920  for(int i = 0; i < numRowsRational(); i++)
3921  mpq_set(vector[i], _solRational._dualFarkas[i].getMpqRef());
3922 
3923  return true;
3924  }
3925  else
3926  return false;
3927 }
3928 #endif
3929 
3930 
3931 
3932 /// get size of primal solution
3934 {
3935  if(hasSol() || hasPrimalRay())
3936  {
3938  return _solRational.totalSizePrimal(base);
3939  }
3940  else
3941  return 0;
3942 }
3943 
3944 
3945 
3946 /// get size of dual solution
3948 {
3949  if(hasSol() || hasDualFarkas())
3950  {
3952  return _solRational.totalSizeDual(base);
3953  }
3954  else
3955  return 0;
3956 }
3957 
3958 
3959 
3960 /// get size of least common multiple of denominators in primal solution
3962 {
3963  if(hasSol() || hasPrimalRay())
3964  {
3966  return _solRational.dlcmSizePrimal(base);
3967  }
3968  else
3969  return 0;
3970 }
3971 
3972 
3973 
3974 /// get size of least common multiple of denominators in dual solution
3975 int SoPlex::dlcmSizeDualRational(const int base)
3976 {
3977  if(hasSol() || hasDualFarkas())
3978  {
3980  return _solRational.dlcmSizeDual(base);
3981  }
3982  else
3983  return 0;
3984 }
3985 
3986 
3987 
3988 /// get size of largest denominator in primal solution
3990 {
3991  if(hasSol() || hasPrimalRay())
3992  {
3994  return _solRational.dmaxSizePrimal(base);
3995  }
3996  else
3997  return 0;
3998 }
3999 
4000 
4001 
4002 /// get size of largest denominator in dual solution
4003 int SoPlex::dmaxSizeDualRational(const int base)
4004 {
4005  if(hasSol() || hasDualFarkas())
4006  {
4008  return _solRational.dmaxSizeDual(base);
4009  }
4010  else
4011  return 0;
4012 }
4013 
4014 
4015 
4016 /// is an advanced starting basis available?
4017 bool SoPlex::hasBasis() const
4018 {
4019  return _hasBasis;
4020 }
4021 
4022 
4023 
4024 /// returns the current basis status
4026 {
4027  if(!hasBasis())
4028  return SPxBasis::NO_PROBLEM;
4029  else
4030  return _solver.getBasisStatus();
4031 }
4032 
4033 
4034 
4035 /// returns basis status for a single row
4037 {
4038  assert(row >= 0);
4039  assert(row < numRowsReal());
4040 
4041  // if no basis is available, return slack basis; if index is out of range, return basic status as for a newly
4042  // added row
4043  if(!hasBasis() || row < 0 || row >= numRowsReal())
4044  return SPxSolver::BASIC;
4045  // if the real LP is loaded, ask solver
4046  else if(_isRealLPLoaded)
4047  {
4048  return _solver.getBasisRowStatus(row);
4049  }
4050  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4051  else
4052  {
4053  assert(row < _basisStatusRows.size());
4054  return _basisStatusRows[row];
4055  }
4056 }
4057 
4058 
4059 
4060 /// returns basis status for a single column
4062 {
4063  assert(col >= 0);
4064  assert(col < numColsReal());
4065 
4066  // if index is out of range, return nonbasic status as for a newly added unbounded column
4067  if(col < 0 || col >= numColsReal())
4068  {
4069  return SPxSolver::ZERO;
4070  }
4071  // if no basis is available, return slack basis
4072  else if(!hasBasis())
4073  {
4074  if(lowerReal(col) > -realParam(SoPlex::INFTY))
4075  return SPxSolver::ON_LOWER;
4076  else if(upperReal(col) < realParam(SoPlex::INFTY))
4077  return SPxSolver::ON_UPPER;
4078  else
4079  return SPxSolver::ZERO;
4080  }
4081  // if the real LP is loaded, ask solver
4082  else if(_isRealLPLoaded)
4083  {
4084  return _solver.getBasisColStatus(col);
4085  }
4086  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4087  else
4088  {
4089  assert(col < _basisStatusCols.size());
4090  return _basisStatusCols[col];
4091  }
4092 }
4093 
4094 
4095 
4096 /// gets current basis
4098 {
4099  // if no basis is available, return slack basis
4100  if(!hasBasis())
4101  {
4102  for(int i = numRowsReal() - 1; i >= 0; i--)
4103  rows[i] = SPxSolver::BASIC;
4104 
4105  for(int i = numColsReal() - 1; i >= 0; i--)
4106  {
4107  if(lowerReal(i) > -realParam(SoPlex::INFTY))
4108  cols[i] = SPxSolver::ON_LOWER;
4109  else if(upperReal(i) < realParam(SoPlex::INFTY))
4110  cols[i] = SPxSolver::ON_UPPER;
4111  else
4112  cols[i] = SPxSolver::ZERO;
4113  }
4114  }
4115  // if the real LP is loaded, ask solver
4116  else if(_isRealLPLoaded)
4117  {
4118  (void)_solver.getBasis(rows, cols);
4119  }
4120  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4121  else
4122  {
4123  assert(numRowsReal() == _basisStatusRows.size());
4124  assert(numColsReal() == _basisStatusCols.size());
4125 
4126  for(int i = numRowsReal() - 1; i >= 0; i--)
4127  rows[i] = _basisStatusRows[i];
4128 
4129  for(int i = numColsReal() - 1; i >= 0; i--)
4130  cols[i] = _basisStatusCols[i];
4131  }
4132 }
4133 
4134 
4135 
4136 /// returns the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m
4137 /// note: the order of the indices might not coincide with the actual order when using ROW representation
4138 void SoPlex::getBasisInd(int* bind) const
4139 {
4140  // if no basis is available, return slack basis
4141  if(!hasBasis())
4142  {
4143  for(int i = 0; i < numRowsReal(); ++i)
4144  bind[i] = -1 - i;
4145  }
4146  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4147  else if(!_isRealLPLoaded)
4148  {
4149  int k = 0;
4150 
4151  assert(numRowsReal() == _basisStatusRows.size());
4152  assert(numColsReal() == _basisStatusCols.size());
4153 
4154  for(int i = 0; i < numRowsReal(); ++i)
4155  {
4157  {
4158  bind[k] = -1 - i;
4159  k++;
4160  }
4161  }
4162 
4163  for(int j = 0; j < numColsReal(); ++j)
4164  {
4166  {
4167  bind[k] = j;
4168  k++;
4169  }
4170  }
4171 
4172  assert(k == numRowsReal());
4173  }
4174  // if the real LP is loaded, the basis is stored in the solver and we need to distinguish between column and row
4175  // representation; ask the solver itself which representation it has, since the REPRESENTATION parameter of this
4176  // class might be set to automatic
4177  else if(_solver.rep() == SPxSolver::COLUMN)
4178  {
4179  for(int i = 0; i < numRowsReal(); ++i)
4180  {
4181  SPxId id = _solver.basis().baseId(i);
4182  bind[i] = (id.isSPxColId() ? _solver.number(id) : - 1 - _solver.number(id));
4183  }
4184  }
4185  // for row representation, return the complement of the row basis; for this, we need to loop through all rows and columns
4186  else
4187  {
4188  assert(_solver.rep() == SPxSolver::ROW);
4189 
4190  int k = 0;
4191 
4192  for(int i = 0; i < numRowsReal(); ++i)
4193  {
4194  if(!_solver.isRowBasic(i))
4195  {
4196  bind[k] = -1 - i;
4197  k++;
4198  }
4199  }
4200 
4201  for(int j = 0; j < numColsReal(); ++j)
4202  {
4203  if(!_solver.isColBasic(j))
4204  {
4205  bind[k] = j;
4206  k++;
4207  }
4208  }
4209 
4210  assert(k == numRowsReal());
4211  }
4212 }
4213 
4214 
4215 /// compute condition number estimate based on the diagonal of the LU factorization; returns true on success
4216 /// type = 0: max/min ratio
4217 /// type = 1: trace of U (sum of diagonal elements)
4218 /// type = 2: product of diagonal elements
4219 bool SoPlex::getFastCondition(Real& condition, int type)
4220 {
4222 
4223  if(!_isRealLPLoaded)
4224  return false;
4225 
4227  return false;
4228 
4229  condition = _solver.basis().getFastCondition(type);
4230 
4231  return true;
4232 }
4233 
4234 /// computes an estimated condition number for the current basis matrix using the power method; returns true on success
4236 {
4238 
4239  if(!_isRealLPLoaded)
4240  return false;
4241 
4243  return false;
4244 
4245  condition = _solver.basis().getEstimatedCondition();
4246 
4247  return true;
4248 }
4249 
4250 /// computes the exact condition number for the current basis matrix using the power method; returns true on success
4252 {
4254 
4255  if(!_isRealLPLoaded)
4256  return false;
4257 
4259  return false;
4260 
4261  condition = _solver.basis().getExactCondition();
4262 
4263  return true;
4264 }
4265 
4266 /// computes row r of basis inverse; returns true on success
4267 bool SoPlex::getBasisInverseRowReal(int r, Real* coef, int* inds, int* ninds, bool unscale)
4268 {
4269  assert(r >= 0);
4270  assert(r < numRowsReal());
4271  assert(coef != 0);
4272 
4273  if(!hasBasis() || r < 0 || r >= numRowsReal())
4274  return false;
4275 
4277 
4278  if(!_isRealLPLoaded)
4279  return false;
4280 
4281  // we need to distinguish between column and row representation; ask the solver itself which representation it
4282  // has, since the REPRESENTATION parameter of this class might be set to automatic
4283  if(_solver.rep() == SPxSolver::COLUMN)
4284  {
4285  int idx;
4287 
4288  try
4289  {
4290  /* unscaling required? */
4291  if(unscale && _solver.isScaled())
4292  {
4293  /* for information on the unscaling procedure see spxscaler.h */
4294 
4295  int scaleExp;
4296  DSVector rhs(_solver.unitVector(r));
4297 
4298  // apply scaling \tilde{C} to rhs
4299  if(_solver.basis().baseId(r).isSPxColId())
4301  else
4302  scaleExp = - _scaler->getRowScaleExp(_solver.number(_solver.basis().baseId(r)));
4303 
4304  rhs *= spxLdexp(1.0, scaleExp);
4305 
4306  _solver.basis().coSolve(x, rhs);
4307  x.setup();
4308  int size = x.size();
4309 
4310  //apply scaling R to solution vector
4311  for(int i = 0; i < size; i++)
4312  {
4313  scaleExp = _scaler->getRowScaleExp(x.index(i));
4314  x.scaleValue(x.index(i), scaleExp);
4315  }
4316  }
4317  else
4318  {
4320  }
4321  }
4322  catch(const SPxException& E)
4323  {
4324  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4325  "> while computing basis inverse row.\n");
4326  return false;
4327  }
4328 
4329  // copy sparse data to dense result vector based on coef array
4330  if(ninds != 0 && inds != 0)
4331  {
4332  // during solving SoPlex may have destroyed the sparsity structure so we need to restore it
4333  x.setup();
4334  *ninds = x.size();
4335 
4336  for(int i = 0; i < *ninds; ++i)
4337  {
4338  idx = x.index(i);
4339  coef[idx] = x[idx];
4340  // set sparsity pattern of coef array
4341  inds[i] = idx;
4342  }
4343  }
4344  else
4345  {
4346  VectorReal y(numRowsReal(), coef);
4347  y = x;
4348 
4349  if(ninds != NULL)
4350  *ninds = -1;
4351  }
4352  }
4353  else
4354  {
4355  assert(_solver.rep() == SPxSolver::ROW);
4356 
4357  /// @todo should rhs be a reference?
4358  DSVector rhs(numColsReal());
4359  SSVector y(numColsReal());
4360  int* bind = 0;
4361  int index;
4362 
4363  // get ordering of column basis matrix
4364  spx_alloc(bind, numRowsReal());
4365  getBasisInd(bind);
4366 
4367  // get vector corresponding to requested index r
4368  index = bind[r];
4369 
4370  // r corresponds to a basic row
4371  if(index < 0)
4372  {
4373  // transform index to actual row index
4374  index = -index - 1;
4375 
4376  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4377  assert(index >= 0);
4378  assert(index < numRowsReal());
4379  assert(!_solver.isRowBasic(index));
4380 
4381  // get row vector
4382  rhs = _solver.rowVector(index);
4383  rhs *= -1.0;
4384 
4385  if(unscale && _solver.isScaled())
4386  {
4387  for(int i = 0; i < rhs.size(); ++i)
4388  rhs.value(i) = spxLdexp(rhs.value(i), -_scaler->getRowScaleExp(index));
4389  }
4390  }
4391  // r corresponds to a basic column
4392  else
4393  {
4394  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4395  assert(index < numColsReal());
4396  assert(!_solver.isColBasic(index));
4397 
4398  // get unit vector
4399  rhs = UnitVectorReal(index);
4400 
4401  if(unscale && _solver.isScaled())
4402  rhs *= spxLdexp(1.0, _scaler->getColScaleExp(index));
4403  }
4404 
4405  // solve system "y B = rhs", where B is the row basis matrix
4406  try
4407  {
4408  _solver.basis().solve(y, rhs);
4409  }
4410  catch(const SPxException& E)
4411  {
4412  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4413  "> while computing basis inverse row.\n");
4414  return false;
4415  }
4416 
4417  // initialize result vector x as zero
4418  memset(coef, 0, (unsigned int)numRowsReal() * sizeof(Real));
4419 
4420  // add nonzero entries
4421  for(int i = 0; i < numColsReal(); ++i)
4422  {
4423  SPxId id = _solver.basis().baseId(i);
4424 
4425  if(id.isSPxRowId())
4426  {
4427  assert(_solver.number(id) >= 0);
4428  assert(_solver.number(id) < numRowsReal());
4429  assert(bind[r] >= 0 || _solver.number(id) != index);
4430 
4431  int rowindex = _solver.number(id);
4432  coef[rowindex] = y[i];
4433 
4434  if(unscale && _solver.isScaled())
4435  coef[rowindex] = spxLdexp(y[i], _scaler->getRowScaleExp(rowindex));
4436  }
4437  }
4438 
4439  // if r corresponds to a row vector, we have to add a 1 at position r
4440  if(bind[r] < 0)
4441  {
4442  assert(coef[index] == 0.0);
4443  coef[index] = 1.0;
4444  }
4445 
4446  /// @todo implement returning of sparsity information like in column wise case
4447  if(ninds != NULL)
4448  *ninds = -1;
4449 
4450  // free memory
4451  spx_free(bind);
4452  }
4453 
4454  return true;
4455 }
4456 
4457 
4458 
4459 /// computes column c of basis inverse; returns true on success
4460 /// @todo does not work correctly for the row representation
4461 bool SoPlex::getBasisInverseColReal(int c, Real* coef, int* inds, int* ninds, bool unscale)
4462 {
4463  assert(c >= 0);
4464  assert(c < numRowsReal());
4465  assert(coef != 0);
4466 
4467  if(!hasBasis() || c < 0 || c >= numRowsReal())
4468  return false;
4469 
4471 
4472  if(!_isRealLPLoaded)
4473  return false;
4474 
4475  // we need to distinguish between column and row representation; ask the solver itself which representation it
4476  // has, since the REPRESENTATION parameter of this class might be set to automatic
4477  if(_solver.rep() == SPxSolver::COLUMN)
4478  {
4479  int idx;
4481 
4482  try
4483  {
4484  /* unscaling required? */
4485  if(unscale && _solver.isScaled())
4486  {
4487  /* for information on the unscaling procedure see spxscaler.h */
4488 
4489  int scaleExp = _scaler->getRowScaleExp(c);
4490  DSVector rhs(_solver.unitVector(c));
4491  rhs *= spxLdexp(1.0, scaleExp);
4492 
4493  _solver.basis().solve(x, rhs);
4494 
4495  x.setup();
4496  int size = x.size();
4497 
4498  for(int i = 0; i < size; i++)
4499  {
4500  if(_solver.basis().baseId(x.index(i)).isSPxColId())
4501  {
4502  idx = _solver.number(_solver.basis().baseId(x.index(i)));
4503  scaleExp = _scaler->getColScaleExp(idx);
4504  x.scaleValue(x.index(i), scaleExp);
4505  }
4506  else
4507  {
4508  idx = _solver.number(_solver.basis().baseId(x.index(i)));
4509  scaleExp = - _scaler->getRowScaleExp(idx);
4510  x.scaleValue(x.index(i), scaleExp);
4511  }
4512  }
4513  }
4514  else
4515  {
4517  }
4518  }
4519  catch(const SPxException& E)
4520  {
4521  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4522  "> while computing basis inverse row.\n");
4523  return false;
4524  }
4525 
4526  // copy sparse data to dense result vector based on coef array
4527  if(ninds != 0 && inds != 0)
4528  {
4529  // SoPlex may have destroyed the sparsity structure so we need to restore it
4530  x.setup();
4531  *ninds = x.size();
4532 
4533  for(int i = 0; i < *ninds; ++i)
4534  {
4535  idx = x.index(i);
4536  coef[idx] = x[idx];
4537  // set sparsity pattern of coef array
4538  inds[i] = idx;
4539  }
4540  }
4541  else
4542  {
4543  VectorReal y(numRowsReal(), coef);
4544  y = x;
4545 
4546  if(ninds != 0)
4547  *ninds = -1;
4548  }
4549  }
4550  else
4551  {
4552  assert(_solver.rep() == SPxSolver::ROW);
4553 
4554  /// @todo should rhs be a reference?
4555  int* bind = 0;
4556  int index;
4557 
4558  // get indices of column basis matrix (not in correct order!)
4559  spx_alloc(bind, numRowsReal());
4560  getBasisInd(bind);
4561 
4562  index = bind[c];
4563  // index = c >= numColsReal() ? 0 : c;
4564 
4565  // initialize result vector x as zero
4566  memset(coef, 0, (unsigned int)numRowsReal() * sizeof(Real));
4567 
4568  if(!_solver.isRowBasic(c))
4569  {
4570  // this column of B^-1 is just a unit column
4571  for(int i = 0; i < numRowsReal(); i++)
4572  {
4573  if(bind[i] < 0 && -bind[i]-1 == c)
4574  coef[i] = 1.0;
4575  }
4576  }
4577  else
4578  {
4580 
4581  for(int k = 0; k < numColsReal(); k++)
4582  {
4583  if(c == _solver.number(_solver.basis().baseId(k)) && _solver.basis().baseId(k).isSPxRowId())
4584  {
4585  index = k;
4586  break;
4587  }
4588  }
4589 
4590  try
4591  {
4592  if(unscale && _solver.isScaled())
4593  {
4594  int scaleExp = -_scaler->getRowScaleExp(index);
4595  DSVectorReal rhs(1);
4596  rhs.add(index, spxLdexp(1.0, scaleExp));
4597  _solver.basis().coSolve(x, rhs);
4598  x.setup();
4599  int size = x.size();
4600 
4601  // apply scaling based on \tilde{C}
4602  for(int i = 0; i < size; i++)
4603  {
4604  int idx = bind[x.index(i)];
4605  if(idx < 0)
4606  {
4607  idx = -idx - 1;
4608  scaleExp = _scaler->getRowScaleExp(idx);
4609  }
4610  else
4611  scaleExp = - _scaler->getColScaleExp(idx);
4612 
4613  spxLdexp(x.value(i), scaleExp);
4614  }
4615  }
4616  else
4617  {
4618 
4619 
4620  _solver.basis().coSolve(x, _solver.unitVector(index));
4621  }
4622  }
4623  catch(const SPxException& E)
4624  {
4625  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4626  "> while computing basis inverse column.\n");
4627  return false;
4628  }
4629 
4630  // add nonzero entries into result vector
4631  for(int i = 0; i < numRowsReal(); i++)
4632  {
4633  int idx = bind[i];
4634 
4635  if(idx < 0)
4636  {
4637  // convert to proper row index
4638  idx = - idx - 1;
4639  // should be a valid row index, basic in the column basis
4640  assert(idx >= 0);
4641  assert(idx < numRowsReal());
4642  assert(!_solver.isRowBasic(idx));
4643 
4644  if(unscale && _solver.isScaled())
4645  {
4646  DSVector r_unscaled(numColsReal());
4647  _solver.getRowVectorUnscaled(idx, r_unscaled);
4648  coef[i] = - (r_unscaled * x);
4649  }
4650  else
4651  coef[i] = - (_solver.rowVector(idx) * x);
4652 
4653  if(unscale && _solver.isScaled())
4654  coef[i] = spxLdexp(coef[i], _scaler->getRowScaleExp(idx));
4655  }
4656  else
4657  {
4658  // should be a valid column index, basic in the column basis
4659  assert(idx >= 0);
4660  assert(idx < numColsReal());
4661  assert(!_solver.isColBasic(idx));
4662 
4663  if(unscale && _solver.isScaled())
4664  coef[i] = spxLdexp(x[idx], _scaler->getColScaleExp(idx));
4665  else
4666  coef[i] = x[idx];
4667  }
4668  }
4669  }
4670 
4671  /// @todo implement returning of sparsity information like in column wise case
4672  if(ninds != NULL)
4673  *ninds = -1;
4674 
4675  // free memory
4676  spx_free(bind);
4677  }
4678 
4679  return true;
4680 }
4681 
4682 
4683 
4684 /// computes dense solution of basis matrix B * sol = rhs; returns true on success
4685 bool SoPlex::getBasisInverseTimesVecReal(Real* rhs, Real* sol, bool unscale)
4686 {
4687  VectorReal v(numRowsReal(), rhs);
4688  VectorReal x(numRowsReal(), sol);
4689 
4690  if(!hasBasis())
4691  return false;
4692 
4694 
4695  if(!_isRealLPLoaded)
4696  return false;
4697 
4698  // we need to distinguish between column and row representation; ask the solver itself which representation it
4699  // has, since the REPRESENTATION parameter of this class might be set to automatic; in the column case we can use
4700  // the existing factorization
4701  if(_solver.rep() == SPxSolver::COLUMN)
4702  {
4703  // solve system "x = B^-1 * v"
4704  try
4705  {
4706  /* unscaling required? */
4707  if(unscale && _solver.isScaled())
4708  {
4709  /* for information on the unscaling procedure see spxscaler.h */
4710  int scaleExp;
4711  int idx;
4712 
4713  for(int i = 0; i < v.dim(); ++i)
4714  {
4715  if(isNotZero(v[i]))
4716  {
4717  scaleExp = _scaler->getRowScaleExp(i);
4718  v[i] = spxLdexp(v[i], scaleExp);
4719  }
4720  }
4721 
4722  _solver.basis().solve(x, v);
4723 
4724  for(int i = 0; i < x.dim(); i++)
4725  {
4726  if(isNotZero(x[i]))
4727  {
4728  idx = _solver.number(_solver.basis().baseId(i));
4729 
4730  if(_solver.basis().baseId(i).isSPxColId())
4731  scaleExp = _scaler->getColScaleExp(idx);
4732  else
4733  scaleExp = - _scaler->getRowScaleExp(idx);
4734 
4735  x[i] = spxLdexp(x[i], scaleExp);
4736  }
4737  }
4738  }
4739  else
4740  {
4741  _solver.basis().solve(x, v);
4742  }
4743  }
4744  catch(const SPxException& E)
4745  {
4746  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4747  "> while solving with basis matrix.\n");
4748  return false;
4749  }
4750  }
4751  else
4752  {
4753  assert(_solver.rep() == SPxSolver::ROW);
4754 
4755  DSVectorReal rowrhs(numColsReal());
4757  int* bind = 0;
4758 
4759  bool adaptScaling = unscale && _realLP->isScaled();
4760  int scaleExp;
4761  int idx;
4762 
4763  // get ordering of column basis matrix
4764  spx_alloc(bind, numRowsReal());
4765  getBasisInd(bind);
4766 
4767  // fill right-hand side for row-based system
4768  for(int i = 0; i < numColsReal(); ++i)
4769  {
4770  SPxId id = _solver.basis().baseId(i);
4771 
4772  if(id.isSPxRowId())
4773  {
4774  assert(_solver.number(id) >= 0);
4775  assert(_solver.number(id) < numRowsReal());
4776 
4777  if(adaptScaling)
4778  {
4779  idx = _solver.number(id);
4780  scaleExp = _scaler->getRowScaleExp(idx);
4781  rowrhs.add(i, spxLdexp(v[idx], scaleExp));
4782  }
4783  else
4784  rowrhs.add(i, v[_solver.number(id)]);
4785  }
4786  else
4787  {
4788  assert(rowrhs[i] == 0.0);
4789  }
4790  }
4791 
4792  // solve system "B y = rowrhs", where B is the row basis matrix
4793  try
4794  {
4795  _solver.basis().coSolve(y, rowrhs);
4796  }
4797  catch(const SPxException& E)
4798  {
4799  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4800  "> while solving with basis matrix.\n");
4801  return false;
4802  }
4803 
4804  // fill result w.r.t. order given by bind
4805  for(int i = 0; i < numRowsReal(); ++i)
4806  {
4807  int index;
4808 
4809  index = bind[i];
4810 
4811  if(index < 0)
4812  {
4813  index = -index - 1;
4814 
4815  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4816  assert(index >= 0);
4817  assert(index < numRowsReal());
4818  assert(!_solver.isRowBasic(index));
4819 
4820  x[i] = v[index] - (rowVectorRealInternal(index) * Vector(numColsReal(), y.get_ptr()));
4821 
4822  if(adaptScaling)
4823  {
4824  scaleExp = -_scaler->getRowScaleExp(index);
4825  x[i] = spxLdexp(x[i], scaleExp);
4826  }
4827  }
4828  else
4829  {
4830  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4831  assert(index >= 0);
4832  assert(index < numColsReal());
4833  assert(!_solver.isColBasic(index));
4834 
4835  if(adaptScaling)
4836  {
4837  scaleExp = _scaler->getColScaleExp(index);
4838  x[i] = spxLdexp(y[index], scaleExp);
4839  }
4840  else
4841  x[i] = y[index];
4842  }
4843  }
4844 
4845  // free memory
4846  spx_free(bind);
4847  }
4848 
4849  return true;
4850 }
4851 
4852 
4853 
4854 /// multiply with basis matrix; B * vec (inplace)
4855 bool SoPlex::multBasis(Real* vec, bool unscale)
4856 {
4857  if(!hasBasis())
4858  return false;
4859 
4861 
4862  if(!_isRealLPLoaded)
4863  return false;
4864 
4865  if(_solver.rep() == SPxSolver::COLUMN)
4866  {
4867  int basisdim = numRowsReal();
4868 
4869  // create Vector from input values
4870  Vector x(basisdim, vec);
4871 
4872  if(unscale && _solver.isScaled())
4873  {
4874  /* for information on the unscaling procedure see spxscaler.h */
4875 
4876  int scaleExp;
4877 
4878  for(int i = 0; i < basisdim; ++i)
4879  {
4880  if(isNotZero(vec[i]))
4881  {
4882  if(_solver.basis().baseId(i).isSPxColId())
4883  scaleExp = - _scaler->getColScaleExp(_solver.number(_solver.basis().baseId(i)));
4884  else
4886 
4887  vec[i] = spxLdexp(vec[i], scaleExp);
4888  }
4889  }
4890 
4891  _solver.basis().multBaseWith(x);
4892 
4893  for(int i = 0; i < basisdim; ++i)
4894  {
4895  scaleExp = _scaler->getRowScaleExp(i);
4896  vec[i] = spxLdexp(vec[i], -scaleExp);
4897  }
4898  }
4899  else
4900  _solver.basis().multBaseWith(x);
4901  }
4902  else
4903  {
4904  int colbasisdim = numRowsReal();
4905 
4906  DSVector y(colbasisdim);
4907 
4908  y.clear();
4909 
4910  // create Vector from input values
4911  Vector x(colbasisdim, vec);
4912 
4913  int* bind = 0;
4914  int index;
4915 
4916  // get ordering of column basis matrix
4917  spx_alloc(bind, colbasisdim);
4918  getBasisInd(bind);
4919 
4920  // temporarily create the column basis and multiply every column with x
4921  for(int i = 0; i < colbasisdim; ++i)
4922  {
4923  if(isNotZero(x[i]))
4924  {
4925  // get vector corresponding to requested index i
4926  index = bind[i];
4927 
4928  // r corresponds to a row vector
4929  if(index < 0)
4930  {
4931  // transform index to actual row index
4932  index = -index - 1;
4933 
4934  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4935  assert(index >= 0);
4936  assert(index < numRowsReal());
4937  assert(!_solver.isRowBasic(index));
4938 
4939  y.add(x[i] * UnitVectorReal(index));
4940  }
4941  // r corresponds to a column vector
4942  else
4943  {
4944  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4945  assert(index < numColsReal());
4946  assert(!_solver.isColBasic(index));
4947 
4948  if(unscale && _solver.isScaled())
4949  {
4950  DSVector col;
4951  _solver.getColVectorUnscaled(index, col);
4952  y.add(x[i] * col);
4953  }
4954 
4955  y.add(x[i] * _solver.colVector(index));
4956  }
4957  }
4958  }
4959 
4960  spx_free(bind);
4961  x = y;
4962  }
4963 
4964  return true;
4965 }
4966 
4967 
4968 
4969 /// multiply with transpose of basis matrix; vec * B^T (inplace)
4970 bool SoPlex::multBasisTranspose(Real* vec, bool unscale)
4971 {
4972  if(!hasBasis())
4973  return false;
4974 
4976 
4977  if(!_isRealLPLoaded)
4978  return false;
4979 
4980  if(_solver.rep() == SPxSolver::COLUMN)
4981  {
4982  int basisdim = numRowsReal();
4983 
4984  // create Vector from input values
4985  Vector x(basisdim, vec);
4986 
4987  if(unscale && _solver.isScaled())
4988  {
4989  /* for information on the unscaling procedure see spxscaler.h */
4990 
4991  int scaleExp;
4992 
4993  for(int i = 0; i < basisdim; ++i)
4994  {
4995  if(isNotZero(vec[i]))
4996  {
4997  scaleExp = - _scaler->getRowScaleExp(i);
4998  vec[i] = spxLdexp(vec[i], scaleExp);
4999  }
5000  }
5001 
5002  _solver.basis().multWithBase(x);
5003 
5004  for(int i = 0; i < basisdim; ++i)
5005  {
5006  if(isNotZero(vec[i]))
5007  {
5008  if(_solver.basis().baseId(i).isSPxColId())
5009  scaleExp = - _scaler->getColScaleExp(_solver.number(_solver.basis().baseId(i)));
5010  else
5012 
5013  vec[i] = spxLdexp(vec[i], scaleExp);
5014  }
5015  }
5016  }
5017  else
5018  _solver.basis().multWithBase(x);
5019  }
5020  else
5021  {
5022  int colbasisdim = numRowsReal();
5023 
5024  DSVector y(colbasisdim);
5025 
5026  // create Vector from input values
5027  Vector x(colbasisdim, vec);
5028 
5029  int* bind = 0;
5030  int index;
5031 
5032  // get ordering of column basis matrix
5033  spx_alloc(bind, colbasisdim);
5034  getBasisInd(bind);
5035 
5036  // temporarily create the column basis and multiply every column with x
5037  for(int i = 0; i < colbasisdim; ++i)
5038  {
5039  // get vector corresponding to requested index i
5040  index = bind[i];
5041 
5042  // r corresponds to a row vector
5043  if(index < 0)
5044  {
5045  // transform index to actual row index
5046  index = -index - 1;
5047 
5048  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
5049  assert(index >= 0);
5050  assert(index < numRowsReal());
5051  assert(!_solver.isRowBasic(index));
5052 
5053  y.add(i, x * UnitVectorReal(index));
5054  }
5055  // r corresponds to a column vector
5056  else
5057  {
5058  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
5059  assert(index < numColsReal());
5060  assert(!_solver.isColBasic(index));
5061 
5062  if(unscale && _solver.isScaled())
5063  {
5064  DSVector col;
5065  _solver.getColVectorUnscaled(index, col);
5066  y.add(i, x * col);
5067  }
5068  else
5069  y.add(i, x * _solver.colVector(index));
5070  }
5071  }
5072 
5073  spx_free(bind);
5074  x = y;
5075  }
5076 
5077  return true;
5078 }
5079 
5080 
5081 
5082 /// compute rational basis inverse; returns true on success
5084 {
5085  if(!hasBasis())
5086  {
5089  return false;
5090  }
5091 
5094  {
5098  }
5099 
5101  return true;
5102 
5103  return false;
5104 }
5105 
5106 
5107 
5108 /// gets an array of indices for the columns of the rational basis matrix; bind[i] >= 0 means that the i-th column of
5109 /// the basis matrix contains variable bind[i]; bind[i] < 0 means that the i-th column of the basis matrix contains
5110 /// the slack variable for row -bind[i]-1; performs rational factorization if not available; returns true on success
5112 {
5115 
5117  return false;
5118 
5119  bind = _rationalLUSolverBind;
5120  assert(bind.size() == numRowsRational());
5121  return true;
5122 }
5123 
5124 
5125 
5126 /// computes row r of basis inverse; performs rational factorization if not available; returns true on success
5128 {
5131 
5133  return false;
5134 
5135  try
5136  {
5137  vec.reDim(numRowsRational());
5139  }
5140  catch(const SPxException& E)
5141  {
5142  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5143  "> while computing rational basis inverse row.\n");
5144  return false;
5145  }
5146 
5147  return true;
5148 }
5149 
5150 
5151 
5152 /// computes column c of basis inverse; performs rational factorization if not available; returns true on success
5154 {
5157 
5159  return false;
5160 
5161  try
5162  {
5163  vec.reDim(numRowsRational());
5165  }
5166  catch(const SPxException& E)
5167  {
5168  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5169  "> while computing rational basis inverse column.\n");
5170  return false;
5171  }
5172 
5173  return true;
5174 }
5175 
5176 
5177 
5178 /// computes solution of basis matrix B * sol = rhs; performs rational factorization if not available; returns true
5179 /// on success
5181 {
5184 
5186  return false;
5187 
5188  try
5189  {
5190  sol.reDim(numRowsRational());
5191  _rationalLUSolver.solveRight(sol, rhs);
5192  }
5193  catch(const SPxException& E)
5194  {
5195  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5196  "> during right solve with rational basis inverse.\n");
5197  return false;
5198  }
5199 
5200  return true;
5201 }
5202 
5203 
5204 
5205 /// sets starting basis via arrays of statuses
5207 {
5209 
5210  if(_isRealLPLoaded)
5211  {
5212  assert(numRowsReal() == _solver.nRows());
5213  assert(numColsReal() == _solver.nCols());
5214 
5215  _solver.setBasis(rows, cols);
5217  }
5218  else
5219  {
5222 
5223  for(int i = numRowsReal() - 1; i >= 0; i--)
5224  _basisStatusRows[i] = rows[i];
5225 
5226  for(int j = numColsReal() - 1; j >= 0; j--)
5227  _basisStatusCols[j] = cols[j];
5228 
5229  _hasBasis = true;
5230  }
5231 }
5232 
5233 
5234 
5235 /// clears starting basis
5237 {
5238  _solver.reLoad();
5239  _status = _solver.status();
5240  _hasBasis = false;
5242 }
5243 
5244 
5245 
5246 /// number of iterations since last call to solve
5248 {
5249  return _statistics->iterations;
5250 }
5251 
5252 
5253 
5254 /// time spent in last call to solve
5256 {
5257  return _statistics->solvingTime->time();
5258 }
5259 
5260 
5261 
5262 /// statistical information in form of a string
5263 std::string SoPlex::statisticString() const
5264 {
5265  std::stringstream s;
5266  s << "Factorizations : " << std::setw(10) << _statistics->luFactorizationsReal << std::endl
5267  << " Time spent : " << std::setw(10) << std::fixed << std::setprecision(
5268  2) << _statistics->luFactorizationTimeReal << std::endl
5269  << "Solves : " << std::setw(10) << _statistics->luSolvesReal << std::endl
5270  << " Time spent : " << std::setw(10) << _statistics->luSolveTimeReal << std::endl
5271  << "Solution time : " << std::setw(10) << std::fixed << std::setprecision(
5272  2) << solveTime() << std::endl
5273  << "Iterations : " << std::setw(10) << numIterations() << std::endl;
5274 
5275  return s.str();
5276 }
5277 
5278 
5279 
5280 /// name of starter
5282 {
5283  if(_starter)
5284  return _starter->getName();
5285  else
5286  return "none";
5287 }
5288 
5289 
5290 
5291 /// name of simplifier
5293 {
5294  if(_simplifier)
5295  return _simplifier->getName();
5296  else
5297  return "none";
5298 }
5299 
5300 
5301 
5302 /// name of scaling method after simplifier
5304 {
5305  if(_scaler)
5306  return _scaler->getName();
5307  else
5308  return "none";
5309 }
5310 
5311 
5312 
5313 /// name of currently loaded pricer
5315 {
5316  return _solver.pricer()->getName();
5317 }
5318 
5319 
5320 
5321 /// name of currently loaded ratiotester
5323 {
5324  return _solver.ratiotester()->getName();
5325 }
5326 
5327 
5328 
5329 /// reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and
5330 /// integer variables if desired; returns true on success
5331 bool SoPlex::readFile(const char* filename, NameSet* rowNames, NameSet* colNames, DIdxSet* intVars)
5332 {
5333  bool success = false;
5334 
5336  success = _readFileReal(filename, rowNames, colNames, intVars);
5337  else
5338  success = _readFileRational(filename, rowNames, colNames, intVars);
5339 
5340  // storing the row and column names for use in the DBDS print basis methods
5341  _rowNames = rowNames;
5342  _colNames = colNames;
5343 
5344  return success;
5345 }
5346 
5347 /// writes real LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
5348 /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
5349 /// marked as integer; returns true on success
5350 bool SoPlex::writeFileReal(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5351  const DIdxSet* intVars, const bool unscale) const
5352 {
5353  ///@todo implement return value
5354  if(unscale && _realLP->isScaled())
5355  {
5356  MSG_INFO3(spxout, spxout << "copy LP to write unscaled original problem" << std::endl;)
5357  SPxLPReal* origLP;
5358  origLP = 0;
5359  spx_alloc(origLP);
5360  origLP = new(origLP) SPxLPReal(*_realLP);
5361  origLP->unscaleLP();
5362  origLP->writeFile(filename, rowNames, colNames, intVars);
5363  origLP->~SPxLPReal();
5364  spx_free(origLP);
5365  }
5366  else
5367  _realLP->writeFile(filename, rowNames, colNames, intVars);
5368 
5369  return true;
5370 }
5371 
5372 
5373 
5374 /// writes rational LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
5375 /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
5376 /// marked as integer; returns true on success
5377 bool SoPlex::writeFileRational(const char* filename, const NameSet* rowNames,
5378  const NameSet* colNames, const DIdxSet* intVars) const
5379 {
5381  return false;
5382  else
5383  {
5384  assert(_rationalLP != 0);
5385  _rationalLP->writeFile(filename, rowNames, colNames, intVars);
5386 
5387  ///@todo implement return value
5388  return true;
5389  }
5390 }
5391 
5392 
5393 
5394 /// writes the dual of the real LP to file; LP or MPS format is chosen from the extension in \p filename;
5395 /// if \p rowNames and \p colNames are \c NULL, default names are used; if \p intVars is not \c NULL,
5396 /// the variables contained in it are marked as integer; returns true on success
5397 bool SoPlex::writeDualFileReal(const char* filename, const NameSet* rowNames,
5398  const NameSet* colNames, const DIdxSet* intVars) const
5399 {
5400  SPxLPReal dualLP;
5401  _realLP->buildDualProblem(dualLP);
5402  dualLP.setOutstream(spxout);
5403 
5404  // swap colnames and rownames
5405  dualLP.writeFile(filename, colNames, rowNames);
5406  return true;
5407 }
5408 
5409 
5410 
5411 /// reads basis information from \p filename and returns true on success; if \p rowNames and \p colNames are \c NULL,
5412 /// default names are assumed; returns true on success
5413 bool SoPlex::readBasisFile(const char* filename, const NameSet* rowNames, const NameSet* colNames)
5414 {
5415  clearBasis();
5416 
5417 #if 1
5418  assert(filename != 0);
5419  assert(_realLP != 0);
5420 
5421  // start timing
5423 
5424  // read
5425  if(!_isRealLPLoaded)
5426  {
5427  assert(_realLP != &_solver);
5428 
5430  _realLP->~SPxLPReal();
5431  spx_free(_realLP);
5432  _realLP = &_solver;
5433  _isRealLPLoaded = true;
5434  }
5435 
5436  _hasBasis = _solver.readBasisFile(filename, rowNames, colNames);
5437  assert(_hasBasis == (_solver.basis().status() > SPxBasis::NO_PROBLEM));
5438 
5439  // stop timing
5441 
5442  return _hasBasis;
5443 #else
5444  // this is alternative code for reading bases without the SPxSolver class
5445  assert(filename != 0);
5446 
5447  // start timing
5449 
5450  // read
5451  spxifstream file(filename);
5452 
5453  if(!file)
5454  return false;
5455 
5456  // get problem size
5457  int numRows = numRowsReal();
5458  int numCols = numColsReal();
5459 
5460  // prepare column names
5461  const NameSet* colNamesPtr = colNames;
5462  NameSet* tmpColNames = 0;
5463 
5464  if(colNames == 0)
5465  {
5466  std::stringstream name;
5467 
5468  spx_alloc(tmpColNames);
5469  tmpColNames = new(tmpColNames) NameSet();
5470  tmpColNames->reMax(numCols);
5471 
5472  for(int j = 0; j < numCols; ++j)
5473  {
5474  name << "x" << j;
5475  tmpColNames->add(name.str().c_str());
5476  }
5477 
5478  colNamesPtr = tmpColNames;
5479  }
5480 
5481  // prepare row names
5482  const NameSet* rowNamesPtr = rowNames;
5483  NameSet* tmpRowNames = 0;
5484 
5485  if(rowNamesPtr == 0)
5486  {
5487  std::stringstream name;
5488 
5489  spx_alloc(tmpRowNames);
5490  tmpRowNames = new(tmpRowNames) NameSet();
5491  tmpRowNames->reMax(numRows);
5492 
5493  for(int i = 0; i < numRows; ++i)
5494  {
5495  name << "C" << i;
5496  tmpRowNames->add(name.str().c_str());
5497  }
5498 
5499  rowNamesPtr = tmpRowNames;
5500  }
5501 
5502  // initialize with default slack basis
5503  _basisStatusRows.reSize(numRows);
5504  _basisStatusCols.reSize(numCols);
5505 
5506  for(int i = 0; i < numRows; i++)
5508 
5509  for(int i = 0; i < numCols; i++)
5510  {
5513  else if(lowerRealInternal(i) <= double(-realParam(SoPlex::INFTY))
5514  && upperRealInternal(i) >= double(realParam(SoPlex::INFTY)))
5516  else if(lowerRealInternal(i) <= double(-realParam(SoPlex::INFTY)))
5518  else
5520  }
5521 
5522  // read basis
5523  MPSInput mps(file);
5524 
5525  if(mps.readLine() && (mps.field0() != 0) && !strcmp(mps.field0(), "NAME"))
5526  {
5527  while(mps.readLine())
5528  {
5529  int c = -1;
5530  int r = -1;
5531 
5532  if(mps.field0() != 0 && !strcmp(mps.field0(), "ENDATA"))
5533  {
5535  break;
5536  }
5537 
5538  if(mps.field1() == 0 || mps.field2() == 0)
5539  break;
5540 
5541  if((c = colNamesPtr->number(mps.field2())) < 0)
5542  break;
5543 
5544  if(*mps.field1() == 'X')
5545  {
5546  if(mps.field3() == 0 || (r = rowNamesPtr->number(mps.field3())) < 0)
5547  break;
5548  }
5549 
5550  if(!strcmp(mps.field1(), "XU"))
5551  {
5553 
5556  else if(_rowTypes[r] == SoPlex::RANGETYPE_FIXED)
5558  else
5560  }
5561  else if(!strcmp(mps.field1(), "XL"))
5562  {
5564 
5567  else if(_rowTypes[r] == SoPlex::RANGETYPE_FIXED)
5569  else
5571  }
5572  else if(!strcmp(mps.field1(), "UL"))
5573  {
5575  }
5576  else if(!strcmp(mps.field1(), "LL"))
5577  {
5579  }
5580  else
5581  {
5582  mps.syntaxError();
5583  break;
5584  }
5585  }
5586  }
5587 
5588  if(rowNames == 0)
5589  {
5590  tmpRowNames->~NameSet();
5591  spx_free(tmpRowNames);
5592  }
5593 
5594  if(colNames == 0)
5595  {
5596  tmpColNames->~NameSet();
5597  spx_free(tmpColNames);
5598  }
5599 
5600  _hasBasis = !mps.hasError();
5601 
5602  // stop timing
5604 
5605  return _hasBasis;
5606 #endif
5607 }
5608 
5609 
5610 
5611 /// writes basis information to \p filename; if \p rowNames and \p colNames are \c NULL, default names are used;
5612 /// returns true on success
5613 bool SoPlex::writeBasisFile(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5614  const bool cpxFormat) const
5615 {
5616  assert(filename != 0);
5617 
5618  if(_isRealLPLoaded)
5619  return _solver.writeBasisFile(filename, rowNames, colNames, cpxFormat);
5620  else
5621  {
5622  std::ofstream file(filename);
5623 
5624  if(!file.good())
5625  return false;
5626 
5627  file.setf(std::ios::left);
5628  file << "NAME " << filename << "\n";
5629 
5630  // do not write basis if there is none
5631  if(!_hasBasis)
5632  {
5633  file << "ENDATA\n";
5634  return true;
5635  }
5636 
5637  // start writing
5638  int numRows = _basisStatusRows.size();
5639  int numCols = _basisStatusCols.size();
5640  int row = 0;
5641 
5642  for(int col = 0; col < numCols; col++)
5643  {
5644  assert(_basisStatusCols[col] != SPxSolver::UNDEFINED);
5645 
5647  {
5648  // find nonbasic row
5649  for(; row < numRows; row++)
5650  {
5651  assert(_basisStatusRows[row] != SPxSolver::UNDEFINED);
5652 
5654  break;
5655  }
5656 
5657  assert(row != numRows);
5658 
5659  if(_basisStatusRows[row] == SPxSolver::ON_UPPER && (!cpxFormat
5660  || _rowTypes[row] == SoPlex::RANGETYPE_BOXED))
5661  file << " XU ";
5662  else
5663  file << " XL ";
5664 
5665  file << std::setw(8);
5666 
5667  if(colNames != 0 && colNames->has(col))
5668  file << (*colNames)[col];
5669  else
5670  file << "x" << col;
5671 
5672  file << " ";
5673 
5674  if(rowNames != 0 && rowNames->has(row))
5675  file << (*rowNames)[row];
5676  else
5677  file << "C" << row;
5678 
5679  file << "\n";
5680  row++;
5681  }
5682  else
5683  {
5685  {
5686  file << " UL ";
5687 
5688  file << std::setw(8);
5689 
5690  if(colNames != 0 && colNames->has(col))
5691  file << (*colNames)[col];
5692  else
5693  file << "x" << col;
5694 
5695  file << "\n";
5696  }
5697  }
5698  }
5699 
5700  file << "ENDATA\n";
5701 
5702 #ifndef NDEBUG
5703 
5704  // check that the remaining rows are basic
5705  for(; row < numRows; row++)
5706  {
5707  assert(_basisStatusRows[row] == SPxSolver::BASIC);
5708  }
5709 
5710 #endif
5711 
5712  return true;
5713  }
5714 }
5715 
5716 
5717 
5718 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
5719 /// default names are used
5720 void SoPlex::writeStateReal(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5721  const bool cpxFormat) const
5722 {
5723  std::string ofname;
5724 
5725  // write parameter settings
5726  ofname = std::string(filename) + ".set";
5727  saveSettingsFile(ofname.c_str());
5728 
5729  // write problem in MPS/LP format
5730  ofname = std::string(filename) + ((cpxFormat) ? ".lp" : ".mps");
5731  writeFileReal(ofname.c_str(), rowNames, colNames, 0);
5732 
5733  // write basis
5734  ofname = std::string(filename) + ".bas";
5735  writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
5736 }
5737 
5738 
5739 
5740 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
5741 /// default names are used
5742 void SoPlex::writeStateRational(const char* filename, const NameSet* rowNames,
5743  const NameSet* colNames, const bool cpxFormat) const
5744 {
5745  std::string ofname;
5746 
5747  // write parameter settings
5748  ofname = std::string(filename) + ".set";
5749  saveSettingsFile(ofname.c_str());
5750 
5751  // write problem in MPS/LP format
5752  ofname = std::string(filename) + ((cpxFormat) ? ".lp" : ".mps");
5753  writeFileRational(ofname.c_str(), rowNames, colNames, 0);
5754 
5755  // write basis
5756  ofname = std::string(filename) + ".bas";
5757  writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
5758 }
5759 
5760 
5761 
5762 /// returns boolean parameter value
5763 bool SoPlex::boolParam(const BoolParam param) const
5764 {
5765  assert(param >= 0);
5766  assert(param < SoPlex::BOOLPARAM_COUNT);
5767  return _currentSettings->_boolParamValues[param];
5768 }
5769 
5770 
5771 
5772 /// returns integer parameter value
5773 int SoPlex::intParam(const IntParam param) const
5774 {
5775  assert(param >= 0);
5776  assert(param < INTPARAM_COUNT);
5777  return _currentSettings->_intParamValues[param];
5778 }
5779 
5780 
5781 
5782 /// returns real parameter value
5784 {
5785  assert(param >= 0);
5786  assert(param < REALPARAM_COUNT);
5787  return _currentSettings->_realParamValues[param];
5788 }
5789 
5790 
5791 
5792 #ifdef SOPLEX_WITH_RATIONALPARAM
5793 /// returns rational parameter value
5794 Rational SoPlex::rationalParam(const RationalParam param) const
5795 {
5796  assert(param >= 0);
5797  assert(param < RATIONALPARAM_COUNT);
5798  return _currentSettings->_rationalParamValues[param];
5799 }
5800 #endif
5801 
5802 
5803 
5804 /// returns current parameter settings
5806 {
5807  return *_currentSettings;
5808 }
5809 
5810 
5811 
5812 /// sets boolean parameter value; returns true on success
5813 bool SoPlex::setBoolParam(const BoolParam param, const bool value, const bool init)
5814 {
5815  assert(param >= 0);
5816  assert(param < SoPlex::BOOLPARAM_COUNT);
5817  assert(init || _isConsistent());
5818 
5819  if(!init && value == boolParam(param))
5820  return true;
5821 
5822  switch(param)
5823  {
5824  case LIFTING:
5825  break;
5826 
5827  case EQTRANS:
5828  break;
5829 
5830  case TESTDUALINF:
5831  break;
5832 
5833  case RATFAC:
5834  break;
5835 
5836  case USEDECOMPDUALSIMPLEX:
5837  break;
5838 
5839  case COMPUTEDEGEN:
5840  break;
5841 
5842  case USECOMPDUAL:
5843  break;
5844 
5845  case EXPLICITVIOL:
5846  break;
5847 
5848  case ACCEPTCYCLING:
5849  break;
5850 
5851  case RATREC:
5852  break;
5853 
5854  case POWERSCALING:
5855  break;
5856 
5857  case RATFACJUMP:
5858  break;
5859 
5860  case ROWBOUNDFLIPS:
5862  break;
5863 
5864  case PERSISTENTSCALING:
5865  break;
5866 
5867  case FULLPERTURBATION:
5869  break;
5870 
5871  case ENSURERAY:
5872  break;
5873 
5874  default:
5875  return false;
5876  }
5877 
5878  _currentSettings->_boolParamValues[param] = value;
5879  return true;
5880 }
5881 
5882 
5883 
5884 /// sets integer parameter value; returns true on success
5885 bool SoPlex::setIntParam(const IntParam param, const int value, const bool init)
5886 {
5887  assert(param >= 0);
5888  assert(param < INTPARAM_COUNT);
5889  assert(init || _isConsistent());
5890 
5891  if(!init && value == intParam(param))
5892  return true;
5893 
5894  // check for a valid parameter value wrt bounds
5895  if(value < _currentSettings->intParam.lower[param]
5896  || value > _currentSettings->intParam.upper[param])
5897  return false;
5898 
5899  switch(param)
5900  {
5901  // objective sense
5902  case SoPlex::OBJSENSE:
5903  if(value != SoPlex::OBJSENSE_MAXIMIZE && value != SoPlex::OBJSENSE_MINIMIZE)
5904  return false;
5905 
5908 
5909  if(_rationalLP != 0)
5912 
5914  break;
5915 
5916  // type of computational form, i.e., column or row representation
5919  && value != SoPlex::REPRESENTATION_AUTO)
5920  return false;
5921 
5922  break;
5923 
5924  // type of algorithm, i.e., primal or dual
5925  case SoPlex::ALGORITHM:
5926  // decide upon entering/leaving at solve time depending on representation
5927  break;
5928 
5929  // type of LU update
5932  return false;
5933 
5936  break;
5937 
5938  // maximum number of updates before fresh factorization
5940  if(value == 0)
5942  else
5943  _solver.basis().setMaxUpdates(value);
5944 
5945  break;
5946 
5947  // iteration limit (-1 if unlimited)
5948  case SoPlex::ITERLIMIT:
5949  break;
5950 
5951  // refinement limit (-1 if unlimited)
5952  case SoPlex::REFLIMIT:
5953  break;
5954 
5955  // stalling refinement limit (-1 if unlimited)
5956  case SoPlex::STALLREFLIMIT:
5957  break;
5958 
5959  // display frequency
5960  case SoPlex::DISPLAYFREQ:
5961  _solver.setDisplayFreq(value);
5962  break;
5963 
5964  // verbosity level
5965  case SoPlex::VERBOSITY:
5966  switch(value)
5967  {
5968  case 0:
5970  break;
5971 
5972  case 1:
5974  break;
5975 
5976  case 2:
5978  break;
5979 
5980  case 3:
5982  break;
5983 
5984  case 4:
5986  break;
5987 
5988  case 5:
5990  break;
5991  }
5992 
5993  break;
5994 
5995  // type of simplifier
5996  case SoPlex::SIMPLIFIER:
5997  switch(value)
5998  {
5999  case SIMPLIFIER_OFF:
6000  _simplifier = 0;
6001  break;
6002 
6003  case SIMPLIFIER_AUTO:
6005  assert(_simplifier != 0);
6006  break;
6007 
6008  default:
6009  return false;
6010  }
6011 
6012  break;
6013 
6014  // type of scaler
6015  case SoPlex::SCALER:
6016  switch(value)
6017  {
6018  case SCALER_OFF:
6019  _scaler = 0;
6020  break;
6021 
6022  case SCALER_UNIEQUI:
6024  break;
6025 
6026  case SCALER_BIEQUI:
6028  break;
6029 
6030  case SCALER_GEO1:
6031  _scaler = &_scalerGeo1;
6032  break;
6033 
6034  case SCALER_GEO8:
6035  _scaler = &_scalerGeo8;
6036  break;
6037 
6038  case SCALER_LEASTSQ:
6040  break;
6041 
6042  case SCALER_GEOEQUI:
6044  break;
6045 
6046  default:
6047  return false;
6048  }
6049 
6050  break;
6051 
6052  // type of starter used to create crash basis
6053  case SoPlex::STARTER:
6054  switch(value)
6055  {
6056  case STARTER_OFF:
6057  _starter = 0;
6058  break;
6059 
6060  case STARTER_WEIGHT:
6062  break;
6063 
6064  case STARTER_SUM:
6065  _starter = &_starterSum;
6066  break;
6067 
6068  case STARTER_VECTOR:
6070  break;
6071 
6072  default:
6073  return false;
6074  }
6075 
6076  break;
6077 
6078  // type of pricer
6079  case SoPlex::PRICER:
6080  switch(value)
6081  {
6082  case PRICER_AUTO:
6084  break;
6085 
6086  case PRICER_DANTZIG:
6088  break;
6089 
6090  case PRICER_PARMULT:
6092  break;
6093 
6094  case PRICER_DEVEX:
6096  break;
6097 
6098  case PRICER_QUICKSTEEP:
6100  break;
6101 
6102  case PRICER_STEEP:
6104  break;
6105 
6106  default:
6107  return false;
6108  }
6109 
6110  break;
6111 
6112  // mode for synchronizing real and rational LP
6113  case SoPlex::SYNCMODE:
6114  switch(value)
6115  {
6116  case SYNCMODE_ONLYREAL:
6117  if(_rationalLP != 0)
6118  {
6119  _rationalLP->~SPxLPRational();
6121  }
6122 
6123  break;
6124 
6125  case SYNCMODE_AUTO:
6126  if(intParam(param) == SYNCMODE_ONLYREAL)
6127  _syncLPRational();
6128 
6129  break;
6130 
6131  case SYNCMODE_MANUAL:
6133  break;
6134 
6135  default:
6136  return false;
6137  }
6138 
6139  break;
6140 
6141  // mode for reading LP files; nothing to do but change the value if valid
6142  case SoPlex::READMODE:
6143  switch(value)
6144  {
6145  case READMODE_REAL:
6146  case READMODE_RATIONAL:
6147  break;
6148 
6149  default:
6150  return false;
6151  }
6152 
6153  break;
6154 
6155  // mode for iterative refinement strategy; nothing to do but change the value if valid
6156  case SoPlex::SOLVEMODE:
6157  switch(value)
6158  {
6159  case SOLVEMODE_REAL:
6160  case SOLVEMODE_AUTO:
6161  case SOLVEMODE_RATIONAL:
6162  break;
6163 
6164  default:
6165  return false;
6166  }
6167 
6168  break;
6169 
6170  // mode for a posteriori feasibility checks; nothing to do but change the value if valid
6171  case SoPlex::CHECKMODE:
6172  switch(value)
6173  {
6174  case CHECKMODE_REAL:
6175  case CHECKMODE_AUTO:
6176  case CHECKMODE_RATIONAL:
6177  break;
6178 
6179  default:
6180  return false;
6181  }
6182 
6183  break;
6184 
6185  // type of ratio test
6186  case SoPlex::RATIOTESTER:
6187  switch(value)
6188  {
6189  case RATIOTESTER_TEXTBOOK:
6191  break;
6192 
6193  case RATIOTESTER_HARRIS:
6195  break;
6196 
6197  case RATIOTESTER_FAST:
6199  break;
6200 
6203  break;
6204 
6205  default:
6206  return false;
6207  }
6208 
6209  break;
6210 
6211  // type of timer
6212  case SoPlex::TIMER:
6213  switch(value)
6214  {
6215  case TIMER_OFF:
6217  break;
6218 
6219  case TIMER_CPU:
6221  break;
6222 
6223  case TIMER_WALLCLOCK:
6225  break;
6226 
6227  default:
6228  return false;
6229  }
6230 
6231  break;
6232 
6233  // mode of hyper pricing
6234  case SoPlex::HYPER_PRICING:
6235  switch(value)
6236  {
6237  case HYPER_PRICING_OFF:
6238  case HYPER_PRICING_AUTO:
6239  case HYPER_PRICING_ON:
6240  break;
6241 
6242  default:
6243  return false;
6244  }
6245 
6246  break;
6247 
6248  // minimum number of stalling refinements since last pivot to trigger rational factorization
6250  break;
6251 
6252  // maximum number of conjugate gradient iterations in least square scaling
6254  if(_scaler)
6255  _scaler->setIntParam(value);
6256 
6257  break;
6258 
6259  // mode of solution polishing
6261  switch(value)
6262  {
6263  case POLISHING_OFF:
6265  break;
6266 
6267  case POLISHING_INTEGRALITY:
6269  break;
6270 
6273  break;
6274 
6275  default:
6276  return false;
6277  }
6278 
6279  break;
6280 
6281  // the decomposition based simplex parameter settings
6282  case DECOMP_ITERLIMIT:
6283  break;
6284 
6285  case DECOMP_MAXADDEDROWS:
6286  break;
6287 
6288  case DECOMP_DISPLAYFREQ:
6289  break;
6290 
6291  case DECOMP_VERBOSITY:
6292  break;
6293 
6294  // printing of condition n
6295  case PRINTCONDITION:
6297  break;
6298 
6299  default:
6300  return false;
6301  }
6302 
6303  _currentSettings->_intParamValues[param] = value;
6304  return true;
6305 }
6306 
6307 
6308 
6309 /// sets real parameter value; returns true on success
6310 bool SoPlex::setRealParam(const RealParam param, const Real value, const bool init)
6311 {
6312  assert(param >= 0);
6313  assert(param < REALPARAM_COUNT);
6314  assert(init || _isConsistent());
6315 
6316  if(!init && value == realParam(param))
6317  return true;
6318 
6319  if(value < _currentSettings->realParam.lower[param]
6320  || value > _currentSettings->realParam.upper[param])
6321  return false;
6322 
6323  // required to set a different feastol or opttol
6324  Real tmp_value = value;
6325 
6326  switch(param)
6327  {
6328  // primal feasibility tolerance; passed to the floating point solver only when calling solve()
6329  case SoPlex::FEASTOL:
6330 #ifndef SOPLEX_WITH_GMP
6331  if(value < DEFAULT_EPS_PIVOT)
6332  {
6333  MSG_WARNING(spxout, spxout << "Cannot set feasibility tolerance to small value " << value <<
6334  " without GMP - using " << DEFAULT_EPS_PIVOT << ".\n");
6335  tmp_value = DEFAULT_EPS_PIVOT;
6337  break;
6338  }
6339 
6340 #endif
6341  _rationalFeastol = value;
6342  break;
6343 
6344  // dual feasibility tolerance; passed to the floating point solver only when calling solve()
6345  case SoPlex::OPTTOL:
6346 #ifndef SOPLEX_WITH_GMP
6347  if(value < DEFAULT_EPS_PIVOT)
6348  {
6349  MSG_WARNING(spxout, spxout << "Cannot set optimality tolerance to small value " << value <<
6350  " without GMP - using " << DEFAULT_EPS_PIVOT << ".\n");
6351  tmp_value = DEFAULT_EPS_PIVOT;
6353  break;
6354  }
6355 
6356 #endif
6357  _rationalOpttol = value;
6358  break;
6359 
6360  // general zero tolerance
6361  case SoPlex::EPSILON_ZERO:
6362  Param::setEpsilon(value);
6363  break;
6364 
6365  // zero tolerance used in factorization
6368  break;
6369 
6370  // zero tolerance used in update of the factorization
6372  Param::setEpsilonUpdate(value);
6373  break;
6374 
6375  // pivot zero tolerance used in factorization (declare numerical singularity for small LU pivots)
6376  case SoPlex::EPSILON_PIVOT:
6377  Param::setEpsilonPivot(value);
6378  break;
6379 
6380  // infinity threshold
6381  case SoPlex::INFTY:
6382  _rationalPosInfty = value;
6383  _rationalNegInfty = -value;
6384 
6387 
6388  break;
6389 
6390  // time limit in seconds (INFTY if unlimited)
6391  case SoPlex::TIMELIMIT:
6392  break;
6393 
6394  // lower limit on objective value is set in solveReal()
6396  break;
6397 
6398  // upper limit on objective value is set in solveReal()
6400  break;
6401 
6402  // working tolerance for feasibility in floating-point solver
6403  case SoPlex::FPFEASTOL:
6404  break;
6405 
6406  // working tolerance for optimality in floating-point solver
6407  case SoPlex::FPOPTTOL:
6408  break;
6409 
6410  // maximum increase of scaling factors between refinements
6411  case SoPlex::MAXSCALEINCR:
6412  _rationalMaxscaleincr = value;
6413  break;
6414 
6415  // lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)
6416  case SoPlex::LIFTMINVAL:
6417  break;
6418 
6419  // upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulated)
6420  case SoPlex::LIFTMAXVAL:
6421  break;
6422 
6423  // threshold for sparse pricing
6425  break;
6426 
6427  // threshold on number of rows vs. number of columns for switching from column to row representations in auto mode
6429  break;
6430 
6431  // geometric frequency at which to apply rational reconstruction
6432  case SoPlex::RATREC_FREQ:
6433  break;
6434 
6435  // minimal reduction (sum of removed rows/cols) to continue simplification
6436  case SoPlex::MINRED:
6437  break;
6438 
6440  break;
6441 
6443  break;
6444 
6446  break;
6447 
6448  // accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations)
6449  case SoPlex::LEASTSQ_ACRCY:
6450  if(_scaler)
6451  _scaler->setRealParam(value);
6452 
6453  break;
6454 
6455  // objective offset
6456  case SoPlex::OBJ_OFFSET:
6457  if(_realLP)
6458  _realLP->changeObjOffset(value);
6459 
6460  if(_rationalLP)
6461  _rationalLP->changeObjOffset(value);
6462 
6463  break;
6464 
6465  default:
6466  return false;
6467  }
6468 
6469  _currentSettings->_realParamValues[param] = tmp_value;
6470  return true;
6471 }
6472 
6473 
6474 
6475 #ifdef SOPLEX_WITH_RATIONALPARAM
6476 /// sets rational parameter value; returns true on success
6477 bool SoPlex::setRationalParam(const RationalParam param, const Rational value, const bool init)
6478 {
6479  assert(param >= 0);
6480  assert(param < RATIONALPARAM_COUNT);
6481  assert(init || _isConsistent());
6482 
6483  if(!init && value == rationalParam(param))
6484  return true;
6485 
6486  if(value < _currentSettings->rationalParam.lower[param]
6487  || value > _currentSettings->rationalParam.upper[param])
6488  return false;
6489 
6490  switch(param)
6491  {
6492  default:
6493  // currently, there are no rational-valued parameters
6494  return false;
6495  }
6496 
6497  _currentSettings->_rationalParamValues[param] = value;
6498  return true;
6499 }
6500 #endif
6501 
6502 
6503 
6504 /// sets parameter settings; returns true on success
6505 bool SoPlex::setSettings(const Settings& newSettings, const bool init)
6506 {
6507  assert(init || _isConsistent());
6508 
6509  bool success = true;
6510 
6511  *_currentSettings = newSettings;
6512 
6513  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6514  success &= setBoolParam((BoolParam)i, _currentSettings->_boolParamValues[i], init);
6515 
6516  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6517  success &= setIntParam((IntParam)i, _currentSettings->_intParamValues[i], init);
6518 
6519  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6520  success &= setRealParam((RealParam)i, _currentSettings->_realParamValues[i], init);
6521 
6522 #ifdef SOPLEX_WITH_RATIONALPARAM
6523 
6524  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6525  success &= setRationalParam((RationalParam)i, _currentSettings->_rationalParamValues[i], init);
6526 
6527 #endif
6528 
6529  assert(_isConsistent());
6530 
6531  return success;
6532 }
6533 
6534 /// resets default parameter settings
6535 void SoPlex::resetSettings(const bool quiet, const bool init)
6536 {
6537  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6539 
6540  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6542 
6543  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6545 
6546 #ifdef SOPLEX_WITH_RATIONALPARAM
6547 
6548  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6549  success &= setRationalParam((RationalParam)i, _currentSettings->rationalParam.defaultValue[i],
6550  init);
6551 
6552 #endif
6553 }
6554 
6555 
6556 /// print non-default parameter values
6558 {
6559  bool printedValue = false;
6560 
6562 
6563  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6564  {
6566  continue;
6567 
6568  spxout << "bool:" << _currentSettings->boolParam.name[i] << " = " <<
6569  (_currentSettings->_boolParamValues[i] ? "true\n" : "false\n");
6570  printedValue = true;
6571  }
6572 
6573  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6574  {
6576  continue;
6577 
6578  spxout << "int:" << _currentSettings->intParam.name[i] << " = " <<
6579  _currentSettings->_intParamValues[i] << "\n";
6580  printedValue = true;
6581  }
6582 
6584 
6585  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6586  {
6588  continue;
6589 
6590  spxout << "real:" << _currentSettings->realParam.name[i] << " = " <<
6591  _currentSettings->_realParamValues[i] << "\n";
6592  printedValue = true;
6593  }
6594 
6595 #ifdef SOPLEX_WITH_RATIONALPARAM
6596 
6597  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6598  {
6599  if(_currentSettings->_rationalParamValues[i] == _currentSettings->rationalParam.defaultValue[i])
6600  continue;
6601 
6602  spxout << "rational:" << _currentSettings->rationalParam.name[i] << " = " <<
6603  _currentSettings->_rationalParamValues[i] << "\n";
6604  printedValue = true;
6605  }
6606 
6607 #endif
6608 
6610  {
6611  spxout << "uint:random_seed = " << _solver.random.getSeed() << "\n";
6612  printedValue = true;
6613  }
6614 
6615  if(printedValue)
6616  spxout << std::endl;
6617 }
6618 
6619 
6620 
6621 /// writes settings file; returns true on success
6622 bool SoPlex::saveSettingsFile(const char* filename, const bool onlyChanged) const
6623 {
6624  assert(filename != 0);
6625 
6626  std::ofstream file(filename);
6627  SPxOut::setScientific(file, 16);
6628 
6629  if(!file.good())
6630  return false;
6631 
6632  file.setf(std::ios::left);
6633 
6634  SPxOut::setFixed(file);
6635 
6636  file << "# SoPlex version " << SOPLEX_VERSION / 100 << "." << (SOPLEX_VERSION / 10) % 10 << "." <<
6637  SOPLEX_VERSION % 10;
6638 #if SOPLEX_SUBVERSION > 0
6639  file << "." << SOPLEX_SUBVERSION;
6640 #endif
6641  file << "\n";
6642 
6643  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6644  {
6645  if(onlyChanged
6647  continue;
6648 
6649  file << "\n";
6650  file << "# " << _currentSettings->boolParam.description[i] << "\n";
6651  file << "# range {true, false}, default " << (_currentSettings->boolParam.defaultValue[i] ?
6652  "true\n" : "false\n");
6653  file << "bool:" << _currentSettings->boolParam.name[i] << " = " <<
6654  (_currentSettings->_boolParamValues[i] ? "true\n" : "false\n");
6655  }
6656 
6657  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6658  {
6659  if(onlyChanged
6661  continue;
6662 
6663  file << "\n";
6664  file << "# " << _currentSettings->intParam.description[i] << "\n";
6665  file << "# range [" << _currentSettings->intParam.lower[i] << "," <<
6667  << "], default " << _currentSettings->intParam.defaultValue[i] << "\n";
6668  file << "int:" << _currentSettings->intParam.name[i] << " = " <<
6669  _currentSettings->_intParamValues[i] << "\n";
6670  }
6671 
6672  SPxOut::setScientific(file);
6673 
6674  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6675  {
6676  if(onlyChanged
6678  continue;
6679 
6680  file << "\n";
6681  file << "# " << _currentSettings->realParam.description[i] << "\n";
6682  file << "# range [" << _currentSettings->realParam.lower[i] << "," <<
6684  << "], default " << _currentSettings->realParam.defaultValue[i] << "\n";
6685  file << "real:" << _currentSettings->realParam.name[i] << " = " <<
6686  _currentSettings->_realParamValues[i] << "\n";
6687  }
6688 
6689 #ifdef SOPLEX_WITH_RATIONALPARAM
6690 
6691  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6692  {
6693  if(onlyChanged
6694  && _currentSettings->_rationalParamValues[i] == _currentSettings->rationalParam.defaultValue[i])
6695  continue;
6696 
6697  file << "\n";
6698  file << "# " << _currentSettings->rationalParam.description[i] << "\n";
6699  file << "# range [" << _currentSettings->rationalParam.lower[i] << "," <<
6700  _currentSettings->rationalParam.upper[i]
6701  << "], default " << _currentSettings->rationalParam.defaultValue[i] << "\n";
6702  file << "rational:" << _currentSettings->rationalParam.name[i] << " = " <<
6703  _currentSettings->_rationalParamValues[i] << "\n";
6704  }
6705 
6706 #endif
6707 
6708  if(!onlyChanged || _solver.random.getSeed() != DEFAULT_RANDOM_SEED)
6709  {
6710  file << "\n";
6711  file << "# initial random seed used for perturbation\n";
6712  file << "# range [0, " << UINT_MAX << "], default " << DEFAULT_RANDOM_SEED << "\n";
6713  file << "uint:random_seed = " << _solver.random.getSeed() << "\n";
6714  }
6715 
6716  return true;
6717 }
6718 
6719 
6720 
6721 /// reads settings file; returns true on success
6722 bool SoPlex::loadSettingsFile(const char* filename)
6723 {
6724  assert(filename != 0);
6725 
6726  // start timing
6728 
6729  MSG_INFO1(spxout, spxout << "Loading settings file <" << filename << "> . . .\n");
6730 
6731  // open file
6732  spxifstream file(filename);
6733 
6734  if(!file)
6735  {
6736  MSG_INFO1(spxout, spxout << "Error opening settings file.\n");
6737  return false;
6738  }
6739 
6740  // read file
6741  char line[SET_MAX_LINE_LEN];
6742  int lineNumber = 0;
6743  bool readError = false;
6744  bool parseError = false;
6745 
6746  while(!readError && !parseError)
6747  {
6748  lineNumber++;
6749  readError = !file.getline(line, sizeof(line));
6750 
6751  if(!readError)
6752  parseError = !_parseSettingsLine(line, lineNumber);
6753  }
6754 
6755  readError = readError && !file.eof();
6756 
6757  if(readError && strlen(line) == SET_MAX_LINE_LEN - 1)
6758  {
6759  MSG_INFO1(spxout, spxout << "Error reading settings file: line " << lineNumber <<
6760  " in settings file exceeds " << SET_MAX_LINE_LEN - 2 << " characters.\n");
6761  }
6762  else if(readError)
6763  {
6764  MSG_INFO1(spxout, spxout << "Error reading settings file: line " << lineNumber << ".\n");
6765  }
6766 
6767  // stop timing
6769 
6770  return !readError;
6771 }
6772 
6773 /// parses one setting string and returns true on success
6775 {
6776  assert(string != 0);
6777 
6778  if(string == 0)
6779  return false;
6780 
6781  char parseString[SET_MAX_LINE_LEN];
6782  spxSnprintf(parseString, SET_MAX_LINE_LEN - 1, "%s", string);
6783 
6784  char* line = parseString;
6785 
6786  // find the start of the parameter type
6787  while(*line == ' ' || *line == '\t' || *line == '\r')
6788  line++;
6789 
6790  if(*line == '\0' || *line == '\n' || *line == '#')
6791  return true;
6792 
6793  char* paramTypeString = line;
6794 
6795  // find the end of the parameter type
6796  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6797  && *line != '\0' && *line != ':')
6798  line++;
6799 
6800  if(*line == ':')
6801  {
6802  *line = '\0';
6803  line++;
6804  }
6805  else
6806  {
6807  *line = '\0';
6808  line++;
6809 
6810  // search for the ':' char in the line
6811  while(*line == ' ' || *line == '\t' || *line == '\r')
6812  line++;
6813 
6814  if(*line != ':')
6815  {
6816  MSG_INFO1(spxout, spxout <<
6817  "Error parsing setting string: no ':' separating parameter type and name.\n");
6818  return false;
6819  }
6820 
6821  line++;
6822  }
6823 
6824  // find the start of the parameter name
6825  while(*line == ' ' || *line == '\t' || *line == '\r')
6826  line++;
6827 
6828  if(*line == '\0' || *line == '\n' || *line == '#')
6829  {
6830  MSG_INFO1(spxout, spxout << "Error parsing setting string: no parameter name.\n");
6831  return false;
6832  }
6833 
6834  char* paramName = line;
6835 
6836  // find the end of the parameter name
6837  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6838  && *line != '\0' && *line != '=')
6839  line++;
6840 
6841  if(*line == '=')
6842  {
6843  *line = '\0';
6844  line++;
6845  }
6846  else
6847  {
6848  *line = '\0';
6849  line++;
6850 
6851  // search for the '=' char in the line
6852  while(*line == ' ' || *line == '\t' || *line == '\r')
6853  line++;
6854 
6855  if(*line != '=')
6856  {
6857  MSG_INFO1(spxout, spxout << "Error parsing setting string: no '=' after parameter name.\n");
6858  return false;
6859  }
6860 
6861  line++;
6862  }
6863 
6864  // find the start of the parameter value string
6865  while(*line == ' ' || *line == '\t' || *line == '\r')
6866  line++;
6867 
6868  if(*line == '\0' || *line == '\n' || *line == '#')
6869  {
6870  MSG_INFO1(spxout, spxout << "Error parsing setting string: no parameter value.\n");
6871  return false;
6872  }
6873 
6874  char* paramValueString = line;
6875 
6876  // find the end of the parameter value string
6877  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6878  && *line != '\0')
6879  line++;
6880 
6881  if(*line != '\0')
6882  {
6883  // check, if the rest of the line is clean
6884  *line = '\0';
6885  line++;
6886 
6887  while(*line == ' ' || *line == '\t' || *line == '\r')
6888  line++;
6889 
6890  if(*line != '\0' && *line != '\n' && *line != '#')
6891  {
6892  MSG_INFO1(spxout, spxout << "Error parsing setting string: additional character '" << *line <<
6893  "' after parameter value.\n");
6894  return false;
6895  }
6896  }
6897 
6898  // check whether we have a bool parameter
6899  if(strncmp(paramTypeString, "bool", 4) == 0)
6900  {
6901  for(int param = 0; ; param++)
6902  {
6903  if(param >= SoPlex::BOOLPARAM_COUNT)
6904  {
6905  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6906  ">.\n");
6907  return false;
6908  }
6909  else if(strncmp(paramName, _currentSettings->boolParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6910  {
6911  if(strncasecmp(paramValueString, "true", 4) == 0
6912  || strncasecmp(paramValueString, "TRUE", 4) == 0
6913  || strncasecmp(paramValueString, "t", 4) == 0
6914  || strncasecmp(paramValueString, "T", 4) == 0
6915  || strtol(paramValueString, NULL, 4) == 1)
6916  {
6917  setBoolParam((SoPlex::BoolParam)param, true);
6918  break;
6919  }
6920  else if(strncasecmp(paramValueString, "false", 5) == 0
6921  || strncasecmp(paramValueString, "FALSE", 5) == 0
6922  || strncasecmp(paramValueString, "f", 5) == 0
6923  || strncasecmp(paramValueString, "F", 5) == 0
6924  || strtol(paramValueString, NULL, 5) == 0)
6925  {
6926  setBoolParam((SoPlex::BoolParam)param, false);
6927  break;
6928  }
6929  else
6930  {
6931  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
6932  "> for bool parameter <" << paramName << ">.\n");
6933  return false;
6934  }
6935  }
6936  }
6937 
6938  return true;
6939  }
6940 
6941  // check whether we have an integer parameter
6942  if(strncmp(paramTypeString, "int", 3) == 0)
6943  {
6944  for(int param = 0; ; param++)
6945  {
6946  if(param >= SoPlex::INTPARAM_COUNT)
6947  {
6948  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6949  ">.\n");
6950  return false;
6951  }
6952  else if(strncmp(paramName, _currentSettings->intParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6953  {
6954  int value;
6955  value = std::stoi(paramValueString);
6956 
6957  if(setIntParam((SoPlex::IntParam)param, value, false))
6958  break;
6959  else
6960  {
6961  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
6962  "> for int parameter <" << paramName << ">.\n");
6963  return false;
6964  }
6965  }
6966  }
6967 
6968  return true;
6969  }
6970 
6971  // check whether we have a real parameter
6972  if(strncmp(paramTypeString, "real", 4) == 0)
6973  {
6974  for(int param = 0; ; param++)
6975  {
6976  if(param >= SoPlex::REALPARAM_COUNT)
6977  {
6978  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6979  ">.\n");
6980  return false;
6981  }
6982  else if(strncmp(paramName, _currentSettings->realParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6983  {
6984  Real value;
6985 #ifdef WITH_LONG_DOUBLE
6986  value = std::stold(paramValueString);
6987 #else
6988 #ifdef WITH_FLOAT
6989  value = std::stof(paramValueString);
6990 #else
6991  value = std::stod(paramValueString);
6992 #endif
6993 #endif
6994 
6995  if(setRealParam((SoPlex::RealParam)param, value))
6996  break;
6997  else
6998  {
6999  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
7000  "> for real parameter <" << paramName << ">.\n");
7001  return false;
7002  }
7003  }
7004  }
7005 
7006  return true;
7007  }
7008 
7009 #ifdef SOPLEX_WITH_RATIONALPARAM
7010 
7011  // check whether we have a rational parameter
7012  if(strncmp(paramTypeString, "rational", 8) == 0)
7013  {
7014  for(int param = 0; ; param++)
7015  {
7016  if(param >= SoPlex::RATIONALPARAM_COUNT)
7017  {
7018  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
7019  ">.\n");
7020  return false;
7021  }
7022  else if(strncmp(paramName, _currentSettings->rationalParam.name[param].c_str(),
7023  SET_MAX_LINE_LEN) == 0)
7024  {
7025  Rational value;
7026 
7027  if(readStringRational(paramValueString, value)
7028  && setRationalParam((SoPlex::RationalParam)param, value))
7029  break;
7030  else
7031  {
7032  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
7033  "> for rational parameter <" << paramName << ">.\n");
7034  return false;
7035  }
7036  }
7037  }
7038 
7039  return true;
7040  }
7041 
7042 #endif
7043 
7044  // check whether we have the random seed
7045  if(strncmp(paramTypeString, "uint", 4) == 0)
7046  {
7047  if(strncmp(paramName, "random_seed", 11) == 0)
7048  {
7049  unsigned int value;
7050  unsigned long parseval;
7051 
7052  parseval = std::stoul(paramValueString);
7053 
7054  if(parseval > UINT_MAX)
7055  {
7056  value = UINT_MAX;
7057  MSG_WARNING(spxout, spxout << "Converting number greater than UINT_MAX to uint.\n");
7058  }
7059  else
7060  value = (unsigned int) parseval;
7061 
7062  setRandomSeed(value);
7063  return true;
7064  }
7065 
7066  MSG_INFO1(spxout, spxout << "Error parsing setting string for uint parameter <random_seed>.\n");
7067  return false;
7068  }
7069 
7070  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid parameter type <" <<
7071  paramTypeString << "> for parameter <" << paramName << ">.\n");
7072 
7073  return false;
7074 }
7075 
7076 
7077 
7078 
7079 /// prints solution statistics
7080 void SoPlex::printSolutionStatistics(std::ostream& os)
7081 {
7083 
7085  {
7086  os << "Solution (real) : \n"
7087  << " Objective value : " << objValueReal() << "\n";
7088  }
7090  {
7091  os << "Solution (rational) : \n"
7092  << " Objective value : " << rationalToString(objValueRational()) << "\n";
7093  os << "Size (base 2/10) : \n"
7094  << " Total primal : " << totalSizePrimalRational() << " / " << totalSizePrimalRational(
7095  10) << "\n"
7096  << " Total dual : " << totalSizeDualRational() << " / " << totalSizeDualRational(10) << "\n"
7097  << " DLCM primal : " << dlcmSizePrimalRational() << " / " << dlcmSizePrimalRational(
7098  10) << "\n"
7099  << " DLCM dual : " << dlcmSizeDualRational() << " / " << dlcmSizeDualRational(10) << "\n"
7100  << " DMAX primal : " << dmaxSizePrimalRational() << " / " << dmaxSizePrimalRational(
7101  10) << "\n"
7102  << " DMAX dual : " << dmaxSizeDualRational() << " / " << dmaxSizeDualRational(10) << "\n";
7103  }
7104  else
7105  {
7106  os << "Solution : \n"
7107  << " Objective value : -\n";
7108  }
7109 
7113  {
7114  Rational maxviol;
7115  Rational sumviol;
7116 
7117  os << "Violation (rational): \n";
7118 
7119  if(getBoundViolationRational(maxviol, sumviol))
7120  os << " Max/sum bound : " << rationalToString(maxviol) << " / " << rationalToString(
7121  sumviol) << "\n";
7122  else
7123  os << " Max/sum bound : - / -\n";
7124 
7125  if(getRowViolationRational(maxviol, sumviol))
7126  os << " Max/sum row : " << rationalToString(maxviol) << " / " << rationalToString(
7127  sumviol) << "\n";
7128  else
7129  os << " Max/sum row : - / -\n";
7130 
7131  if(getRedCostViolationRational(maxviol, sumviol))
7132  os << " Max/sum redcost : " << rationalToString(maxviol) << " / " << rationalToString(
7133  sumviol) << "\n";
7134  else
7135  os << " Max/sum redcost : - / -\n";
7136 
7137  if(getDualViolationRational(maxviol, sumviol))
7138  os << " Max/sum dual : " << rationalToString(maxviol) << " / " << rationalToString(
7139  sumviol) << "\n";
7140  else
7141  os << " Max/sum dual : - / -\n";
7142  }
7143  else
7144  {
7145  Real maxviol;
7146  Real sumviol;
7147 
7148  os << "Violations (real) : \n";
7149 
7150  if(getBoundViolationReal(maxviol, sumviol))
7151  os << " Max/sum bound : " << maxviol << " / " << sumviol << "\n";
7152  else
7153  os << " Max/sum bound : - / -\n";
7154 
7155  if(getRowViolationReal(maxviol, sumviol))
7156  os << " Max/sum row : " << maxviol << " / " << sumviol << "\n";
7157  else
7158  os << " Max/sum row : - / -\n";
7159 
7160  if(getRedCostViolationReal(maxviol, sumviol))
7161  os << " Max/sum redcost : " << maxviol << " / " << sumviol << "\n";
7162  else
7163  os << " Max/sum redcost : - / -\n";
7164 
7165  if(getDualViolationReal(maxviol, sumviol))
7166  os << " Max/sum dual : " << maxviol << " / " << sumviol << "\n";
7167  else
7168  os << " Max/sum dual : - / -\n";
7169  }
7170 }
7171 
7172 
7173 /// prints statistics on solving process
7174 void SoPlex::printSolvingStatistics(std::ostream& os)
7175 {
7176  assert(_statistics != 0);
7177  _statistics->print(os);
7178 }
7179 
7180 
7181 
7182 /// prints short statistics
7183 void SoPlex::printShortStatistics(std::ostream& os)
7184 {
7185  printStatus(os, _status);
7186  SPxOut::setFixed(os, 2);
7187  os << "Solving time (sec) : " << _statistics->solvingTime->time() << "\n"
7188  << "Iterations : " << _statistics->iterations << "\n";
7190  os << "Objective value : " << objValueReal() << "\n";
7191 }
7192 
7193 
7194 
7195 /// prints complete statistics
7196 void SoPlex::printStatistics(std::ostream& os)
7197 {
7198  SPxOut::setFixed(os, 2);
7199 
7200  printStatus(os, _status);
7201 
7202  os << "Original problem : \n";
7203 
7206  else
7207  {
7210  else
7212  }
7213 
7214  os << "Objective sense : " << (intParam(SoPlex::OBJSENSE) == SoPlex::OBJSENSE_MINIMIZE ?
7215  "minimize\n" : "maximize\n");
7218 }
7219 
7220 /// prints status
7221 void SoPlex::printStatus(std::ostream& os, SPxSolver::Status stat)
7222 {
7223  os << "SoPlex status : ";
7224 
7225  switch(stat)
7226  {
7227  case SPxSolver::ERROR:
7228  os << "error [unspecified]";
7229  break;
7230 
7232  os << "error [no ratiotester loaded]";
7233  break;
7234 
7235  case SPxSolver::NO_PRICER:
7236  os << "error [no pricer loaded]";
7237  break;
7238 
7239  case SPxSolver::NO_SOLVER:
7240  os << "error [no linear solver loaded]";
7241  break;
7242 
7243  case SPxSolver::NOT_INIT:
7244  os << "error [not initialized]";
7245  break;
7246 
7248  os << "solving aborted [cycling]";
7249  break;
7250 
7251  case SPxSolver::ABORT_TIME:
7252  os << "solving aborted [time limit reached]";
7253  break;
7254 
7255  case SPxSolver::ABORT_ITER:
7256  os << "solving aborted [iteration limit reached]";
7257  break;
7258 
7260  os << "solving aborted [objective limit reached]";
7261  break;
7262 
7263  case SPxSolver::NO_PROBLEM:
7264  os << "no problem loaded";
7265  break;
7266 
7267  case SPxSolver::REGULAR:
7268  os << "basis is regular";
7269  break;
7270 
7271  case SPxSolver::SINGULAR:
7272  os << "basis is singular";
7273  break;
7274 
7275  case SPxSolver::OPTIMAL:
7276  os << "problem is solved [optimal]";
7277  break;
7278 
7279  case SPxSolver::UNBOUNDED:
7280  os << "problem is solved [unbounded]";
7281  break;
7282 
7283  case SPxSolver::INFEASIBLE:
7284  os << "problem is solved [infeasible]";
7285  break;
7286 
7287  case SPxSolver::INForUNBD:
7288  os << "problem is solved [infeasible or unbounded]";
7289  break;
7290 
7292  os << "problem is solved [optimal with unscaled violations]";
7293  break;
7294 
7295  default:
7296  case SPxSolver::UNKNOWN:
7297  os << "unknown";
7298  break;
7299  }
7300 
7301  os << "\n";
7302 }
7303 
7304 
7305 
7306 /// prints version and compilation options
7308 {
7309  // do not use preprocessor directives within the MSG_INFO1 macro
7310 #if (SOPLEX_SUBVERSION > 0)
7311  MSG_INFO1(spxout, spxout << "SoPlex version " << SOPLEX_VERSION / 100
7312  << "." << (SOPLEX_VERSION % 100) / 10
7313  << "." << SOPLEX_VERSION % 10
7314  << "." << SOPLEX_SUBVERSION);
7315 #else
7316  MSG_INFO1(spxout, spxout << "SoPlex version " << SOPLEX_VERSION / 100
7317  << "." << (SOPLEX_VERSION % 100) / 10
7318  << "." << SOPLEX_VERSION % 10);
7319 #endif
7320 
7321 #ifndef NDEBUG
7322  MSG_INFO1(spxout, spxout << " [mode: debug]");
7323 #else
7324  MSG_INFO1(spxout, spxout << " [mode: optimized]");
7325 #endif
7326 
7327  MSG_INFO1(spxout, spxout << " [precision: " << (int)sizeof(Real) << " byte]");
7328 
7329 #ifdef SOPLEX_WITH_GMP
7330 #ifdef mpir_version
7331  MSG_INFO1(spxout, spxout << " [rational: MPIR " << mpir_version << "]");
7332 #else
7333  MSG_INFO1(spxout, spxout << " [rational: GMP " << gmp_version << "]");
7334 #endif
7335 #else
7336  MSG_INFO1(spxout, spxout << " [rational: long double]");
7337 #endif
7338 
7339  MSG_INFO1(spxout, spxout << " [githash: " << getGitHash() << "]\n");
7340 }
7341 
7342 
7343 
7344 /// checks if real LP and rational LP are in sync; dimensions will always be compared,
7345 /// vector and matrix values only if the respective parameter is set to true.
7346 /// If quiet is set to true the function will only display which vectors are different.
7347 bool SoPlex::areLPsInSync(const bool checkVecVals, const bool checkMatVals, const bool quiet) const
7348 {
7349  bool result = true;
7350  bool nRowsMatch = true;
7351  bool nColsMatch = true;
7352  bool rhsDimMatch = true;
7353  bool lhsDimMatch = true;
7354  bool maxObjDimMatch = true;
7355  bool upperDimMatch = true;
7356  bool lowerDimMatch = true;
7357 
7358  // compare number of Rows
7359  if(_realLP->nRows() != _rationalLP->nRows())
7360  {
7361  MSG_INFO1(spxout, spxout <<
7362  "The number of Rows in the Real LP does not match the one in the Rational LP."
7363  << " Real LP: " << _realLP->nRows() << " Rational LP: " << _rationalLP->nRows() << std::endl);
7364  result = false;
7365  nRowsMatch = false;
7366  }
7367 
7368  // compare number of Columns
7369  if(_realLP->nCols() != _rationalLP->nCols())
7370  {
7371  MSG_INFO1(spxout, spxout <<
7372  "The number of Columns in the Real LP does not match the one in the Rational LP."
7373  << " Real LP: " << _realLP->nCols() << " Rational LP: " << _rationalLP->nCols() << std::endl);
7374  result = false;
7375  nColsMatch = false;
7376  }
7377 
7378  // compare number of nonZeros
7379  if(_realLP->nNzos() != _rationalLP->nNzos())
7380  {
7381  MSG_INFO1(spxout, spxout <<
7382  "The number of nonZeros in the Real LP does not match the one in the Rational LP."
7383  << " Real LP: " << _realLP->nNzos() << " Rational LP: " << _rationalLP->nNzos() << std::endl);
7384  result = false;
7385  }
7386 
7387  // compare the dimensions of the right hand side vectors
7388  if(_realLP->rhs().dim() != _rationalLP->rhs().dim())
7389  {
7390  MSG_INFO1(spxout, spxout <<
7391  "The dimension of the right hand side vector of the Real LP does not match the one of the Rational LP."
7392  << " Real LP: " << _realLP->rhs().dim() << " Rational LP: " << _rationalLP->rhs().dim() <<
7393  std::endl);
7394  result = false;
7395  rhsDimMatch = false;
7396 
7397  }
7398 
7399  // compare the dimensions of the left hand side vectors
7400  if(_realLP->lhs().dim() != _rationalLP->lhs().dim())
7401  {
7402  MSG_INFO1(spxout, spxout <<
7403  "The dimension of the left hand side vector of the Real LP does not match the one of the Rational LP."
7404  << " Real LP: " << _realLP->lhs().dim() << " Rational LP: " << _rationalLP->lhs().dim() <<
7405  std::endl);
7406  result = false;
7407  lhsDimMatch = false;
7408  }
7409 
7410  // compare the dimensions of the objective function vectors
7411  if(_realLP->maxObj().dim() != _rationalLP->maxObj().dim())
7412  {
7413  MSG_INFO1(spxout, spxout <<
7414  "The dimension of the objective function vector of the Real LP does not match the one of the Rational LP."
7415  << " Real LP: " << _realLP->maxObj().dim() << " Rational LP: " << _rationalLP->maxObj().dim() <<
7416  std::endl);
7417  result = false;
7418  maxObjDimMatch = false;
7419  }
7420 
7421  // compare the sense
7422  if((int)_realLP->spxSense() != (int)_rationalLP->spxSense())
7423  {
7424  MSG_INFO1(spxout, spxout <<
7425  "The objective function sense of the Real LP does not match the one of the Rational LP."
7426  << " Real LP: " << (_realLP->spxSense() == SPxLPReal::MINIMIZE ? "MIN" : "MAX")
7427  << " Rational LP: " << (_rationalLP->spxSense() == SPxLPRational::MINIMIZE ? "MIN" : "MAX") <<
7428  std::endl);
7429  result = false;
7430  }
7431 
7432  // compare the dimensions of upper bound vectors
7433  if(_realLP->upper().dim() != _rationalLP->upper().dim())
7434  {
7435  MSG_INFO1(spxout, spxout <<
7436  "The dimension of the upper bound vector of the Real LP does not match the one of the Rational LP."
7437  << " Real LP: " << _realLP->upper().dim() << " Rational LP: " << _rationalLP->upper().dim() <<
7438  std::endl);
7439  result = false;
7440  upperDimMatch = false;
7441  }
7442 
7443  // compare the dimensions of the objective function vectors
7444  if(_realLP->lower().dim() != _rationalLP->lower().dim())
7445  {
7446  MSG_INFO1(spxout, spxout <<
7447  "The dimension of the lower bound vector of the Real LP does not match the one of the Rational LP."
7448  << " Real LP: " << _realLP->lower().dim() << " Rational LP: " << _rationalLP->lower().dim() <<
7449  std::endl);
7450  result = false;
7451  lowerDimMatch = false;
7452  }
7453 
7454  // compares the values of the rhs, lhs, maxObj, upper, lower vectors
7455  if(checkVecVals)
7456  {
7457  bool rhsValMatch = true;
7458  bool lhsValMatch = true;
7459  bool maxObjValMatch = true;
7460  bool upperValMatch = true;
7461  bool lowerValMatch = true;
7462 
7463  // compares the values of the right hand side vectors
7464  if(rhsDimMatch)
7465  {
7466  for(int i = 0; i < _realLP->rhs().dim(); i++)
7467  {
7470  && !_rationalLP->rhs()[i].isAdjacentTo((double)_realLP->rhs()[i])))
7471  {
7472  if(!quiet)
7473  {
7474  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the right hand side vectors don't match."
7475  << " Real LP: " << _realLP->rhs()[i] << " Rational LP: " << _rationalLP->rhs()[i] << std::endl);
7476  }
7477 
7478  rhsValMatch = false;
7479  result = false;
7480  }
7481  }
7482 
7483  if(!rhsValMatch && quiet)
7484  {
7485  MSG_INFO1(spxout, spxout << "The values of the right hand side vectors don't match." << std::endl);
7486  }
7487  }
7488 
7489  // compares the values of the left hand side vectors
7490  if(lhsDimMatch)
7491  {
7492  for(int i = 0; i < _realLP->lhs().dim(); i++)
7493  {
7494  if((LE(_realLP->lhs()[i], -realParam(SoPlex::INFTY)) != (_rationalLP->lhs()[i] <=
7497  && !_rationalLP->lhs()[i].isAdjacentTo((double)_realLP->lhs()[i])))
7498  {
7499  if(!quiet)
7500  {
7501  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the left hand side vectors don't match."
7502  << " Real LP: " << _realLP->lhs()[i] << " Rational LP: " << _rationalLP->lhs()[i] << std::endl);
7503  }
7504 
7505  lhsValMatch = false;
7506  result = false;
7507  }
7508  }
7509 
7510  if(!lhsValMatch && quiet)
7511  {
7512  MSG_INFO1(spxout, spxout << "The values of the left hand side vectors don't match." << std::endl);
7513  }
7514  }
7515 
7516  // compares the values of the objective function vectors
7517  if(maxObjDimMatch)
7518  {
7519  for(int i = 0; i < _realLP->maxObj().dim(); i++)
7520  {
7521  if(!_rationalLP->maxObj()[i].isAdjacentTo((double)_realLP->maxObj()[i]))
7522  {
7523  if(!quiet)
7524  {
7525  MSG_INFO1(spxout, spxout << "Entries number " << i <<
7526  " of the objective function vectors don't match."
7527  << " Real LP: " << _realLP->maxObj()[i] << " Rational LP: " << _rationalLP->maxObj()[i] <<
7528  std::endl);
7529  }
7530 
7531  maxObjValMatch = false;
7532  result = false;
7533  }
7534  }
7535 
7536  if(!maxObjValMatch && quiet)
7537  {
7538  MSG_INFO1(spxout, spxout << "The values of the objective function vectors don't match." <<
7539  std::endl);
7540  }
7541  }
7542 
7543  // compares the values of the upper bound vectors
7544  if(upperDimMatch)
7545  {
7546  for(int i = 0; i < _realLP->upper().dim(); i++)
7547  {
7548  if((GE(_realLP->upper()[i], realParam(SoPlex::INFTY)) != (_rationalLP->upper()[i] >=
7551  && !_rationalLP->upper()[i].isAdjacentTo((double)_realLP->upper()[i])))
7552  {
7553  if(!quiet)
7554  {
7555  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the upper bound vectors don't match."
7556  << " Real LP: " << _realLP->upper()[i] << " Rational LP: " << _rationalLP->upper()[i] <<
7557  std::endl);
7558  }
7559 
7560  upperValMatch = false;
7561  result = false;
7562  }
7563  }
7564 
7565  if(!upperValMatch && quiet)
7566  {
7567  MSG_INFO1(spxout, spxout << "The values of the upper bound vectors don't match." << std::endl);
7568  }
7569  }
7570 
7571  // compares the values of the lower bound vectors
7572  if(lowerDimMatch)
7573  {
7574  for(int i = 0; i < _realLP->lower().dim(); i++)
7575  {
7576  if((LE(_realLP->lower()[i], -realParam(SoPlex::INFTY)) != (_rationalLP->lower()[i] <=
7578  || (GT(_realLP->lower()[i], -realParam(SoPlex::INFTY))
7580  && !_rationalLP->lower()[i].isAdjacentTo((double)_realLP->lower()[i])))
7581  {
7582  if(!quiet)
7583  {
7584  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the lower bound vectors don't match."
7585  << " Real LP: " << _realLP->lower()[i] << " Rational LP: " << _rationalLP->lower()[i] <<
7586  std::endl);
7587  }
7588 
7589  lowerValMatch = false;
7590  result = false;
7591  }
7592  }
7593 
7594  if(!lowerValMatch && quiet)
7595  {
7596  MSG_INFO1(spxout, spxout << "The values of the lower bound vectors don't match." << std::endl);
7597  }
7598  }
7599  }
7600 
7601  // compare the values of the matrix
7602  if(checkMatVals && nRowsMatch && nColsMatch)
7603  {
7604  bool matrixValMatch = true;
7605 
7606  for(int i = 0; i < _realLP->nCols() ; i++)
7607  {
7608  for(int j = 0; j < _realLP->nRows() ; j++)
7609  {
7610  if(!_rationalLP->colVector(i)[j].isAdjacentTo((double)_realLP->colVector(i)[j]))
7611  {
7612  if(!quiet)
7613  {
7614  MSG_INFO1(spxout, spxout << "Entries number " << j << " of column number " << i << " don't match."
7615  << " Real LP: " << _realLP->colVector(i)[j] << " Rational LP: " << _rationalLP->colVector(
7616  i)[j] << std::endl);
7617  }
7618 
7619  matrixValMatch = false;
7620  result = false;
7621  }
7622  }
7623  }
7624 
7625  if(!matrixValMatch && quiet)
7626  {
7627  MSG_INFO1(spxout, spxout << "The values of the matrices don't match." << std::endl);
7628  }
7629  }
7630 
7631  return result;
7632 }
7633 
7634 
7635 
7636 /// set the random seed of the solver instance
7637 void SoPlex::setRandomSeed(unsigned int seed)
7638 {
7639  _solver.random.setSeed(seed);
7640 }
7641 
7642 
7643 
7644 /// returns the current random seed of the solver instance or the one stored in the settings
7645 unsigned int SoPlex::randomSeed() const
7646 {
7647  return _solver.random.getSeed();
7648 }
7649 
7650 
7651 
7652 /// extends sparse vector to hold newmax entries if and only if it holds no more free entries
7654 {
7655  assert(newmax > vec.size());
7656 
7657  if(vec.size() >= vec.max())
7658  vec.setMax(newmax);
7659 }
7660 
7661 
7662 
7663 /// creates a permutation for removing rows/columns from an array of indices
7664 void SoPlex::_idxToPerm(int* idx, int idxSize, int* perm, int permSize) const
7665 {
7666  assert(idx != 0);
7667  assert(idxSize >= 0);
7668  assert(perm != 0);
7669  assert(permSize >= 0);
7670 
7671  for(int i = 0; i < permSize; i++)
7672  perm[i] = i;
7673 
7674  for(int i = 0; i < idxSize; i++)
7675  {
7676  assert(idx[i] >= 0);
7677  assert(idx[i] < permSize);
7678  perm[idx[i]] = -1;
7679  }
7680 }
7681 
7682 
7683 
7684 /// creates a permutation for removing rows/columns from a range of indices
7685 void SoPlex::_rangeToPerm(int start, int end, int* perm, int permSize) const
7686 {
7687  assert(perm != 0);
7688  assert(permSize >= 0);
7689 
7690  for(int i = 0; i < permSize; i++)
7691  perm[i] = (i < start || i > end) ? i : -1;
7692 }
7693 
7694 
7695 
7696 /// checks consistency
7698 {
7699  assert(_statistics != 0);
7700  assert(_currentSettings != 0);
7701 
7702  assert(_realLP != 0);
7704 
7705  assert(_realLP != &_solver || _isRealLPLoaded);
7706  assert(_realLP == &_solver || !_isRealLPLoaded);
7707 
7715 
7716  assert(_rationalLP == 0 || _colTypes.size() == numColsRational());
7717  assert(_rationalLP == 0 || _rowTypes.size() == numRowsRational());
7718 
7719  return true;
7720 }
7721 
7722 
7723 
7724 /// should solving process be stopped?
7725 bool SoPlex::_isSolveStopped(bool& stoppedTime, bool& stoppedIter) const
7726 {
7727  assert(_statistics != 0);
7728 
7729  stoppedTime = (realParam(TIMELIMIT) < realParam(INFTY)
7731  stoppedIter = (intParam(ITERLIMIT) >= 0 && _statistics->iterations >= intParam(ITERLIMIT))
7734 
7735  return stoppedTime || stoppedIter;
7736 }
7737 
7738 
7739 
7740 /// determines RangeType from real bounds
7741 SoPlex::RangeType SoPlex::_rangeTypeReal(const Real& lower, const Real& upper) const
7742 {
7743  assert(lower <= upper);
7744 
7745  if(lower <= -infinity)
7746  {
7747  if(upper >= infinity)
7748  return RANGETYPE_FREE;
7749  else
7750  return RANGETYPE_UPPER;
7751  }
7752  else
7753  {
7754  if(upper >= infinity)
7755  return RANGETYPE_LOWER;
7756  else if(lower == upper)
7757  return RANGETYPE_FIXED;
7758  else
7759  return RANGETYPE_BOXED;
7760  }
7761 }
7762 
7763 
7764 
7765 /// determines RangeType from rational bounds
7767 {
7768  assert(lower <= upper);
7769 
7770  if(lower <= _rationalNegInfty)
7771  {
7772  if(upper >= _rationalPosInfty)
7773  return RANGETYPE_FREE;
7774  else
7775  return RANGETYPE_UPPER;
7776  }
7777  else
7778  {
7779  if(upper >= _rationalPosInfty)
7780  return RANGETYPE_LOWER;
7781  else if(lower == upper)
7782  return RANGETYPE_FIXED;
7783  else
7784  return RANGETYPE_BOXED;
7785  }
7786 }
7787 
7788 
7789 
7790 /// switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
7792 {
7793  if(rangeType == RANGETYPE_LOWER)
7794  return RANGETYPE_UPPER;
7795  else if(rangeType == RANGETYPE_UPPER)
7796  return RANGETYPE_LOWER;
7797  else
7798  return rangeType;
7799 }
7800 
7801 
7802 
7803 /// checks whether RangeType corresponds to finite lower bound
7804 bool SoPlex::_lowerFinite(const RangeType& rangeType) const
7805 {
7806  return (rangeType == RANGETYPE_LOWER || rangeType == RANGETYPE_BOXED
7807  || rangeType == RANGETYPE_FIXED);
7808 }
7809 
7810 
7811 
7812 /// checks whether RangeType corresponds to finite upper bound
7813 bool SoPlex::_upperFinite(const RangeType& rangeType) const
7814 {
7815  return (rangeType == RANGETYPE_UPPER || rangeType == RANGETYPE_BOXED
7816  || rangeType == RANGETYPE_FIXED);
7817 }
7818 
7819 
7820 
7821 /// adds a single row to the real LP and adjusts basis
7822 void SoPlex::_addRowReal(const LPRowReal& lprow)
7823 {
7824  assert(_realLP != 0);
7825 
7826  bool scale = _realLP->isScaled();
7827  _realLP->addRow(lprow, scale);
7828 
7829  if(_isRealLPLoaded)
7831  else if(_hasBasis)
7833 
7835 }
7836 
7837 
7838 
7839 /// adds a single row to the real LP and adjusts basis
7840 void SoPlex::_addRowReal(Real lhs, const SVectorReal& lprow, Real rhs)
7841 {
7842  assert(_realLP != 0);
7843 
7844  bool scale = _realLP->isScaled();
7845  _realLP->addRow(lhs, lprow, rhs, scale);
7846 
7847  if(_isRealLPLoaded)
7849  else if(_hasBasis)
7851 
7853 }
7854 
7855 
7856 
7857 /// adds multiple rows to the real LP and adjusts basis
7858 void SoPlex::_addRowsReal(const LPRowSetReal& lprowset)
7859 {
7860  assert(_realLP != 0);
7861 
7862  bool scale = _realLP->isScaled();
7863  _realLP->addRows(lprowset, scale);
7864 
7865  if(_isRealLPLoaded)
7867  else if(_hasBasis)
7869 
7871 }
7872 
7873 
7874 /// adds a single column to the real LP and adjusts basis
7875 void SoPlex::_addColReal(const LPColReal& lpcol)
7876 {
7877  assert(_realLP != 0);
7878 
7879  bool scale = _realLP->isScaled();
7880  _realLP->addCol(lpcol, scale);
7881 
7882  if(_isRealLPLoaded)
7884  else if(_hasBasis)
7885  {
7886  if(lpcol.lower() > -realParam(SoPlex::INFTY))
7888  else if(lpcol.upper() < realParam(SoPlex::INFTY))
7890  else
7892  }
7893 
7895 }
7896 
7897 
7898 
7899 /// adds a single column to the real LP and adjusts basis
7900 void SoPlex::_addColReal(Real obj, Real lower, const SVectorReal& lpcol, Real upper)
7901 {
7902  assert(_realLP != 0);
7903 
7904  bool scale = _realLP->isScaled();
7905  _realLP->addCol(obj, lower, lpcol, upper, scale);
7906 
7907  if(_isRealLPLoaded)
7909  else if(_hasBasis)
7911 
7913 }
7914 
7915 
7916 
7917 /// adds multiple columns to the real LP and adjusts basis
7918 void SoPlex::_addColsReal(const LPColSetReal& lpcolset)
7919 {
7920  assert(_realLP != 0);
7921 
7922  bool scale = _realLP->isScaled();
7923  _realLP->addCols(lpcolset, scale);
7924 
7925  if(_isRealLPLoaded)
7927  else if(_hasBasis)
7928  {
7929  for(int i = 0; i < lpcolset.num(); i++)
7930  {
7931  if(lpcolset.lower(i) > -realParam(SoPlex::INFTY))
7933  else if(lpcolset.upper(i) < realParam(SoPlex::INFTY))
7935  else
7937  }
7938  }
7939 
7941 }
7942 
7943 
7944 /// replaces row \p i with \p lprow and adjusts basis
7945 void SoPlex::_changeRowReal(int i, const LPRowReal& lprow)
7946 {
7947  assert(_realLP != 0);
7948 
7949  bool scale = _realLP->isScaled();
7950  _realLP->changeRow(i, lprow, scale);
7951 
7952  if(_isRealLPLoaded)
7954  else if(_hasBasis)
7955  {
7957  _hasBasis = false;
7958  else if(_basisStatusRows[i] == SPxSolver::ON_LOWER && lprow.lhs() <= -realParam(SoPlex::INFTY))
7961  else if(_basisStatusRows[i] == SPxSolver::ON_UPPER && lprow.rhs() >= realParam(SoPlex::INFTY))
7964  }
7965 
7967 }
7968 
7969 
7970 
7971 /// changes left-hand side vector for constraints to \p lhs and adjusts basis
7973 {
7974  assert(_realLP != 0);
7975 
7976  bool scale = _realLP->isScaled();
7977  _realLP->changeLhs(lhs, scale);
7978 
7979  if(_isRealLPLoaded)
7981  else if(_hasBasis)
7982  {
7983  for(int i = numRowsReal() - 1; i >= 0; i--)
7984  {
7988  }
7989  }
7990 }
7991 
7992 
7993 
7994 /// changes left-hand side of row \p i to \p lhs and adjusts basis
7995 void SoPlex::_changeLhsReal(int i, const Real& lhs)
7996 {
7997  assert(_realLP != 0);
7998 
7999  bool scale = _realLP->isScaled();
8000  _realLP->changeLhs(i, lhs, scale);
8001 
8002  if(_isRealLPLoaded)
8003  {
8005  }
8009 
8010 }
8011 
8012 
8013 
8014 /// changes right-hand side vector to \p rhs and adjusts basis
8016 {
8017  assert(_realLP != 0);
8018 
8019  bool scale = _realLP->isScaled();
8020  _realLP->changeRhs(rhs, scale);
8021 
8022  if(_isRealLPLoaded)
8023  {
8025  }
8026  else if(_hasBasis)
8027  {
8028  for(int i = numRowsReal() - 1; i >= 0; i--)
8029  {
8033  }
8034  }
8035 }
8036 
8037 
8038 
8039 /// changes right-hand side of row \p i to \p rhs and adjusts basis
8040 void SoPlex::_changeRhsReal(int i, const Real& rhs)
8041 {
8042  assert(_realLP != 0);
8043 
8044  bool scale = _realLP->isScaled();
8045  _realLP->changeRhs(i, rhs, scale);
8046 
8047  if(_isRealLPLoaded)
8048  {
8050  }
8054 }
8055 
8056 
8057 
8058 /// changes left- and right-hand side vectors and adjusts basis
8059 void SoPlex::_changeRangeReal(const VectorReal& lhs, const VectorReal& rhs)
8060 {
8061  assert(_realLP != 0);
8062 
8063  bool scale = _realLP->isScaled();
8064  _realLP->changeRange(lhs, rhs, scale);
8065 
8066  if(_isRealLPLoaded)
8067  {
8069  }
8070  else if(_hasBasis)
8071  {
8072  for(int i = numRowsReal() - 1; i >= 0; i--)
8073  {
8076  else if(_basisStatusRows[i] == SPxSolver::ON_UPPER && rhs[i] >= realParam(SoPlex::INFTY))
8078  }
8079  }
8080 }
8081 
8082 
8083 
8084 /// changes left- and right-hand side of row \p i and adjusts basis
8085 void SoPlex::_changeRangeReal(int i, const Real& lhs, const Real& rhs)
8086 {
8087  assert(_realLP != 0);
8088 
8089  bool scale = _realLP->isScaled();
8090  _realLP->changeRange(i, lhs, rhs, scale);
8091 
8092  if(_isRealLPLoaded)
8093  {
8095  }
8096  else if(_hasBasis)
8097  {
8102  }
8103 }
8104 
8105 
8106 
8107 /// replaces column \p i with \p lpcol and adjusts basis
8108 void SoPlex::_changeColReal(int i, const LPColReal& lpcol)
8109 {
8110  assert(_realLP != 0);
8111 
8112  bool scale = _realLP->isScaled();
8113  _realLP->changeCol(i, lpcol, scale);
8114 
8115  if(_isRealLPLoaded)
8116  {
8118  }
8119  else if(_hasBasis)
8120  {
8122  _hasBasis = false;
8123  else if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lpcol.lower() <= -realParam(SoPlex::INFTY))
8126  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && lpcol.upper() >= realParam(SoPlex::INFTY))
8129  }
8130 
8132 }
8133 
8134 
8135 
8136 /// changes vector of lower bounds to \p lower and adjusts basis
8138 {
8139  assert(_realLP != 0);
8140 
8141  bool scale = _realLP->isScaled();
8142  _realLP->changeLower(lower, scale);
8143 
8144  if(_isRealLPLoaded)
8145  {
8147  }
8148  else if(_hasBasis)
8149  {
8150  for(int i = numColsReal() - 1; i >= 0; i--)
8151  {
8152  if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lower[i] <= -realParam(SoPlex::INFTY))
8155  }
8156  }
8157 }
8158 
8159 
8160 
8161 /// changes lower bound of column i to \p lower and adjusts basis
8162 void SoPlex::_changeLowerReal(int i, const Real& lower)
8163 {
8164  assert(_realLP != 0);
8165 
8166  bool scale = _realLP->isScaled();
8167  _realLP->changeLower(i, lower, scale);
8168 
8169  if(_isRealLPLoaded)
8170  {
8172  }
8174  && lower <= -realParam(SoPlex::INFTY))
8177 }
8178 
8179 
8180 
8181 /// changes vector of upper bounds to \p upper and adjusts basis
8183 {
8184  assert(_realLP != 0);
8185 
8186  bool scale = _realLP->isScaled();
8187  _realLP->changeUpper(upper, scale);
8188 
8189  if(_isRealLPLoaded)
8190  {
8192  }
8193  else if(_hasBasis)
8194  {
8195  for(int i = numColsReal() - 1; i >= 0; i--)
8196  {
8200  }
8201  }
8202 }
8203 
8204 
8205 
8206 /// changes \p i 'th upper bound to \p upper and adjusts basis
8207 void SoPlex::_changeUpperReal(int i, const Real& upper)
8208 {
8209  assert(_realLP != 0);
8210 
8211  bool scale = _realLP->isScaled();
8212  _realLP->changeUpper(i, upper, scale);
8213 
8214  if(_isRealLPLoaded)
8215  {
8217  }
8219  && upper >= realParam(SoPlex::INFTY))
8222 }
8223 
8224 
8225 
8226 /// changes vectors of column bounds to \p lower and \p upper and adjusts basis
8227 void SoPlex::_changeBoundsReal(const VectorReal& lower, const VectorReal& upper)
8228 {
8229  assert(_realLP != 0);
8230 
8231  bool scale = _realLP->isScaled();
8232  _realLP->changeBounds(lower, upper, scale);
8233 
8234  if(_isRealLPLoaded)
8235  {
8237  }
8238  else if(_hasBasis)
8239  {
8240  for(int i = numColsReal() - 1; i >= 0; i--)
8241  {
8242  if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lower[i] <= -realParam(SoPlex::INFTY))
8244  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && upper[i] >= realParam(SoPlex::INFTY))
8247  }
8248  }
8249 }
8250 
8251 
8252 
8253 /// changes bounds of column \p i to \p lower and \p upper and adjusts basis
8254 void SoPlex::_changeBoundsReal(int i, const Real& lower, const Real& upper)
8255 {
8256  assert(_realLP != 0);
8257 
8258  bool scale = _realLP->isScaled();
8259  _realLP->changeBounds(i, lower, upper, scale);
8260 
8261  if(_isRealLPLoaded)
8262  {
8264  }
8265  else if(_hasBasis)
8266  {
8269  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && upper >= realParam(SoPlex::INFTY))
8271  }
8272 }
8273 
8274 
8275 
8276 /// changes matrix entry in row \p i and column \p j to \p val and adjusts basis
8277 void SoPlex::_changeElementReal(int i, int j, const Real& val)
8278 {
8279  assert(_realLP != 0);
8280 
8281  bool scale = _realLP->isScaled();
8282  _realLP->changeElement(i, j, val, scale);
8283 
8284  if(_isRealLPLoaded)
8285  {
8287  }
8288  else if(_hasBasis)
8289  {
8291  _hasBasis = false;
8292  }
8293 
8295 }
8296 
8297 
8298 
8299 /// removes row \p i and adjusts basis
8301 {
8302  assert(_realLP != 0);
8303 
8304  _realLP->removeRow(i);
8305 
8306  if(_isRealLPLoaded)
8307  {
8309  }
8310  else if(_hasBasis)
8311  {
8313  _hasBasis = false;
8314  else
8315  {
8318  }
8319  }
8320 
8322 }
8323 
8324 
8325 
8326 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
8327 /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
8328 /// #numRowsReal()
8329 void SoPlex::_removeRowsReal(int perm[])
8330 {
8331  assert(_realLP != 0);
8332 
8333  _realLP->removeRows(perm);
8334 
8335  if(_isRealLPLoaded)
8336  {
8338  }
8339  else if(_hasBasis)
8340  {
8341  for(int i = numRowsReal() - 1; i >= 0 && _hasBasis; i--)
8342  {
8343  if(perm[i] < 0 && _basisStatusRows[i] != SPxSolver::BASIC)
8344  _hasBasis = false;
8345  else if(perm[i] >= 0 && perm[i] != i)
8346  {
8347  assert(perm[i] < numRowsReal());
8348  assert(perm[perm[i]] < 0);
8349 
8350  _basisStatusRows[perm[i]] = _basisStatusRows[i];
8351  }
8352  }
8353 
8354  if(_hasBasis)
8356  }
8357 
8359 }
8360 
8361 
8362 
8363 /// removes column i
8365 {
8366  assert(_realLP != 0);
8367 
8368  _realLP->removeCol(i);
8369 
8370  if(_isRealLPLoaded)
8371  {
8373  }
8374  else if(_hasBasis)
8375  {
8377  _hasBasis = false;
8378  else
8379  {
8382  }
8383  }
8384 
8386 }
8387 
8388 
8389 
8390 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
8391 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
8392 /// #numColsReal()
8393 void SoPlex::_removeColsReal(int perm[])
8394 {
8395  assert(_realLP != 0);
8396 
8397  _realLP->removeCols(perm);
8398 
8399  if(_isRealLPLoaded)
8400  {
8402  }
8403  else if(_hasBasis)
8404  {
8405  for(int i = numColsReal() - 1; i >= 0 && _hasBasis; i--)
8406  {
8407  if(perm[i] < 0 && _basisStatusCols[i] == SPxSolver::BASIC)
8408  _hasBasis = false;
8409  else if(perm[i] >= 0 && perm[i] != i)
8410  {
8411  assert(perm[i] < numColsReal());
8412  assert(perm[perm[i]] < 0);
8413 
8414  _basisStatusCols[perm[i]] = _basisStatusCols[i];
8415  }
8416  }
8417 
8418  if(_hasBasis)
8420  }
8421 
8423 }
8424 
8425 
8426 
8427 /// invalidates solution
8429 {
8430  ///@todo maybe this should be done individually at the places when this method is called
8432 
8433  _solReal.invalidate();
8434  _hasSolReal = false;
8435 
8437  _hasSolRational = false;
8438 }
8439 
8440 
8441 
8442 /// enables simplifier and scaler
8444 {
8445  // type of simplifier
8446  switch(intParam(SoPlex::SIMPLIFIER))
8447  {
8448  case SIMPLIFIER_OFF:
8449  _simplifier = 0;
8450  break;
8451 
8452  case SIMPLIFIER_AUTO:
8454  assert(_simplifier != 0);
8456  break;
8457 
8458  default:
8459  break;
8460  }
8461 
8462  // type of scaler
8463  switch(intParam(SoPlex::SCALER))
8464  {
8465  case SCALER_OFF:
8466  _scaler = 0;
8467  break;
8468 
8469  case SCALER_UNIEQUI:
8471  break;
8472 
8473  case SCALER_BIEQUI:
8475  break;
8476 
8477  case SCALER_GEO1:
8478  _scaler = &_scalerGeo1;
8479  break;
8480 
8481  case SCALER_GEO8:
8482  _scaler = &_scalerGeo8;
8483  break;
8484 
8485  case SCALER_LEASTSQ:
8487  break;
8488 
8489  case SCALER_GEOEQUI:
8491  break;
8492 
8493  default:
8494  break;
8495  }
8496 }
8497 
8498 
8499 
8500 /// disables simplifier and scaler
8502 {
8503  _simplifier = 0;
8504 
8505  // preserve scaler when persistent scaling is used
8506  if(!_isRealLPScaled)
8507  _scaler = 0;
8508  else
8510 }
8511 
8512 
8513 
8514 /// ensures that the rational LP is available; performs no sync
8516 {
8517  if(_rationalLP == 0)
8518  {
8522  }
8523 }
8524 
8525 
8526 
8527 /// ensures that the real LP and the basis are loaded in the solver; performs no sync
8529 {
8530  if(!_isRealLPLoaded)
8531  {
8532  assert(_realLP != &_solver);
8533 
8535  _realLP->~SPxLPReal();
8536  spx_free(_realLP);
8537  _realLP = &_solver;
8538  _isRealLPLoaded = true;
8539 
8540  if(_hasBasis)
8541  {
8542  ///@todo this should not fail even if the basis is invalid (wrong dimension or wrong number of basic
8543  /// entries); fix either in SPxSolver or in SPxBasis
8544  assert(_basisStatusRows.size() == numRowsReal());
8545  assert(_basisStatusCols.size() == numColsReal());
8548  }
8549  }
8550 }
8551 
8552 
8553 
8554 /// call floating-point solver and update statistics on iterations etc.
8556 {
8557  bool _hadBasis = _hasBasis;
8558 
8559  // set time and iteration limit
8562  else
8564 
8567  else
8569 
8570  // ensure that tolerances are not too small
8571  if(_solver.feastol() < 1e-12)
8572  _solver.setFeastol(1e-12);
8573 
8574  if(_solver.opttol() < 1e-12)
8575  _solver.setOpttol(1e-12);
8576 
8577  // set correct representation
8581  && _solver.rep() != SPxSolver::COLUMN)
8582  {
8584  }
8588  && _solver.rep() != SPxSolver::ROW)
8589  {
8591  }
8592 
8593  // set correct type
8596  && _solver.type() != SPxSolver::ENTER)
8597  {
8599  }
8602  && _solver.type() != SPxSolver::LEAVE)
8603  {
8605  }
8606 
8607  // set pricing modes
8609 
8613  _solver.hyperPricing(true);
8615  _solver.hyperPricing(false);
8616 
8620 
8621  // call floating-point solver and catch exceptions
8623 
8624  try
8625  {
8626  _solver.solve();
8627  }
8628  catch(const SPxException& E)
8629  {
8630  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() << "> while solving real LP.\n");
8632  }
8633  catch(...)
8634  {
8635  MSG_INFO1(spxout, spxout << "Caught unknown exception while solving real LP.\n");
8637  }
8638 
8640 
8641  // invalidate rational factorization of basis if pivots have been performed
8642  if(_solver.iterations() > 0)
8644 
8645  // record statistics
8648  _statistics->iterationsFromBasis += _hadBasis ? _solver.iterations() : 0;
8656 
8661 }
8662 
8663 
8664 
8665 /// reads real LP in LP or MPS format from file and returns true on success; gets row names, column names, and
8666 /// integer variables if desired
8667 bool SoPlex::_readFileReal(const char* filename, NameSet* rowNames, NameSet* colNames,
8668  DIdxSet* intVars)
8669 {
8670  assert(_realLP != 0);
8671 
8672  // clear statistics
8674 
8675  // update status
8676  clearBasis();
8679 
8680  // start timing
8682 
8683  // read
8684  bool success = _realLP->readFile(filename, rowNames, colNames, intVars);
8685 
8686  // stop timing
8688 
8689  if(success)
8690  {
8694 
8695  // if sync mode is auto, we have to copy the (rounded) real LP to the rational LP; this is counted to sync time
8696  // and not to reading time
8698  _syncLPRational();
8699  }
8700  else
8701  clearLPReal();
8702 
8703  return success;
8704 }
8705 
8706 
8707 
8708 /// reads rational LP in LP or MPS format from file and returns true on success; gets row names, column names, and
8709 /// integer variables if desired
8710 bool SoPlex::_readFileRational(const char* filename, NameSet* rowNames, NameSet* colNames,
8711  DIdxSet* intVars)
8712 {
8713  // clear statistics
8715 
8716  // start timing
8718 
8719  // update status
8720  clearBasis();
8723 
8724  // read
8726  bool success = _rationalLP->readFile(filename, rowNames, colNames, intVars);
8727 
8728  // stop timing
8730 
8731  if(success)
8732  {
8737 
8738  // if sync mode is auto, we have to copy the (rounded) real LP to the rational LP; this is counted to sync time
8739  // and not to reading time
8741  _syncLPReal();
8742  // if a rational LP file is read, but only the (rounded) real LP should be kept, we have to free the rational LP
8744  {
8745  _syncLPReal();
8746  _rationalLP->~SPxLPRational();
8748  }
8749  }
8750  else
8751  clearLPRational();
8752 
8753  return success;
8754 }
8755 
8756 
8757 
8758 /// completes range type arrays after adding columns and/or rows
8760 {
8761  // we use one method for bot columns and rows, because during column/row addition, rows/columns can be added
8762  // implicitly
8763  for(int i = _colTypes.size(); i < numColsRational(); i++)
8765 
8766  for(int i = _rowTypes.size(); i < numRowsRational(); i++)
8768 }
8769 
8770 
8771 
8772 /// recomputes range types from scratch using real LP
8774 {
8776 
8777  for(int i = 0; i < numRowsReal(); i++)
8778  _rowTypes[i] = _rangeTypeReal(_realLP->lhs(i), _realLP->rhs(i));
8779 
8781 
8782  for(int i = 0; i < numColsReal(); i++)
8784 }
8785 
8786 
8787 
8788 /// recomputes range types from scratch using rational LP
8790 {
8792 
8793  for(int i = 0; i < numRowsRational(); i++)
8795 
8797 
8798  for(int i = 0; i < numColsRational(); i++)
8800 }
8801 
8802 
8803 
8804 /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, without looking at the sync mode
8805 void SoPlex::_syncLPReal(bool time)
8806 {
8807  // start timing
8808  if(time)
8810 
8811  // copy LP
8812  if(_isRealLPLoaded)
8814  else
8815  *_realLP = *_rationalLP;
8816 
8817  ///@todo try loading old basis
8818  _hasBasis = false;
8820 
8821  // stop timing
8822  if(time)
8824 }
8825 
8826 
8827 
8828 /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sync mode
8830 {
8831  // start timing
8832  if(time)
8834 
8835  // copy LP
8837  *_rationalLP = *_realLP;
8839 
8840  // stop timing
8841  if(time)
8843 }
8844 
8845 
8846 
8847 /// synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real solution
8849 {
8851  {
8853  _hasSolReal = true;
8854  }
8855 }
8856 
8857 
8858 
8859 /// synchronizes real solution with rational solution, i.e., copies real solution to rational solution
8861 {
8863  {
8865  _hasSolRational = true;
8866  }
8867 }
8868 
8869 
8870 
8871 /// returns pointer to a constant unit vector available until destruction of the SoPlex class
8873 {
8874  assert(i >= 0);
8875 
8876  if(i < 0)
8877  return 0;
8878  else if(i >= _unitMatrixRational.size())
8879  _unitMatrixRational.append(i + 1 - _unitMatrixRational.size(), (UnitVectorRational*)0);
8880 
8881  assert(i < _unitMatrixRational.size());
8882 
8883  if(_unitMatrixRational[i] == 0)
8884  {
8887  }
8888 
8889  assert(_unitMatrixRational[i] != 0);
8890 
8891  return _unitMatrixRational[i];
8892 }
8893 
8894 
8895 
8896 /// parses one line in a settings file and returns true on success; note that the string is modified
8897 bool SoPlex::_parseSettingsLine(char* line, const int lineNumber)
8898 {
8899  assert(line != 0);
8900 
8901  // find the start of the parameter type
8902  while(*line == ' ' || *line == '\t' || *line == '\r')
8903  line++;
8904 
8905  if(*line == '\0' || *line == '\n' || *line == '#')
8906  return true;
8907 
8908  char* paramTypeString = line;
8909 
8910  // find the end of the parameter type
8911  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8912  && *line != '\0' && *line != ':')
8913  line++;
8914 
8915  if(*line == ':')
8916  {
8917  *line = '\0';
8918  line++;
8919  }
8920  else
8921  {
8922  *line = '\0';
8923  line++;
8924 
8925  // search for the ':' char in the line
8926  while(*line == ' ' || *line == '\t' || *line == '\r')
8927  line++;
8928 
8929  if(*line != ':')
8930  {
8931  MSG_INFO1(spxout, spxout <<
8932  "Error parsing settings file: no ':' separating parameter type and name in line " << lineNumber <<
8933  ".\n");
8934  return false;
8935  }
8936 
8937  line++;
8938  }
8939 
8940  // find the start of the parameter name
8941  while(*line == ' ' || *line == '\t' || *line == '\r')
8942  line++;
8943 
8944  if(*line == '\0' || *line == '\n' || *line == '#')
8945  {
8946  MSG_INFO1(spxout, spxout << "Error parsing settings file: no parameter name in line " << lineNumber
8947  << ".\n");
8948  return false;
8949  }
8950 
8951  char* paramName = line;
8952 
8953  // find the end of the parameter name
8954  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8955  && *line != '\0' && *line != '=')
8956  line++;
8957 
8958  if(*line == '=')
8959  {
8960  *line = '\0';
8961  line++;
8962  }
8963  else
8964  {
8965  *line = '\0';
8966  line++;
8967 
8968  // search for the '=' char in the line
8969  while(*line == ' ' || *line == '\t' || *line == '\r')
8970  line++;
8971 
8972  if(*line != '=')
8973  {
8974  MSG_INFO1(spxout, spxout << "Error parsing settings file: no '=' after parameter name in line " <<
8975  lineNumber << ".\n");
8976  return false;
8977  }
8978 
8979  line++;
8980  }
8981 
8982  // find the start of the parameter value string
8983  while(*line == ' ' || *line == '\t' || *line == '\r')
8984  line++;
8985 
8986  if(*line == '\0' || *line == '\n' || *line == '#')
8987  {
8988  MSG_INFO1(spxout, spxout << "Error parsing settings file: no parameter value in line " << lineNumber
8989  << ".\n");
8990  return false;
8991  }
8992 
8993  char* paramValueString = line;
8994 
8995  // find the end of the parameter value string
8996  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8997  && *line != '\0')
8998  line++;
8999 
9000  if(*line != '\0')
9001  {
9002  // check, if the rest of the line is clean
9003  *line = '\0';
9004  line++;
9005 
9006  while(*line == ' ' || *line == '\t' || *line == '\r')
9007  line++;
9008 
9009  if(*line != '\0' && *line != '\n' && *line != '#')
9010  {
9011  MSG_INFO1(spxout, spxout << "Error parsing settings file: additional character '" << *line <<
9012  "' after parameter value in line " << lineNumber << ".\n");
9013  return false;
9014  }
9015  }
9016 
9017  // check whether we have a bool parameter
9018  if(strncmp(paramTypeString, "bool", 4) == 0)
9019  {
9020  for(int param = 0; ; param++)
9021  {
9022  if(param >= SoPlex::BOOLPARAM_COUNT)
9023  {
9024  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9025  "> in line " << lineNumber << ".\n");
9026  return false;
9027  }
9028  else if(strncmp(paramName, _currentSettings->boolParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9029  {
9030  if(strncasecmp(paramValueString, "true", 4) == 0
9031  || strncasecmp(paramValueString, "TRUE", 4) == 0
9032  || strncasecmp(paramValueString, "t", 4) == 0
9033  || strncasecmp(paramValueString, "T", 4) == 0
9034  || strtol(paramValueString, NULL, 4) == 1)
9035  {
9036  setBoolParam((SoPlex::BoolParam)param, true);
9037  break;
9038  }
9039  else if(strncasecmp(paramValueString, "false", 5) == 0
9040  || strncasecmp(paramValueString, "FALSE", 5) == 0
9041  || strncasecmp(paramValueString, "f", 5) == 0
9042  || strncasecmp(paramValueString, "F", 5) == 0
9043  || strtol(paramValueString, NULL, 5) == 0)
9044  {
9045  setBoolParam((SoPlex::BoolParam)param, false);
9046  break;
9047  }
9048  else
9049  {
9050  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9051  "> for bool parameter <" << paramName << "> in line " << lineNumber << ".\n");
9052  return false;
9053  }
9054  }
9055  }
9056 
9057  return true;
9058  }
9059 
9060  // check whether we have an integer parameter
9061  if(strncmp(paramTypeString, "int", 3) == 0)
9062  {
9063  for(int param = 0; ; param++)
9064  {
9065  if(param >= SoPlex::INTPARAM_COUNT)
9066  {
9067  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9068  "> in line " << lineNumber << ".\n");
9069  return false;
9070  }
9071  else if(strncmp(paramName, _currentSettings->intParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9072  {
9073  int value;
9074  value = std::stoi(paramValueString);
9075 
9076  if(setIntParam((SoPlex::IntParam)param, value, false))
9077  break;
9078  else
9079  {
9080  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9081  "> for int parameter <" << paramName << "> in line " << lineNumber << ".\n");
9082  return false;
9083  }
9084  }
9085  }
9086 
9087  return true;
9088  }
9089 
9090  // check whether we have a real parameter
9091  if(strncmp(paramTypeString, "real", 4) == 0)
9092  {
9093  for(int param = 0; ; param++)
9094  {
9095  if(param >= SoPlex::REALPARAM_COUNT)
9096  {
9097  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9098  "> in line " << lineNumber << ".\n");
9099  return false;
9100  }
9101  else if(strncmp(paramName, _currentSettings->realParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9102  {
9103  Real value;
9104 
9105 #ifdef WITH_LONG_DOUBLE
9106  value = std::stold(paramValueString);
9107 #else
9108 #ifdef WITH_FLOAT
9109  value = std::stof(paramValueString);
9110 #else
9111  value = std::stod(paramValueString);
9112 #endif
9113 #endif
9114 
9115  if(setRealParam((SoPlex::RealParam)param, value))
9116  break;
9117  else
9118  {
9119  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9120  "> for real parameter <" << paramName << "> in line " << lineNumber << ".\n");
9121  return false;
9122  }
9123  }
9124  }
9125 
9126  return true;
9127  }
9128 
9129 #ifdef SOPLEX_WITH_RATIONALPARAM
9130 
9131  // check whether we have a rational parameter
9132  if(strncmp(paramTypeString, "rational", 8) == 0)
9133  {
9134  for(int param = 0; ; param++)
9135  {
9136  if(param >= SoPlex::RATIONALPARAM_COUNT)
9137  {
9138  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9139  "> in line " << lineNumber << ".\n");
9140  return false;
9141  }
9142  else if(strncmp(paramName, _currentSettings->rationalParam.name[param].c_str(),
9143  SET_MAX_LINE_LEN) == 0)
9144  {
9145  Rational value;
9146 
9147  if(readStringRational(paramValueString, value)
9148  && setRationalParam((SoPlex::RationalParam)param, value))
9149  break;
9150  else
9151  {
9152  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9153  "> for rational parameter <" << paramName << "> in line " << lineNumber << ".\n");
9154  return false;
9155  }
9156  }
9157  }
9158 
9159  return true;
9160  }
9161 
9162 #endif
9163 
9164  // check whether we have the random seed
9165  if(strncmp(paramTypeString, "uint", 4) == 0)
9166  {
9167  if(strncmp(paramName, "random_seed", 11) == 0)
9168  {
9169  unsigned int value;
9170  unsigned long parseval;
9171 
9172  parseval = std::stoul(paramValueString);
9173 
9174  if(parseval > UINT_MAX)
9175  {
9176  value = UINT_MAX;
9177  MSG_WARNING(spxout, spxout << "Converting number greater than UINT_MAX to uint.\n");
9178  }
9179  else
9180  value = (unsigned int) parseval;
9181 
9182  setRandomSeed(value);
9183  return true;
9184  }
9185 
9186  MSG_INFO1(spxout, spxout << "Error parsing settings file for uint parameter <random_seed>.\n");
9187  return false;
9188  }
9189 
9190  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid parameter type <" <<
9191  paramTypeString << "> for parameter <" << paramName << "> in line " << lineNumber << ".\n");
9192 
9193  return false;
9194 }
9195 } // namespace soplex
const VectorBase< R > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:221
void changeLhsRational(const VectorRational &lhs)
changes left-hand side vector for constraints to lhs
Definition: soplex.cpp:2187
virtual void buildDualProblem(SPxLPBase< R > &dualLP, SPxRowId primalRowIds[]=0, SPxColId primalColIds[]=0, SPxRowId dualRowIds[]=0, SPxColId dualColIds[]=0, int *nprimalrows=0, int *nprimalcols=0, int *ndualrows=0, int *ndualcols=0)
Building the dual problem from a given LP.
int _lastSolveMode
Definition: soplex.h:1867
const VectorRational & rhsRational() const
returns right-hand side vector
Definition: soplex.cpp:1214
bool isNotZero(Real a, Real eps=Param::epsilon())
returns true iff |a| > eps
Definition: spxdefines.h:418
RangeType
type of bounds and sides
Definition: soplex.h:1688
SPxLPBase< Real > SPxLPReal
Definition: spxlp.h:36
const char * getRatiotesterName()
name of currently loaded ratiotester
Definition: soplex.cpp:5322
DVectorBase< R > _slacks
Definition: solbase.h:219
void getRowsRational(int start, int end, LPRowSetRational &lprowset) const
gets rows start, ..., end.
Definition: soplex.cpp:1196
const VectorReal & maxObjRealInternal() const
returns objective function vector after transformation to a maximization problem; since this is how i...
Definition: soplex.cpp:1090
void _computeBasisInverseRational()
computes rational inverse of basis matrix as defined by _rationalLUSolverBind
int getSolveCount() const
number of solves performed
Definition: slufactor.h:264
bool multBasisTranspose(Real *vec, bool unscale=true)
multiply with transpose of basis matrix; vec * B^T (inplace)
Definition: soplex.cpp:4970
void _changeUpperReal(const VectorReal &upper)
changes vector of upper bounds to upper and adjusts basis
Definition: soplex.cpp:8182
bool getDual(VectorBase< R > &vector) const
gets the dual solution vector; returns true on success
Definition: solbase.h:94
void getRhsUnscaled(VectorBase< Real > &vec) const
Gets unscaled right hand side vector.
accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations...
Definition: soplex.h:1377
Vector & multWithBase(Vector &x) const
Vector-basis product.
Definition: spxbasis.cpp:984
virtual void removeRow(int i)
Removes i &#39;th row.
Definition: spxlpbase.h:933
int iterations() const
get number of iterations of current solution.
Definition: spxsolver.h:2118
zero tolerance used in factorization
Definition: soplex.h:1320
void getRow(int i, LPRowBase< R > &row) const
Gets i &#39;th row.
Definition: spxlpbase.h:182
void getUpperReal(DVectorReal &upper) const
gets upper bound vector
Definition: soplex.cpp:1034
Rational _rationalMaxscaleincr
Definition: soplex.h:1603
free variable fixed to zero.
Definition: spxsolver.h:194
int totalSizeDual(const int base=2) const
returns total size of dual solution
Definition: solbase.h:139
#define DEFAULT_EPS_FACTOR
Definition: spxdefines.h:233
void printVersion() const
prints version and compilation options
Definition: soplex.cpp:7307
SoPlex()
default constructor
Definition: soplex.cpp:611
not initialised error
Definition: spxsolver.h:208
bool getDualViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of dual multipliers; returns true on success
Definition: soplex.cpp:3701
bool GE(Real a, Real b, Real eps=Param::epsilon())
returns true iff a >= b + eps
Definition: spxdefines.h:406
standard floating-point parsing
Definition: soplex.h:1236
void printSolutionStatistics(std::ostream &os)
prints solution statistics
Definition: soplex.cpp:7080
refactor threshold for memory growth in factorization since last refactorization
Definition: soplex.h:1374
DVectorBase< R > _dualFarkas
Definition: solbase.h:223
Timer * syncTime
time for synchronization between real and rational LP (included in solving time)
Definition: statistics.h:91
void setRep(Representation p_rep)
switch to ROW or COLUMN representation if not already used.
Definition: spxsolver.cpp:257
No matrix has yet been loaded.
void coSolve(Vector &x, const Vector &rhs)
Cosolves linear system with basis matrix.
Definition: spxbasis.h:730
bool getDualNorms(int &nnormsRow, int &nnormsCol, Real *norms) const
gets steepest edge norms and returns false if they are not available
Definition: soplex.cpp:1117
const VectorBase< R > & lower() const
Definition: lpcolsetbase.h:130
void _addColReal(const LPColReal &lpcol)
adds a single column to the real LP and adjusts basis
Definition: soplex.cpp:7875
int numRowsReal() const
returns number of rows
Definition: soplex.cpp:850
bool getBasisInverseRowReal(int r, Real *coef, int *inds=NULL, int *ninds=NULL, bool unscale=true)
computes row r of basis inverse; returns true on success
Definition: soplex.cpp:4267
Rational minAbsNonzeroRational() const
returns smallest non-zero element in absolute value
Definition: soplex.cpp:1169
static void setEpsilon(Real eps)
Definition: spxdefines.cpp:50
SPxBasis::SPxStatus getBasisStatus() const
gets basis status
Definition: spxsolver.h:2039
void removeRowsRational(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
Definition: soplex.cpp:2697
type of starter used to create crash basis
Definition: soplex.h:1011
void removeColsReal(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
Definition: soplex.cpp:1882
bool getDualNorms(int &nnormsRow, int &nnormsCol, Real *norms) const
get dual norms
Definition: spxsolver.cpp:2087
The time limit has been hit.
const VectorBase< R > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:461
void _optimizeReal()
solves real LP
Definition: solvereal.cpp:28
const Settings & settings() const
returns current parameter settings
Definition: soplex.cpp:5805
upper limit on objective value
Definition: soplex.h:1338
geometric mean scaling on rows and columns, max 8 rounds
Definition: soplex.h:1156
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
get number of dual norms
Definition: spxsolver.cpp:2062
void _changeElementReal(int i, int j, const Real &val)
changes matrix entry in row i and column j to val and adjusts basis
Definition: soplex.cpp:8277
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
steepest edge pricer with exact initialization of norms
Definition: soplex.h:1200
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
general zero tolerance
Definition: soplex.h:1317
void getRows(int start, int end, LPRowSetBase< R > &set) const
Gets rows start, ... end.
Definition: spxlpbase.h:197
mode for solution polishing
Definition: soplex.h:1044
void setOutstream(SPxOut &newOutstream)
Definition: spxlpbase.h:126
Real _realParamValues[SoPlex::REALPARAM_COUNT]
array of current real parameter values
Definition: soplex.h:1468
void _changeRangeReal(const VectorReal &lhs, const VectorReal &rhs)
changes left- and right-hand side vectors and adjusts basis
Definition: soplex.cpp:8059
const SPxRatioTester * ratiotester() const
return loaded SPxRatioTester.
Definition: spxsolver.h:1781
disable timing
Definition: soplex.h:1272
type of ratio test
Definition: soplex.h:1017
void removeColReal(int i)
removes column i
Definition: soplex.cpp:1854
maximum increase of scaling factors between refinements
Definition: soplex.h:1347
virtual void getRowUnscaled(const SPxLPBase< Real > &lp, int i, DSVector &vec) const
returns unscaled row i
Definition: spxscaler.cpp:468
SPxMainSM _simplifierMainSM
Definition: soplex.h:1613
Real maxAbsNonzeroReal() const
returns biggest non-zero element in absolute value
Definition: soplex.cpp:886
LP has beed solved to optimality but unscaled solution contains violations.
Definition: spxsolver.h:224
verbosity level
Definition: soplex.h:1002
continue iterative refinement with exact basic solution if not optimal?
Definition: soplex.h:953
void setBasis(const VarStatus rows[], const VarStatus cols[])
set the lp solver&#39;s basis.
Definition: spxsolver.cpp:1975
const SVectorReal & colVectorRealInternal(int i) const
returns vector of col i, ignoring scaling
Definition: soplex.cpp:998
type of timer
Definition: soplex.h:1032
void setMaxUpdates(int maxUp)
change maximum number of iterations until a refactorization is performed
Definition: spxbasis.h:451
void resetCounters()
reset timers and counters
Definition: slufactor.h:269
Read MPS format files.
number of real parameters
Definition: soplex.h:1383
type of computational form, i.e., column or row representation
Definition: soplex.h:978
int stallRefinements
number of refinement steps without pivots
Definition: statistics.h:110
int totalSizePrimal(const int base=2) const
returns total size of primal solution
Definition: solbase.h:125
void changeColRational(int i, const LPColRational &lpcol)
replaces column i with lpcol
Definition: soplex.cpp:2373
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-...
Definition: soplex.cpp:5111
bool getPrimalReal(VectorReal &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:3070
T * get_ptr()
get a C pointer to the data.
Definition: dataarray.h:110
void reMax(int newmax=0)
resets max() to newmax.
Definition: nameset.cpp:144
int size() const
Number of used indices.
Definition: svectorbase.h:153
pivot zero tolerance used in factorization
Definition: soplex.h:1326
int numRowsRational() const
returns number of rows
Definition: soplex.cpp:1142
bool writeDualFileReal(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *intvars=0) const
writes the dual of the real LP to file; LP or MPS format is chosen from the extension in filename; if...
Definition: soplex.cpp:5397
objective offset
Definition: soplex.h:1380
bool getDualRational(VectorRational &vector)
gets the dual solution vector if available; returns true on success
Definition: soplex.cpp:3445
refinement limit (-1 if unlimited)
Definition: soplex.h:993
void setSolutionPolishing(SolutionPolish _polishObj)
set objective of solution polishing (0: off, 1: max_basic_slack, 2: min_basic_slack) ...
Definition: spxsolver.h:644
class of parameter settings
Definition: soplex.h:1396
SPxLPRational * _rationalLP
Definition: soplex.h:1659
void printShortStatistics(std::ostream &os)
prints short statistics
Definition: soplex.cpp:7183
Status getBasis(VarStatus rows[], VarStatus cols[], const int rowsSize=-1, const int colsSize=-1) const
get current basis, and return solver status.
Definition: spxsolver.cpp:1900
Real coefReal(int row, int col) const
returns (unscaled) coefficient
Definition: soplex.cpp:895
bool getSlacksRational(VectorRational &vector)
gets the vector of slack values if available; returns true on success
Definition: soplex.cpp:3415
minimize number of basic slack variables, i.e. more variables in between bounds
Definition: spxsolver.h:232
bool multBasis(Real *vec, bool unscale=true)
multiply with basis matrix; B * vec (inplace)
Definition: soplex.cpp:4855
void getColsRational(int start, int end, LPColSetRational &lpcolset) const
gets columns start, ..., end
Definition: soplex.cpp:1268
bool hasSol() const
is a solution available (not neccessarily feasible)?
Definition: soplex.cpp:3015
bool getSlacks(VectorBase< R > &vector) const
gets the vector of slack values; returns true on success
Definition: solbase.h:65
int totalSizePrimalRational(const int base=2)
get size of primal solution
Definition: soplex.cpp:3933
void _addColsReal(const LPColSetReal &lpcolset)
adds multiple columns to the real LP and adjusts basis
Definition: soplex.cpp:7918
Forrest-Tomlin type update.
Definition: soplex.h:1105
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:803
unsigned int randomSeed() const
returns the current random seed of the solver instance
Definition: soplex.cpp:7645
virtual void setBasisSolver(SLinSolver *slu, const bool destroy=false)
setup linear solver to use. If destroy is true, slusolver will be freed in destructor.
Definition: spxsolver.cpp:89
Real sumDualDegeneracy()
get the sum of dual degeneracy
Definition: spxsolver.h:2106
time limit in seconds (INFTY if unlimited)
Definition: soplex.h:1332
mode for iterative refinement strategy
Definition: soplex.h:1026
SPxGeometSC _scalerGeo8
Definition: soplex.h:1617
void changeRangeReal(const VectorReal &lhs, const VectorReal &rhs)
changes left- and right-hand side vectors
Definition: soplex.cpp:1538
virtual bool readFile(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP from a file.
Definition: spxlpbase.h:1192
Rational _rationalFeastol
Definition: soplex.h:1601
void writeStateReal(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const bool cpxFormat=false) const
writes internal LP, basis information, and parameter settings; if rowNames and colNames are NULL...
Definition: soplex.cpp:5720
DVectorBase< R > _primalRay
Definition: solbase.h:220
bool isScaled() const
Returns true if and only if the LP is scaled.
Definition: spxlpbase.h:140
minimize number of basic slack variables, i.e. more variables between bounds
Definition: soplex.h:1304
void setUtype(UpdateType tp)
sets update type.
Definition: slufactor.h:123
R rhsUnscaled(int i) const
Returns unscaled right hand side of row number i.
void _removeColsReal(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
Definition: soplex.cpp:8393
virtual void changeCol(int n, const LPColBase< R > &newCol, bool scale=false)
Replaces i &#39;th column of LP with newCol. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1701
virtual ~SoPlex()
destructor
Definition: soplex.cpp:808
virtual void removeCols(int perm[])
Removes multiple columns.
Definition: spxlpbase.h:1052
bool getRedCostRational(VectorRational &vector)
gets the vector of reduced cost values if available; returns true on success
Definition: soplex.cpp:3460
bool LE(Real a, Real b, Real eps=Param::epsilon())
returns true iff a <= b + eps
Definition: spxdefines.h:394
DVectorBase< R > _redCost
Definition: solbase.h:222
int _unscaleCalls
Definition: soplex.h:1886
Real getFactorTime() const
time spent in factorizations
Definition: slufactor.h:239
primal feasibility tolerance
Definition: soplex.h:1311
static struct soplex::SoPlex::Settings::RealParam realParam
Definition: soplex.cpp:605
void getObj(VectorBase< R > &pobj) const
Gets objective vector.
Definition: spxlpbase.h:398
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
Definition: spxdefines.h:388
void setType(Type tp)
set LEAVE or ENTER algorithm.
Definition: spxsolver.cpp:180
void setFillFactor(Real f)
set refactor threshold for fill-in in current factor update compared to fill-in in last factorization...
Definition: spxsolver.h:482
bool writeBasisFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const bool cpxFormat=false) const
writes basis information to filename; if rowNames and colNames are NULL, default names are used; retu...
Definition: soplex.cpp:5613
void _addRowReal(const LPRowReal &lprow)
adds a single row to the real LP and adjusts basis
Definition: soplex.cpp:7822
bool defaultValue[SoPlex::BOOLPARAM_COUNT]
array of default values for boolean parameters
Definition: soplex.h:1408
solve() aborted due to iteration limit.
Definition: spxsolver.h:213
R rhs() const
Right-hand side value.
Definition: lprowbase.h:223
SPxScaler * _scaler
Definition: soplex.h:1638
std::string name[SoPlex::BOOLPARAM_COUNT]
array of names for boolean parameters
Definition: soplex.h:1404
cpu or user time
Definition: soplex.h:1275
#define SOPLEX_VERSION
Definition: spxdefines.h:45
bool readBasisFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0)
reads basis information from filename and returns true on success; if rowNames and colNames are NULL...
Definition: soplex.cpp:5413
void changeRangeRational(const VectorRational &lhs, const VectorRational &rhs)
changes left- and right-hand side vectors
Definition: soplex.cpp:2312
mode for reading LP files
Definition: soplex.h:1023
crash basis from a greedy solution
Definition: soplex.h:1175
mode for synchronizing real and rational LP
Definition: soplex.h:1020
apply standard floating-point algorithm
Definition: soplex.h:1246
void _syncLPReal(bool time=true)
synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP...
Definition: soplex.cpp:8805
bool hasDualFarkas() const
is a dual farkas ray available?
Definition: solbase.h:110
void _optimizeRational()
solves rational LP
No Problem has been loaded.
Definition: spxsolver.h:216
bool getDualFarkasReal(VectorReal &vector)
gets the Farkas proof if available; returns true on success
Definition: soplex.cpp:3145
void resetSettings(const bool quiet=false, const bool init=true)
resets default parameter settings
Definition: soplex.cpp:6535
void _recomputeRangeTypesRational()
recomputes range types from scratch using rational LP
Definition: soplex.cpp:8789
void syntaxError()
Definition: mpsinput.h:237
iteration limit (-1 if unlimited)
Definition: soplex.h:990
int number(const SPxRowId &id) const
Returns the row number of the row with identifier id.
Definition: spxlpbase.h:527
void changeObjReal(const VectorReal &obj)
changes objective function vector to obj
Definition: soplex.cpp:1710
void changeRowRational(int i, const LPRowRational &lprow)
replaces row i with lprow
Definition: soplex.cpp:2167
bool getRowViolationReal(Real &maxviol, Real &sumviol)
gets violation of constraints; returns true on success
Definition: soplex.cpp:3203
re-optimize the original problem to get a proof (ray) of infeasibility/unboundedness?
Definition: soplex.h:965
SPxFastRT _ratiotesterFast
Definition: soplex.h:1631
should cycling solutions be accepted during iterative refinement?
Definition: soplex.h:944
void _disableSimplifierAndScaler()
disables simplifier and scaler
Definition: soplex.cpp:8501
bool getRowViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of constraints; returns true on success
Definition: soplex.cpp:3547
static struct soplex::SoPlex::Settings::IntParam intParam
Definition: soplex.cpp:604
should the decomposition based dual simplex be used to solve the LP? Setting this to true forces the ...
Definition: soplex.h:932
void add(const LPColBase< R > &pcol)
Definition: lpcolsetbase.h:255
Real lowerReal(int i) const
returns lower bound of column i
Definition: soplex.cpp:1052
#define DEFAULT_INFINITY
Definition: spxdefines.h:241
bool getBasisInverseRowRational(const int r, SSVectorRational &vec)
computes row r of basis inverse; performs rational factorization if not available; returns true on su...
Definition: soplex.cpp:5127
NameSet * _rowNames
Definition: soplex.h:1831
Vector & multBaseWith(Vector &x) const
Definition: spxbasis.cpp:1023
void _removeRowReal(int i)
removes row i and adjusts basis
Definition: soplex.cpp:8300
lower bound is finite, upper bound is infinite
Definition: soplex.h:1694
bool _readFileReal(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
reads real LP in LP or MPS format from file and returns true on success; gets row names...
Definition: soplex.cpp:8667
UnitVectorBase< Rational > UnitVectorRational
Definition: unitvector.h:31
bool getRedCost(VectorBase< R > &vector) const
gets the vector of reduced cost values if available; returns true on success
Definition: solbase.h:102
Timer * simplexTime
simplex time
Definition: statistics.h:90
int luSolvesReal
number of (forward and backward) solves with basis matrix in real precision
Definition: statistics.h:106
Real upperReal(int i) const
returns upper bound of column i
Definition: soplex.cpp:1025
void getColRational(int i, LPColRational &lpcol) const
gets column i
Definition: soplex.cpp:1259
int refinements
number of refinement steps
Definition: statistics.h:109
const char * getStarterName()
name of starter
Definition: soplex.cpp:5281
void clear()
remove all elements.
Definition: dataarray.h:208
variable fixed to identical bounds.
Definition: spxsolver.h:193
int luFactorizationsReal
number of basis matrix factorizations in real precision
Definition: statistics.h:105
objective sense
Definition: soplex.h:975
bool hasError() const
Definition: mpsinput.h:195
Real getFastCondition(int type=0)
Definition: spxbasis.cpp:1175
int getFactorCount() const
number of factorizations performed
Definition: slufactor.h:249
#define DEFAULT_EPS_UPDATE
Definition: spxdefines.h:236
virtual void removeCol(int i)
Removes i &#39;th column.
Definition: spxlpbase.h:1033
LP has been proven to be primal infeasible.
Definition: spxsolver.h:222
void setComputeDegenFlag(bool computeDegen)
sets whether the degeneracy is computed at each iteration
Definition: spxsolver.h:2233
Real defaultValue[SoPlex::REALPARAM_COUNT]
array of default values for real parameters
Definition: soplex.h:1436
automatic pricer
Definition: soplex.h:1185
void _checkBasisScaling()
check correctness of (un)scaled basis matrix operations
Definition: testsoplex.cpp:92
bool readFile(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and integer variables if desired; returns true on success
Definition: soplex.cpp:5331
void setSparsePricingFactor(Real fac)
Definition: spxsolver.h:864
display frequency
Definition: soplex.h:999
int intParam(const IntParam param) const
returns integer parameter value
Definition: soplex.cpp:5773
void setOpttol(Real d)
set parameter opttol.
Definition: spxsolver.cpp:992
void _ensureRationalLP()
ensures that the rational LP is available; performs no sync
Definition: soplex.cpp:8515
minimum number of stalling refinements since last pivot to trigger rational factorization ...
Definition: soplex.h:1038
minimal reduction (sum of removed rows/cols) to continue simplification
Definition: soplex.h:1365
void getRowVectorReal(int i, DSVectorReal &row) const
gets vector of row i
Definition: soplex.cpp:918
Wrapper for GMP type mpq_class.We wrap mpq_class so that we can replace it by a double type if GMP is...
Definition: rational.h:44
static void setScientific(std::ostream &stream, int precision=8)
Sets the precision of the stream to 16 and the floatfield to scientifix.
Definition: spxout.h:171
bool setSettings(const Settings &newSettings, const bool init=true)
sets parameter settings; returns true on success
Definition: soplex.cpp:6505
void _changeRhsReal(const VectorReal &rhs)
changes right-hand side vector to rhs and adjusts basis
Definition: soplex.cpp:8015
void changeElementReal(int i, int j, const Real &val)
changes matrix entry in row i and column j to val
Definition: soplex.cpp:1742
void printStatistics(std::ostream &os)
prints complete statistics
Definition: soplex.cpp:7196
std::string name[SoPlex::REALPARAM_COUNT]
array of names for real parameters
Definition: soplex.h:1432
Real rhsReal(int i) const
returns right-hand side of row i
Definition: soplex.cpp:953
std::ostream & getStream(const Verbosity &verbosity) const
Returns the stream for the specified verbosity level.
Definition: spxout.h:157
should a rational factorization be performed after iterative refinement?
Definition: soplex.h:928
const SPxPricer * pricer() const
return loaded SPxPricer.
Definition: spxsolver.h:1771
virtual bool readBasisFile(const char *filename, const NameSet *rowNames, const NameSet *colNames)
Definition: spxfileio.cpp:24
rowwise representation.
Definition: spxsolver.h:107
mode for hyper sparse pricing
Definition: soplex.h:1035
void getRhsReal(DVectorReal &rhs) const
gets right-hand side vector
Definition: soplex.cpp:944
void add(const LPRowBase< R > &row)
Definition: lprowsetbase.h:328
bool setDualNorms(int nnormsRow, int nnormsCol, Real *norms)
set dual norms
Definition: spxsolver.cpp:2125
maximum number of updates without fresh factorization
Definition: soplex.h:987
int dlcmSizeDual(const int base=2) const
returns size of least common multiple of denominators in dual solution
Definition: solbase.h:167
void removeColRangeRational(int start, int end, int perm[]=0)
removes columns start to end including both; an array perm of size numColsRational() may be passed as...
Definition: soplex.cpp:2849
virtual void setTerminationTime(Real time=infinity)
set time limit.
Definition: spxsolver.cpp:1630
standard Harris ratio test
Definition: soplex.h:1210
void changeUpperRational(const VectorRational &upper)
changes vector of upper bounds to upper
Definition: soplex.cpp:2454
bool _boolParamValues[SoPlex::BOOLPARAM_COUNT]
array of current boolean parameter values
Definition: soplex.h:1462
Rational _rationalPosInfty
Definition: soplex.h:1599
number of integer parameters
Definition: soplex.h:1062
Rational _rationalOpttol
Definition: soplex.h:1602
bool getPrimal(VectorBase< R > &vector) const
gets the primal solution vector; returns true on success
Definition: solbase.h:57
RealParam
real parameters
Definition: soplex.h:1308
virtual void changeObjOffset(const R &o)
Definition: spxlpbase.h:1841
bool setDualNorms(int nnormsRow, int nnormsCol, Real *norms)
sets steepest edge norms and returns false if that&#39;s not possible
Definition: soplex.cpp:1125
static struct soplex::SoPlex::Settings::BoolParam boolParam
Definition: soplex.cpp:603
const VectorRational & lhsRational() const
returns left-hand side vector
Definition: soplex.cpp:1232
virtual void removeRows(int perm[])
Removes multiple rows.
Definition: spxlpbase.h:952
bool writeFileRational(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *intvars=0) const
writes rational LP to file; LP or MPS format is chosen from the extension in filename; if rowNames an...
Definition: soplex.cpp:5377
void removeLast(int m=1)
remove m last elements.
Definition: dataarray.h:202
maximize number of basic slack variables, i.e. more variables on bounds
Definition: spxsolver.h:231
SPxEquiliSC _scalerBiequi
Definition: soplex.h:1615
int numNonzerosRational() const
returns number of nonzeros
Definition: soplex.cpp:1160
void getObjUnscaled(VectorBase< Real > &pobj) const
Gets unscaled objective vector.
automatic choice according to number of rows and columns
Definition: soplex.h:1079
virtual const std::string what() const
returns exception message
Definition: exceptions.h:57
bool isDualFeasible() const
is stored dual solution feasible?
Definition: soplex.cpp:3031
void removeColRangeReal(int start, int end, int perm[]=0)
removes columns start to end including both; an array perm of size numColsReal() may be passed as buf...
Definition: soplex.cpp:1933
void addColReal(const LPCol &lpcol)
adds a single column
Definition: soplex.cpp:1407
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:152
Rational objRational(int i) const
returns objective value of column i
Definition: soplex.cpp:1342
void add(const SVectorBase< S > &vec)
Append nonzeros of sv.
Definition: dsvectorbase.h:218
void clearLPRational()
clears the LP
Definition: soplex.cpp:2867
No ratiotester loaded.
Definition: spxsolver.h:205
R lower() const
Gets lower bound.
Definition: lpcolbase.h:137
No pricer loaded.
Definition: spxsolver.h:206
void printOriginalProblemStatistics(std::ostream &os)
stores the problem statistics of the original problem
Definition: solvedbds.cpp:3700
SPxSolver::Status optimize()
optimize the given LP
Definition: soplex.cpp:2902
void getObjReal(VectorReal &obj) const
gets objective function vector
Definition: soplex.cpp:1071
void getLowerReal(DVectorReal &lower) const
gets lower bound vector
Definition: soplex.cpp:1061
virtual void start()=0
start timer, resume accounting user, system and real time.
Entering Simplex.
Definition: spxsolver.h:134
#define HYPERPRICINGTHRESHOLD
Definition: spxsolver.h:38
void addRowRational(const LPRowRational &lprow)
adds a single row
Definition: soplex.cpp:1983
void addColRational(const LPColRational &lpcol)
adds a single column
Definition: soplex.cpp:2073
virtual Real stop()=0
stop timer, return accounted user time.
int dualDegeneratePivots()
get number of dual degenerate pivots
Definition: spxsolver.h:2094
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:48
std::ostream & getCurrentStream() const
Returns the stream for the current verbosity.
Definition: spxout.h:164
Real getExactCondition()
Definition: spxbasis.h:614
SPxGeometSC _scalerGeoequi
Definition: soplex.h:1618
const UnitVectorRational * _unitVectorRational(const int i)
returns pointer to a constant unit vector available until destruction of the SoPlex class ...
Definition: soplex.cpp:8872
void _rangeToPerm(int start, int end, int *perm, int permSize) const
creates a permutation for removing rows/columns from a range of indices
Definition: soplex.cpp:7685
bool readLine()
reads an MPS format data line and parse the fields.
Definition: mpsinput.cpp:58
void _syncRealSolution()
synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real s...
Definition: soplex.cpp:8848
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
row representation (lower,lhs) <= (x,Ax) <= (upper,rhs)
Definition: soplex.h:1085
void removeColsRational(int perm[])
removes all columns with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates th...
Definition: soplex.cpp:2797
floating-point check
Definition: soplex.h:1259
LP is primal infeasible or unbounded.
Definition: spxsolver.h:223
R objUnscaled(int i) const
Returns unscaled objective value of column i.
refactor threshold for fill-in in current factor update compared to fill-in in last factorization ...
Definition: soplex.h:1371
int nNzos() const
Returns number of nonzeros in LP.
Definition: spxlpbase.h:164
void changeRhsRational(const VectorRational &rhs)
changes right-hand side vector to rhs
Definition: soplex.cpp:2248
virtual void setOutstream(SPxOut &newOutstream)
set message handler
Definition: spxscaler.h:138
Leaving Simplex.
Definition: spxsolver.h:143
int dmaxSizeDualRational(const int base=2)
get size of largest denominator in dual solution
Definition: soplex.cpp:4003
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 ...
Definition: soplex.cpp:7653
Real luFactorizationTimeReal
time for factorizing bases matrices in real precision
Definition: statistics.h:96
void getLowerUnscaled(DVector &vec) const
Gets unscaled lower bound vector.
Real spxLdexp(Real x, int exp)
returns x * 2^exp
Definition: spxdefines.h:348
int dlcmSizePrimalRational(const int base=2)
get size of least common multiple of denominators in primal solution
Definition: soplex.cpp:3961
Rational objValueRational()
returns the objective value if a primal solution is available
Definition: soplex.cpp:3369
void getBasis(SPxSolver::VarStatus rows[], SPxSolver::VarStatus cols[]) const
gets current basis via arrays of statuses
Definition: soplex.cpp:4097
column representation Ax - s = 0, lower <= x <= upper, lhs <= s <= rhs
Definition: soplex.h:1082
void setNonzeroFactor(Real f)
set refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix ...
Definition: spxsolver.h:476
DataArray< SPxSolver::VarStatus > _basisStatusCols
Definition: soplex.h:1870
nothing known about basis status (possibly due to a singular basis in transformed problem) ...
Definition: spxsolver.h:196
partial multiple pricer based on Dantzig pricing
Definition: soplex.h:1191
virtual void writeFile(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *p_intvars=0) const
Write loaded LP to filename.
Definition: spxlpbase.h:1216
void getLhsReal(DVectorReal &lhs) const
gets left-hand side vector
Definition: soplex.cpp:971
SPxStatus status() const
Definition: spxbasis.h:425
Real upper[SoPlex::REALPARAM_COUNT]
array of upper bounds for real parameter values
Definition: soplex.h:1440
decompStatus _currentProb
Definition: soplex.h:1858
declaration of types for file output
bool isPrimalFeasible() const
is stored primal solution feasible?
Definition: soplex.cpp:3006
DataArray< RangeType > _colTypes
Definition: soplex.h:1706
type of scaler
Definition: soplex.h:1008
void maxObjUnscaled(VectorBase< Real > &vec) const
Returns unscaled objective vector for maximization problem.
double Real
Definition: spxdefines.h:218
Rational _rationalPosone
Definition: soplex.h:1888
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)
Definition: soplex.cpp:2116
void removeRowRangeReal(int start, int end, int perm[]=0)
removes rows start to end including both; an array perm of size numRowsReal() may be passed as buffer...
Definition: soplex.cpp:1836
SPxBoundFlippingRT _ratiotesterBoundFlipping
Definition: soplex.h:1632
bool _isRealLPLoaded
Definition: soplex.h:1641
SLUFactorRational _rationalLUSolver
Definition: soplex.h:1660
bool isColBasic(int i) const
is the i &#39;th column vector basic ?
Definition: spxsolver.h:1296
void getRowRational(int i, LPRowRational &lprow) const
gets row i
Definition: soplex.cpp:1187
void _solveRealLPAndRecordStatistics()
call floating-point solver and update statistics on iterations etc.
Definition: soplex.cpp:8555
DVectorBase< R > _primal
Definition: solbase.h:218
user sync of real and rational LP
Definition: soplex.h:1229
number of boolean parameters
Definition: soplex.h:968
SPxEquiliSC _scalerUniequi
Definition: soplex.h:1614
#define MSG_DEBUG(x)
Definition: spxdefines.h:132
Status status() const
Status of solution process.
Definition: spxsolve.cpp:2213
Real sumPrimalDegeneracy()
get the sum of primal degeneracy
Definition: spxsolver.h:2112
void printSolvingStatistics(std::ostream &os)
prints statistics on solving process
Definition: soplex.cpp:7174
bool _readFileRational(const char *filename, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
reads rational LP in LP or MPS format from file and returns true on success; gets row names...
Definition: soplex.cpp:8710
lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformula...
Definition: soplex.h:1350
bool getPrimalRayReal(VectorReal &vector)
gets the primal ray if available; returns true on success
Definition: soplex.cpp:3100
void getColVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets column vector of column i.
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
Definition: spxdefines.h:400
static void setFixed(std::ostream &stream, int precision=8)
Sets the precision of the stream to 8 and the floatfield to fixed.
Definition: spxout.h:177
SPxSense spxSense() const
Returns the optimization sense.
Definition: spxlpbase.h:515
static void setEpsilonPivot(Real eps)
Definition: spxdefines.cpp:80
void changeLhsReal(const VectorReal &lhs)
changes left-hand side vector for constraints to lhs
Definition: soplex.cpp:1462
DVectorBase< Real > DVectorReal
Definition: dvector.h:29
bool hasDualFarkas() const
is Farkas proof of infeasibility available?
Definition: soplex.cpp:3040
virtual const char * getName() const
get name of simplifier.
std::string description[SoPlex::INTPARAM_COUNT]
array of descriptions for integer parameters
Definition: soplex.h:1418
bool _isConsistent() const
checks consistency
Definition: soplex.cpp:7697
void _changeLowerReal(const VectorReal &lower)
changes vector of lower bounds to lower and adjusts basis
Definition: soplex.cpp:8137
R upperUnscaled(int i) const
Returns unscaled upper bound of column i.
R lhs() const
Left-hand side value.
Definition: lprowbase.h:211
the iteration frequency at which the decomposition solve output is displayed.
Definition: soplex.h:1053
decide depending on tolerances whether to apply iterative refinement
Definition: soplex.h:1249
LP has been solved to optimality.
Definition: spxsolver.h:220
Rational maxAbsNonzeroRational() const
returns biggest non-zero element in absolute value
Definition: soplex.cpp:1178
use persistent scaling?
Definition: soplex.h:959
VectorBase< Real > Vector
Definition: vector.h:29
virtual void setPricer(SPxPricer *pricer, const bool destroy=false)
setup pricer to use. If destroy is true, pricer will be freed in destructor.
Definition: spxsolver.cpp:111
bool computeBasisInverseRational()
compute rational basis inverse; returns true on success
Definition: soplex.cpp:5083
bool _upperFinite(const RangeType &rangeType) const
checks whether RangeType corresponds to finite upper bound
Definition: soplex.cpp:7813
bool _hasBasis
Definition: soplex.h:1876
use bound flipping also for row representation?
Definition: soplex.h:956
bool hasBasis() const
is an advanced starting basis available?
Definition: soplex.cpp:4017
void _invalidateSolution()
invalidates solution
Definition: soplex.cpp:8428
bool getBasisInverseColReal(int c, Real *coef, int *inds=NULL, int *ninds=NULL, bool unscale=true)
computes column c of basis inverse; returns true on success
Definition: soplex.cpp:4461
bool getDualViolationReal(Real &maxviol, Real &sumviol)
gets violation of dual multipliers; returns true on success
Definition: soplex.cpp:3309
bool getBasisInverseColRational(const int c, SSVectorRational &vec)
computes column c of basis inverse; performs rational factorization if not available; returns true on...
Definition: soplex.cpp:5153
Real sumPrimalDegen
the sum of the rate of primal degeneracy at each iteration
Definition: statistics.h:127
void append(const T &t)
append element t.
Definition: dataarray.h:121
const char * getSimplifierName()
name of simplifier
Definition: soplex.cpp:5292
void changeLowerReal(const VectorReal &lower)
changes vector of lower bounds to lower
Definition: soplex.cpp:1595
DVectorBase< Rational > DVectorRational
Definition: dvector.h:30
virtual void addRows(const LPRowSetBase< R > &pset, bool scale=false)
Definition: spxlpbase.h:643
const char * getPricerName()
name of currently loaded pricer
Definition: soplex.cpp:5314
Class for collecting statistical information.
bool isSPxColId() const
is id a column id?
Definition: spxid.h:166
print condition number during the solve
Definition: soplex.h:1059
void setDisplayFreq(int freq)
set display frequency
Definition: spxsolver.h:846
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
Definition: spxdefines.h:460
solve() aborted due to time limit.
Definition: spxsolver.h:212
Rational _rationalNegone
Definition: soplex.h:1889
an error occured.
Definition: spxsolver.h:204
round scaling factors for iterative refinement to powers of two?
Definition: soplex.h:950
const T * get_const_ptr() const
get a const C pointer to the data.
Definition: dataarray.h:115
SPxBasis::SPxStatus basisStatus() const
returns the current basis status
Definition: soplex.cpp:4025
virtual void setMinReduction(const Real minRed)
set minimal reduction threshold to continue simplification
void removeRowReal(int i)
removes row i
Definition: soplex.cpp:1757
#define DEFAULT_EPS_ZERO
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Definition: spxdefines.h:230
bool getBasisInverseTimesVecReal(Real *rhs, Real *sol, bool unscale=true)
computes dense solution of basis matrix B * sol = rhs; returns true on success
Definition: soplex.cpp:4685
int dlcmSizeDualRational(const int base=2)
get size of least common multiple of denominators in dual solution
Definition: soplex.cpp:3975
virtual void changeLower(const VectorBase< R > &newLower, bool scale=false)
Changes vector of lower bounds to newLower. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1409
virtual void setVerbosity(const Verbosity &v)
Definition: spxout.h:111
LPRowBase< R >::Type rowType(int i) const
Returns the inequality type of the i&#39;th LPRow.
Definition: spxlpbase.h:327
SPxWeightST _starterWeight
Definition: soplex.h:1620
Statistics * _statistics
statistics since last call to solveReal() or solveRational()
Definition: soplex.h:1586
only error output
Definition: soplex.h:1112
#define DEFAULT_EPS_PIVOT
Definition: spxdefines.h:239
virtual void changeRhs(const VectorBase< R > &newRhs, bool scale=false)
Changes right hand side vector for constraints to newRhs. scale determines whether the new data shoul...
Definition: spxlpbase.h:1555
type of simplifier
Definition: soplex.h:1005
bool isPrimalFeasible() const
is the stored solution primal feasible?
Definition: solbase.h:51
R obj(int i) const
Returns objective value of column i.
Definition: spxlpbase.h:407
decide according to problem size
Definition: soplex.h:1288
void getColVectorReal(int i, DSVectorReal &col) const
gets vector of col i
Definition: soplex.cpp:1007
void solveRight(VectorRational &x, const VectorRational &b)
Solves .
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:255
void _removeRowsReal(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
Definition: soplex.cpp:8329
void _syncLPRational(bool time=true)
synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sy...
Definition: soplex.cpp:8829
void printUserSettings()
print non-default parameter values
Definition: soplex.cpp:6557
void changeBoundsReal(const VectorReal &lower, const VectorReal &upper)
changes vectors of column bounds to lower and upper
Definition: soplex.cpp:1672
const char * field3() const
Definition: mpsinput.h:165
RangeType _rangeTypeRational(const Rational &lower, const Rational &upper) const
determines RangeType from rational bounds
Definition: soplex.cpp:7766
SPxSteepPR _pricerQuickSteep
Definition: soplex.h:1627
virtual int getColScaleExp(int i) const
returns scaling factor for column i
Definition: spxscaler.cpp:293
Real getEstimatedCondition()
Definition: spxbasis.h:608
store only real LP
Definition: soplex.h:1223
int numColsRational() const
returns number of columns
Definition: soplex.cpp:1151
void syncLPReal()
synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP...
Definition: soplex.cpp:1972
SPxDantzigPR _pricerDantzig
Definition: soplex.h:1624
SPxParMultPR _pricerParMult
Definition: soplex.h:1625
bool getPrimalRational(VectorRational &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:3400
void changeObjRational(const VectorRational &obj)
changes objective function vector to obj
Definition: soplex.cpp:2576
std::string statisticString() const
statistical information in form of a string
Definition: soplex.cpp:5263
RangeType _switchRangeType(const RangeType &rangeType) const
switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
Definition: soplex.cpp:7791
SLUFactor _slufactor
Definition: soplex.h:1612
variable set to its upper bound.
Definition: spxsolver.h:191
int primalDegeneratePivots()
get number of primal degenerate pivots
Definition: spxsolver.h:2100
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
Definition: didxset.h:42
void clearBasis()
clears starting basis
Definition: soplex.cpp:5236
const SVectorReal & rowVectorRealInternal(int i) const
returns vector of row i, ignoring scaling
Definition: soplex.cpp:909
void syncLPRational()
synchronizes rational LP with real LP, i.e., copies real LP to rational LP, if sync mode is manual ...
Definition: soplex.cpp:2891
virtual void setRealParam(Real param, const char *name="realparam")
set real parameter
Definition: spxscaler.cpp:123
bool getRedCostReal(VectorReal &vector)
gets the vector of reduced cost values if available; returns true on success
Definition: soplex.cpp:3130
virtual void changeBounds(const VectorBase< R > &newLower, const VectorBase< R > &newUpper, bool scale=false)
Changes variable bounds to newLower and newUpper. scale determines whether the new data should be sca...
Definition: spxlpbase.h:1485
void add(const char *str)
Definition: nameset.cpp:25
int polishIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2137
void getCol(int i, LPColBase< R > &col) const
Gets i &#39;th column.
Definition: spxlpbase.h:339
Real realParam(const RealParam param) const
returns real parameter value
Definition: soplex.cpp:5783
virtual Real time() const =0
~Statistics()
destructor
Definition: statistics.h:51
SPxSteepExPR _pricerSteep
Definition: soplex.h:1628
int boundFlips() const
get number of bound flips.
Definition: spxsolver.h:2088
const char * field0() const
Definition: mpsinput.h:150
int degenPivotsDual
number of dual degenerate pivots
Definition: statistics.h:123
void useFullPerturbation(bool full)
perturb entire problem or only the bounds relevant to the current pivot
Definition: spxsolver.h:893
bool parseSettingsString(char *line)
parses one setting string and returns true on success; note that string is modified ...
Definition: soplex.cpp:6774
const VectorReal & upperRealInternal() const
returns upper bound vector
Definition: soplex.cpp:1016
SPxLPBase< Rational > SPxLPRational
Definition: spxlp.h:37
SPxOut spxout
Definition: soplex.h:1485
infinity threshold
Definition: soplex.h:1329
void changeBoundsRational(const VectorRational &lower, const VectorRational &upper)
changes vectors of column bounds to lower and upper
Definition: soplex.cpp:2515
const SVectorRational & colVectorRational(int i) const
returns vector of column i
Definition: soplex.cpp:1277
R lhsUnscaled(int i) const
Returns unscaled left hand side of row number i.
int index(int n) const
Returns index of the n &#39;th nonzero element.
Definition: ssvectorbase.h:175
int numIterations() const
number of iterations since last call to solve
Definition: soplex.cpp:5247
SPxDefaultRT _ratiotesterTextbook
Definition: soplex.h:1629
bool getPrimalRay(VectorBase< R > &vector) const
gets the primal unbounded ray if available; returns true on success
Definition: solbase.h:79
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
Definition: lprowbase.h:45
int dmaxSizeDual(const int base=2) const
returns size of largest denominator in dual solution
Definition: solbase.h:195
greedy crash basis weighted by objective, bounds, and sides
Definition: soplex.h:1172
virtual void loadLP(const SPxLP &LP, bool initSlackBasis=true)
copy LP.
Definition: spxsolver.cpp:71
void setSection(Section p_section)
Definition: mpsinput.h:210
variable set to its lower bound.
Definition: spxsolver.h:192
Settings * _currentSettings
Definition: soplex.h:1597
bool getBasisInverseTimesVecRational(const SVectorRational &rhs, SSVectorRational &sol)
computes solution of basis matrix B * sol = rhs; performs rational factorization if not available; re...
Definition: soplex.cpp:5180
SPxId & baseId(int i)
Definition: spxbasis.h:504
virtual const char * getName() const
get name of ratio tester.
Real lhsReal(int i) const
returns left-hand side of row i
Definition: soplex.cpp:980
LPRowReal::Type rowTypeReal(int i) const
returns inequality type of row i
Definition: soplex.cpp:989
Preconfigured SoPlex LP solver.
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Definition: spxdefines.h:122
Sparse vector .A UnitVectorBase is an SVectorBase that can take only one nonzero value with value 1 b...
maximize number of basic slack variables, i.e. more variables on bounds
Definition: soplex.h:1301
void _syncRationalSolution()
synchronizes real solution with rational solution, i.e., copies real solution to rational solution ...
Definition: soplex.cpp:8860
int _intParamValues[SoPlex::INTPARAM_COUNT]
array of current integer parameter values
Definition: soplex.h:1465
virtual void changeRow(int n, const LPRowBase< R > &newRow, bool scale=false)
Replaces i &#39;th row of LP with newRow. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1652
virtual void changeUpper(const VectorBase< R > &newUpper, bool scale=false)
Changes vector of upper bounds to newUpper. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1447
void reDim(int newdim)
Resets dimension to newdim.
Definition: ssvectorbase.h:569
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)
Definition: soplex.cpp:2025
virtual const char * getName() const
get name of scaler
Definition: spxscaler.cpp:105
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, vector and matrix values only if the respective parameter is set to true. If quiet is set to true the function will only display which vectors are different.
Definition: soplex.cpp:7347
dual simplex algorithm, i.e., leaving for column and entering for row representation ...
Definition: soplex.h:1095
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
force iterative refinement
Definition: soplex.h:1252
lower and upper bound finite, but different
Definition: soplex.h:1700
bool isDualFeasible() const
is a dual solution available?
Definition: solbase.h:88
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
virtual bool writeBasisFile(const char *filename, const NameSet *rowNames, const NameSet *colNames, const bool cpxFormat=false) const
Definition: spxfileio.cpp:39
Real luSolveTimeReal
time for solving linear systems in real precision
Definition: statistics.h:97
virtual void changeObj(const VectorBase< R > &newObj, bool scale=false)
Changes objective vector to newObj. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1335
R * get_ptr()
Only used in slufactor.cpp.
Definition: ssvectorbase.h:100
geometric mean scaling (max 8 rounds) followed by equilibrium scaling (rows and columns) ...
Definition: soplex.h:1162
Rational _rationalNegInfty
Definition: soplex.h:1600
const SVectorRational & rowVectorRational(int i) const
returns vector of row i
Definition: soplex.cpp:1205
int dlcmSizePrimal(const int base=2) const
returns size of least common multiple of denominators in primal solution
Definition: solbase.h:153
void printStatus(std::ostream &os, SPxSolver::Status status)
prints status
Definition: soplex.cpp:7221
virtual void setTerminationIter(int iteration=-1)
set iteration limit.
Definition: spxsolver.cpp:1643
threshold on number of rows vs. number of columns for switching from column to row representations in...
Definition: soplex.h:1359
lower bound equals upper bound
Definition: soplex.h:1703
virtual void addCol(const LPColBase< R > &col, bool scale=false)
Definition: spxlpbase.h:757
std::string description[SoPlex::REALPARAM_COUNT]
array of descriptions for real parameters
Definition: soplex.h:1434
bool getSlacksReal(VectorReal &vector)
gets the vector of slack values if available; returns true on success
Definition: soplex.cpp:3085
#define DEFAULT_RANDOM_SEED
Definition: soplex.h:63
int dim() const
Dimension of vector.
Definition: vectorbase.h:217
Exception base class.This class implements a base class for our SoPlex exceptions We provide a what()...
Definition: exceptions.h:32
int size() const
Returns the number of nonzeros.
Definition: ssvectorbase.h:200
standard verbosity level
Definition: soplex.h:1121
Everything should be within this namespace.
bool setRealParam(const RealParam param, const Real value, const bool init=true)
sets real parameter value; returns true on success
Definition: soplex.cpp:6310
void _changeLhsReal(const VectorReal &lhs)
changes left-hand side vector for constraints to lhs and adjusts basis
Definition: soplex.cpp:7972
working tolerance for feasibility in floating-point solver during iterative refinement ...
Definition: soplex.h:1341
SPxLPReal * _realLP
Definition: soplex.h:1635
int max() const
Maximal number of indices.
Definition: svectorbase.h:160
bool _lowerFinite(const RangeType &rangeType) const
checks whether RangeType corresponds to finite lower bound
Definition: soplex.cpp:7804
void getCols(int start, int end, LPColSetBase< R > &set) const
Gets columns start, ..., end.
Definition: spxlpbase.h:354
the maximum number of rows that are added in each iteration of the decomposition based simplex ...
Definition: soplex.h:1050
bool loadSettingsFile(const char *filename)
reads settings file; returns true on success
Definition: soplex.cpp:6722
SPxGeometSC _scalerGeo1
Definition: soplex.h:1616
virtual void changeRange(const VectorBase< R > &newLhs, const VectorBase< R > &newRhs, bool scale=false)
Changes left and right hand side vectors. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1585
int numNonzerosReal() const
returns number of nonzeros
Definition: soplex.cpp:868
SoPlex & operator=(const SoPlex &rhs)
assignment operator
Definition: soplex.cpp:673
bool getRedCostViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of reduced costs; returns true on success
Definition: soplex.cpp:3606
textbook ratio test without stabilization
Definition: soplex.h:1207
SPxDevexPR _pricerDevex
Definition: soplex.h:1626
void clear()
Remove all indices.
Definition: svectorbase.h:431
virtual void setTester(SPxRatioTester *tester, const bool destroy=false)
setup ratio-tester to use. If destroy is true, tester will be freed in destructor.
Definition: spxsolver.cpp:140
Real objReal(int i) const
returns objective value of column i
Definition: soplex.cpp:1080
DataArray< RangeType > _rowTypes
Definition: soplex.h:1707
void _removeColReal(int i)
removes column i
Definition: soplex.cpp:8364
void _changeRowReal(int i, const LPRowReal &lprow)
replaces row i with lprow and adjusts basis
Definition: soplex.cpp:7945
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
Definition: soplex.cpp:1133
SPxSumST _starterSum
Definition: soplex.h:1621
bool readStringRational(const char *s, Rational &value)
read Rational from string
Definition: rational.cpp:2147
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...
Definition: soplex.cpp:4138
apply rational reconstruction after each iterative refinement?
Definition: soplex.h:947
void _changeColReal(int i, const LPColReal &lpcol)
replaces column i with lpcol and adjusts basis
Definition: soplex.cpp:8108
solve() aborted due to detection of cycling.
Definition: spxsolver.h:211
Real minAbsNonzeroReal() const
returns smallest non-zero element in absolute value
Definition: soplex.cpp:877
type of pricer
Definition: soplex.h:1014
bound flipping ratio test for long steps in the dual simplex
Definition: soplex.h:1216
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
Definition: spxlpbase.h:80
const VectorReal & lowerRealInternal() const
returns lower bound vector
Definition: soplex.cpp:1043
bool getDualReal(VectorReal &vector)
gets the dual solution vector if available; returns true on success
Definition: soplex.cpp:3115
SPxHarrisRT _ratiotesterHarris
Definition: soplex.h:1630
DSVectorBase< Real > DSVectorReal
Definition: dsvector.h:29
equilibrium scaling on rows and columns
Definition: soplex.h:1150
void changeColReal(int i, const LPColReal &lpcol)
replaces column i with lpcol
Definition: soplex.cpp:1576
working tolerance for optimality in floating-point solver during iterative refinement ...
Definition: soplex.h:1344
void clearLPReal()
clears the LP
Definition: soplex.cpp:1951
Preconfigured SoPlex LP-solver.
Definition: soplex.h:89
should the dual of the complementary problem be used in the decomposition simplex?
Definition: soplex.h:938
void removeRowRational(int i)
removes row i
Definition: soplex.cpp:2668
R lowerUnscaled(int i) const
Returns unscaled lower bound of column i.
#define MSG_WARNING(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::WARNING.
Definition: spxdefines.h:116
Type
(In)Equality type of an LP row.
Definition: lprowbase.h:72
int iterations
number of iterations/pivots
Definition: statistics.h:100
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:434
virtual const char * getName() const
get name of pricer.
Definition: spxpricer.h:104
R upper() const
Gets upper bound.
Definition: lpcolbase.h:125
int upper[SoPlex::INTPARAM_COUNT]
array of upper bounds for int parameter values
Definition: soplex.h:1424
Real lower[SoPlex::REALPARAM_COUNT]
array of lower bounds for real parameter values
Definition: soplex.h:1438
SPxVectorST _starterVector
Definition: soplex.h:1622
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
Definition: spxsolver.cpp:2160
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
Definition: ssvectorbase.h:133
#define SET_MAX_LINE_LEN
maximum length of lines in settings file
Definition: soplex.cpp:34
static void setEpsilonUpdate(Real eps)
Definition: spxdefines.cpp:70
bool getBoundViolationReal(Real &maxviol, Real &sumviol)
gets violation of bounds; returns true on success
Definition: soplex.cpp:3160
automatic sync of real and rational LP
Definition: soplex.h:1226
bool writeFileReal(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const DIdxSet *intvars=0, const bool unscale=true) const
writes real LP to file; LP or MPS format is chosen from the extension in filename; if rowNames and co...
Definition: soplex.cpp:5350
const VectorRational & upperRational() const
returns upper bound vector
Definition: soplex.cpp:1286
void setConditionInformation(int condInfo)
print condition number within the usual output
Definition: spxsolver.h:858
NameSet * _colNames
Definition: soplex.h:1832
int boundflips
number of dual bound flips
Definition: statistics.h:104
void clearAllData()
clears all statistics
Definition: statistics.cpp:89
SPxSolver _solver
Definition: soplex.h:1611
const char * getGitHash()
Definition: spxgithash.cpp:23
mode for a posteriori feasibility checks
Definition: soplex.h:1029
refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix ...
Definition: soplex.h:1368
nothing known on loaded problem.
Definition: spxsolver.h:219
steepest edge pricer with initialization to unit norms
Definition: soplex.h:1197
don&#39;t perform modifications on optimal basis
Definition: spxsolver.h:230
VarStatus getBasisRowStatus(int row) const
gets basis status for a single row
Definition: spxsolver.cpp:1888
int _optimizeCalls
Definition: soplex.h:1885
variable is basic.
Definition: spxsolver.h:195
LPRowRational::Type rowTypeRational(int i) const
returns inequality type of row i
Definition: soplex.cpp:1250
type of algorithm, i.e., primal or dual
Definition: soplex.h:981
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
Definition: spxlpbase.h:206
VarStatus getBasisColStatus(int col) const
gets basis status for a single column
Definition: spxsolver.cpp:1894
void print(std::ostream &os)
prints statistics
Definition: statistics.cpp:148
void clearSolvingData()
clears statistics on solving process
Definition: statistics.cpp:96
primal simplex algorithm, i.e., entering for column and leaving for row representation ...
Definition: soplex.h:1092
void _recomputeRangeTypesReal()
recomputes range types from scratch using real LP
Definition: soplex.cpp:8773
virtual void addRow(const LPRowBase< R > &row, bool scale=false)
Definition: spxlpbase.h:585
std::string name[SoPlex::INTPARAM_COUNT]
array of names for integer parameters
Definition: soplex.h:1416
#define DEFAULT_REFACTOR_INTERVAL
default setting for LU refactorization interval
Definition: soplex.cpp:36
DataArray< UnitVectorRational *> _unitMatrixRational
Definition: soplex.h:1682
bool getDualFarkasRational(VectorRational &vector)
gets the Farkas proof if LP is infeasible; returns true on success
Definition: soplex.cpp:3475
stalling refinement limit (-1 if unlimited)
Definition: soplex.h:996
bool isSPxRowId() const
is id a row id?
Definition: spxid.h:161
int lower[SoPlex::INTPARAM_COUNT]
array of lower bounds for int parameter values
Definition: soplex.h:1422
DataArray< SPxSolver::VarStatus > _basisStatusRows
Definition: soplex.h:1869
std::ifstream spxifstream
Definition: spxfileio.h:43
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
Definition: lprowsetbase.h:44
geometric mean scaling on rows and columns, max 1 round
Definition: soplex.h:1153
Timer * readingTime
reading time not included in solving time
Definition: statistics.h:87
int iterationsFromBasis
number of iterations from Basis
Definition: statistics.h:102
int iterationsPolish
number of iterations during solution polishing
Definition: statistics.h:103
modified Harris ratio test
Definition: soplex.h:1213
SPxSolver::VarStatus basisColStatus(int col) const
returns basis status for a single column
Definition: soplex.cpp:4061
void _solveDecompositionDualSimplex()
solves LP using the decomposition based dual simplex
Definition: solvedbds.cpp:47
void getNdualNorms(int &nnormsRow, int &nnormsCol) const
gets number of available dual norms
Definition: soplex.cpp:1109
should dual infeasibility be tested in order to try to return a dual solution even if primal infeasib...
Definition: soplex.h:925
int defaultValue[SoPlex::INTPARAM_COUNT]
array of default values for integer parameters
Definition: soplex.h:1420
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
Definition: spxlpbase.h:1830
bool getFastCondition(Real &condition, int type=0)
compute condition number estimate based on the diagonal of the LU factorization; returns true on succ...
Definition: soplex.cpp:4219
void getUpperUnscaled(DVector &vec) const
Gets unscaled upper bound vector.
uint32_t getSeed() const
returns the initial seed shift
Definition: random.h:113
Timer * solvingTime
solving time
Definition: statistics.h:88
int size() const
return nr. of elements.
Definition: dataarray.h:214
std::string description[SoPlex::BOOLPARAM_COUNT]
array of descriptions for boolean parameters
Definition: soplex.h:1406
Type type() const
return current Type.
Definition: spxsolver.h:512
const VectorReal & rhsRealInternal() const
returns right-hand side vector, ignoring scaling
Definition: soplex.cpp:935
bool boolParam(const BoolParam param) const
returns boolean parameter value
Definition: soplex.cpp:5763
void setSeed(uint32_t initshift)
initialize all seeds of the random number generator.
Definition: random.h:124
void unscaleLP()
unscales the lp and clears basis
virtual const char * getName() const
get name of starter.
Definition: spxstarter.h:88
the verbosity of the decomposition based simplex
Definition: soplex.h:1056
const VectorBase< R > & upper() const
Definition: lpcolsetbase.h:166
Real getSolveTime() const
time spent in solves
Definition: slufactor.h:254
should lifting be used to reduce range of nonzero matrix coefficients?
Definition: soplex.h:919
void printProblemStatistics(std::ostream &os)
Definition: spxlpbase.h:1235
int dmaxSizePrimalRational(const int base=2)
get size of largest denominator in primal solution
Definition: soplex.cpp:3989
bool getEstimatedCondition(Real &condition)
computes an estimated condition number for the current basis matrix using the power method; returns t...
Definition: soplex.cpp:4235
int dmaxSizePrimal(const int base=2) const
returns size of largest denominator in primal solution
Definition: solbase.h:181
Real maxObjReal(int i) const
returns objective value of column i after transformation to a maximization problem; since this is how...
Definition: soplex.cpp:1100
void setRandomSeed(unsigned int seed)
set the random seeds of the solver instance
Definition: soplex.cpp:7637
DataArray< int > _rationalLUSolverBind
Definition: soplex.h:1661
should the degeneracy be computed for each basis?
Definition: soplex.h:935
#define MSG_INFO1(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO1.
Definition: spxdefines.h:118
bool _applyPolishing
Definition: soplex.h:1644
bool getExactCondition(Real &condition)
computes the exact condition number for the current basis matrix using the power method; returns true...
Definition: soplex.cpp:4251
SPxStatus
basis status.
Definition: spxbasis.h:90
virtual int getRowScaleExp(int i) const
returns scaling factor for row i
Definition: spxscaler.cpp:300
const char * getScalerName()
name of scaling method
Definition: soplex.cpp:5303
Real solveTime() const
time spent in last call to solve
Definition: soplex.cpp:5255
void addColsReal(const LPColSetReal &lpcolset)
adds multiple columns
Definition: soplex.cpp:1425
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
Definition: spxlpbase.h:377
Random random
The random number generator used throughout the whole computation. Its seed can be modified...
Definition: spxsolver.h:424
const char * field1() const
Definition: mpsinput.h:155
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:158
virtual void changeElement(int i, int j, const R &val, bool scale=false)
Changes LP element (i, j) to val. scale determines whether the new data should be scaled...
Definition: spxlpbase.h:1750
SPxSolver::Status status() const
returns the current solver status
Definition: soplex.cpp:2998
SolReal _solReal
Definition: soplex.h:1872
zero tolerance used in update of the factorization
Definition: soplex.h:1323
int iterationsPrimal
number of iterations with Primal
Definition: statistics.h:101
void changeLowerRational(const VectorRational &lower)
changes vector of lower bounds to lower
Definition: soplex.cpp:2393
lower limit on objective value
Definition: soplex.h:1335
both bounds are infinite
Definition: soplex.h:1691
bool getRedCostViolationReal(Real &maxviol, Real &sumviol)
gets violation of reduced costs; returns true on success
Definition: soplex.cpp:3249
BoolParam
boolean parameters
Definition: soplex.h:916
bool _hasSolReal
Definition: soplex.h:1877
bool _isSolveStopped(bool &stoppedTime, bool &stoppedIter) const
should solving process be stopped?
Definition: soplex.cpp:7725
virtual void changeLhs(const VectorBase< R > &newLhs, bool scale=false)
Changes left hand side vector for constraints to newLhs. scale determines whether the new data should...
Definition: spxlpbase.h:1517
virtual Real getCoefUnscaled(const SPxLPBase< Real > &lp, int row, int col) const
returns unscaled coefficient of lp
Definition: spxscaler.cpp:602
void _changeBoundsReal(const VectorReal &lower, const VectorReal &upper)
changes vectors of column bounds to lower and upper and adjusts basis
Definition: soplex.cpp:8227
#define SOPLEX_SUBVERSION
Definition: spxdefines.h:46
Settings()
default constructor initializing default settings
Definition: soplex.cpp:558
maximum number of conjugate gradient iterations in least square scaling
Definition: soplex.h:1041
sparse pricing threshold (#violations < dimension * SPARSITY_THRESHOLD activates sparse pricing) ...
Definition: soplex.h:1356
Settings & operator=(const Settings &settings)
assignment operator
Definition: soplex.cpp:582
void setFeastol(Real d)
set parameter feastol.
Definition: spxsolver.cpp:980
bool getDualFarkas(VectorBase< R > &vector) const
gets the Farkas proof if available; returns true on success
Definition: solbase.h:116
void addRowReal(const LPRowReal &lprow)
adds a single row
Definition: soplex.cpp:1371
static void setEpsilonFactorization(Real eps)
Definition: spxdefines.cpp:60
bool getPrimalRayRational(VectorRational &vector)
gets the primal ray if LP is unbounded; returns true on success
Definition: soplex.cpp:3430
dual feasibility tolerance
Definition: soplex.h:1314
void _ensureRealLPLoaded()
ensures that the real LP and the basis are loaded in the solver; performs no sync ...
Definition: soplex.cpp:8528
void invalidate()
invalidate solution
Definition: solbase.h:209
void changeRowReal(int i, const LPRowReal &lprow)
replaces row i with lprow
Definition: soplex.cpp:1443
void setBasis(const SPxSolver::VarStatus rows[], const SPxSolver::VarStatus cols[])
sets starting basis via arrays of statuses
Definition: soplex.cpp:5206
bool hasPrimalRay() const
is a primal unbounded ray available?
Definition: solbase.h:73
bool setIntParam(const IntParam param, const int value, const bool init=true)
sets integer parameter value; returns true on success
Definition: soplex.cpp:5885
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:632
SolRational _solRational
Definition: soplex.h:1873
void getLhsUnscaled(VectorBase< Real > &vec) const
Returns unscaled left hand side vector.
bool saveSettingsFile(const char *filename, const bool onlyChanged=false) const
writes settings file; returns true on success
Definition: soplex.cpp:6622
UnitVectorBase< Real > UnitVectorReal
Definition: unitvector.h:30
std::string rationalToString(const Rational &r, const int precision)
convert rational number to string
Definition: rational.cpp:2108
Real objValueReal()
returns the objective value if a primal solution is available
Definition: soplex.cpp:3049
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 ...
Definition: soplex.cpp:8897
void changeRhsReal(const VectorReal &rhs)
changes right-hand side vector to rhs
Definition: soplex.cpp:1500
SPxLeastSqSC _scalerLeastsq
Definition: soplex.h:1619
geometric frequency at which to apply rational reconstruction
Definition: soplex.h:1362
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:811
void changeElementRational(int i, int j, const Rational &val)
changes matrix entry in row i and column j to val
Definition: soplex.cpp:2632
no solution polishing
Definition: soplex.h:1298
bool isRowBasic(int i) const
is the i &#39;th row vector basic ?
Definition: spxsolver.h:1290
SPxStarter * _starter
Definition: soplex.h:1639
bool _hasSolRational
Definition: soplex.h:1878
void hyperPricing(bool h)
enable or disable hyper sparse pricing
Definition: spxsolver.cpp:1014
void writeStateRational(const char *filename, const NameSet *rowNames=0, const NameSet *colNames=0, const bool cpxFormat=false) const
writes internal LP, basis information, and parameter settings; if rowNames and colNames are NULL...
Definition: soplex.cpp:5742
void _enableSimplifierAndScaler()
enables simplifier and scaler according to current parameters
Definition: soplex.cpp:8443
bool setBoolParam(const BoolParam param, const bool value, const bool init=true)
sets boolean parameter value; returns true on success
Definition: soplex.cpp:5813
should LP be transformed to equality form before a rational solve?
Definition: soplex.h:922
void setOutstream(SPxOut &newOutstream)
Definition: spxsolver.h:469
const char * field2() const
Definition: mpsinput.h:160
Real sumDualDegen
the sum of the rate of dual degeneracy at each iteration
Definition: statistics.h:126
void _idxToPerm(int *idx, int idxSize, int *perm, int permSize) const
creates a permutation for removing rows/columns from an array of indices
Definition: soplex.cpp:7664
DVectorBase< R > _dual
Definition: solbase.h:221
virtual void clear()
clears the LP.
Definition: spxlpbase.h:1133
void setMemFactor(Real f)
set refactor threshold for memory growth in current factor update compared to the last factorization ...
Definition: spxsolver.h:488
void solveLeft(VectorRational &x, const VectorRational &b)
Solves .
int number(const DataKey &pkey) const
returns number of name with DataKey pkey in NameSet.
Definition: nameset.h:212
const SPxBasis & basis() const
Return current basis.
Definition: spxsolver.h:1761
SPxSolver::VarStatus basisRowStatus(int row) const
returns basis status for a single row
Definition: soplex.cpp:4036
the number of iterations before the decomposition simplex initialisation is terminated.
Definition: soplex.h:1047
equilibrium scaling on rows or columns
Definition: soplex.h:1147
virtual void reLoad()
reload LP.
Definition: spxsolver.cpp:56
const VectorRational & maxObjRational() const
returns objective function vector after transformation to a maximization problem; since this is how i...
Definition: soplex.cpp:1352
upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulat...
Definition: soplex.h:1353
void _addRowsReal(const LPRowSetReal &lprowset)
adds multiple rows to the real LP and adjusts basis
Definition: soplex.cpp:7858
int numColsReal() const
returns number of columns
Definition: soplex.cpp:859
virtual Status solve()
solve loaded LP.
Definition: spxsolve.cpp:131
void changeUpperReal(const VectorReal &upper)
changes vector of upper bounds to upper
Definition: soplex.cpp:1634
void reSize(int newsize)
reset size to newsize.
Definition: dataarray.h:226
bool hasPrimalRay() const
is a primal unbounded ray available?
Definition: soplex.cpp:3023
void removeColRational(int i)
removes column i
Definition: soplex.cpp:2768
bool _isRealLPScaled
Definition: soplex.h:1643
IntParam
integer parameters
Definition: soplex.h:972
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:488
~NameSet()
destructor.
Definition: nameset.cpp:219
SPxSolver::Status _status
Definition: soplex.h:1866
least square scaling
Definition: soplex.h:1159
void setTiming(Timer::TYPE ttype)
set timing type
Definition: spxsolver.h:833
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
void getObjRational(VectorRational &obj) const
gets objective function vector
Definition: soplex.cpp:1322
int num() const
Returns the number of LPColBases currently in LPColSetBase.
Definition: lpcolsetbase.h:82
virtual void setIntParam(int param, const char *name="intparam")
set int parameter
Definition: spxscaler.cpp:126
virtual void computePrimalActivity(const VectorBase< R > &primal, VectorBase< R > &activity, const bool unscaled=true) const
Computes activity of the rows for a given primal vector; activity does not need to be zero...
Rational _rationalZero
Definition: soplex.h:1890
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
Definition: lpcolbase.h:45
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:506
RangeType _rangeTypeReal(const Real &lower, const Real &upper) const
determines RangeType from real bounds
Definition: soplex.cpp:7741
void _completeRangeTypesRational()
completes range type arrays after adding columns and/or rows
Definition: soplex.cpp:8759
const VectorReal & lhsRealInternal() const
returns left-hand side vector, ignoring scaling
Definition: soplex.cpp:962
solve() aborted due to objective limit.
Definition: spxsolver.h:214
columnwise representation.
Definition: spxsolver.h:108
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:110
decide according to READMODE
Definition: soplex.h:1262
SPxSimplifier * _simplifier
Definition: soplex.h:1637
void removeRowRangeRational(int start, int end, int perm[]=0)
removes rows start to end including both; an array perm of size numRowsRational() may be passed as bu...
Definition: soplex.cpp:2750
void addRowsReal(const LPRowSetReal &lprowset)
adds multiple rows
Definition: soplex.cpp:1389
bool has(int pnum) const
does NameSet has a name with number pnum?
Definition: nameset.h:232
void getRowVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets unscaled row vector of row i.
virtual void addCols(const LPColSetBase< R > &pset, bool scale=false)
Definition: spxlpbase.h:813
void scaleValue(int i, int scaleExp)
Scale i &#39;th element by a.
Definition: ssvectorbase.h:243
perturb the entire problem or only the relevant bounds of s single pivot?
Definition: soplex.h:962
Basis is singular, numerical troubles?
Definition: spxsolver.h:215
R value(int n) const
Returns value of the n &#39;th nonzero element.
Definition: ssvectorbase.h:183
const SVector & unitVector(int i) const
return i &#39;th unit vector.
Definition: spxsolver.h:1236
should row and bound violations be computed explicitly in the update of reduced problem in the decomp...
Definition: soplex.h:941
upper bound is finite, lower bound is infinite
Definition: soplex.h:1697
bool getBoundViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of bounds; returns true on success
Definition: soplex.cpp:3490
LP has a usable Basis (maybe LP is changed).
Definition: spxsolver.h:217
SPxAutoPR _pricerAuto
Definition: soplex.h:1623
int num() const
Returns the number of LPRowBases in LPRowSetBase.
Definition: lprowsetbase.h:83
int primalIterations()
return number of iterations done with primal algorithm
Definition: spxsolver.h:2124
generic solution-based crash basis
Definition: soplex.h:1178
void setMax(int newmax=1)
Reset nonzero memory to >= newmax.
Definition: dsvectorbase.h:250
LP has been proven to be primal unbounded.
Definition: spxsolver.h:221
int totalSizeDualRational(const int base=2)
get size of dual solution
Definition: soplex.cpp:3947
int degenPivotsPrimal
number of primal degenerate pivots
Definition: statistics.h:122
No Problem has been loaded to the basis.
Definition: spxbasis.h:92
No linear solver loaded.
Definition: spxsolver.h:207
void removeRowsReal(int perm[])
removes all rows with an index i such that perm[i] < 0; upon completion, perm[i] >= 0 indicates the n...
Definition: soplex.cpp:1785
const VectorRational & lowerRational() const
returns lower bound vector
Definition: soplex.cpp:1304