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
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
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
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
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
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
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
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
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
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
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 primal feasible solution available?
3015 bool SoPlex::hasPrimal() 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 a dual feasible solution available?
3040 bool SoPlex::hasDual() const
3041 {
3042  return _hasSolReal || _hasSolRational;
3043 }
3044 
3045 
3046 
3047 /// is Farkas proof of infeasibility available?
3049 {
3052 }
3053 
3054 
3055 
3056 /// returns the objective value if a primal or dual solution is available
3058 {
3059  assert(OBJSENSE_MAXIMIZE == 1);
3060  assert(OBJSENSE_MINIMIZE == -1);
3061 
3062  if(status() == SPxSolver::UNBOUNDED)
3064  else if(status() == SPxSolver::INFEASIBLE)
3066  else if(hasPrimal() || hasDual())
3067  {
3069  return _solReal._objVal;
3070  }
3071  else
3072  return 0.0;
3073 }
3074 
3075 
3076 
3077 /// gets the primal solution vector if available; returns true on success
3079 {
3080  if(hasPrimal() && vector.dim() >= numColsReal())
3081  {
3083  _solReal.getPrimal(vector);
3084  return true;
3085  }
3086  else
3087  return false;
3088 }
3089 
3090 
3091 
3092 /// gets the vector of slack values if available; returns true on success
3094 {
3095  if(hasPrimal() && vector.dim() >= numRowsReal())
3096  {
3098  _solReal.getSlacks(vector);
3099  return true;
3100  }
3101  else
3102  return false;
3103 }
3104 
3105 
3106 
3107 /// gets the primal ray if available; returns true on success
3109 {
3110  if(hasPrimalRay() && vector.dim() >= numColsReal())
3111  {
3113  _solReal.getPrimalRay(vector);
3114  return true;
3115  }
3116  else
3117  return false;
3118 }
3119 
3120 
3121 
3122 /// gets the dual solution vector if available; returns true on success
3124 {
3125  if(hasDual() && vector.dim() >= numRowsReal())
3126  {
3128  _solReal.getDual(vector);
3129  return true;
3130  }
3131  else
3132  return false;
3133 }
3134 
3135 
3136 
3137 /// gets the vector of reduced cost values if available; returns true on success
3139 {
3140  if(hasDual() && vector.dim() >= numColsReal())
3141  {
3143  _solReal.getRedCost(vector);
3144  return true;
3145  }
3146  else
3147  return false;
3148 }
3149 
3150 
3151 
3152 /// gets the Farkas proof if available; returns true on success
3154 {
3155  if(hasDualFarkas() && vector.dim() >= numRowsReal())
3156  {
3158  _solReal.getDualFarkas(vector);
3159  return true;
3160  }
3161  else
3162  return false;
3163 }
3164 
3165 
3166 
3167 /// gets violation of bounds; returns true on success
3168 bool SoPlex::getBoundViolationReal(Real& maxviol, Real& sumviol)
3169 {
3170  if(!isPrimalFeasible())
3171  return false;
3172 
3174  VectorReal& primal = _solReal._primal;
3175  assert(primal.dim() == numColsReal());
3176 
3177  maxviol = 0.0;
3178  sumviol = 0.0;
3179 
3180  for(int i = numColsReal() - 1; i >= 0; i--)
3181  {
3182  Real lower = _realLP->lowerUnscaled(i);
3183  Real upper = _realLP->upperUnscaled(i);
3184  Real viol = lower - primal[i];
3185 
3186  if(viol > 0.0)
3187  {
3188  sumviol += viol;
3189 
3190  if(viol > maxviol)
3191  maxviol = viol;
3192  }
3193 
3194  viol = primal[i] - upper;
3195 
3196  if(viol > 0.0)
3197  {
3198  sumviol += viol;
3199 
3200  if(viol > maxviol)
3201  maxviol = viol;
3202  }
3203  }
3204 
3205  return true;
3206 }
3207 
3208 
3209 
3210 /// gets violation of constraints; returns true on success
3211 bool SoPlex::getRowViolationReal(Real& maxviol, Real& sumviol)
3212 {
3213  if(!isPrimalFeasible())
3214  return false;
3215 
3217  VectorReal& primal = _solReal._primal;
3218  assert(primal.dim() == numColsReal());
3219 
3220  DVectorReal activity(numRowsReal());
3221  _realLP->computePrimalActivity(primal, activity, true);
3222  maxviol = 0.0;
3223  sumviol = 0.0;
3224 
3225  for(int i = numRowsReal() - 1; i >= 0; i--)
3226  {
3227  Real lhs = _realLP->lhsUnscaled(i);
3228  Real rhs = _realLP->rhsUnscaled(i);
3229 
3230  Real viol = lhs - activity[i];
3231 
3232  if(viol > 0.0)
3233  {
3234  sumviol += viol;
3235 
3236  if(viol > maxviol)
3237  maxviol = viol;
3238  }
3239 
3240  viol = activity[i] - rhs;
3241 
3242  if(viol > 0.0)
3243  {
3244  sumviol += viol;
3245 
3246  if(viol > maxviol)
3247  maxviol = viol;
3248  }
3249  }
3250 
3251  return true;
3252 }
3253 
3254 
3255 
3256 /// gets violation of reduced costs; returns true on success
3258 {
3259  if(!isDualFeasible() || !hasBasis())
3260  return false;
3261 
3263  VectorReal& redcost = _solReal._redCost;
3264  assert(redcost.dim() == numColsReal());
3265 
3266  maxviol = 0.0;
3267  sumviol = 0.0;
3268 
3269  for(int c = numColsReal() - 1; c >= 0; c--)
3270  {
3271  SPxSolver::VarStatus colStatus = basisColStatus(c);
3272 
3274  {
3275  if(colStatus != SPxSolver::ON_UPPER && 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  if(colStatus != SPxSolver::ON_LOWER && colStatus != SPxSolver::FIXED && redcost[c] > 0.0)
3284  {
3285  sumviol += redcost[c];
3286 
3287  if(redcost[c] > maxviol)
3288  maxviol = redcost[c];
3289  }
3290  }
3291  else
3292  {
3293  if(colStatus != SPxSolver::ON_UPPER && 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  if(colStatus != SPxSolver::ON_LOWER && colStatus != SPxSolver::FIXED && redcost[c] < 0.0)
3302  {
3303  sumviol += -redcost[c];
3304 
3305  if(redcost[c] < -maxviol)
3306  maxviol = -redcost[c];
3307  }
3308  }
3309  }
3310 
3311  return true;
3312 }
3313 
3314 
3315 
3316 /// gets violation of dual multipliers; returns true on success
3317 bool SoPlex::getDualViolationReal(Real& maxviol, Real& sumviol)
3318 {
3319  if(!isDualFeasible() || !hasBasis())
3320  return false;
3321 
3323  VectorReal& dual = _solReal._dual;
3324  assert(dual.dim() == numRowsReal());
3325 
3326  maxviol = 0.0;
3327  sumviol = 0.0;
3328 
3329  for(int r = numRowsReal() - 1; r >= 0; r--)
3330  {
3331  SPxSolver::VarStatus rowStatus = basisRowStatus(r);
3332 
3334  {
3335  if(rowStatus != SPxSolver::ON_UPPER && 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  if(rowStatus != SPxSolver::ON_LOWER && rowStatus != SPxSolver::FIXED && dual[r] > 0.0)
3344  {
3345  sumviol += dual[r];
3346 
3347  if(dual[r] > maxviol)
3348  maxviol = dual[r];
3349  }
3350  }
3351  else
3352  {
3353  if(rowStatus != SPxSolver::ON_UPPER && 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  if(rowStatus != SPxSolver::ON_LOWER && rowStatus != SPxSolver::FIXED && dual[r] < 0.0)
3362  {
3363  sumviol += -dual[r];
3364 
3365  if(dual[r] < -maxviol)
3366  maxviol = -dual[r];
3367  }
3368  }
3369  }
3370 
3371  return true;
3372 }
3373 
3374 
3375 
3376 /// returns the objective value if a primal or dual solution is available
3378 {
3379  assert(OBJSENSE_MAXIMIZE == 1);
3380  assert(OBJSENSE_MINIMIZE == -1);
3381 
3382  if(status() == SPxSolver::UNBOUNDED)
3383  {
3385  return _rationalPosInfty;
3386  else
3387  return _rationalNegInfty;
3388  }
3389  else if(status() == SPxSolver::INFEASIBLE)
3390  {
3392  return _rationalNegInfty;
3393  else
3394  return _rationalPosInfty;
3395  }
3396  else if(hasPrimal() || hasDual())
3397  {
3399  return _solRational._objVal;
3400  }
3401  else
3402  return _rationalZero;
3403 }
3404 
3405 
3406 
3407 /// gets the primal solution vector if available; returns true on success
3409 {
3410  if(_rationalLP != 0 && hasPrimal() && vector.dim() >= numColsRational())
3411  {
3413  _solRational.getPrimal(vector);
3414  return true;
3415  }
3416  else
3417  return false;
3418 }
3419 
3420 
3421 
3422 /// gets the vector of slack values if available; returns true on success
3424 {
3425  if(_rationalLP != 0 && hasPrimal() && vector.dim() >= numRowsRational())
3426  {
3428  _solRational.getSlacks(vector);
3429  return true;
3430  }
3431  else
3432  return false;
3433 }
3434 
3435 
3436 
3437 /// gets the primal ray if LP is unbounded; returns true on success
3439 {
3440  if(_rationalLP != 0 && hasPrimalRay() && vector.dim() >= numColsRational())
3441  {
3443  _solRational.getPrimalRay(vector);
3444  return true;
3445  }
3446  else
3447  return false;
3448 }
3449 
3450 
3451 
3452 /// gets the dual solution vector if available; returns true on success
3454 {
3455  if(_rationalLP != 0 && hasDual() && vector.dim() >= numRowsRational())
3456  {
3458  _solRational.getDual(vector);
3459  return true;
3460  }
3461  else
3462  return false;
3463 }
3464 
3465 
3466 
3467 /// gets the vector of reduced cost values if available; returns true on success
3469 {
3470  if(_rationalLP != 0 && hasDual() && vector.dim() >= numColsRational())
3471  {
3473  _solRational.getRedCost(vector);
3474  return true;
3475  }
3476  else
3477  return false;
3478 }
3479 
3480 
3481 
3482 /// gets the Farkas proof if LP is infeasible; returns true on success
3484 {
3485  if(_rationalLP != 0 && hasDualFarkas() && vector.dim() >= numRowsRational())
3486  {
3488  _solRational.getDualFarkas(vector);
3489  return true;
3490  }
3491  else
3492  return false;
3493 }
3494 
3495 
3496 
3497 /// gets violation of bounds; returns true on success
3499 {
3500  if(!isPrimalFeasible())
3501  return false;
3502 
3503  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3505  _syncLPRational(false);
3506 
3509  assert(primal.dim() == numColsRational());
3510 
3511  maxviol = 0;
3512  sumviol = 0;
3513 
3514  for(int i = numColsRational() - 1; i >= 0; i--)
3515  {
3516  Rational viol = lowerRational(i) - primal[i];
3517 
3518  if(viol > 0)
3519  {
3520  sumviol += viol;
3521 
3522  if(viol > maxviol)
3523  {
3524  maxviol = viol;
3525  MSG_DEBUG(std::cout << "increased bound violation for column " << i << ": " << rationalToString(
3526  viol)
3527  << " lower: " << rationalToString(lowerRational(i))
3528  << ", primal: " << rationalToString(primal[i]) << "\n");
3529  }
3530  }
3531 
3532  viol = primal[i] - upperRational(i);
3533 
3534  if(viol > 0)
3535  {
3536  sumviol += viol;
3537 
3538  if(viol > maxviol)
3539  {
3540  maxviol = viol;
3541  MSG_DEBUG(std::cout << "increased bound violation for column " << i << ": " << rationalToString(
3542  viol)
3543  << " upper: " << rationalToString(upperRational(i))
3544  << ", primal: " << rationalToString(primal[i]) << "\n");
3545  }
3546  }
3547  }
3548 
3549  return true;
3550 }
3551 
3552 
3553 
3554 /// gets violation of constraints; returns true on success
3556 {
3557  if(!isPrimalFeasible())
3558  return false;
3559 
3560  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3562  _syncLPRational(false);
3563 
3566  assert(primal.dim() == numColsRational());
3567 
3568  DVectorRational activity(numRowsRational());
3569  _rationalLP->computePrimalActivity(primal, activity);
3570  maxviol = 0;
3571  sumviol = 0;
3572 
3573  for(int i = numRowsRational() - 1; i >= 0; i--)
3574  {
3575  Rational viol = lhsRational(i) - activity[i];
3576 
3577  if(viol > 0)
3578  {
3579  sumviol += viol;
3580 
3581  if(viol > maxviol)
3582  {
3583  maxviol = viol;
3584  MSG_DEBUG(std::cout << "increased constraint violation for row " << i << ": " << rationalToString(
3585  viol)
3586  << " lhs: " << rationalToString(lhsRational(i))
3587  << ", activity: " << rationalToString(activity[i]) << "\n");
3588  }
3589  }
3590 
3591  viol = activity[i] - rhsRational(i);
3592 
3593  if(viol > 0)
3594  {
3595  sumviol += viol;
3596 
3597  if(viol > maxviol)
3598  {
3599  maxviol = viol;
3600  MSG_DEBUG(std::cout << "increased constraint violation for row " << i << ": " << rationalToString(
3601  viol)
3602  << " rhs: " << rationalToString(rhsRational(i))
3603  << ", activity: " << rationalToString(activity[i]) << "\n");
3604  }
3605  }
3606  }
3607 
3608  return true;
3609 }
3610 
3611 
3612 
3613 /// gets violation of reduced costs; returns true on success
3615 {
3616  if(!isPrimalFeasible() || !isDualFeasible())
3617  return false;
3618 
3619  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3621  _syncLPRational(false);
3622 
3625  assert(redcost.dim() == numColsRational());
3626 
3627  maxviol = 0;
3628  sumviol = 0;
3629 
3630  for(int c = numColsReal() - 1; c >= 0; c--)
3631  {
3632  assert(!_hasBasis || basisColStatus(c) != SPxSolver::UNDEFINED);
3633 
3634  if(_colTypes[c] == RANGETYPE_FIXED)
3635  {
3636  assert(lowerRational(c) == upperRational(c));
3637  continue;
3638  }
3639 
3641  || _solRational._primal[c] == lowerRational(c));
3643  || _solRational._primal[c] == upperRational(c));
3644  assert(!_hasBasis || basisColStatus(c) != SPxSolver::FIXED
3645  || _solRational._primal[c] == lowerRational(c));
3646  assert(!_hasBasis || basisColStatus(c) != SPxSolver::FIXED
3647  || _solRational._primal[c] == upperRational(c));
3648 
3650  {
3651  if(_solRational._primal[c] != upperRational(c) && redcost[c] < 0)
3652  {
3653  sumviol += -redcost[c];
3654 
3655  if(redcost[c] < -maxviol)
3656  {
3657  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3658  " not on upper bound: " << rationalToString(-redcost[c]) << "\n");
3659  maxviol = -redcost[c];
3660  }
3661  }
3662 
3663  if(_solRational._primal[c] != lowerRational(c) && redcost[c] > 0)
3664  {
3665  sumviol += redcost[c];
3666 
3667  if(redcost[c] > maxviol)
3668  {
3669  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3670  " not on lower bound: " << rationalToString(redcost[c]) << "\n");
3671  maxviol = redcost[c];
3672  }
3673  }
3674  }
3675  else
3676  {
3677  if(_solRational._primal[c] != upperRational(c) && redcost[c] > 0)
3678  {
3679  sumviol += redcost[c];
3680 
3681  if(redcost[c] > maxviol)
3682  {
3683  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3684  " not on upper bound: " << rationalToString(redcost[c]) << "\n");
3685  maxviol = redcost[c];
3686  }
3687  }
3688 
3689  if(_solRational._primal[c] != lowerRational(c) && redcost[c] < 0)
3690  {
3691  sumviol += -redcost[c];
3692 
3693  if(redcost[c] < -maxviol)
3694  {
3695  MSG_DEBUG(std::cout << "increased reduced cost violation for column " << c <<
3696  " not on lower bound: " << rationalToString(-redcost[c]) << "\n");
3697  maxviol = -redcost[c];
3698  }
3699  }
3700  }
3701  }
3702 
3703  return true;
3704 }
3705 
3706 
3707 
3708 /// gets violation of dual multipliers; returns true on success
3710 {
3711  if(!isDualFeasible() || !isPrimalFeasible())
3712  return false;
3713 
3714  // if we have to synchronize, we do not measure time, because this would affect the solving statistics
3716  _syncLPRational(false);
3717 
3720  assert(dual.dim() == numRowsRational());
3721 
3722  maxviol = 0;
3723  sumviol = 0;
3724 
3725  for(int r = numRowsReal() - 1; r >= 0; r--)
3726  {
3727  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::UNDEFINED);
3728 
3729  if(_rowTypes[r] == RANGETYPE_FIXED)
3730  {
3731  assert(lhsRational(r) == rhsRational(r));
3732  continue;
3733  }
3734 
3739  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::FIXED
3741  assert(!_hasBasis || basisRowStatus(r) != SPxSolver::FIXED
3743 
3745  {
3746  if(_solRational._slacks[r] < rhsRational(r) - _rationalFeastol && dual[r] < 0)
3747  {
3748  sumviol += -dual[r];
3749 
3750  if(dual[r] < -maxviol)
3751  {
3752  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on upper bound: " <<
3753  rationalToString(-dual[r])
3754  << " (slack = " << rationalToString(_solRational._slacks[r])
3755  << ", status = " << basisRowStatus(r)
3756  << ", lhs = " << rationalToString(lhsRational(r))
3757  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3758  maxviol = -dual[r];
3759  }
3760  }
3761 
3762  if(_solRational._slacks[r] > lhsRational(r) + _rationalFeastol && dual[r] > 0)
3763  {
3764  sumviol += dual[r];
3765 
3766  if(dual[r] > maxviol)
3767  {
3768  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on lower bound: " <<
3769  rationalToString(dual[r])
3770  << " (slack = " << rationalToString(_solRational._slacks[r])
3771  << ", status = " << basisRowStatus(r)
3772  << ", lhs = " << rationalToString(lhsRational(r))
3773  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3774  maxviol = dual[r];
3775  }
3776  }
3777  }
3778  else
3779  {
3780  if(_solRational._slacks[r] < rhsRational(r) - _rationalFeastol && dual[r] > 0)
3781  {
3782  sumviol += dual[r];
3783 
3784  if(dual[r] > maxviol)
3785  {
3786  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on upper bound: " <<
3787  rationalToString(dual[r])
3788  << " (slack = " << rationalToString(_solRational._slacks[r])
3789  << ", status = " << basisRowStatus(r)
3790  << ", lhs = " << rationalToString(lhsRational(r))
3791  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3792  maxviol = dual[r];
3793  }
3794  }
3795 
3796  if(_solRational._slacks[r] > lhsRational(r) + _rationalFeastol && dual[r] < 0)
3797  {
3798  sumviol += -dual[r];
3799 
3800  if(dual[r] < -maxviol)
3801  {
3802  MSG_DEBUG(std::cout << "increased dual violation for row " << r << " not on lower bound: " <<
3803  rationalToString(-dual[r])
3804  << " (slack = " << rationalToString(_solRational._slacks[r])
3805  << ", status = " << basisRowStatus(r)
3806  << ", lhs = " << rationalToString(lhsRational(r))
3807  << ", rhs = " << rationalToString(rhsRational(r)) << ")\n");
3808  maxviol = -dual[r];
3809  }
3810  }
3811  }
3812  }
3813 
3814  return true;
3815 }
3816 
3817 
3818 
3819 #ifdef SOPLEX_WITH_GMP
3820 /// gets the primal solution vector if available; returns true on success
3821 bool SoPlex::getPrimalRational(mpq_t* vector, const int size)
3822 {
3823  assert(size >= numColsRational());
3824 
3825  if(hasPrimal())
3826  {
3828 
3829  for(int i = 0; i < numColsRational(); i++)
3830  mpq_set(vector[i], _solRational._primal[i].getMpqRef());
3831 
3832  return true;
3833  }
3834  else
3835  return false;
3836 }
3837 
3838 
3839 /// gets the vector of slack values if available; returns true on success
3840 bool SoPlex::getSlacksRational(mpq_t* vector, const int size)
3841 {
3842  assert(size >= numRowsRational());
3843 
3844  if(hasPrimal())
3845  {
3847 
3848  for(int i = 0; i < numRowsRational(); i++)
3849  mpq_set(vector[i], _solRational._slacks[i].getMpqRef());
3850 
3851  return true;
3852  }
3853  else
3854  return false;
3855 }
3856 
3857 
3858 
3859 /// gets the primal ray if LP is unbounded; returns true on success
3860 bool SoPlex::getPrimalRayRational(mpq_t* vector, const int size)
3861 {
3862  assert(size >= numColsRational());
3863 
3864  if(hasPrimalRay())
3865  {
3867 
3868  for(int i = 0; i < numColsRational(); i++)
3869  mpq_set(vector[i], _solRational._primalRay[i].getMpqRef());
3870 
3871  return true;
3872  }
3873  else
3874  return false;
3875 }
3876 
3877 
3878 
3879 /// gets the dual solution vector if available; returns true on success
3880 bool SoPlex::getDualRational(mpq_t* vector, const int size)
3881 {
3882  assert(size >= numRowsRational());
3883 
3884  if(hasDual())
3885  {
3887 
3888  for(int i = 0; i < numRowsRational(); i++)
3889  mpq_set(vector[i], _solRational._dual[i].getMpqRef());
3890 
3891  return true;
3892  }
3893  else
3894  return false;
3895 }
3896 
3897 
3898 
3899 /// gets the vector of reduced cost values if available; returns true on success
3900 bool SoPlex::getRedCostRational(mpq_t* vector, const int size)
3901 {
3902  assert(size >= numColsRational());
3903 
3904  if(hasDual())
3905  {
3907 
3908  for(int i = 0; i < numColsRational(); i++)
3909  mpq_set(vector[i], _solRational._redCost[i].getMpqRef());
3910 
3911  return true;
3912  }
3913  else
3914  return false;
3915 }
3916 
3917 
3918 
3919 /// gets the Farkas proof if LP is infeasible; returns true on success
3920 bool SoPlex::getDualFarkasRational(mpq_t* vector, const int size)
3921 {
3922  assert(size >= numRowsRational());
3923 
3924  if(hasDualFarkas())
3925  {
3927 
3928  for(int i = 0; i < numRowsRational(); i++)
3929  mpq_set(vector[i], _solRational._dualFarkas[i].getMpqRef());
3930 
3931  return true;
3932  }
3933  else
3934  return false;
3935 }
3936 #endif
3937 
3938 
3939 
3940 /// get size of primal solution
3942 {
3943  if(hasPrimal() || hasPrimalRay())
3944  {
3946  return _solRational.totalSizePrimal(base);
3947  }
3948  else
3949  return 0;
3950 }
3951 
3952 
3953 
3954 /// get size of dual solution
3956 {
3957  if(hasDual() || hasDualFarkas())
3958  {
3960  return _solRational.totalSizeDual(base);
3961  }
3962  else
3963  return 0;
3964 }
3965 
3966 
3967 
3968 /// get size of least common multiple of denominators in primal solution
3970 {
3971  if(hasPrimal() || hasPrimalRay())
3972  {
3974  return _solRational.dlcmSizePrimal(base);
3975  }
3976  else
3977  return 0;
3978 }
3979 
3980 
3981 
3982 /// get size of least common multiple of denominators in dual solution
3983 int SoPlex::dlcmSizeDualRational(const int base)
3984 {
3985  if(hasDual() || hasDualFarkas())
3986  {
3988  return _solRational.dlcmSizeDual(base);
3989  }
3990  else
3991  return 0;
3992 }
3993 
3994 
3995 
3996 /// get size of largest denominator in primal solution
3998 {
3999  if(hasPrimal() || hasPrimalRay())
4000  {
4002  return _solRational.dmaxSizePrimal(base);
4003  }
4004  else
4005  return 0;
4006 }
4007 
4008 
4009 
4010 /// get size of largest denominator in dual solution
4011 int SoPlex::dmaxSizeDualRational(const int base)
4012 {
4013  if(hasDual() || hasDualFarkas())
4014  {
4016  return _solRational.dmaxSizeDual(base);
4017  }
4018  else
4019  return 0;
4020 }
4021 
4022 
4023 
4024 /// is an advanced starting basis available?
4025 bool SoPlex::hasBasis() const
4026 {
4027  return _hasBasis;
4028 }
4029 
4030 
4031 
4032 /// returns the current basis status
4034 {
4035  if(!hasBasis())
4036  return SPxBasis::NO_PROBLEM;
4038  return SPxBasis::OPTIMAL;
4039  else if(status() == SPxSolver::UNBOUNDED)
4040  return SPxBasis::UNBOUNDED;
4041  else if(status() == SPxSolver::INFEASIBLE)
4042  return SPxBasis::INFEASIBLE;
4043  else if(hasPrimal())
4044  return SPxBasis::PRIMAL;
4045  else if(hasDual())
4046  return SPxBasis::DUAL;
4047  else
4048  return SPxBasis::REGULAR;
4049 }
4050 
4051 
4052 
4053 /// returns basis status for a single row
4055 {
4056  assert(row >= 0);
4057  assert(row < numRowsReal());
4058 
4059  // if no basis is available, return slack basis; if index is out of range, return basic status as for a newly
4060  // added row
4061  if(!hasBasis() || row < 0 || row >= numRowsReal())
4062  return SPxSolver::BASIC;
4063  // if the real LP is loaded, ask solver
4064  else if(_isRealLPLoaded)
4065  {
4066  return _solver.getBasisRowStatus(row);
4067  }
4068  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4069  else
4070  {
4071  assert(row < _basisStatusRows.size());
4072  return _basisStatusRows[row];
4073  }
4074 }
4075 
4076 
4077 
4078 /// returns basis status for a single column
4080 {
4081  assert(col >= 0);
4082  assert(col < numColsReal());
4083 
4084  // if index is out of range, return nonbasic status as for a newly added unbounded column
4085  if(col < 0 || col >= numColsReal())
4086  {
4087  return SPxSolver::ZERO;
4088  }
4089  // if no basis is available, return slack basis
4090  else if(!hasBasis())
4091  {
4092  if(lowerReal(col) > -realParam(SoPlex::INFTY))
4093  return SPxSolver::ON_LOWER;
4094  else if(upperReal(col) < realParam(SoPlex::INFTY))
4095  return SPxSolver::ON_UPPER;
4096  else
4097  return SPxSolver::ZERO;
4098  }
4099  // if the real LP is loaded, ask solver
4100  else if(_isRealLPLoaded)
4101  {
4102  return _solver.getBasisColStatus(col);
4103  }
4104  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4105  else
4106  {
4107  assert(col < _basisStatusCols.size());
4108  return _basisStatusCols[col];
4109  }
4110 }
4111 
4112 
4113 
4114 /// gets current basis
4116 {
4117  // if no basis is available, return slack basis
4118  if(!hasBasis())
4119  {
4120  for(int i = numRowsReal() - 1; i >= 0; i--)
4121  rows[i] = SPxSolver::BASIC;
4122 
4123  for(int i = numColsReal() - 1; i >= 0; i--)
4124  {
4125  if(lowerReal(i) > -realParam(SoPlex::INFTY))
4126  cols[i] = SPxSolver::ON_LOWER;
4127  else if(upperReal(i) < realParam(SoPlex::INFTY))
4128  cols[i] = SPxSolver::ON_UPPER;
4129  else
4130  cols[i] = SPxSolver::ZERO;
4131  }
4132  }
4133  // if the real LP is loaded, ask solver
4134  else if(_isRealLPLoaded)
4135  {
4136  (void)_solver.getBasis(rows, cols);
4137  }
4138  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4139  else
4140  {
4141  assert(numRowsReal() == _basisStatusRows.size());
4142  assert(numColsReal() == _basisStatusCols.size());
4143 
4144  for(int i = numRowsReal() - 1; i >= 0; i--)
4145  rows[i] = _basisStatusRows[i];
4146 
4147  for(int i = numColsReal() - 1; i >= 0; i--)
4148  cols[i] = _basisStatusCols[i];
4149  }
4150 }
4151 
4152 
4153 
4154 /// returns the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m
4155 void SoPlex::getBasisInd(int* bind) const
4156 {
4157  // if no basis is available, return slack basis
4158  if(!hasBasis())
4159  {
4160  for(int i = 0; i < numRowsReal(); ++i)
4161  bind[i] = -1 - i;
4162  }
4163  // if the real LP is not loaded, the basis is stored in the basis arrays of this class
4164  else if(!_isRealLPLoaded)
4165  {
4166  int k = 0;
4167 
4168  assert(numRowsReal() == _basisStatusRows.size());
4169  assert(numColsReal() == _basisStatusCols.size());
4170 
4171  for(int i = 0; i < numRowsReal(); ++i)
4172  {
4174  {
4175  bind[k] = -1 - i;
4176  k++;
4177  }
4178  }
4179 
4180  for(int j = 0; j < numColsReal(); ++j)
4181  {
4183  {
4184  bind[k] = j;
4185  k++;
4186  }
4187  }
4188 
4189  assert(k == numRowsReal());
4190  }
4191  // if the real LP is loaded, the basis is stored in the solver and we need to distinguish between column and row
4192  // representation; ask the solver itself which representation it has, since the REPRESENTATION parameter of this
4193  // class might be set to automatic
4194  else if(_solver.rep() == SPxSolver::COLUMN)
4195  {
4196  for(int i = 0; i < numRowsReal(); ++i)
4197  {
4198  SPxId id = _solver.basis().baseId(i);
4199  bind[i] = (id.isSPxColId() ? _solver.number(id) : - 1 - _solver.number(id));
4200  }
4201  }
4202  // for row representation, return the complement of the row basis; for this, we need to loop through all rows and columns
4203  else
4204  {
4205  assert(_solver.rep() == SPxSolver::ROW);
4206 
4207  int k = 0;
4208 
4209  for(int i = 0; i < numRowsReal(); ++i)
4210  {
4211  if(!_solver.isRowBasic(i))
4212  {
4213  bind[k] = -1 - i;
4214  k++;
4215  }
4216  }
4217 
4218  for(int j = 0; j < numColsReal(); ++j)
4219  {
4220  if(!_solver.isColBasic(j))
4221  {
4222  bind[k] = j;
4223  k++;
4224  }
4225  }
4226 
4227  assert(k == numRowsReal());
4228  }
4229 }
4230 
4231 
4232 /// compute condition number estimate based on the diagonal of the LU factorization; returns true on success
4233 /// type = 0: max/min ratio
4234 /// type = 1: trace of U (sum of diagonal elements)
4235 /// type = 2: product of diagonal elements
4236 bool SoPlex::getFastCondition(Real& condition, int type)
4237 {
4239 
4240  if(!_isRealLPLoaded)
4241  return false;
4242 
4244  return false;
4245 
4246  condition = _solver.basis().getFastCondition(type);
4247 
4248  return true;
4249 }
4250 
4251 /// computes an estimated condition number for the current basis matrix using the power method; returns true on success
4253 {
4255 
4256  if(!_isRealLPLoaded)
4257  return false;
4258 
4260  return false;
4261 
4262  condition = _solver.basis().getEstimatedCondition();
4263 
4264  return true;
4265 }
4266 
4267 /// computes the exact condition number for the current basis matrix using the power method; returns true on success
4269 {
4271 
4272  if(!_isRealLPLoaded)
4273  return false;
4274 
4276  return false;
4277 
4278  condition = _solver.basis().getExactCondition();
4279 
4280  return true;
4281 }
4282 
4283 /// computes row r of basis inverse; returns true on success
4284 bool SoPlex::getBasisInverseRowReal(int r, Real* coef, int* inds, int* ninds, bool unscale)
4285 {
4286  assert(r >= 0);
4287  assert(r < numRowsReal());
4288  assert(coef != 0);
4289 
4290  if(!hasBasis() || r < 0 || r >= numRowsReal())
4291  return false;
4292 
4294 
4295  if(!_isRealLPLoaded)
4296  return false;
4297 
4298  // we need to distinguish between column and row representation; ask the solver itself which representation it
4299  // has, since the REPRESENTATION parameter of this class might be set to automatic
4300  if(_solver.rep() == SPxSolver::COLUMN)
4301  {
4302  int idx;
4304 
4305  try
4306  {
4307  /* unscaling required? */
4308  if(unscale && _solver.isScaled())
4309  {
4310  /* for information on the unscaling procedure see spxscaler.h */
4311 
4312  int scaleExp;
4313  DSVector rhs(_solver.unitVector(r));
4314 
4315  if(_solver.basis().baseId(r).isSPxColId())
4317  else
4318  scaleExp = - _scaler->getRowScaleExp(_solver.number(_solver.basis().baseId(r)));
4319 
4320  rhs *= spxLdexp(1.0, scaleExp);
4321 
4322  _solver.basis().coSolve(x, rhs);
4323  x.setup();
4324  int size = x.size();
4325 
4326  for(int i = 0; i < size; i++)
4327  {
4328  scaleExp = _scaler->getRowScaleExp(x.index(i));
4329  x.scaleValue(x.index(i), scaleExp);
4330  }
4331  }
4332  else
4333  {
4335  }
4336  }
4337  catch(const SPxException& E)
4338  {
4339  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4340  "> while computing basis inverse row.\n");
4341  return false;
4342  }
4343 
4344  // copy sparse data to dense result vector based on coef array
4345  if(ninds != 0 && inds != 0)
4346  {
4347  // during solving SoPlex may have destroyed the sparsity structure so we need to restore it
4348  x.setup();
4349  *ninds = x.size();
4350 
4351  for(int i = 0; i < *ninds; ++i)
4352  {
4353  idx = x.index(i);
4354  coef[idx] = x[idx];
4355  // set sparsity pattern of coef array
4356  inds[i] = idx;
4357  }
4358  }
4359  else
4360  {
4361  VectorReal y(numRowsReal(), coef);
4362  y = x;
4363 
4364  if(ninds != NULL)
4365  *ninds = -1;
4366  }
4367  }
4368  else
4369  {
4370  assert(_solver.rep() == SPxSolver::ROW);
4371 
4372  // @todo should rhs be a reference?
4373  DSVector rhs(numColsReal());
4374  SSVector y(numColsReal());
4375  int* bind = 0;
4376  int index;
4377 
4378  // get ordering of column basis matrix
4379  spx_alloc(bind, numRowsReal());
4380  getBasisInd(bind);
4381 
4382  // get vector corresponding to requested index r
4383  index = bind[r];
4384 
4385  // r corresponds to a row vector
4386  if(index < 0)
4387  {
4388  // transform index to actual row index
4389  index = -index - 1;
4390 
4391  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4392  assert(index >= 0);
4393  assert(index < numRowsReal());
4394  assert(!_solver.isRowBasic(index));
4395 
4396  // get row vector
4397  rhs = _solver.rowVector(index);
4398  rhs *= -1.0;
4399 
4400  if(unscale && _solver.isScaled())
4401  {
4402  for(int i = 0; i < rhs.size(); ++i)
4403  rhs.value(i) = spxLdexp(rhs.value(i), -_scaler->getRowScaleExp(index));
4404  }
4405  }
4406  // r corresponds to a column vector
4407  else
4408  {
4409  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4410  assert(index < numColsReal());
4411  assert(!_solver.isColBasic(index));
4412 
4413  // get unit vector
4414  rhs = UnitVectorReal(index);
4415 
4416  if(unscale && _solver.isScaled())
4417  rhs *= spxLdexp(1.0, _scaler->getColScaleExp(index));
4418  }
4419 
4420  // solve system "y B = rhs", where B is the row basis matrix
4421  try
4422  {
4423  _solver.basis().solve(y, rhs);
4424  }
4425  catch(const SPxException& E)
4426  {
4427  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4428  "> while computing basis inverse row.\n");
4429  return false;
4430  }
4431 
4432  // initialize result vector x as zero
4433  memset(coef, 0, (unsigned int)numRowsReal() * sizeof(Real));
4434 
4435  // add nonzero entries
4436  for(int i = 0; i < numColsReal(); ++i)
4437  {
4438  SPxId id = _solver.basis().baseId(i);
4439 
4440  if(id.isSPxRowId())
4441  {
4442  assert(_solver.number(id) >= 0);
4443  assert(_solver.number(id) < numRowsReal());
4444  assert(bind[r] >= 0 || _solver.number(id) != index);
4445 
4446  int rowindex = _solver.number(id);
4447  coef[rowindex] = y[i];
4448 
4449  if(unscale && _solver.isScaled())
4450  coef[rowindex] = spxLdexp(y[i], _scaler->getRowScaleExp(rowindex));
4451  }
4452  }
4453 
4454  // if r corresponds to a row vector, we have to add a 1 at position r
4455  if(bind[r] < 0)
4456  {
4457  assert(coef[index] == 0.0);
4458  coef[index] = 1.0;
4459  }
4460 
4461  // @todo implement returning of sparsity information like in column wise case
4462  if(ninds != NULL)
4463  *ninds = -1;
4464 
4465  // free memory
4466  spx_free(bind);
4467  }
4468 
4469  return true;
4470 }
4471 
4472 
4473 
4474 /// computes column c of basis inverse; returns true on success
4475 /// @todo does not work correctly for the row representation
4476 bool SoPlex::getBasisInverseColReal(int c, Real* coef, int* inds, int* ninds, bool unscale)
4477 {
4478  assert(c >= 0);
4479  assert(c < numRowsReal());
4480  assert(coef != 0);
4481 
4482  if(!hasBasis() || c < 0 || c >= numRowsReal())
4483  return false;
4484 
4486 
4487  if(!_isRealLPLoaded)
4488  return false;
4489 
4490  // we need to distinguish between column and row representation; ask the solver itself which representation it
4491  // has, since the REPRESENTATION parameter of this class might be set to automatic
4492  if(_solver.rep() == SPxSolver::COLUMN)
4493  {
4494  int idx;
4496 
4497  try
4498  {
4499  /* unscaling required? */
4500  if(unscale && _solver.isScaled())
4501  {
4502  /* for information on the unscaling procedure see spxscaler.h */
4503 
4504  int scaleExp = _scaler->getRowScaleExp(c);
4505  DSVector rhs(_solver.unitVector(c));
4506  rhs *= spxLdexp(1.0, scaleExp);
4507 
4508  _solver.basis().solve(x, rhs);
4509 
4510  x.setup();
4511  int size = x.size();
4512 
4513  for(int i = 0; i < size; i++)
4514  {
4515  if(_solver.basis().baseId(x.index(i)).isSPxColId())
4516  {
4517  idx = _solver.number(_solver.basis().baseId(x.index(i)));
4518  scaleExp = _scaler->getColScaleExp(idx);
4519  x.scaleValue(x.index(i), scaleExp);
4520  }
4521  else
4522  {
4523  idx = _solver.number(_solver.basis().baseId(x.index(i)));
4524  scaleExp = - _scaler->getRowScaleExp(idx);
4525  x.scaleValue(x.index(i), scaleExp);
4526  }
4527  }
4528  }
4529  else
4530  {
4532  }
4533  }
4534  catch(const SPxException& E)
4535  {
4536  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4537  "> while computing basis inverse row.\n");
4538  return false;
4539  }
4540 
4541  // copy sparse data to dense result vector based on coef array
4542  if(ninds != 0 && inds != 0)
4543  {
4544  // SoPlex may have destroyed the sparsity structure so we need to restore it
4545  x.setup();
4546  *ninds = x.size();
4547 
4548  for(int i = 0; i < *ninds; ++i)
4549  {
4550  idx = x.index(i);
4551  coef[idx] = x[idx];
4552  // set sparsity pattern of coef array
4553  inds[i] = idx;
4554  }
4555  }
4556  else
4557  {
4558  VectorReal y(numRowsReal(), coef);
4559  y = x;
4560 
4561  if(ninds != 0)
4562  *ninds = -1;
4563  }
4564  }
4565  else
4566  {
4567  assert(_solver.rep() == SPxSolver::ROW);
4568 
4569  // @todo should rhs be a reference?
4570  DSVectorReal rhs(numColsReal());
4572  int* bind = 0;
4573  int index;
4574 
4575  // get ordering of column basis matrix
4576  spx_alloc(bind, numRowsReal());
4577  getBasisInd(bind);
4578 
4579  // get vector corresponding to requested index c
4580  index = bind[c];
4581 
4582  // c corresponds to a row vector
4583  if(index < 0)
4584  {
4585  // transform index to actual row index
4586  index = -index - 1;
4587 
4588  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4589  assert(index >= 0);
4590  assert(index < numRowsReal());
4591  assert(!_solver.isRowBasic(index));
4592 
4593  // get row vector
4594  rhs = _solver.rowVector(index);
4595  rhs *= -1.0;
4596  }
4597  // c corresponds to a column vector
4598  else
4599  {
4600  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4601  assert(index < numColsReal());
4602  assert(!_solver.isColBasic(index));
4603 
4604  // get unit vector
4605  rhs = UnitVectorReal(index);
4606  }
4607 
4608  // solve system "y B = rhs", where B is the row basis matrix
4609  try
4610  {
4611  /* unscaling required? */
4612  if(unscale && _solver.isScaled())
4613  {
4614  int size = rhs.size();
4615  int scaleExp;
4616 
4617  for(int i = 0; i < size; i++)
4618  {
4619  scaleExp = _scaler->getColScaleExp(i);
4620  rhs.value(i) *= spxLdexp(1.0, scaleExp);
4621  }
4622 
4623  _solver.basis().coSolve(y, rhs);
4624 
4625  int rowIdx;
4626  size = y.size();
4627 
4628  for(int i = 0; i < size; i++)
4629  {
4630  assert(_solver.basis().baseId(y.index(i)).isSPxRowId());
4631  rowIdx = _solver.basis().baseId(y.index(i)).getIdx();
4632  scaleExp = _scaler->getRowScaleExp(rowIdx);
4633  y.setValue(i, y.value(i) * spxLdexp(1.0, scaleExp));
4634  }
4635  }
4636  else
4637  {
4638  _solver.basis().coSolve(y, rhs);
4639  }
4640  }
4641  catch(const SPxException& E)
4642  {
4643  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4644  "> while computing basis inverse row.\n");
4645  return false;
4646  }
4647 
4648  // initialize result vector x as zero
4649  memset(coef, 0, (unsigned int)numRowsReal() * sizeof(Real));
4650 
4651  // add nonzero entries
4652  for(int i = 0; i < numColsReal(); ++i)
4653  {
4654  SPxId id = _solver.basis().baseId(i);
4655 
4656  if(id.isSPxRowId())
4657  {
4658  assert(_solver.number(id) >= 0);
4659  assert(_solver.number(id) < numRowsReal());
4660  assert(bind[c] >= 0 || _solver.number(id) != index);
4661 
4662  coef[_solver.number(id)] = y[i];
4663  }
4664  }
4665 
4666  // if c corresponds to a row vector, we have to add a 1 at position c
4667  if(bind[c] < 0)
4668  {
4669  assert(coef[index] == 0.0);
4670  coef[index] = 1.0;
4671  }
4672 
4673  // @todo implement returning of sparsity information like in column wise case
4674  if(ninds != NULL)
4675  *ninds = -1;
4676 
4677  // free memory
4678  spx_free(bind);
4679  }
4680 
4681  return true;
4682 }
4683 
4684 
4685 
4686 /// computes dense solution of basis matrix B * sol = rhs; returns true on success
4687 bool SoPlex::getBasisInverseTimesVecReal(Real* rhs, Real* sol, bool unscale)
4688 {
4689  VectorReal v(numRowsReal(), rhs);
4690  VectorReal x(numRowsReal(), sol);
4691 
4692  if(!hasBasis())
4693  return false;
4694 
4696 
4697  if(!_isRealLPLoaded)
4698  return false;
4699 
4700  // we need to distinguish between column and row representation; ask the solver itself which representation it
4701  // has, since the REPRESENTATION parameter of this class might be set to automatic; in the column case we can use
4702  // the existing factorization
4703  if(_solver.rep() == SPxSolver::COLUMN)
4704  {
4705  // solve system "x = B^-1 * v"
4706  try
4707  {
4708  /* unscaling required? */
4709  if(unscale && _solver.isScaled())
4710  {
4711  /* for information on the unscaling procedure see spxscaler.h */
4712  int scaleExp;
4713  int idx;
4714 
4715  for(int i = 0; i < v.dim(); ++i)
4716  {
4717  if(isNotZero(v[i]))
4718  {
4719  scaleExp = _scaler->getRowScaleExp(i);
4720  v[i] = spxLdexp(v[i], scaleExp);
4721  }
4722  }
4723 
4724  _solver.basis().solve(x, v);
4725 
4726  for(int i = 0; i < x.dim(); i++)
4727  {
4728  if(isNotZero(x[i]))
4729  {
4730  idx = _solver.number(_solver.basis().baseId(i));
4731 
4732  if(_solver.basis().baseId(i).isSPxColId())
4733  scaleExp = _scaler->getColScaleExp(idx);
4734  else
4735  scaleExp = - _scaler->getRowScaleExp(idx);
4736 
4737  x[i] = spxLdexp(x[i], scaleExp);
4738  }
4739  }
4740  }
4741  else
4742  {
4743  _solver.basis().solve(x, v);
4744  }
4745  }
4746  catch(const SPxException& E)
4747  {
4748  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4749  "> while solving with basis matrix.\n");
4750  return false;
4751  }
4752  }
4753  else
4754  {
4755  assert(_solver.rep() == SPxSolver::ROW);
4756 
4757  DSVectorReal rowrhs(numColsReal());
4759  int* bind = 0;
4760 
4761  bool adaptScaling = unscale && _realLP->isScaled();
4762  int scaleExp;
4763  int idx;
4764 
4765  // get ordering of column basis matrix
4766  spx_alloc(bind, numRowsReal());
4767  getBasisInd(bind);
4768 
4769  // fill right-hand side for row-based system
4770  for(int i = 0; i < numColsReal(); ++i)
4771  {
4772  SPxId id = _solver.basis().baseId(i);
4773 
4774  if(id.isSPxRowId())
4775  {
4776  assert(_solver.number(id) >= 0);
4777  assert(_solver.number(id) < numRowsReal());
4778 
4779  if(adaptScaling)
4780  {
4781  idx = _solver.number(id);
4782  scaleExp = _scaler->getRowScaleExp(idx);
4783  rowrhs.add(i, spxLdexp(v[idx], scaleExp));
4784  }
4785  else
4786  rowrhs.add(i, v[_solver.number(id)]);
4787  }
4788  else
4789  {
4790  assert(rowrhs[i] == 0.0);
4791  }
4792  }
4793 
4794  // solve system "B y = rowrhs", where B is the row basis matrix
4795  try
4796  {
4797  _solver.basis().coSolve(y, rowrhs);
4798  }
4799  catch(const SPxException& E)
4800  {
4801  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
4802  "> while solving with basis matrix.\n");
4803  return false;
4804  }
4805 
4806  // fill result w.r.t. order given by bind
4807  for(int i = 0; i < numRowsReal(); ++i)
4808  {
4809  int index;
4810 
4811  index = bind[i];
4812 
4813  if(index < 0)
4814  {
4815  index = -index - 1;
4816 
4817  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4818  assert(index >= 0);
4819  assert(index < numRowsReal());
4820  assert(!_solver.isRowBasic(index));
4821 
4822  x[i] = v[index] - (rowVectorRealInternal(index) * Vector(numColsReal(), y.get_ptr()));
4823 
4824  if(adaptScaling)
4825  {
4826  scaleExp = -_scaler->getRowScaleExp(index);
4827  x[i] = spxLdexp(x[i], scaleExp);
4828  }
4829  }
4830  else
4831  {
4832  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4833  assert(index >= 0);
4834  assert(index < numColsReal());
4835  assert(!_solver.isColBasic(index));
4836 
4837  if(adaptScaling)
4838  {
4839  scaleExp = _scaler->getColScaleExp(index);
4840  x[i] = spxLdexp(y[index], scaleExp);
4841  }
4842  else
4843  x[i] = y[index];
4844  }
4845  }
4846 
4847  // free memory
4848  spx_free(bind);
4849  }
4850 
4851  return true;
4852 }
4853 
4854 
4855 
4856 /// multiply with basis matrix; B * vec (inplace)
4857 bool SoPlex::multBasis(Real* vec, bool unscale)
4858 {
4859  if(!hasBasis())
4860  return false;
4861 
4863 
4864  if(!_isRealLPLoaded)
4865  return false;
4866 
4867  if(_solver.rep() == SPxSolver::COLUMN)
4868  {
4869  int basisdim = numRowsReal();
4870 
4871  // create Vector from input values
4872  Vector x(basisdim, vec);
4873 
4874  if(unscale && _solver.isScaled())
4875  {
4876  /* for information on the unscaling procedure see spxscaler.h */
4877 
4878  int scaleExp;
4879 
4880  for(int i = 0; i < basisdim; ++i)
4881  {
4882  if(isNotZero(vec[i]))
4883  {
4884  if(_solver.basis().baseId(i).isSPxColId())
4885  scaleExp = - _scaler->getColScaleExp(_solver.number(_solver.basis().baseId(i)));
4886  else
4888 
4889  vec[i] = spxLdexp(vec[i], scaleExp);
4890  }
4891  }
4892 
4893  _solver.basis().multBaseWith(x);
4894 
4895  for(int i = 0; i < basisdim; ++i)
4896  {
4897  scaleExp = _scaler->getRowScaleExp(i);
4898  vec[i] = spxLdexp(vec[i], -scaleExp);
4899  }
4900  }
4901  else
4902  _solver.basis().multBaseWith(x);
4903  }
4904  else
4905  {
4906  int colbasisdim = numRowsReal();
4907 
4908  DSVector y(colbasisdim);
4909 
4910  y.clear();
4911 
4912  // create Vector from input values
4913  Vector x(colbasisdim, vec);
4914 
4915  int* bind = 0;
4916  int index;
4917 
4918  // get ordering of column basis matrix
4919  spx_alloc(bind, colbasisdim);
4920  getBasisInd(bind);
4921 
4922  // temporarily create the column basis and multiply every column with x
4923  for(int i = 0; i < colbasisdim; ++i)
4924  {
4925  if(isNotZero(x[i]))
4926  {
4927  // get vector corresponding to requested index i
4928  index = bind[i];
4929 
4930  // r corresponds to a row vector
4931  if(index < 0)
4932  {
4933  // transform index to actual row index
4934  index = -index - 1;
4935 
4936  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
4937  assert(index >= 0);
4938  assert(index < numRowsReal());
4939  assert(!_solver.isRowBasic(index));
4940 
4941  y.add(x[i] * UnitVectorReal(index));
4942  }
4943  // r corresponds to a column vector
4944  else
4945  {
4946  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
4947  assert(index < numColsReal());
4948  assert(!_solver.isColBasic(index));
4949 
4950  if(unscale && _solver.isScaled())
4951  {
4952  DSVector col;
4953  _solver.getColVectorUnscaled(index, col);
4954  y.add(x[i] * col);
4955  }
4956 
4957  y.add(x[i] * _solver.colVector(index));
4958  }
4959  }
4960  }
4961 
4962  spx_free(bind);
4963  x = y;
4964  }
4965 
4966  return true;
4967 }
4968 
4969 
4970 
4971 /// multiply with transpose of basis matrix; vec * B^T (inplace)
4972 bool SoPlex::multBasisTranspose(Real* vec, bool unscale)
4973 {
4974  if(!hasBasis())
4975  return false;
4976 
4978 
4979  if(!_isRealLPLoaded)
4980  return false;
4981 
4982  if(_solver.rep() == SPxSolver::COLUMN)
4983  {
4984  int basisdim = numRowsReal();
4985 
4986  // create Vector from input values
4987  Vector x(basisdim, vec);
4988 
4989  if(unscale && _solver.isScaled())
4990  {
4991  /* for information on the unscaling procedure see spxscaler.h */
4992 
4993  int scaleExp;
4994 
4995  for(int i = 0; i < basisdim; ++i)
4996  {
4997  if(isNotZero(vec[i]))
4998  {
4999  scaleExp = - _scaler->getRowScaleExp(i);
5000  vec[i] = spxLdexp(vec[i], scaleExp);
5001  }
5002  }
5003 
5004  _solver.basis().multWithBase(x);
5005 
5006  for(int i = 0; i < basisdim; ++i)
5007  {
5008  if(isNotZero(vec[i]))
5009  {
5010  if(_solver.basis().baseId(i).isSPxColId())
5011  scaleExp = - _scaler->getColScaleExp(_solver.number(_solver.basis().baseId(i)));
5012  else
5014 
5015  vec[i] = spxLdexp(vec[i], scaleExp);
5016  }
5017  }
5018  }
5019  else
5020  _solver.basis().multWithBase(x);
5021  }
5022  else
5023  {
5024  int colbasisdim = numRowsReal();
5025 
5026  DSVector y(colbasisdim);
5027 
5028  // create Vector from input values
5029  Vector x(colbasisdim, vec);
5030 
5031  int* bind = 0;
5032  int index;
5033 
5034  // get ordering of column basis matrix
5035  spx_alloc(bind, colbasisdim);
5036  getBasisInd(bind);
5037 
5038  // temporarily create the column basis and multiply every column with x
5039  for(int i = 0; i < colbasisdim; ++i)
5040  {
5041  // get vector corresponding to requested index i
5042  index = bind[i];
5043 
5044  // r corresponds to a row vector
5045  if(index < 0)
5046  {
5047  // transform index to actual row index
5048  index = -index - 1;
5049 
5050  // should be a valid row index and in the column basis matrix, i.e., not basic w.r.t. row representation
5051  assert(index >= 0);
5052  assert(index < numRowsReal());
5053  assert(!_solver.isRowBasic(index));
5054 
5055  y.add(i, x * UnitVectorReal(index));
5056  }
5057  // r corresponds to a column vector
5058  else
5059  {
5060  // should be a valid column index and in the column basis matrix, i.e., not basic w.r.t. row representation
5061  assert(index < numColsReal());
5062  assert(!_solver.isColBasic(index));
5063 
5064  if(unscale && _solver.isScaled())
5065  {
5066  DSVector col;
5067  _solver.getColVectorUnscaled(index, col);
5068  y.add(i, x * col);
5069  }
5070  else
5071  y.add(i, x * _solver.colVector(index));
5072  }
5073  }
5074 
5075  spx_free(bind);
5076  x = y;
5077  }
5078 
5079  return true;
5080 }
5081 
5082 
5083 
5084 /// compute rational basis inverse; returns true on success
5086 {
5087  if(!hasBasis())
5088  {
5091  return false;
5092  }
5093 
5096  {
5100  }
5101 
5103  return true;
5104 
5105  return false;
5106 }
5107 
5108 
5109 
5110 /// gets an array of indices for the columns of the rational basis matrix; bind[i] >= 0 means that the i-th column of
5111 /// the basis matrix contains variable bind[i]; bind[i] < 0 means that the i-th column of the basis matrix contains
5112 /// the slack variable for row -bind[i]-1; performs rational factorization if not available; returns true on success
5114 {
5117 
5119  return false;
5120 
5121  bind = _rationalLUSolverBind;
5122  assert(bind.size() == numRowsRational());
5123  return true;
5124 }
5125 
5126 
5127 
5128 /// computes row r of basis inverse; performs rational factorization if not available; returns true on success
5130 {
5133 
5135  return false;
5136 
5137  try
5138  {
5139  vec.reDim(numRowsRational());
5141  }
5142  catch(const SPxException& E)
5143  {
5144  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5145  "> while computing rational basis inverse row.\n");
5146  return false;
5147  }
5148 
5149  return true;
5150 }
5151 
5152 
5153 
5154 /// computes column c of basis inverse; performs rational factorization if not available; returns true on success
5156 {
5159 
5161  return false;
5162 
5163  try
5164  {
5165  vec.reDim(numRowsRational());
5167  }
5168  catch(const SPxException& E)
5169  {
5170  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5171  "> while computing rational basis inverse column.\n");
5172  return false;
5173  }
5174 
5175  return true;
5176 }
5177 
5178 
5179 
5180 /// computes solution of basis matrix B * sol = rhs; performs rational factorization if not available; returns true
5181 /// on success
5183 {
5186 
5188  return false;
5189 
5190  try
5191  {
5192  sol.reDim(numRowsRational());
5193  _rationalLUSolver.solveRight(sol, rhs);
5194  }
5195  catch(const SPxException& E)
5196  {
5197  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() <<
5198  "> during right solve with rational basis inverse.\n");
5199  return false;
5200  }
5201 
5202  return true;
5203 }
5204 
5205 
5206 
5207 /// sets starting basis via arrays of statuses
5209 {
5211 
5212  if(_isRealLPLoaded)
5213  {
5214  assert(numRowsReal() == _solver.nRows());
5215  assert(numColsReal() == _solver.nCols());
5216 
5217  _solver.setBasis(rows, cols);
5219  }
5220  else
5221  {
5224 
5225  for(int i = numRowsReal() - 1; i >= 0; i--)
5226  _basisStatusRows[i] = rows[i];
5227 
5228  for(int j = numColsReal() - 1; j >= 0; j--)
5229  _basisStatusCols[j] = cols[j];
5230 
5231  _hasBasis = true;
5232  }
5233 }
5234 
5235 
5236 
5237 /// clears starting basis
5239 {
5240  _solver.reLoad();
5241  _status = _solver.status();
5242  _hasBasis = false;
5244 }
5245 
5246 
5247 
5248 /// number of iterations since last call to solve
5250 {
5251  return _statistics->iterations;
5252 }
5253 
5254 
5255 
5256 /// time spent in last call to solve
5258 {
5259  return _statistics->solvingTime->time();
5260 }
5261 
5262 
5263 
5264 /// statistical information in form of a string
5265 std::string SoPlex::statisticString() const
5266 {
5267  std::stringstream s;
5268  s << "Factorizations : " << std::setw(10) << _statistics->luFactorizationsReal << std::endl
5269  << " Time spent : " << std::setw(10) << std::fixed << std::setprecision(
5270  2) << _statistics->luFactorizationTimeReal << std::endl
5271  << "Solves : " << std::setw(10) << _statistics->luSolvesReal << std::endl
5272  << " Time spent : " << std::setw(10) << _statistics->luSolveTimeReal << std::endl
5273  << "Solution time : " << std::setw(10) << std::fixed << std::setprecision(
5274  2) << solveTime() << std::endl
5275  << "Iterations : " << std::setw(10) << numIterations() << std::endl;
5276 
5277  return s.str();
5278 }
5279 
5280 
5281 
5282 /// name of starter
5284 {
5285  if(_starter)
5286  return _starter->getName();
5287  else
5288  return "none";
5289 }
5290 
5291 
5292 
5293 /// name of simplifier
5295 {
5296  if(_simplifier)
5297  return _simplifier->getName();
5298  else
5299  return "none";
5300 }
5301 
5302 
5303 
5304 /// name of scaling method after simplifier
5306 {
5307  if(_scaler)
5308  return _scaler->getName();
5309  else
5310  return "none";
5311 }
5312 
5313 
5314 
5315 /// name of currently loaded pricer
5317 {
5318  return _solver.pricer()->getName();
5319 }
5320 
5321 
5322 
5323 /// name of currently loaded ratiotester
5325 {
5326  return _solver.ratiotester()->getName();
5327 }
5328 
5329 
5330 
5331 /// reads LP file in LP or MPS format according to READMODE parameter; gets row names, column names, and
5332 /// integer variables if desired; returns true on success
5333 bool SoPlex::readFile(const char* filename, NameSet* rowNames, NameSet* colNames, DIdxSet* intVars)
5334 {
5335  bool success = false;
5336 
5338  success = _readFileReal(filename, rowNames, colNames, intVars);
5339  else
5340  success = _readFileRational(filename, rowNames, colNames, intVars);
5341 
5342  // storing the row and column names for use in the DBDS print basis methods
5343  _rowNames = rowNames;
5344  _colNames = colNames;
5345 
5346  return success;
5347 }
5348 
5349 /// writes real LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
5350 /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
5351 /// marked as integer; returns true on success
5352 bool SoPlex::writeFileReal(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5353  const DIdxSet* intVars, const bool unscale) const
5354 {
5355  ///@todo implement return value
5356  if(unscale && _realLP->isScaled())
5357  {
5358  MSG_INFO3(spxout, spxout << "copy LP to write unscaled original problem" << std::endl;)
5359  SPxLPReal* origLP;
5360  origLP = 0;
5361  spx_alloc(origLP);
5362  origLP = new(origLP) SPxLPReal(*_realLP);
5363  origLP->unscaleLP();
5364  origLP->writeFile(filename, rowNames, colNames, intVars);
5365  origLP->~SPxLPReal();
5366  spx_free(origLP);
5367  }
5368  else
5369  _realLP->writeFile(filename, rowNames, colNames, intVars);
5370 
5371  return true;
5372 }
5373 
5374 
5375 
5376 /// writes rational LP to file; LP or MPS format is chosen from the extension in \p filename; if \p rowNames and \p
5377 /// colNames are \c NULL, default names are used; if \p intVars is not \c NULL, the variables contained in it are
5378 /// marked as integer; returns true on success
5379 bool SoPlex::writeFileRational(const char* filename, const NameSet* rowNames,
5380  const NameSet* colNames, const DIdxSet* intVars) const
5381 {
5383  return false;
5384  else
5385  {
5386  assert(_rationalLP != 0);
5387  _rationalLP->writeFile(filename, rowNames, colNames, intVars);
5388 
5389  ///@todo implement return value
5390  return true;
5391  }
5392 }
5393 
5394 
5395 
5396 /// writes the dual of the real LP to file; LP or MPS format is chosen from the extension in \p filename;
5397 /// if \p rowNames and \p colNames are \c NULL, default names are used; if \p intVars is not \c NULL,
5398 /// the variables contained in it are marked as integer; returns true on success
5399 bool SoPlex::writeDualFileReal(const char* filename, const NameSet* rowNames,
5400  const NameSet* colNames, const DIdxSet* intVars) const
5401 {
5402  SPxLPReal dualLP;
5403  _realLP->buildDualProblem(dualLP);
5404  dualLP.setOutstream(spxout);
5405 
5406  // swap colnames and rownames
5407  dualLP.writeFile(filename, colNames, rowNames);
5408  return true;
5409 }
5410 
5411 
5412 
5413 /// reads basis information from \p filename and returns true on success; if \p rowNames and \p colNames are \c NULL,
5414 /// default names are assumed; returns true on success
5415 bool SoPlex::readBasisFile(const char* filename, const NameSet* rowNames, const NameSet* colNames)
5416 {
5417  clearBasis();
5418 
5419 #if 1
5420  assert(filename != 0);
5421  assert(_realLP != 0);
5422 
5423  // start timing
5425 
5426  // read
5427  if(!_isRealLPLoaded)
5428  {
5429  assert(_realLP != &_solver);
5430 
5432  _realLP->~SPxLPReal();
5433  spx_free(_realLP);
5434  _realLP = &_solver;
5435  _isRealLPLoaded = true;
5436  }
5437 
5438  _hasBasis = _solver.readBasisFile(filename, rowNames, colNames);
5439  assert(_hasBasis == (_solver.basis().status() > SPxBasis::NO_PROBLEM));
5440 
5441  // stop timing
5443 
5444  return _hasBasis;
5445 #else
5446  // this is alternative code for reading bases without the SPxSolver class
5447  assert(filename != 0);
5448 
5449  // start timing
5451 
5452  // read
5453  spxifstream file(filename);
5454 
5455  if(!file)
5456  return false;
5457 
5458  // get problem size
5459  int numRows = numRowsReal();
5460  int numCols = numColsReal();
5461 
5462  // prepare column names
5463  const NameSet* colNamesPtr = colNames;
5464  NameSet* tmpColNames = 0;
5465 
5466  if(colNames == 0)
5467  {
5468  std::stringstream name;
5469 
5470  spx_alloc(tmpColNames);
5471  tmpColNames = new(tmpColNames) NameSet();
5472  tmpColNames->reMax(numCols);
5473 
5474  for(int j = 0; j < numCols; ++j)
5475  {
5476  name << "x" << j;
5477  tmpColNames->add(name.str().c_str());
5478  }
5479 
5480  colNamesPtr = tmpColNames;
5481  }
5482 
5483  // prepare row names
5484  const NameSet* rowNamesPtr = rowNames;
5485  NameSet* tmpRowNames = 0;
5486 
5487  if(rowNamesPtr == 0)
5488  {
5489  std::stringstream name;
5490 
5491  spx_alloc(tmpRowNames);
5492  tmpRowNames = new(tmpRowNames) NameSet();
5493  tmpRowNames->reMax(numRows);
5494 
5495  for(int i = 0; i < numRows; ++i)
5496  {
5497  name << "C" << i;
5498  tmpRowNames->add(name.str().c_str());
5499  }
5500 
5501  rowNamesPtr = tmpRowNames;
5502  }
5503 
5504  // initialize with default slack basis
5505  _basisStatusRows.reSize(numRows);
5506  _basisStatusCols.reSize(numCols);
5507 
5508  for(int i = 0; i < numRows; i++)
5510 
5511  for(int i = 0; i < numCols; i++)
5512  {
5515  else if(lowerRealInternal(i) <= double(-realParam(SoPlex::INFTY))
5516  && upperRealInternal(i) >= double(realParam(SoPlex::INFTY)))
5518  else if(lowerRealInternal(i) <= double(-realParam(SoPlex::INFTY)))
5520  else
5522  }
5523 
5524  // read basis
5525  MPSInput mps(file);
5526 
5527  if(mps.readLine() && (mps.field0() != 0) && !strcmp(mps.field0(), "NAME"))
5528  {
5529  while(mps.readLine())
5530  {
5531  int c = -1;
5532  int r = -1;
5533 
5534  if(mps.field0() != 0 && !strcmp(mps.field0(), "ENDATA"))
5535  {
5537  break;
5538  }
5539 
5540  if(mps.field1() == 0 || mps.field2() == 0)
5541  break;
5542 
5543  if((c = colNamesPtr->number(mps.field2())) < 0)
5544  break;
5545 
5546  if(*mps.field1() == 'X')
5547  {
5548  if(mps.field3() == 0 || (r = rowNamesPtr->number(mps.field3())) < 0)
5549  break;
5550  }
5551 
5552  if(!strcmp(mps.field1(), "XU"))
5553  {
5555 
5558  else if(_rowTypes[r] == SoPlex::RANGETYPE_FIXED)
5560  else
5562  }
5563  else if(!strcmp(mps.field1(), "XL"))
5564  {
5566 
5569  else if(_rowTypes[r] == SoPlex::RANGETYPE_FIXED)
5571  else
5573  }
5574  else if(!strcmp(mps.field1(), "UL"))
5575  {
5577  }
5578  else if(!strcmp(mps.field1(), "LL"))
5579  {
5581  }
5582  else
5583  {
5584  mps.syntaxError();
5585  break;
5586  }
5587  }
5588  }
5589 
5590  if(rowNames == 0)
5591  {
5592  tmpRowNames->~NameSet();
5593  spx_free(tmpRowNames);
5594  }
5595 
5596  if(colNames == 0)
5597  {
5598  tmpColNames->~NameSet();
5599  spx_free(tmpColNames);
5600  }
5601 
5602  _hasBasis = !mps.hasError();
5603 
5604  // stop timing
5606 
5607  return _hasBasis;
5608 #endif
5609 }
5610 
5611 
5612 
5613 /// writes basis information to \p filename; if \p rowNames and \p colNames are \c NULL, default names are used;
5614 /// returns true on success
5615 bool SoPlex::writeBasisFile(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5616  const bool cpxFormat) const
5617 {
5618  assert(filename != 0);
5619 
5620  if(_isRealLPLoaded)
5621  return _solver.writeBasisFile(filename, rowNames, colNames, cpxFormat);
5622  else
5623  {
5624  std::ofstream file(filename);
5625 
5626  if(!file.good())
5627  return false;
5628 
5629  file.setf(std::ios::left);
5630  file << "NAME " << filename << "\n";
5631 
5632  // do not write basis if there is none
5633  if(!_hasBasis)
5634  {
5635  file << "ENDATA\n";
5636  return true;
5637  }
5638 
5639  // start writing
5640  int numRows = _basisStatusRows.size();
5641  int numCols = _basisStatusCols.size();
5642  int row = 0;
5643 
5644  for(int col = 0; col < numCols; col++)
5645  {
5646  assert(_basisStatusCols[col] != SPxSolver::UNDEFINED);
5647 
5649  {
5650  // find nonbasic row
5651  for(; row < numRows; row++)
5652  {
5653  assert(_basisStatusRows[row] != SPxSolver::UNDEFINED);
5654 
5656  break;
5657  }
5658 
5659  assert(row != numRows);
5660 
5661  if(_basisStatusRows[row] == SPxSolver::ON_UPPER && (!cpxFormat
5662  || _rowTypes[row] == SoPlex::RANGETYPE_BOXED))
5663  file << " XU ";
5664  else
5665  file << " XL ";
5666 
5667  file << std::setw(8);
5668 
5669  if(colNames != 0 && colNames->has(col))
5670  file << (*colNames)[col];
5671  else
5672  file << "x" << col;
5673 
5674  file << " ";
5675 
5676  if(rowNames != 0 && rowNames->has(row))
5677  file << (*rowNames)[row];
5678  else
5679  file << "C" << row;
5680 
5681  file << "\n";
5682  row++;
5683  }
5684  else
5685  {
5687  {
5688  file << " UL ";
5689 
5690  file << std::setw(8);
5691 
5692  if(colNames != 0 && colNames->has(col))
5693  file << (*colNames)[col];
5694  else
5695  file << "x" << col;
5696 
5697  file << "\n";
5698  }
5699  }
5700  }
5701 
5702  file << "ENDATA\n";
5703 
5704 #ifndef NDEBUG
5705 
5706  // check that the remaining rows are basic
5707  for(; row < numRows; row++)
5708  {
5709  assert(_basisStatusRows[row] == SPxSolver::BASIC);
5710  }
5711 
5712 #endif
5713 
5714  return true;
5715  }
5716 }
5717 
5718 
5719 
5720 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
5721 /// default names are used
5722 void SoPlex::writeStateReal(const char* filename, const NameSet* rowNames, const NameSet* colNames,
5723  const bool cpxFormat) const
5724 {
5725  std::string ofname;
5726 
5727  // write parameter settings
5728  ofname = std::string(filename) + ".set";
5729  saveSettingsFile(ofname.c_str());
5730 
5731  // write problem in MPS/LP format
5732  ofname = std::string(filename) + ((cpxFormat) ? ".lp" : ".mps");
5733  writeFileReal(ofname.c_str(), rowNames, colNames, 0);
5734 
5735  // write basis
5736  ofname = std::string(filename) + ".bas";
5737  writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
5738 }
5739 
5740 
5741 
5742 /// writes internal LP, basis information, and parameter settings; if \p rowNames and \p colNames are \c NULL,
5743 /// default names are used
5744 void SoPlex::writeStateRational(const char* filename, const NameSet* rowNames,
5745  const NameSet* colNames, const bool cpxFormat) const
5746 {
5747  std::string ofname;
5748 
5749  // write parameter settings
5750  ofname = std::string(filename) + ".set";
5751  saveSettingsFile(ofname.c_str());
5752 
5753  // write problem in MPS/LP format
5754  ofname = std::string(filename) + ((cpxFormat) ? ".lp" : ".mps");
5755  writeFileRational(ofname.c_str(), rowNames, colNames, 0);
5756 
5757  // write basis
5758  ofname = std::string(filename) + ".bas";
5759  writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
5760 }
5761 
5762 
5763 
5764 /// returns boolean parameter value
5765 bool SoPlex::boolParam(const BoolParam param) const
5766 {
5767  assert(param >= 0);
5768  assert(param < SoPlex::BOOLPARAM_COUNT);
5769  return _currentSettings->_boolParamValues[param];
5770 }
5771 
5772 
5773 
5774 /// returns integer parameter value
5775 int SoPlex::intParam(const IntParam param) const
5776 {
5777  assert(param >= 0);
5778  assert(param < INTPARAM_COUNT);
5779  return _currentSettings->_intParamValues[param];
5780 }
5781 
5782 
5783 
5784 /// returns real parameter value
5786 {
5787  assert(param >= 0);
5788  assert(param < REALPARAM_COUNT);
5789  return _currentSettings->_realParamValues[param];
5790 }
5791 
5792 
5793 
5794 #ifdef SOPLEX_WITH_RATIONALPARAM
5795 /// returns rational parameter value
5796 Rational SoPlex::rationalParam(const RationalParam param) const
5797 {
5798  assert(param >= 0);
5799  assert(param < RATIONALPARAM_COUNT);
5800  return _currentSettings->_rationalParamValues[param];
5801 }
5802 #endif
5803 
5804 
5805 
5806 /// returns current parameter settings
5808 {
5809  return *_currentSettings;
5810 }
5811 
5812 
5813 
5814 /// sets boolean parameter value; returns true on success
5815 bool SoPlex::setBoolParam(const BoolParam param, const bool value, const bool init)
5816 {
5817  assert(param >= 0);
5818  assert(param < SoPlex::BOOLPARAM_COUNT);
5819  assert(init || _isConsistent());
5820 
5821  if(!init && value == boolParam(param))
5822  return true;
5823 
5824  switch(param)
5825  {
5826  case LIFTING:
5827  break;
5828 
5829  case EQTRANS:
5830  break;
5831 
5832  case TESTDUALINF:
5833  break;
5834 
5835  case RATFAC:
5836  break;
5837 
5838  case USEDECOMPDUALSIMPLEX:
5839  break;
5840 
5841  case COMPUTEDEGEN:
5842  break;
5843 
5844  case USECOMPDUAL:
5845  break;
5846 
5847  case EXPLICITVIOL:
5848  break;
5849 
5850  case ACCEPTCYCLING:
5851  break;
5852 
5853  case RATREC:
5854  break;
5855 
5856  case POWERSCALING:
5857  break;
5858 
5859  case RATFACJUMP:
5860  break;
5861 
5862  case ROWBOUNDFLIPS:
5864  break;
5865 
5866  case PERSISTENTSCALING:
5867  break;
5868 
5869  case FULLPERTURBATION:
5871  break;
5872 
5873  case ENSURERAY:
5874  break;
5875 
5876  default:
5877  return false;
5878  }
5879 
5880  _currentSettings->_boolParamValues[param] = value;
5881  return true;
5882 }
5883 
5884 
5885 
5886 /// sets integer parameter value; returns true on success
5887 bool SoPlex::setIntParam(const IntParam param, const int value, const bool init)
5888 {
5889  assert(param >= 0);
5890  assert(param < INTPARAM_COUNT);
5891  assert(init || _isConsistent());
5892 
5893  if(!init && value == intParam(param))
5894  return true;
5895 
5896  // check for a valid parameter value wrt bounds
5897  if(value < _currentSettings->intParam.lower[param]
5898  || value > _currentSettings->intParam.upper[param])
5899  return false;
5900 
5901  switch(param)
5902  {
5903  // objective sense
5904  case SoPlex::OBJSENSE:
5905  if(value != SoPlex::OBJSENSE_MAXIMIZE && value != SoPlex::OBJSENSE_MINIMIZE)
5906  return false;
5907 
5910 
5911  if(_rationalLP != 0)
5914 
5916  break;
5917 
5918  // type of computational form, i.e., column or row representation
5921  && value != SoPlex::REPRESENTATION_AUTO)
5922  return false;
5923 
5924  break;
5925 
5926  // type of algorithm, i.e., primal or dual
5927  case SoPlex::ALGORITHM:
5928  // decide upon entering/leaving at solve time depending on representation
5929  break;
5930 
5931  // type of LU update
5934  return false;
5935 
5938  break;
5939 
5940  // maximum number of updates before fresh factorization
5942  if(value == 0)
5944  else
5945  _solver.basis().setMaxUpdates(value);
5946 
5947  break;
5948 
5949  // iteration limit (-1 if unlimited)
5950  case SoPlex::ITERLIMIT:
5951  break;
5952 
5953  // refinement limit (-1 if unlimited)
5954  case SoPlex::REFLIMIT:
5955  break;
5956 
5957  // stalling refinement limit (-1 if unlimited)
5958  case SoPlex::STALLREFLIMIT:
5959  break;
5960 
5961  // display frequency
5962  case SoPlex::DISPLAYFREQ:
5963  _solver.setDisplayFreq(value);
5964  break;
5965 
5966  // verbosity level
5967  case SoPlex::VERBOSITY:
5968  switch(value)
5969  {
5970  case 0:
5972  break;
5973 
5974  case 1:
5976  break;
5977 
5978  case 2:
5980  break;
5981 
5982  case 3:
5984  break;
5985 
5986  case 4:
5988  break;
5989 
5990  case 5:
5992  break;
5993  }
5994 
5995  break;
5996 
5997  // type of simplifier
5998  case SoPlex::SIMPLIFIER:
5999  switch(value)
6000  {
6001  case SIMPLIFIER_OFF:
6002  _simplifier = 0;
6003  break;
6004 
6005  case SIMPLIFIER_AUTO:
6007  assert(_simplifier != 0);
6008  break;
6009 
6010  default:
6011  return false;
6012  }
6013 
6014  break;
6015 
6016  // type of scaler
6017  case SoPlex::SCALER:
6018  switch(value)
6019  {
6020  case SCALER_OFF:
6021  _scaler = 0;
6022  break;
6023 
6024  case SCALER_UNIEQUI:
6026  break;
6027 
6028  case SCALER_BIEQUI:
6030  break;
6031 
6032  case SCALER_GEO1:
6033  _scaler = &_scalerGeo1;
6034  break;
6035 
6036  case SCALER_GEO8:
6037  _scaler = &_scalerGeo8;
6038  break;
6039 
6040  case SCALER_LEASTSQ:
6042  break;
6043 
6044  case SCALER_GEOEQUI:
6046  break;
6047 
6048  default:
6049  return false;
6050  }
6051 
6052  break;
6053 
6054  // type of starter used to create crash basis
6055  case SoPlex::STARTER:
6056  switch(value)
6057  {
6058  case STARTER_OFF:
6059  _starter = 0;
6060  break;
6061 
6062  case STARTER_WEIGHT:
6064  break;
6065 
6066  case STARTER_SUM:
6067  _starter = &_starterSum;
6068  break;
6069 
6070  case STARTER_VECTOR:
6072  break;
6073 
6074  default:
6075  return false;
6076  }
6077 
6078  break;
6079 
6080  // type of pricer
6081  case SoPlex::PRICER:
6082  switch(value)
6083  {
6084  case PRICER_AUTO:
6086  break;
6087 
6088  case PRICER_DANTZIG:
6090  break;
6091 
6092  case PRICER_PARMULT:
6094  break;
6095 
6096  case PRICER_DEVEX:
6098  break;
6099 
6100  case PRICER_QUICKSTEEP:
6102  break;
6103 
6104  case PRICER_STEEP:
6106  break;
6107 
6108  default:
6109  return false;
6110  }
6111 
6112  break;
6113 
6114  // mode for synchronizing real and rational LP
6115  case SoPlex::SYNCMODE:
6116  switch(value)
6117  {
6118  case SYNCMODE_ONLYREAL:
6119  if(_rationalLP != 0)
6120  {
6121  _rationalLP->~SPxLPRational();
6123  }
6124 
6125  break;
6126 
6127  case SYNCMODE_AUTO:
6128  if(intParam(param) == SYNCMODE_ONLYREAL)
6129  _syncLPRational();
6130 
6131  break;
6132 
6133  case SYNCMODE_MANUAL:
6135  break;
6136 
6137  default:
6138  return false;
6139  }
6140 
6141  break;
6142 
6143  // mode for reading LP files; nothing to do but change the value if valid
6144  case SoPlex::READMODE:
6145  switch(value)
6146  {
6147  case READMODE_REAL:
6148  case READMODE_RATIONAL:
6149  break;
6150 
6151  default:
6152  return false;
6153  }
6154 
6155  break;
6156 
6157  // mode for iterative refinement strategy; nothing to do but change the value if valid
6158  case SoPlex::SOLVEMODE:
6159  switch(value)
6160  {
6161  case SOLVEMODE_REAL:
6162  case SOLVEMODE_AUTO:
6163  case SOLVEMODE_RATIONAL:
6164  break;
6165 
6166  default:
6167  return false;
6168  }
6169 
6170  break;
6171 
6172  // mode for a posteriori feasibility checks; nothing to do but change the value if valid
6173  case SoPlex::CHECKMODE:
6174  switch(value)
6175  {
6176  case CHECKMODE_REAL:
6177  case CHECKMODE_AUTO:
6178  case CHECKMODE_RATIONAL:
6179  break;
6180 
6181  default:
6182  return false;
6183  }
6184 
6185  break;
6186 
6187  // type of ratio test
6188  case SoPlex::RATIOTESTER:
6189  switch(value)
6190  {
6191  case RATIOTESTER_TEXTBOOK:
6193  break;
6194 
6195  case RATIOTESTER_HARRIS:
6197  break;
6198 
6199  case RATIOTESTER_FAST:
6201  break;
6202 
6205  break;
6206 
6207  default:
6208  return false;
6209  }
6210 
6211  break;
6212 
6213  // type of timer
6214  case SoPlex::TIMER:
6215  switch(value)
6216  {
6217  case TIMER_OFF:
6219  break;
6220 
6221  case TIMER_CPU:
6223  break;
6224 
6225  case TIMER_WALLCLOCK:
6227  break;
6228 
6229  default:
6230  return false;
6231  }
6232 
6233  break;
6234 
6235  // mode of hyper pricing
6236  case SoPlex::HYPER_PRICING:
6237  switch(value)
6238  {
6239  case HYPER_PRICING_OFF:
6240  case HYPER_PRICING_AUTO:
6241  case HYPER_PRICING_ON:
6242  break;
6243 
6244  default:
6245  return false;
6246  }
6247 
6248  break;
6249 
6250  // minimum number of stalling refinements since last pivot to trigger rational factorization
6252  break;
6253 
6254  // maximum number of conjugate gradient iterations in least square scaling
6256  if(_scaler)
6257  _scaler->setIntParam(value);
6258 
6259  break;
6260 
6261  // mode of solution polishing
6263  switch(value)
6264  {
6265  case POLISHING_OFF:
6267  break;
6268 
6269  case POLISHING_INTEGRALITY:
6271  break;
6272 
6275  break;
6276 
6277  default:
6278  return false;
6279  }
6280 
6281  break;
6282 
6283  // the decomposition based simplex parameter settings
6284  case DECOMP_ITERLIMIT:
6285  break;
6286 
6287  case DECOMP_MAXADDEDROWS:
6288  break;
6289 
6290  case DECOMP_DISPLAYFREQ:
6291  break;
6292 
6293  case DECOMP_VERBOSITY:
6294  break;
6295 
6296  // printing of condition n
6297  case PRINTCONDITION:
6299  break;
6300 
6301  default:
6302  return false;
6303  }
6304 
6305  _currentSettings->_intParamValues[param] = value;
6306  return true;
6307 }
6308 
6309 
6310 
6311 /// sets real parameter value; returns true on success
6312 bool SoPlex::setRealParam(const RealParam param, const Real value, const bool init)
6313 {
6314  assert(param >= 0);
6315  assert(param < REALPARAM_COUNT);
6316  assert(init || _isConsistent());
6317 
6318  if(!init && value == realParam(param))
6319  return true;
6320 
6321  if(value < _currentSettings->realParam.lower[param]
6322  || value > _currentSettings->realParam.upper[param])
6323  return false;
6324 
6325  // required to set a different feastol or opttol
6326  Real tmp_value = value;
6327 
6328  switch(param)
6329  {
6330  // primal feasibility tolerance; passed to the floating point solver only when calling solve()
6331  case SoPlex::FEASTOL:
6332 #ifndef SOPLEX_WITH_GMP
6333  if(value < DEFAULT_EPS_PIVOT)
6334  {
6335  MSG_WARNING(spxout, spxout << "Cannot set feasibility tolerance to small value " << value <<
6336  " without GMP - using " << DEFAULT_EPS_PIVOT << ".\n");
6337  tmp_value = DEFAULT_EPS_PIVOT;
6339  break;
6340  }
6341 
6342 #endif
6343  _rationalFeastol = value;
6344  break;
6345 
6346  // dual feasibility tolerance; passed to the floating point solver only when calling solve()
6347  case SoPlex::OPTTOL:
6348 #ifndef SOPLEX_WITH_GMP
6349  if(value < DEFAULT_EPS_PIVOT)
6350  {
6351  MSG_WARNING(spxout, spxout << "Cannot set optimality tolerance to small value " << value <<
6352  " without GMP - using " << DEFAULT_EPS_PIVOT << ".\n");
6353  tmp_value = DEFAULT_EPS_PIVOT;
6355  break;
6356  }
6357 
6358 #endif
6359  _rationalOpttol = value;
6360  break;
6361 
6362  // general zero tolerance
6363  case SoPlex::EPSILON_ZERO:
6364  Param::setEpsilon(value);
6365  break;
6366 
6367  // zero tolerance used in factorization
6370  break;
6371 
6372  // zero tolerance used in update of the factorization
6374  Param::setEpsilonUpdate(value);
6375  break;
6376 
6377  // pivot zero tolerance used in factorization (declare numerical singularity for small LU pivots)
6378  case SoPlex::EPSILON_PIVOT:
6379  Param::setEpsilonPivot(value);
6380  break;
6381 
6382  // infinity threshold
6383  case SoPlex::INFTY:
6384  _rationalPosInfty = value;
6385  _rationalNegInfty = -value;
6386 
6389 
6390  break;
6391 
6392  // time limit in seconds (INFTY if unlimited)
6393  case SoPlex::TIMELIMIT:
6394  break;
6395 
6396  // lower limit on objective value is set in solveReal()
6398  break;
6399 
6400  // upper limit on objective value is set in solveReal()
6402  break;
6403 
6404  // working tolerance for feasibility in floating-point solver
6405  case SoPlex::FPFEASTOL:
6406  break;
6407 
6408  // working tolerance for optimality in floating-point solver
6409  case SoPlex::FPOPTTOL:
6410  break;
6411 
6412  // maximum increase of scaling factors between refinements
6413  case SoPlex::MAXSCALEINCR:
6414  _rationalMaxscaleincr = value;
6415  break;
6416 
6417  // lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformulated)
6418  case SoPlex::LIFTMINVAL:
6419  break;
6420 
6421  // upper threshold in lifting (nonzero matrix coefficients with larger absolute value will be reformulated)
6422  case SoPlex::LIFTMAXVAL:
6423  break;
6424 
6425  // threshold for sparse pricing
6427  break;
6428 
6429  // threshold on number of rows vs. number of columns for switching from column to row representations in auto mode
6431  break;
6432 
6433  // geometric frequency at which to apply rational reconstruction
6434  case SoPlex::RATREC_FREQ:
6435  break;
6436 
6437  // minimal reduction (sum of removed rows/cols) to continue simplification
6438  case SoPlex::MINRED:
6439  break;
6440 
6442  break;
6443 
6445  break;
6446 
6448  break;
6449 
6450  // accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations)
6451  case SoPlex::LEASTSQ_ACRCY:
6452  if(_scaler)
6453  _scaler->setRealParam(value);
6454 
6455  break;
6456 
6457  // objective offset
6458  case SoPlex::OBJ_OFFSET:
6459  if(_realLP)
6460  _realLP->changeObjOffset(value);
6461 
6462  if(_rationalLP)
6463  _rationalLP->changeObjOffset(value);
6464 
6465  break;
6466 
6467  default:
6468  return false;
6469  }
6470 
6471  _currentSettings->_realParamValues[param] = tmp_value;
6472  return true;
6473 }
6474 
6475 
6476 
6477 #ifdef SOPLEX_WITH_RATIONALPARAM
6478 /// sets rational parameter value; returns true on success
6479 bool SoPlex::setRationalParam(const RationalParam param, const Rational value, const bool init)
6480 {
6481  assert(param >= 0);
6482  assert(param < RATIONALPARAM_COUNT);
6483  assert(init || _isConsistent());
6484 
6485  if(!init && value == rationalParam(param))
6486  return true;
6487 
6488  if(value < _currentSettings->rationalParam.lower[param]
6489  || value > _currentSettings->rationalParam.upper[param])
6490  return false;
6491 
6492  switch(param)
6493  {
6494  default:
6495  // currently, there are no rational-valued parameters
6496  return false;
6497  }
6498 
6499  _currentSettings->_rationalParamValues[param] = value;
6500  return true;
6501 }
6502 #endif
6503 
6504 
6505 
6506 /// sets parameter settings; returns true on success
6507 bool SoPlex::setSettings(const Settings& newSettings, const bool init)
6508 {
6509  assert(init || _isConsistent());
6510 
6511  bool success = true;
6512 
6513  *_currentSettings = newSettings;
6514 
6515  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6516  success &= setBoolParam((BoolParam)i, _currentSettings->_boolParamValues[i], init);
6517 
6518  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6519  success &= setIntParam((IntParam)i, _currentSettings->_intParamValues[i], init);
6520 
6521  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6522  success &= setRealParam((RealParam)i, _currentSettings->_realParamValues[i], init);
6523 
6524 #ifdef SOPLEX_WITH_RATIONALPARAM
6525 
6526  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6527  success &= setRationalParam((RationalParam)i, _currentSettings->_rationalParamValues[i], init);
6528 
6529 #endif
6530 
6531  assert(_isConsistent());
6532 
6533  return success;
6534 }
6535 
6536 /// resets default parameter settings
6537 void SoPlex::resetSettings(const bool quiet, const bool init)
6538 {
6539  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6541 
6542  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6544 
6545  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6547 
6548 #ifdef SOPLEX_WITH_RATIONALPARAM
6549 
6550  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6551  success &= setRationalParam((RationalParam)i, _currentSettings->rationalParam.defaultValue[i],
6552  init);
6553 
6554 #endif
6555 }
6556 
6557 
6558 /// print non-default parameter values
6560 {
6561  bool printedValue = false;
6562 
6564 
6565  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6566  {
6568  continue;
6569 
6570  spxout << "bool:" << _currentSettings->boolParam.name[i] << " = " <<
6571  (_currentSettings->_boolParamValues[i] ? "true\n" : "false\n");
6572  printedValue = true;
6573  }
6574 
6575  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6576  {
6578  continue;
6579 
6580  spxout << "int:" << _currentSettings->intParam.name[i] << " = " <<
6581  _currentSettings->_intParamValues[i] << "\n";
6582  printedValue = true;
6583  }
6584 
6586 
6587  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6588  {
6590  continue;
6591 
6592  spxout << "real:" << _currentSettings->realParam.name[i] << " = " <<
6593  _currentSettings->_realParamValues[i] << "\n";
6594  printedValue = true;
6595  }
6596 
6597 #ifdef SOPLEX_WITH_RATIONALPARAM
6598 
6599  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6600  {
6601  if(_currentSettings->_rationalParamValues[i] == _currentSettings->rationalParam.defaultValue[i])
6602  continue;
6603 
6604  spxout << "rational:" << _currentSettings->rationalParam.name[i] << " = " <<
6605  _currentSettings->_rationalParamValues[i] << "\n";
6606  printedValue = true;
6607  }
6608 
6609 #endif
6610 
6612  {
6613  spxout << "uint:random_seed = " << _solver.random.getSeed() << "\n";
6614  printedValue = true;
6615  }
6616 
6617  if(printedValue)
6618  spxout << std::endl;
6619 }
6620 
6621 
6622 
6623 /// writes settings file; returns true on success
6624 bool SoPlex::saveSettingsFile(const char* filename, const bool onlyChanged) const
6625 {
6626  assert(filename != 0);
6627 
6628  std::ofstream file(filename);
6629  SPxOut::setScientific(file, 16);
6630 
6631  if(!file.good())
6632  return false;
6633 
6634  file.setf(std::ios::left);
6635 
6636  SPxOut::setFixed(file);
6637 
6638  file << "# SoPlex version " << SOPLEX_VERSION / 100 << "." << (SOPLEX_VERSION / 10) % 10 << "." <<
6639  SOPLEX_VERSION % 10;
6640 #if SOPLEX_SUBVERSION > 0
6641  file << "." << SOPLEX_SUBVERSION;
6642 #endif
6643  file << "\n";
6644 
6645  for(int i = 0; i < SoPlex::BOOLPARAM_COUNT; i++)
6646  {
6647  if(onlyChanged
6649  continue;
6650 
6651  file << "\n";
6652  file << "# " << _currentSettings->boolParam.description[i] << "\n";
6653  file << "# range {true, false}, default " << (_currentSettings->boolParam.defaultValue[i] ?
6654  "true\n" : "false\n");
6655  file << "bool:" << _currentSettings->boolParam.name[i] << " = " <<
6656  (_currentSettings->_boolParamValues[i] ? "true\n" : "false\n");
6657  }
6658 
6659  for(int i = 0; i < SoPlex::INTPARAM_COUNT; i++)
6660  {
6661  if(onlyChanged
6663  continue;
6664 
6665  file << "\n";
6666  file << "# " << _currentSettings->intParam.description[i] << "\n";
6667  file << "# range [" << _currentSettings->intParam.lower[i] << "," <<
6669  << "], default " << _currentSettings->intParam.defaultValue[i] << "\n";
6670  file << "int:" << _currentSettings->intParam.name[i] << " = " <<
6671  _currentSettings->_intParamValues[i] << "\n";
6672  }
6673 
6674  SPxOut::setScientific(file);
6675 
6676  for(int i = 0; i < SoPlex::REALPARAM_COUNT; i++)
6677  {
6678  if(onlyChanged
6680  continue;
6681 
6682  file << "\n";
6683  file << "# " << _currentSettings->realParam.description[i] << "\n";
6684  file << "# range [" << _currentSettings->realParam.lower[i] << "," <<
6686  << "], default " << _currentSettings->realParam.defaultValue[i] << "\n";
6687  file << "real:" << _currentSettings->realParam.name[i] << " = " <<
6688  _currentSettings->_realParamValues[i] << "\n";
6689  }
6690 
6691 #ifdef SOPLEX_WITH_RATIONALPARAM
6692 
6693  for(int i = 0; i < SoPlex::RATIONALPARAM_COUNT; i++)
6694  {
6695  if(onlyChanged
6696  && _currentSettings->_rationalParamValues[i] == _currentSettings->rationalParam.defaultValue[i])
6697  continue;
6698 
6699  file << "\n";
6700  file << "# " << _currentSettings->rationalParam.description[i] << "\n";
6701  file << "# range [" << _currentSettings->rationalParam.lower[i] << "," <<
6702  _currentSettings->rationalParam.upper[i]
6703  << "], default " << _currentSettings->rationalParam.defaultValue[i] << "\n";
6704  file << "rational:" << _currentSettings->rationalParam.name[i] << " = " <<
6705  _currentSettings->_rationalParamValues[i] << "\n";
6706  }
6707 
6708 #endif
6709 
6710  if(!onlyChanged || _solver.random.getSeed() != DEFAULT_RANDOM_SEED)
6711  {
6712  file << "\n";
6713  file << "# initial random seed used for perturbation\n";
6714  file << "# range [0, " << UINT_MAX << "], default " << DEFAULT_RANDOM_SEED << "\n";
6715  file << "uint:random_seed = " << _solver.random.getSeed() << "\n";
6716  }
6717 
6718  return true;
6719 }
6720 
6721 
6722 
6723 /// reads settings file; returns true on success
6724 bool SoPlex::loadSettingsFile(const char* filename)
6725 {
6726  assert(filename != 0);
6727 
6728  // start timing
6730 
6731  MSG_INFO1(spxout, spxout << "Loading settings file <" << filename << "> . . .\n");
6732 
6733  // open file
6734  spxifstream file(filename);
6735 
6736  if(!file)
6737  {
6738  MSG_INFO1(spxout, spxout << "Error opening settings file.\n");
6739  return false;
6740  }
6741 
6742  // read file
6743  char line[SET_MAX_LINE_LEN];
6744  int lineNumber = 0;
6745  bool readError = false;
6746  bool parseError = false;
6747 
6748  while(!readError && !parseError)
6749  {
6750  lineNumber++;
6751  readError = !file.getline(line, sizeof(line));
6752 
6753  if(!readError)
6754  parseError = !_parseSettingsLine(line, lineNumber);
6755  }
6756 
6757  readError = readError && !file.eof();
6758 
6759  if(readError && strlen(line) == SET_MAX_LINE_LEN - 1)
6760  {
6761  MSG_INFO1(spxout, spxout << "Error reading settings file: line " << lineNumber <<
6762  " in settings file exceeds " << SET_MAX_LINE_LEN - 2 << " characters.\n");
6763  }
6764  else if(readError)
6765  {
6766  MSG_INFO1(spxout, spxout << "Error reading settings file: line " << lineNumber << ".\n");
6767  }
6768 
6769  // stop timing
6771 
6772  return !readError;
6773 }
6774 
6775 /// parses one setting string and returns true on success
6777 {
6778  assert(string != 0);
6779 
6780  if(string == 0)
6781  return false;
6782 
6783  char parseString[SET_MAX_LINE_LEN];
6784  spxSnprintf(parseString, SET_MAX_LINE_LEN - 1, "%s", string);
6785 
6786  char* line = parseString;
6787 
6788  // find the start of the parameter type
6789  while(*line == ' ' || *line == '\t' || *line == '\r')
6790  line++;
6791 
6792  if(*line == '\0' || *line == '\n' || *line == '#')
6793  return true;
6794 
6795  char* paramTypeString = line;
6796 
6797  // find the end of the parameter type
6798  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6799  && *line != '\0' && *line != ':')
6800  line++;
6801 
6802  if(*line == ':')
6803  {
6804  *line = '\0';
6805  line++;
6806  }
6807  else
6808  {
6809  *line = '\0';
6810  line++;
6811 
6812  // search for the ':' char in the line
6813  while(*line == ' ' || *line == '\t' || *line == '\r')
6814  line++;
6815 
6816  if(*line != ':')
6817  {
6818  MSG_INFO1(spxout, spxout <<
6819  "Error parsing setting string: no ':' separating parameter type and name.\n");
6820  return false;
6821  }
6822 
6823  line++;
6824  }
6825 
6826  // find the start of the parameter name
6827  while(*line == ' ' || *line == '\t' || *line == '\r')
6828  line++;
6829 
6830  if(*line == '\0' || *line == '\n' || *line == '#')
6831  {
6832  MSG_INFO1(spxout, spxout << "Error parsing setting string: no parameter name.\n");
6833  return false;
6834  }
6835 
6836  char* paramName = line;
6837 
6838  // find the end of the parameter name
6839  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6840  && *line != '\0' && *line != '=')
6841  line++;
6842 
6843  if(*line == '=')
6844  {
6845  *line = '\0';
6846  line++;
6847  }
6848  else
6849  {
6850  *line = '\0';
6851  line++;
6852 
6853  // search for the '=' char in the line
6854  while(*line == ' ' || *line == '\t' || *line == '\r')
6855  line++;
6856 
6857  if(*line != '=')
6858  {
6859  MSG_INFO1(spxout, spxout << "Error parsing setting string: no '=' after parameter name.\n");
6860  return false;
6861  }
6862 
6863  line++;
6864  }
6865 
6866  // find the start of the parameter value string
6867  while(*line == ' ' || *line == '\t' || *line == '\r')
6868  line++;
6869 
6870  if(*line == '\0' || *line == '\n' || *line == '#')
6871  {
6872  MSG_INFO1(spxout, spxout << "Error parsing setting string: no parameter value.\n");
6873  return false;
6874  }
6875 
6876  char* paramValueString = line;
6877 
6878  // find the end of the parameter value string
6879  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
6880  && *line != '\0')
6881  line++;
6882 
6883  if(*line != '\0')
6884  {
6885  // check, if the rest of the line is clean
6886  *line = '\0';
6887  line++;
6888 
6889  while(*line == ' ' || *line == '\t' || *line == '\r')
6890  line++;
6891 
6892  if(*line != '\0' && *line != '\n' && *line != '#')
6893  {
6894  MSG_INFO1(spxout, spxout << "Error parsing setting string: additional character '" << *line <<
6895  "' after parameter value.\n");
6896  return false;
6897  }
6898  }
6899 
6900  // check whether we have a bool parameter
6901  if(strncmp(paramTypeString, "bool", 4) == 0)
6902  {
6903  for(int param = 0; ; param++)
6904  {
6905  if(param >= SoPlex::BOOLPARAM_COUNT)
6906  {
6907  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6908  ">.\n");
6909  return false;
6910  }
6911  else if(strncmp(paramName, _currentSettings->boolParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6912  {
6913  if(strncasecmp(paramValueString, "true", 4) == 0
6914  || strncasecmp(paramValueString, "TRUE", 4) == 0
6915  || strncasecmp(paramValueString, "t", 4) == 0
6916  || strncasecmp(paramValueString, "T", 4) == 0
6917  || strtol(paramValueString, NULL, 4) == 1)
6918  {
6919  setBoolParam((SoPlex::BoolParam)param, true);
6920  break;
6921  }
6922  else if(strncasecmp(paramValueString, "false", 5) == 0
6923  || strncasecmp(paramValueString, "FALSE", 5) == 0
6924  || strncasecmp(paramValueString, "f", 5) == 0
6925  || strncasecmp(paramValueString, "F", 5) == 0
6926  || strtol(paramValueString, NULL, 5) == 0)
6927  {
6928  setBoolParam((SoPlex::BoolParam)param, false);
6929  break;
6930  }
6931  else
6932  {
6933  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
6934  "> for bool parameter <" << paramName << ">.\n");
6935  return false;
6936  }
6937  }
6938  }
6939 
6940  return true;
6941  }
6942 
6943  // check whether we have an integer parameter
6944  if(strncmp(paramTypeString, "int", 3) == 0)
6945  {
6946  for(int param = 0; ; param++)
6947  {
6948  if(param >= SoPlex::INTPARAM_COUNT)
6949  {
6950  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6951  ">.\n");
6952  return false;
6953  }
6954  else if(strncmp(paramName, _currentSettings->intParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6955  {
6956  int value;
6957  value = std::stoi(paramValueString);
6958 
6959  if(setIntParam((SoPlex::IntParam)param, value, false))
6960  break;
6961  else
6962  {
6963  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
6964  "> for int parameter <" << paramName << ">.\n");
6965  return false;
6966  }
6967  }
6968  }
6969 
6970  return true;
6971  }
6972 
6973  // check whether we have a real parameter
6974  if(strncmp(paramTypeString, "real", 4) == 0)
6975  {
6976  for(int param = 0; ; param++)
6977  {
6978  if(param >= SoPlex::REALPARAM_COUNT)
6979  {
6980  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
6981  ">.\n");
6982  return false;
6983  }
6984  else if(strncmp(paramName, _currentSettings->realParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
6985  {
6986  Real value;
6987 #ifdef WITH_LONG_DOUBLE
6988  value = std::stold(paramValueString);
6989 #else
6990 #ifdef WITH_FLOAT
6991  value = std::stof(paramValueString);
6992 #else
6993  value = std::stod(paramValueString);
6994 #endif
6995 #endif
6996 
6997  if(setRealParam((SoPlex::RealParam)param, value))
6998  break;
6999  else
7000  {
7001  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
7002  "> for real parameter <" << paramName << ">.\n");
7003  return false;
7004  }
7005  }
7006  }
7007 
7008  return true;
7009  }
7010 
7011 #ifdef SOPLEX_WITH_RATIONALPARAM
7012 
7013  // check whether we have a rational parameter
7014  if(strncmp(paramTypeString, "rational", 8) == 0)
7015  {
7016  for(int param = 0; ; param++)
7017  {
7018  if(param >= SoPlex::RATIONALPARAM_COUNT)
7019  {
7020  MSG_INFO1(spxout, spxout << "Error parsing setting string: unknown parameter name <" << paramName <<
7021  ">.\n");
7022  return false;
7023  }
7024  else if(strncmp(paramName, _currentSettings->rationalParam.name[param].c_str(),
7025  SET_MAX_LINE_LEN) == 0)
7026  {
7027  Rational value;
7028 
7029  if(readStringRational(paramValueString, value)
7030  && setRationalParam((SoPlex::RationalParam)param, value))
7031  break;
7032  else
7033  {
7034  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid value <" << paramValueString <<
7035  "> for rational parameter <" << paramName << ">.\n");
7036  return false;
7037  }
7038  }
7039  }
7040 
7041  return true;
7042  }
7043 
7044 #endif
7045 
7046  // check whether we have the random seed
7047  if(strncmp(paramTypeString, "uint", 4) == 0)
7048  {
7049  if(strncmp(paramName, "random_seed", 11) == 0)
7050  {
7051  unsigned int value;
7052  unsigned long parseval;
7053 
7054  parseval = std::stoul(paramValueString);
7055 
7056  if(parseval > UINT_MAX)
7057  {
7058  value = UINT_MAX;
7059  MSG_WARNING(spxout, spxout << "Converting number greater than UINT_MAX to uint.\n");
7060  }
7061  else
7062  value = (unsigned int) parseval;
7063 
7064  setRandomSeed(value);
7065  return true;
7066  }
7067 
7068  MSG_INFO1(spxout, spxout << "Error parsing setting string for uint parameter <random_seed>.\n");
7069  return false;
7070  }
7071 
7072  MSG_INFO1(spxout, spxout << "Error parsing setting string: invalid parameter type <" <<
7073  paramTypeString << "> for parameter <" << paramName << ">.\n");
7074 
7075  return false;
7076 }
7077 
7078 
7079 
7080 
7081 /// prints solution statistics
7082 void SoPlex::printSolutionStatistics(std::ostream& os)
7083 {
7085 
7087  {
7088  os << "Solution (real) : \n"
7089  << " Objective value : " << objValueReal() << "\n";
7090  }
7092  {
7093  os << "Solution (rational) : \n"
7094  << " Objective value : " << rationalToString(objValueRational()) << "\n";
7095  os << "Size (base 2/10) : \n"
7096  << " Total primal : " << totalSizePrimalRational() << " / " << totalSizePrimalRational(
7097  10) << "\n"
7098  << " Total dual : " << totalSizeDualRational() << " / " << totalSizeDualRational(10) << "\n"
7099  << " DLCM primal : " << dlcmSizePrimalRational() << " / " << dlcmSizePrimalRational(
7100  10) << "\n"
7101  << " DLCM dual : " << dlcmSizeDualRational() << " / " << dlcmSizeDualRational(10) << "\n"
7102  << " DMAX primal : " << dmaxSizePrimalRational() << " / " << dmaxSizePrimalRational(
7103  10) << "\n"
7104  << " DMAX dual : " << dmaxSizeDualRational() << " / " << dmaxSizeDualRational(10) << "\n";
7105  }
7106  else
7107  {
7108  os << "Solution : \n"
7109  << " Objective value : -\n";
7110  }
7111 
7115  {
7116  Rational maxviol;
7117  Rational sumviol;
7118 
7119  os << "Violation (rational): \n";
7120 
7121  if(getBoundViolationRational(maxviol, sumviol))
7122  os << " Max/sum bound : " << rationalToString(maxviol) << " / " << rationalToString(
7123  sumviol) << "\n";
7124  else
7125  os << " Max/sum bound : - / -\n";
7126 
7127  if(getRowViolationRational(maxviol, sumviol))
7128  os << " Max/sum row : " << rationalToString(maxviol) << " / " << rationalToString(
7129  sumviol) << "\n";
7130  else
7131  os << " Max/sum row : - / -\n";
7132 
7133  if(getRedCostViolationRational(maxviol, sumviol))
7134  os << " Max/sum redcost : " << rationalToString(maxviol) << " / " << rationalToString(
7135  sumviol) << "\n";
7136  else
7137  os << " Max/sum redcost : - / -\n";
7138 
7139  if(getDualViolationRational(maxviol, sumviol))
7140  os << " Max/sum dual : " << rationalToString(maxviol) << " / " << rationalToString(
7141  sumviol) << "\n";
7142  else
7143  os << " Max/sum dual : - / -\n";
7144  }
7145  else
7146  {
7147  Real maxviol;
7148  Real sumviol;
7149 
7150  os << "Violations (real) : \n";
7151 
7152  if(getBoundViolationReal(maxviol, sumviol))
7153  os << " Max/sum bound : " << maxviol << " / " << sumviol << "\n";
7154  else
7155  os << " Max/sum bound : - / -\n";
7156 
7157  if(getRowViolationReal(maxviol, sumviol))
7158  os << " Max/sum row : " << maxviol << " / " << sumviol << "\n";
7159  else
7160  os << " Max/sum row : - / -\n";
7161 
7162  if(getRedCostViolationReal(maxviol, sumviol))
7163  os << " Max/sum redcost : " << maxviol << " / " << sumviol << "\n";
7164  else
7165  os << " Max/sum redcost : - / -\n";
7166 
7167  if(getDualViolationReal(maxviol, sumviol))
7168  os << " Max/sum dual : " << maxviol << " / " << sumviol << "\n";
7169  else
7170  os << " Max/sum dual : - / -\n";
7171  }
7172 }
7173 
7174 
7175 /// prints statistics on solving process
7176 void SoPlex::printSolvingStatistics(std::ostream& os)
7177 {
7178  assert(_statistics != 0);
7179  _statistics->print(os);
7180 }
7181 
7182 
7183 
7184 /// prints short statistics
7185 void SoPlex::printShortStatistics(std::ostream& os)
7186 {
7187  printStatus(os, _status);
7188  SPxOut::setFixed(os, 2);
7189  os << "Solving time (sec) : " << _statistics->solvingTime->time() << "\n"
7190  << "Iterations : " << _statistics->iterations << "\n";
7192  os << "Objective value : " << objValueReal() << "\n";
7193 }
7194 
7195 
7196 
7197 /// prints complete statistics
7198 void SoPlex::printStatistics(std::ostream& os)
7199 {
7200  SPxOut::setFixed(os, 2);
7201 
7202  printStatus(os, _status);
7203 
7204  os << "Original problem : \n";
7205 
7208  else
7209  {
7212  else
7214  }
7215 
7216  os << "Objective sense : " << (intParam(SoPlex::OBJSENSE) == SoPlex::OBJSENSE_MINIMIZE ?
7217  "minimize\n" : "maximize\n");
7220 }
7221 
7222 /// prints status
7223 void SoPlex::printStatus(std::ostream& os, SPxSolver::Status stat)
7224 {
7225  os << "SoPlex status : ";
7226 
7227  switch(stat)
7228  {
7229  case SPxSolver::ERROR:
7230  os << "error [unspecified]";
7231  break;
7232 
7234  os << "error [no ratiotester loaded]";
7235  break;
7236 
7237  case SPxSolver::NO_PRICER:
7238  os << "error [no pricer loaded]";
7239  break;
7240 
7241  case SPxSolver::NO_SOLVER:
7242  os << "error [no linear solver loaded]";
7243  break;
7244 
7245  case SPxSolver::NOT_INIT:
7246  os << "error [not initialized]";
7247  break;
7248 
7250  os << "solving aborted [cycling]";
7251  break;
7252 
7253  case SPxSolver::ABORT_TIME:
7254  os << "solving aborted [time limit reached]";
7255  break;
7256 
7257  case SPxSolver::ABORT_ITER:
7258  os << "solving aborted [iteration limit reached]";
7259  break;
7260 
7262  os << "solving aborted [objective limit reached]";
7263  break;
7264 
7265  case SPxSolver::NO_PROBLEM:
7266  os << "no problem loaded";
7267  break;
7268 
7269  case SPxSolver::REGULAR:
7270  os << "basis is regular";
7271  break;
7272 
7273  case SPxSolver::SINGULAR:
7274  os << "basis is singular";
7275  break;
7276 
7277  case SPxSolver::OPTIMAL:
7278  os << "problem is solved [optimal]";
7279  break;
7280 
7281  case SPxSolver::UNBOUNDED:
7282  os << "problem is solved [unbounded]";
7283  break;
7284 
7285  case SPxSolver::INFEASIBLE:
7286  os << "problem is solved [infeasible]";
7287  break;
7288 
7289  case SPxSolver::INForUNBD:
7290  os << "problem is solved [infeasible or unbounded]";
7291  break;
7292 
7294  os << "problem is solved [optimal with unscaled violations]";
7295  break;
7296 
7297  default:
7298  case SPxSolver::UNKNOWN:
7299  os << "unknown";
7300  break;
7301  }
7302 
7303  os << "\n";
7304 }
7305 
7306 
7307 
7308 /// prints version and compilation options
7310 {
7311  // do not use preprocessor directives within the MSG_INFO1 macro
7312 #if (SOPLEX_SUBVERSION > 0)
7313  MSG_INFO1(spxout, spxout << "SoPlex version " << SOPLEX_VERSION / 100
7314  << "." << (SOPLEX_VERSION % 100) / 10
7315  << "." << SOPLEX_VERSION % 10
7316  << "." << SOPLEX_SUBVERSION);
7317 #else
7318  MSG_INFO1(spxout, spxout << "SoPlex version " << SOPLEX_VERSION / 100
7319  << "." << (SOPLEX_VERSION % 100) / 10
7320  << "." << SOPLEX_VERSION % 10);
7321 #endif
7322 
7323 #ifndef NDEBUG
7324  MSG_INFO1(spxout, spxout << " [mode: debug]");
7325 #else
7326  MSG_INFO1(spxout, spxout << " [mode: optimized]");
7327 #endif
7328 
7329  MSG_INFO1(spxout, spxout << " [precision: " << (int)sizeof(Real) << " byte]");
7330 
7331 #ifdef SOPLEX_WITH_GMP
7332 #ifdef mpir_version
7333  MSG_INFO1(spxout, spxout << " [rational: MPIR " << mpir_version << "]");
7334 #else
7335  MSG_INFO1(spxout, spxout << " [rational: GMP " << gmp_version << "]");
7336 #endif
7337 #else
7338  MSG_INFO1(spxout, spxout << " [rational: long double]");
7339 #endif
7340 
7341  MSG_INFO1(spxout, spxout << " [githash: " << getGitHash() << "]\n");
7342 }
7343 
7344 
7345 
7346 /// checks if real LP and rational LP are in sync; dimensions will always be compared,
7347 /// vector and matrix values only if the respective parameter is set to true.
7348 /// If quiet is set to true the function will only display which vectors are different.
7349 bool SoPlex::areLPsInSync(const bool checkVecVals, const bool checkMatVals, const bool quiet) const
7350 {
7351  bool result = true;
7352  bool nRowsMatch = true;
7353  bool nColsMatch = true;
7354  bool rhsDimMatch = true;
7355  bool lhsDimMatch = true;
7356  bool maxObjDimMatch = true;
7357  bool upperDimMatch = true;
7358  bool lowerDimMatch = true;
7359 
7360  // compare number of Rows
7361  if(_realLP->nRows() != _rationalLP->nRows())
7362  {
7363  MSG_INFO1(spxout, spxout <<
7364  "The number of Rows in the Real LP does not match the one in the Rational LP."
7365  << " Real LP: " << _realLP->nRows() << " Rational LP: " << _rationalLP->nRows() << std::endl);
7366  result = false;
7367  nRowsMatch = false;
7368  }
7369 
7370  // compare number of Columns
7371  if(_realLP->nCols() != _rationalLP->nCols())
7372  {
7373  MSG_INFO1(spxout, spxout <<
7374  "The number of Columns in the Real LP does not match the one in the Rational LP."
7375  << " Real LP: " << _realLP->nCols() << " Rational LP: " << _rationalLP->nCols() << std::endl);
7376  result = false;
7377  nColsMatch = false;
7378  }
7379 
7380  // compare number of nonZeros
7381  if(_realLP->nNzos() != _rationalLP->nNzos())
7382  {
7383  MSG_INFO1(spxout, spxout <<
7384  "The number of nonZeros in the Real LP does not match the one in the Rational LP."
7385  << " Real LP: " << _realLP->nNzos() << " Rational LP: " << _rationalLP->nNzos() << std::endl);
7386  result = false;
7387  }
7388 
7389  // compare the dimensions of the right hand side vectors
7390  if(_realLP->rhs().dim() != _rationalLP->rhs().dim())
7391  {
7392  MSG_INFO1(spxout, spxout <<
7393  "The dimension of the right hand side vector of the Real LP does not match the one of the Rational LP."
7394  << " Real LP: " << _realLP->rhs().dim() << " Rational LP: " << _rationalLP->rhs().dim() <<
7395  std::endl);
7396  result = false;
7397  rhsDimMatch = false;
7398 
7399  }
7400 
7401  // compare the dimensions of the left hand side vectors
7402  if(_realLP->lhs().dim() != _rationalLP->lhs().dim())
7403  {
7404  MSG_INFO1(spxout, spxout <<
7405  "The dimension of the left hand side vector of the Real LP does not match the one of the Rational LP."
7406  << " Real LP: " << _realLP->lhs().dim() << " Rational LP: " << _rationalLP->lhs().dim() <<
7407  std::endl);
7408  result = false;
7409  lhsDimMatch = false;
7410  }
7411 
7412  // compare the dimensions of the objective function vectors
7413  if(_realLP->maxObj().dim() != _rationalLP->maxObj().dim())
7414  {
7415  MSG_INFO1(spxout, spxout <<
7416  "The dimension of the objective function vector of the Real LP does not match the one of the Rational LP."
7417  << " Real LP: " << _realLP->maxObj().dim() << " Rational LP: " << _rationalLP->maxObj().dim() <<
7418  std::endl);
7419  result = false;
7420  maxObjDimMatch = false;
7421  }
7422 
7423  // compare the sense
7424  if((int)_realLP->spxSense() != (int)_rationalLP->spxSense())
7425  {
7426  MSG_INFO1(spxout, spxout <<
7427  "The objective function sense of the Real LP does not match the one of the Rational LP."
7428  << " Real LP: " << (_realLP->spxSense() == SPxLPReal::MINIMIZE ? "MIN" : "MAX")
7429  << " Rational LP: " << (_rationalLP->spxSense() == SPxLPRational::MINIMIZE ? "MIN" : "MAX") <<
7430  std::endl);
7431  result = false;
7432  }
7433 
7434  // compare the dimensions of upper bound vectors
7435  if(_realLP->upper().dim() != _rationalLP->upper().dim())
7436  {
7437  MSG_INFO1(spxout, spxout <<
7438  "The dimension of the upper bound vector of the Real LP does not match the one of the Rational LP."
7439  << " Real LP: " << _realLP->upper().dim() << " Rational LP: " << _rationalLP->upper().dim() <<
7440  std::endl);
7441  result = false;
7442  upperDimMatch = false;
7443  }
7444 
7445  // compare the dimensions of the objective function vectors
7446  if(_realLP->lower().dim() != _rationalLP->lower().dim())
7447  {
7448  MSG_INFO1(spxout, spxout <<
7449  "The dimension of the lower bound vector of the Real LP does not match the one of the Rational LP."
7450  << " Real LP: " << _realLP->lower().dim() << " Rational LP: " << _rationalLP->lower().dim() <<
7451  std::endl);
7452  result = false;
7453  lowerDimMatch = false;
7454  }
7455 
7456  // compares the values of the rhs, lhs, maxObj, upper, lower vectors
7457  if(checkVecVals)
7458  {
7459  bool rhsValMatch = true;
7460  bool lhsValMatch = true;
7461  bool maxObjValMatch = true;
7462  bool upperValMatch = true;
7463  bool lowerValMatch = true;
7464 
7465  // compares the values of the right hand side vectors
7466  if(rhsDimMatch)
7467  {
7468  for(int i = 0; i < _realLP->rhs().dim(); i++)
7469  {
7472  && !_rationalLP->rhs()[i].isAdjacentTo((double)_realLP->rhs()[i])))
7473  {
7474  if(!quiet)
7475  {
7476  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the right hand side vectors don't match."
7477  << " Real LP: " << _realLP->rhs()[i] << " Rational LP: " << _rationalLP->rhs()[i] << std::endl);
7478  }
7479 
7480  rhsValMatch = false;
7481  result = false;
7482  }
7483  }
7484 
7485  if(!rhsValMatch && quiet)
7486  {
7487  MSG_INFO1(spxout, spxout << "The values of the right hand side vectors don't match." << std::endl);
7488  }
7489  }
7490 
7491  // compares the values of the left hand side vectors
7492  if(lhsDimMatch)
7493  {
7494  for(int i = 0; i < _realLP->lhs().dim(); i++)
7495  {
7496  if((LE(_realLP->lhs()[i], -realParam(SoPlex::INFTY)) != (_rationalLP->lhs()[i] <=
7499  && !_rationalLP->lhs()[i].isAdjacentTo((double)_realLP->lhs()[i])))
7500  {
7501  if(!quiet)
7502  {
7503  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the left hand side vectors don't match."
7504  << " Real LP: " << _realLP->lhs()[i] << " Rational LP: " << _rationalLP->lhs()[i] << std::endl);
7505  }
7506 
7507  lhsValMatch = false;
7508  result = false;
7509  }
7510  }
7511 
7512  if(!lhsValMatch && quiet)
7513  {
7514  MSG_INFO1(spxout, spxout << "The values of the left hand side vectors don't match." << std::endl);
7515  }
7516  }
7517 
7518  // compares the values of the objective function vectors
7519  if(maxObjDimMatch)
7520  {
7521  for(int i = 0; i < _realLP->maxObj().dim(); i++)
7522  {
7523  if(!_rationalLP->maxObj()[i].isAdjacentTo((double)_realLP->maxObj()[i]))
7524  {
7525  if(!quiet)
7526  {
7527  MSG_INFO1(spxout, spxout << "Entries number " << i <<
7528  " of the objective function vectors don't match."
7529  << " Real LP: " << _realLP->maxObj()[i] << " Rational LP: " << _rationalLP->maxObj()[i] <<
7530  std::endl);
7531  }
7532 
7533  maxObjValMatch = false;
7534  result = false;
7535  }
7536  }
7537 
7538  if(!maxObjValMatch && quiet)
7539  {
7540  MSG_INFO1(spxout, spxout << "The values of the objective function vectors don't match." <<
7541  std::endl);
7542  }
7543  }
7544 
7545  // compares the values of the upper bound vectors
7546  if(upperDimMatch)
7547  {
7548  for(int i = 0; i < _realLP->upper().dim(); i++)
7549  {
7550  if((GE(_realLP->upper()[i], realParam(SoPlex::INFTY)) != (_rationalLP->upper()[i] >=
7553  && !_rationalLP->upper()[i].isAdjacentTo((double)_realLP->upper()[i])))
7554  {
7555  if(!quiet)
7556  {
7557  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the upper bound vectors don't match."
7558  << " Real LP: " << _realLP->upper()[i] << " Rational LP: " << _rationalLP->upper()[i] <<
7559  std::endl);
7560  }
7561 
7562  upperValMatch = false;
7563  result = false;
7564  }
7565  }
7566 
7567  if(!upperValMatch && quiet)
7568  {
7569  MSG_INFO1(spxout, spxout << "The values of the upper bound vectors don't match." << std::endl);
7570  }
7571  }
7572 
7573  // compares the values of the lower bound vectors
7574  if(lowerDimMatch)
7575  {
7576  for(int i = 0; i < _realLP->lower().dim(); i++)
7577  {
7578  if((LE(_realLP->lower()[i], -realParam(SoPlex::INFTY)) != (_rationalLP->lower()[i] <=
7580  || (GT(_realLP->lower()[i], -realParam(SoPlex::INFTY))
7582  && !_rationalLP->lower()[i].isAdjacentTo((double)_realLP->lower()[i])))
7583  {
7584  if(!quiet)
7585  {
7586  MSG_INFO1(spxout, spxout << "Entries number " << i << " of the lower bound vectors don't match."
7587  << " Real LP: " << _realLP->lower()[i] << " Rational LP: " << _rationalLP->lower()[i] <<
7588  std::endl);
7589  }
7590 
7591  lowerValMatch = false;
7592  result = false;
7593  }
7594  }
7595 
7596  if(!lowerValMatch && quiet)
7597  {
7598  MSG_INFO1(spxout, spxout << "The values of the lower bound vectors don't match." << std::endl);
7599  }
7600  }
7601  }
7602 
7603  // compare the values of the matrix
7604  if(checkMatVals && nRowsMatch && nColsMatch)
7605  {
7606  bool matrixValMatch = true;
7607 
7608  for(int i = 0; i < _realLP->nCols() ; i++)
7609  {
7610  for(int j = 0; j < _realLP->nRows() ; j++)
7611  {
7612  if(!_rationalLP->colVector(i)[j].isAdjacentTo((double)_realLP->colVector(i)[j]))
7613  {
7614  if(!quiet)
7615  {
7616  MSG_INFO1(spxout, spxout << "Entries number " << j << " of column number " << i << " don't match."
7617  << " Real LP: " << _realLP->colVector(i)[j] << " Rational LP: " << _rationalLP->colVector(
7618  i)[j] << std::endl);
7619  }
7620 
7621  matrixValMatch = false;
7622  result = false;
7623  }
7624  }
7625  }
7626 
7627  if(!matrixValMatch && quiet)
7628  {
7629  MSG_INFO1(spxout, spxout << "The values of the matrices don't match." << std::endl);
7630  }
7631  }
7632 
7633  return result;
7634 }
7635 
7636 
7637 
7638 /// set the random seed of the solver instance
7639 void SoPlex::setRandomSeed(unsigned int seed)
7640 {
7641  _solver.random.setSeed(seed);
7642 }
7643 
7644 
7645 
7646 /// returns the current random seed of the solver instance or the one stored in the settings
7647 unsigned int SoPlex::randomSeed() const
7648 {
7649  return _solver.random.getSeed();
7650 }
7651 
7652 
7653 
7654 /// extends sparse vector to hold newmax entries if and only if it holds no more free entries
7656 {
7657  assert(newmax > vec.size());
7658 
7659  if(vec.size() >= vec.max())
7660  vec.setMax(newmax);
7661 }
7662 
7663 
7664 
7665 /// creates a permutation for removing rows/columns from an array of indices
7666 void SoPlex::_idxToPerm(int* idx, int idxSize, int* perm, int permSize) const
7667 {
7668  assert(idx != 0);
7669  assert(idxSize >= 0);
7670  assert(perm != 0);
7671  assert(permSize >= 0);
7672 
7673  for(int i = 0; i < permSize; i++)
7674  perm[i] = i;
7675 
7676  for(int i = 0; i < idxSize; i++)
7677  {
7678  assert(idx[i] >= 0);
7679  assert(idx[i] < permSize);
7680  perm[idx[i]] = -1;
7681  }
7682 }
7683 
7684 
7685 
7686 /// creates a permutation for removing rows/columns from a range of indices
7687 void SoPlex::_rangeToPerm(int start, int end, int* perm, int permSize) const
7688 {
7689  assert(perm != 0);
7690  assert(permSize >= 0);
7691 
7692  for(int i = 0; i < permSize; i++)
7693  perm[i] = (i < start || i > end) ? i : -1;
7694 }
7695 
7696 
7697 
7698 /// checks consistency
7700 {
7701  assert(_statistics != 0);
7702  assert(_currentSettings != 0);
7703 
7704  assert(_realLP != 0);
7706 
7707  assert(_realLP != &_solver || _isRealLPLoaded);
7708  assert(_realLP == &_solver || !_isRealLPLoaded);
7709 
7717 
7718  assert(_rationalLP == 0 || _colTypes.size() == numColsRational());
7719  assert(_rationalLP == 0 || _rowTypes.size() == numRowsRational());
7720 
7721  return true;
7722 }
7723 
7724 
7725 
7726 /// should solving process be stopped?
7727 bool SoPlex::_isSolveStopped(bool& stoppedTime, bool& stoppedIter) const
7728 {
7729  assert(_statistics != 0);
7730 
7731  stoppedTime = (realParam(TIMELIMIT) < realParam(INFTY)
7733  stoppedIter = (intParam(ITERLIMIT) >= 0 && _statistics->iterations >= intParam(ITERLIMIT))
7736 
7737  return stoppedTime || stoppedIter;
7738 }
7739 
7740 
7741 
7742 /// determines RangeType from real bounds
7743 SoPlex::RangeType SoPlex::_rangeTypeReal(const Real& lower, const Real& upper) const
7744 {
7745  assert(lower <= upper);
7746 
7747  if(lower <= -infinity)
7748  {
7749  if(upper >= infinity)
7750  return RANGETYPE_FREE;
7751  else
7752  return RANGETYPE_UPPER;
7753  }
7754  else
7755  {
7756  if(upper >= infinity)
7757  return RANGETYPE_LOWER;
7758  else if(lower == upper)
7759  return RANGETYPE_FIXED;
7760  else
7761  return RANGETYPE_BOXED;
7762  }
7763 }
7764 
7765 
7766 
7767 /// determines RangeType from rational bounds
7769 {
7770  assert(lower <= upper);
7771 
7772  if(lower <= _rationalNegInfty)
7773  {
7774  if(upper >= _rationalPosInfty)
7775  return RANGETYPE_FREE;
7776  else
7777  return RANGETYPE_UPPER;
7778  }
7779  else
7780  {
7781  if(upper >= _rationalPosInfty)
7782  return RANGETYPE_LOWER;
7783  else if(lower == upper)
7784  return RANGETYPE_FIXED;
7785  else
7786  return RANGETYPE_BOXED;
7787  }
7788 }
7789 
7790 
7791 
7792 /// switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
7794 {
7795  if(rangeType == RANGETYPE_LOWER)
7796  return RANGETYPE_UPPER;
7797  else if(rangeType == RANGETYPE_UPPER)
7798  return RANGETYPE_LOWER;
7799  else
7800  return rangeType;
7801 }
7802 
7803 
7804 
7805 /// checks whether RangeType corresponds to finite lower bound
7806 bool SoPlex::_lowerFinite(const RangeType& rangeType) const
7807 {
7808  return (rangeType == RANGETYPE_LOWER || rangeType == RANGETYPE_BOXED
7809  || rangeType == RANGETYPE_FIXED);
7810 }
7811 
7812 
7813 
7814 /// checks whether RangeType corresponds to finite upper bound
7815 bool SoPlex::_upperFinite(const RangeType& rangeType) const
7816 {
7817  return (rangeType == RANGETYPE_UPPER || rangeType == RANGETYPE_BOXED
7818  || rangeType == RANGETYPE_FIXED);
7819 }
7820 
7821 
7822 
7823 /// adds a single row to the real LP and adjusts basis
7824 void SoPlex::_addRowReal(const LPRowReal& lprow)
7825 {
7826  assert(_realLP != 0);
7827 
7828  bool scale = _realLP->isScaled();
7829  _realLP->addRow(lprow, scale);
7830 
7831  if(_isRealLPLoaded)
7833  else if(_hasBasis)
7835 
7837 }
7838 
7839 
7840 
7841 /// adds a single row to the real LP and adjusts basis
7842 void SoPlex::_addRowReal(Real lhs, const SVectorReal& lprow, Real rhs)
7843 {
7844  assert(_realLP != 0);
7845 
7846  bool scale = _realLP->isScaled();
7847  _realLP->addRow(lhs, lprow, rhs, scale);
7848 
7849  if(_isRealLPLoaded)
7851  else if(_hasBasis)
7853 
7855 }
7856 
7857 
7858 
7859 /// adds multiple rows to the real LP and adjusts basis
7860 void SoPlex::_addRowsReal(const LPRowSetReal& lprowset)
7861 {
7862  assert(_realLP != 0);
7863 
7864  bool scale = _realLP->isScaled();
7865  _realLP->addRows(lprowset, scale);
7866 
7867  if(_isRealLPLoaded)
7869  else if(_hasBasis)
7871 
7873 }
7874 
7875 
7876 /// adds a single column to the real LP and adjusts basis
7877 void SoPlex::_addColReal(const LPColReal& lpcol)
7878 {
7879  assert(_realLP != 0);
7880 
7881  bool scale = _realLP->isScaled();
7882  _realLP->addCol(lpcol, scale);
7883 
7884  if(_isRealLPLoaded)
7886  else if(_hasBasis)
7887  {
7888  if(lpcol.lower() > -realParam(SoPlex::INFTY))
7890  else if(lpcol.upper() < realParam(SoPlex::INFTY))
7892  else
7894  }
7895 
7897 }
7898 
7899 
7900 
7901 /// adds a single column to the real LP and adjusts basis
7902 void SoPlex::_addColReal(Real obj, Real lower, const SVectorReal& lpcol, Real upper)
7903 {
7904  assert(_realLP != 0);
7905 
7906  bool scale = _realLP->isScaled();
7907  _realLP->addCol(obj, lower, lpcol, upper, scale);
7908 
7909  if(_isRealLPLoaded)
7911  else if(_hasBasis)
7913 
7915 }
7916 
7917 
7918 
7919 /// adds multiple columns to the real LP and adjusts basis
7920 void SoPlex::_addColsReal(const LPColSetReal& lpcolset)
7921 {
7922  assert(_realLP != 0);
7923 
7924  bool scale = _realLP->isScaled();
7925  _realLP->addCols(lpcolset, scale);
7926 
7927  if(_isRealLPLoaded)
7929  else if(_hasBasis)
7930  {
7931  for(int i = 0; i < lpcolset.num(); i++)
7932  {
7933  if(lpcolset.lower(i) > -realParam(SoPlex::INFTY))
7935  else if(lpcolset.upper(i) < realParam(SoPlex::INFTY))
7937  else
7939  }
7940  }
7941 
7943 }
7944 
7945 
7946 /// replaces row \p i with \p lprow and adjusts basis
7947 void SoPlex::_changeRowReal(int i, const LPRowReal& lprow)
7948 {
7949  assert(_realLP != 0);
7950 
7951  bool scale = _realLP->isScaled();
7952  _realLP->changeRow(i, lprow, scale);
7953 
7954  if(_isRealLPLoaded)
7956  else if(_hasBasis)
7957  {
7959  _hasBasis = false;
7960  else if(_basisStatusRows[i] == SPxSolver::ON_LOWER && lprow.lhs() <= -realParam(SoPlex::INFTY))
7963  else if(_basisStatusRows[i] == SPxSolver::ON_UPPER && lprow.rhs() >= realParam(SoPlex::INFTY))
7966  }
7967 
7969 }
7970 
7971 
7972 
7973 /// changes left-hand side vector for constraints to \p lhs and adjusts basis
7975 {
7976  assert(_realLP != 0);
7977 
7978  bool scale = _realLP->isScaled();
7979  _realLP->changeLhs(lhs, scale);
7980 
7981  if(_isRealLPLoaded)
7983  else if(_hasBasis)
7984  {
7985  for(int i = numRowsReal() - 1; i >= 0; i--)
7986  {
7990  }
7991  }
7992 }
7993 
7994 
7995 
7996 /// changes left-hand side of row \p i to \p lhs and adjusts basis
7997 void SoPlex::_changeLhsReal(int i, const Real& lhs)
7998 {
7999  assert(_realLP != 0);
8000 
8001  bool scale = _realLP->isScaled();
8002  _realLP->changeLhs(i, lhs, scale);
8003 
8004  if(_isRealLPLoaded)
8005  {
8007  }
8011 
8012 }
8013 
8014 
8015 
8016 /// changes right-hand side vector to \p rhs and adjusts basis
8018 {
8019  assert(_realLP != 0);
8020 
8021  bool scale = _realLP->isScaled();
8022  _realLP->changeRhs(rhs, scale);
8023 
8024  if(_isRealLPLoaded)
8025  {
8027  }
8028  else if(_hasBasis)
8029  {
8030  for(int i = numRowsReal() - 1; i >= 0; i--)
8031  {
8035  }
8036  }
8037 }
8038 
8039 
8040 
8041 /// changes right-hand side of row \p i to \p rhs and adjusts basis
8042 void SoPlex::_changeRhsReal(int i, const Real& rhs)
8043 {
8044  assert(_realLP != 0);
8045 
8046  bool scale = _realLP->isScaled();
8047  _realLP->changeRhs(i, rhs, scale);
8048 
8049  if(_isRealLPLoaded)
8050  {
8052  }
8056 }
8057 
8058 
8059 
8060 /// changes left- and right-hand side vectors and adjusts basis
8061 void SoPlex::_changeRangeReal(const VectorReal& lhs, const VectorReal& rhs)
8062 {
8063  assert(_realLP != 0);
8064 
8065  bool scale = _realLP->isScaled();
8066  _realLP->changeRange(lhs, rhs, scale);
8067 
8068  if(_isRealLPLoaded)
8069  {
8071  }
8072  else if(_hasBasis)
8073  {
8074  for(int i = numRowsReal() - 1; i >= 0; i--)
8075  {
8078  else if(_basisStatusRows[i] == SPxSolver::ON_UPPER && rhs[i] >= realParam(SoPlex::INFTY))
8080  }
8081  }
8082 }
8083 
8084 
8085 
8086 /// changes left- and right-hand side of row \p i and adjusts basis
8087 void SoPlex::_changeRangeReal(int i, const Real& lhs, const Real& rhs)
8088 {
8089  assert(_realLP != 0);
8090 
8091  bool scale = _realLP->isScaled();
8092  _realLP->changeRange(i, lhs, rhs, scale);
8093 
8094  if(_isRealLPLoaded)
8095  {
8097  }
8098  else if(_hasBasis)
8099  {
8104  }
8105 }
8106 
8107 
8108 
8109 /// replaces column \p i with \p lpcol and adjusts basis
8110 void SoPlex::_changeColReal(int i, const LPColReal& lpcol)
8111 {
8112  assert(_realLP != 0);
8113 
8114  bool scale = _realLP->isScaled();
8115  _realLP->changeCol(i, lpcol, scale);
8116 
8117  if(_isRealLPLoaded)
8118  {
8120  }
8121  else if(_hasBasis)
8122  {
8124  _hasBasis = false;
8125  else if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lpcol.lower() <= -realParam(SoPlex::INFTY))
8128  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && lpcol.upper() >= realParam(SoPlex::INFTY))
8131  }
8132 
8134 }
8135 
8136 
8137 
8138 /// changes vector of lower bounds to \p lower and adjusts basis
8140 {
8141  assert(_realLP != 0);
8142 
8143  bool scale = _realLP->isScaled();
8144  _realLP->changeLower(lower, scale);
8145 
8146  if(_isRealLPLoaded)
8147  {
8149  }
8150  else if(_hasBasis)
8151  {
8152  for(int i = numColsReal() - 1; i >= 0; i--)
8153  {
8154  if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lower[i] <= -realParam(SoPlex::INFTY))
8157  }
8158  }
8159 }
8160 
8161 
8162 
8163 /// changes lower bound of column i to \p lower and adjusts basis
8164 void SoPlex::_changeLowerReal(int i, const Real& lower)
8165 {
8166  assert(_realLP != 0);
8167 
8168  bool scale = _realLP->isScaled();
8169  _realLP->changeLower(i, lower, scale);
8170 
8171  if(_isRealLPLoaded)
8172  {
8174  }
8176  && lower <= -realParam(SoPlex::INFTY))
8179 }
8180 
8181 
8182 
8183 /// changes vector of upper bounds to \p upper and adjusts basis
8185 {
8186  assert(_realLP != 0);
8187 
8188  bool scale = _realLP->isScaled();
8189  _realLP->changeUpper(upper, scale);
8190 
8191  if(_isRealLPLoaded)
8192  {
8194  }
8195  else if(_hasBasis)
8196  {
8197  for(int i = numColsReal() - 1; i >= 0; i--)
8198  {
8202  }
8203  }
8204 }
8205 
8206 
8207 
8208 /// changes \p i 'th upper bound to \p upper and adjusts basis
8209 void SoPlex::_changeUpperReal(int i, const Real& upper)
8210 {
8211  assert(_realLP != 0);
8212 
8213  bool scale = _realLP->isScaled();
8214  _realLP->changeUpper(i, upper, scale);
8215 
8216  if(_isRealLPLoaded)
8217  {
8219  }
8221  && upper >= realParam(SoPlex::INFTY))
8224 }
8225 
8226 
8227 
8228 /// changes vectors of column bounds to \p lower and \p upper and adjusts basis
8229 void SoPlex::_changeBoundsReal(const VectorReal& lower, const VectorReal& upper)
8230 {
8231  assert(_realLP != 0);
8232 
8233  bool scale = _realLP->isScaled();
8234  _realLP->changeBounds(lower, upper, scale);
8235 
8236  if(_isRealLPLoaded)
8237  {
8239  }
8240  else if(_hasBasis)
8241  {
8242  for(int i = numColsReal() - 1; i >= 0; i--)
8243  {
8244  if(_basisStatusCols[i] == SPxSolver::ON_LOWER && lower[i] <= -realParam(SoPlex::INFTY))
8246  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && upper[i] >= realParam(SoPlex::INFTY))
8249  }
8250  }
8251 }
8252 
8253 
8254 
8255 /// changes bounds of column \p i to \p lower and \p upper and adjusts basis
8256 void SoPlex::_changeBoundsReal(int i, const Real& lower, const Real& upper)
8257 {
8258  assert(_realLP != 0);
8259 
8260  bool scale = _realLP->isScaled();
8261  _realLP->changeBounds(i, lower, upper, scale);
8262 
8263  if(_isRealLPLoaded)
8264  {
8266  }
8267  else if(_hasBasis)
8268  {
8271  else if(_basisStatusCols[i] == SPxSolver::ON_UPPER && upper >= realParam(SoPlex::INFTY))
8273  }
8274 }
8275 
8276 
8277 
8278 /// changes matrix entry in row \p i and column \p j to \p val and adjusts basis
8279 void SoPlex::_changeElementReal(int i, int j, const Real& val)
8280 {
8281  assert(_realLP != 0);
8282 
8283  bool scale = _realLP->isScaled();
8284  _realLP->changeElement(i, j, val, scale);
8285 
8286  if(_isRealLPLoaded)
8287  {
8289  }
8290  else if(_hasBasis)
8291  {
8293  _hasBasis = false;
8294  }
8295 
8297 }
8298 
8299 
8300 
8301 /// removes row \p i and adjusts basis
8303 {
8304  assert(_realLP != 0);
8305 
8306  _realLP->removeRow(i);
8307 
8308  if(_isRealLPLoaded)
8309  {
8311  }
8312  else if(_hasBasis)
8313  {
8315  _hasBasis = false;
8316  else
8317  {
8320  }
8321  }
8322 
8324 }
8325 
8326 
8327 
8328 /// removes all rows with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
8329 /// new index where row \p i has been moved to; note that \p perm must point to an array of size at least
8330 /// #numRowsReal()
8331 void SoPlex::_removeRowsReal(int perm[])
8332 {
8333  assert(_realLP != 0);
8334 
8335  _realLP->removeRows(perm);
8336 
8337  if(_isRealLPLoaded)
8338  {
8340  }
8341  else if(_hasBasis)
8342  {
8343  for(int i = numRowsReal() - 1; i >= 0 && _hasBasis; i--)
8344  {
8345  if(perm[i] < 0 && _basisStatusRows[i] != SPxSolver::BASIC)
8346  _hasBasis = false;
8347  else if(perm[i] >= 0 && perm[i] != i)
8348  {
8349  assert(perm[i] < numRowsReal());
8350  assert(perm[perm[i]] < 0);
8351 
8352  _basisStatusRows[perm[i]] = _basisStatusRows[i];
8353  }
8354  }
8355 
8356  if(_hasBasis)
8358  }
8359 
8361 }
8362 
8363 
8364 
8365 /// removes column i
8367 {
8368  assert(_realLP != 0);
8369 
8370  _realLP->removeCol(i);
8371 
8372  if(_isRealLPLoaded)
8373  {
8375  }
8376  else if(_hasBasis)
8377  {
8379  _hasBasis = false;
8380  else
8381  {
8384  }
8385  }
8386 
8388 }
8389 
8390 
8391 
8392 /// removes all columns with an index \p i such that \p perm[i] < 0; upon completion, \p perm[i] >= 0 indicates the
8393 /// new index where column \p i has been moved to; note that \p perm must point to an array of size at least
8394 /// #numColsReal()
8395 void SoPlex::_removeColsReal(int perm[])
8396 {
8397  assert(_realLP != 0);
8398 
8399  _realLP->removeCols(perm);
8400 
8401  if(_isRealLPLoaded)
8402  {
8404  }
8405  else if(_hasBasis)
8406  {
8407  for(int i = numColsReal() - 1; i >= 0 && _hasBasis; i--)
8408  {
8409  if(perm[i] < 0 && _basisStatusCols[i] == SPxSolver::BASIC)
8410  _hasBasis = false;
8411  else if(perm[i] >= 0 && perm[i] != i)
8412  {
8413  assert(perm[i] < numColsReal());
8414  assert(perm[perm[i]] < 0);
8415 
8416  _basisStatusCols[perm[i]] = _basisStatusCols[i];
8417  }
8418  }
8419 
8420  if(_hasBasis)
8422  }
8423 
8425 }
8426 
8427 
8428 
8429 /// invalidates solution
8431 {
8432  ///@todo maybe this should be done individually at the places when this method is called
8434 
8435  _solReal.invalidate();
8436  _hasSolReal = false;
8437 
8439  _hasSolRational = false;
8440 }
8441 
8442 
8443 
8444 /// enables simplifier and scaler
8446 {
8447  // type of simplifier
8448  switch(intParam(SoPlex::SIMPLIFIER))
8449  {
8450  case SIMPLIFIER_OFF:
8451  _simplifier = 0;
8452  break;
8453 
8454  case SIMPLIFIER_AUTO:
8456  assert(_simplifier != 0);
8458  break;
8459 
8460  default:
8461  break;
8462  }
8463 
8464  // type of scaler
8465  switch(intParam(SoPlex::SCALER))
8466  {
8467  case SCALER_OFF:
8468  _scaler = 0;
8469  break;
8470 
8471  case SCALER_UNIEQUI:
8473  break;
8474 
8475  case SCALER_BIEQUI:
8477  break;
8478 
8479  case SCALER_GEO1:
8480  _scaler = &_scalerGeo1;
8481  break;
8482 
8483  case SCALER_GEO8:
8484  _scaler = &_scalerGeo8;
8485  break;
8486 
8487  case SCALER_LEASTSQ:
8489  break;
8490 
8491  case SCALER_GEOEQUI:
8493  break;
8494 
8495  default:
8496  break;
8497  }
8498 }
8499 
8500 
8501 
8502 /// disables simplifier and scaler
8504 {
8505  _simplifier = 0;
8506 
8507  // preserve scaler when persistent scaling is used
8508  if(!_isRealLPScaled)
8509  _scaler = 0;
8510  else
8512 }
8513 
8514 
8515 
8516 /// ensures that the rational LP is available; performs no sync
8518 {
8519  if(_rationalLP == 0)
8520  {
8524  }
8525 }
8526 
8527 
8528 
8529 /// ensures that the real LP and the basis are loaded in the solver; performs no sync
8531 {
8532  if(!_isRealLPLoaded)
8533  {
8534  assert(_realLP != &_solver);
8535 
8537  _realLP->~SPxLPReal();
8538  spx_free(_realLP);
8539  _realLP = &_solver;
8540  _isRealLPLoaded = true;
8541 
8542  if(_hasBasis)
8543  {
8544  ///@todo this should not fail even if the basis is invalid (wrong dimension or wrong number of basic
8545  /// entries); fix either in SPxSolver or in SPxBasis
8546  assert(_basisStatusRows.size() == numRowsReal());
8547  assert(_basisStatusCols.size() == numColsReal());
8550  }
8551  }
8552 }
8553 
8554 
8555 
8556 /// call floating-point solver and update statistics on iterations etc.
8558 {
8559  bool _hadBasis = _hasBasis;
8560 
8561  // set time and iteration limit
8564  else
8566 
8569  else
8571 
8572  // ensure that tolerances are not too small
8573  if(_solver.feastol() < 1e-12)
8574  _solver.setFeastol(1e-12);
8575 
8576  if(_solver.opttol() < 1e-12)
8577  _solver.setOpttol(1e-12);
8578 
8579  // set correct representation
8583  && _solver.rep() != SPxSolver::COLUMN)
8584  {
8586  }
8590  && _solver.rep() != SPxSolver::ROW)
8591  {
8593  }
8594 
8595  // set correct type
8598  && _solver.type() != SPxSolver::ENTER)
8599  {
8601  }
8604  && _solver.type() != SPxSolver::LEAVE)
8605  {
8607  }
8608 
8609  // set pricing modes
8611 
8615  _solver.hyperPricing(true);
8617  _solver.hyperPricing(false);
8618 
8622 
8623  // call floating-point solver and catch exceptions
8625 
8626  try
8627  {
8628  _solver.solve();
8629  }
8630  catch(const SPxException& E)
8631  {
8632  MSG_INFO1(spxout, spxout << "Caught exception <" << E.what() << "> while solving real LP.\n");
8634  }
8635  catch(...)
8636  {
8637  MSG_INFO1(spxout, spxout << "Caught unknown exception while solving real LP.\n");
8639  }
8640 
8642 
8643  // invalidate rational factorization of basis if pivots have been performed
8644  if(_solver.iterations() > 0)
8646 
8647  // record statistics
8650  _statistics->iterationsFromBasis += _hadBasis ? _solver.iterations() : 0;
8658 
8663 }
8664 
8665 
8666 
8667 /// reads real LP in LP or MPS format from file and returns true on success; gets row names, column names, and
8668 /// integer variables if desired
8669 bool SoPlex::_readFileReal(const char* filename, NameSet* rowNames, NameSet* colNames,
8670  DIdxSet* intVars)
8671 {
8672  assert(_realLP != 0);
8673 
8674  // clear statistics
8676 
8677  // update status
8678  clearBasis();
8681 
8682  // start timing
8684 
8685  // read
8686  bool success = _realLP->readFile(filename, rowNames, colNames, intVars);
8687 
8688  // stop timing
8690 
8691  if(success)
8692  {
8696 
8697  // if sync mode is auto, we have to copy the (rounded) real LP to the rational LP; this is counted to sync time
8698  // and not to reading time
8700  _syncLPRational();
8701  }
8702  else
8703  clearLPReal();
8704 
8705  return success;
8706 }
8707 
8708 
8709 
8710 /// reads rational LP in LP or MPS format from file and returns true on success; gets row names, column names, and
8711 /// integer variables if desired
8712 bool SoPlex::_readFileRational(const char* filename, NameSet* rowNames, NameSet* colNames,
8713  DIdxSet* intVars)
8714 {
8715  // clear statistics
8717 
8718  // start timing
8720 
8721  // update status
8722  clearBasis();
8725 
8726  // read
8728  bool success = _rationalLP->readFile(filename, rowNames, colNames, intVars);
8729 
8730  // stop timing
8732 
8733  if(success)
8734  {
8739 
8740  // if sync mode is auto, we have to copy the (rounded) real LP to the rational LP; this is counted to sync time
8741  // and not to reading time
8743  _syncLPReal();
8744  // if a rational LP file is read, but only the (rounded) real LP should be kept, we have to free the rational LP
8746  {
8747  _syncLPReal();
8748  _rationalLP->~SPxLPRational();
8750  }
8751  }
8752  else
8753  clearLPRational();
8754 
8755  return success;
8756 }
8757 
8758 
8759 
8760 /// completes range type arrays after adding columns and/or rows
8762 {
8763  // we use one method for bot columns and rows, because during column/row addition, rows/columns can be added
8764  // implicitly
8765  for(int i = _colTypes.size(); i < numColsRational(); i++)
8767 
8768  for(int i = _rowTypes.size(); i < numRowsRational(); i++)
8770 }
8771 
8772 
8773 
8774 /// recomputes range types from scratch using real LP
8776 {
8778 
8779  for(int i = 0; i < numRowsReal(); i++)
8780  _rowTypes[i] = _rangeTypeReal(_realLP->lhs(i), _realLP->rhs(i));
8781 
8783 
8784  for(int i = 0; i < numColsReal(); i++)
8786 }
8787 
8788 
8789 
8790 /// recomputes range types from scratch using rational LP
8792 {
8794 
8795  for(int i = 0; i < numRowsRational(); i++)
8797 
8799 
8800  for(int i = 0; i < numColsRational(); i++)
8802 }
8803 
8804 
8805 
8806 /// synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP, without looking at the sync mode
8807 void SoPlex::_syncLPReal(bool time)
8808 {
8809  // start timing
8810  if(time)
8812 
8813  // copy LP
8814  if(_isRealLPLoaded)
8816  else
8817  *_realLP = *_rationalLP;
8818 
8819  ///@todo try loading old basis
8820  _hasBasis = false;
8822 
8823  // stop timing
8824  if(time)
8826 }
8827 
8828 
8829 
8830 /// synchronizes rational LP with real LP, i.e., copies real LP to rational LP, without looking at the sync mode
8832 {
8833  // start timing
8834  if(time)
8836 
8837  // copy LP
8839  *_rationalLP = *_realLP;
8841 
8842  // stop timing
8843  if(time)
8845 }
8846 
8847 
8848 
8849 /// synchronizes rational solution with real solution, i.e., copies (rounded) rational solution to real solution
8851 {
8853  {
8855  _hasSolReal = true;
8856  }
8857 }
8858 
8859 
8860 
8861 /// synchronizes real solution with rational solution, i.e., copies real solution to rational solution
8863 {
8865  {
8867  _hasSolRational = true;
8868  }
8869 }
8870 
8871 
8872 
8873 /// returns pointer to a constant unit vector available until destruction of the SoPlex class
8875 {
8876  assert(i >= 0);
8877 
8878  if(i < 0)
8879  return 0;
8880  else if(i >= _unitMatrixRational.size())
8881  _unitMatrixRational.append(i + 1 - _unitMatrixRational.size(), (UnitVectorRational*)0);
8882 
8883  assert(i < _unitMatrixRational.size());
8884 
8885  if(_unitMatrixRational[i] == 0)
8886  {
8889  }
8890 
8891  assert(_unitMatrixRational[i] != 0);
8892 
8893  return _unitMatrixRational[i];
8894 }
8895 
8896 
8897 
8898 /// parses one line in a settings file and returns true on success; note that the string is modified
8899 bool SoPlex::_parseSettingsLine(char* line, const int lineNumber)
8900 {
8901  assert(line != 0);
8902 
8903  // find the start of the parameter type
8904  while(*line == ' ' || *line == '\t' || *line == '\r')
8905  line++;
8906 
8907  if(*line == '\0' || *line == '\n' || *line == '#')
8908  return true;
8909 
8910  char* paramTypeString = line;
8911 
8912  // find the end of the parameter type
8913  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8914  && *line != '\0' && *line != ':')
8915  line++;
8916 
8917  if(*line == ':')
8918  {
8919  *line = '\0';
8920  line++;
8921  }
8922  else
8923  {
8924  *line = '\0';
8925  line++;
8926 
8927  // search for the ':' char in the line
8928  while(*line == ' ' || *line == '\t' || *line == '\r')
8929  line++;
8930 
8931  if(*line != ':')
8932  {
8933  MSG_INFO1(spxout, spxout <<
8934  "Error parsing settings file: no ':' separating parameter type and name in line " << lineNumber <<
8935  ".\n");
8936  return false;
8937  }
8938 
8939  line++;
8940  }
8941 
8942  // find the start of the parameter name
8943  while(*line == ' ' || *line == '\t' || *line == '\r')
8944  line++;
8945 
8946  if(*line == '\0' || *line == '\n' || *line == '#')
8947  {
8948  MSG_INFO1(spxout, spxout << "Error parsing settings file: no parameter name in line " << lineNumber
8949  << ".\n");
8950  return false;
8951  }
8952 
8953  char* paramName = line;
8954 
8955  // find the end of the parameter name
8956  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8957  && *line != '\0' && *line != '=')
8958  line++;
8959 
8960  if(*line == '=')
8961  {
8962  *line = '\0';
8963  line++;
8964  }
8965  else
8966  {
8967  *line = '\0';
8968  line++;
8969 
8970  // search for the '=' char in the line
8971  while(*line == ' ' || *line == '\t' || *line == '\r')
8972  line++;
8973 
8974  if(*line != '=')
8975  {
8976  MSG_INFO1(spxout, spxout << "Error parsing settings file: no '=' after parameter name in line " <<
8977  lineNumber << ".\n");
8978  return false;
8979  }
8980 
8981  line++;
8982  }
8983 
8984  // find the start of the parameter value string
8985  while(*line == ' ' || *line == '\t' || *line == '\r')
8986  line++;
8987 
8988  if(*line == '\0' || *line == '\n' || *line == '#')
8989  {
8990  MSG_INFO1(spxout, spxout << "Error parsing settings file: no parameter value in line " << lineNumber
8991  << ".\n");
8992  return false;
8993  }
8994 
8995  char* paramValueString = line;
8996 
8997  // find the end of the parameter value string
8998  while(*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#'
8999  && *line != '\0')
9000  line++;
9001 
9002  if(*line != '\0')
9003  {
9004  // check, if the rest of the line is clean
9005  *line = '\0';
9006  line++;
9007 
9008  while(*line == ' ' || *line == '\t' || *line == '\r')
9009  line++;
9010 
9011  if(*line != '\0' && *line != '\n' && *line != '#')
9012  {
9013  MSG_INFO1(spxout, spxout << "Error parsing settings file: additional character '" << *line <<
9014  "' after parameter value in line " << lineNumber << ".\n");
9015  return false;
9016  }
9017  }
9018 
9019  // check whether we have a bool parameter
9020  if(strncmp(paramTypeString, "bool", 4) == 0)
9021  {
9022  for(int param = 0; ; param++)
9023  {
9024  if(param >= SoPlex::BOOLPARAM_COUNT)
9025  {
9026  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9027  "> in line " << lineNumber << ".\n");
9028  return false;
9029  }
9030  else if(strncmp(paramName, _currentSettings->boolParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9031  {
9032  if(strncasecmp(paramValueString, "true", 4) == 0
9033  || strncasecmp(paramValueString, "TRUE", 4) == 0
9034  || strncasecmp(paramValueString, "t", 4) == 0
9035  || strncasecmp(paramValueString, "T", 4) == 0
9036  || strtol(paramValueString, NULL, 4) == 1)
9037  {
9038  setBoolParam((SoPlex::BoolParam)param, true);
9039  break;
9040  }
9041  else if(strncasecmp(paramValueString, "false", 5) == 0
9042  || strncasecmp(paramValueString, "FALSE", 5) == 0
9043  || strncasecmp(paramValueString, "f", 5) == 0
9044  || strncasecmp(paramValueString, "F", 5) == 0
9045  || strtol(paramValueString, NULL, 5) == 0)
9046  {
9047  setBoolParam((SoPlex::BoolParam)param, false);
9048  break;
9049  }
9050  else
9051  {
9052  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9053  "> for bool parameter <" << paramName << "> in line " << lineNumber << ".\n");
9054  return false;
9055  }
9056  }
9057  }
9058 
9059  return true;
9060  }
9061 
9062  // check whether we have an integer parameter
9063  if(strncmp(paramTypeString, "int", 3) == 0)
9064  {
9065  for(int param = 0; ; param++)
9066  {
9067  if(param >= SoPlex::INTPARAM_COUNT)
9068  {
9069  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9070  "> in line " << lineNumber << ".\n");
9071  return false;
9072  }
9073  else if(strncmp(paramName, _currentSettings->intParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9074  {
9075  int value;
9076  value = std::stoi(paramValueString);
9077 
9078  if(setIntParam((SoPlex::IntParam)param, value, false))
9079  break;
9080  else
9081  {
9082  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9083  "> for int parameter <" << paramName << "> in line " << lineNumber << ".\n");
9084  return false;
9085  }
9086  }
9087  }
9088 
9089  return true;
9090  }
9091 
9092  // check whether we have a real parameter
9093  if(strncmp(paramTypeString, "real", 4) == 0)
9094  {
9095  for(int param = 0; ; param++)
9096  {
9097  if(param >= SoPlex::REALPARAM_COUNT)
9098  {
9099  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9100  "> in line " << lineNumber << ".\n");
9101  return false;
9102  }
9103  else if(strncmp(paramName, _currentSettings->realParam.name[param].c_str(), SET_MAX_LINE_LEN) == 0)
9104  {
9105  Real value;
9106 
9107 #ifdef WITH_LONG_DOUBLE
9108  value = std::stold(paramValueString);
9109 #else
9110 #ifdef WITH_FLOAT
9111  value = std::stof(paramValueString);
9112 #else
9113  value = std::stod(paramValueString);
9114 #endif
9115 #endif
9116 
9117  if(setRealParam((SoPlex::RealParam)param, value))
9118  break;
9119  else
9120  {
9121  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9122  "> for real parameter <" << paramName << "> in line " << lineNumber << ".\n");
9123  return false;
9124  }
9125  }
9126  }
9127 
9128  return true;
9129  }
9130 
9131 #ifdef SOPLEX_WITH_RATIONALPARAM
9132 
9133  // check whether we have a rational parameter
9134  if(strncmp(paramTypeString, "rational", 8) == 0)
9135  {
9136  for(int param = 0; ; param++)
9137  {
9138  if(param >= SoPlex::RATIONALPARAM_COUNT)
9139  {
9140  MSG_INFO1(spxout, spxout << "Error parsing settings file: unknown parameter name <" << paramName <<
9141  "> in line " << lineNumber << ".\n");
9142  return false;
9143  }
9144  else if(strncmp(paramName, _currentSettings->rationalParam.name[param].c_str(),
9145  SET_MAX_LINE_LEN) == 0)
9146  {
9147  Rational value;
9148 
9149  if(readStringRational(paramValueString, value)
9150  && setRationalParam((SoPlex::RationalParam)param, value))
9151  break;
9152  else
9153  {
9154  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid value <" << paramValueString <<
9155  "> for rational parameter <" << paramName << "> in line " << lineNumber << ".\n");
9156  return false;
9157  }
9158  }
9159  }
9160 
9161  return true;
9162  }
9163 
9164 #endif
9165 
9166  // check whether we have the random seed
9167  if(strncmp(paramTypeString, "uint", 4) == 0)
9168  {
9169  if(strncmp(paramName, "random_seed", 11) == 0)
9170  {
9171  unsigned int value;
9172  unsigned long parseval;
9173 
9174  parseval = std::stoul(paramValueString);
9175 
9176  if(parseval > UINT_MAX)
9177  {
9178  value = UINT_MAX;
9179  MSG_WARNING(spxout, spxout << "Converting number greater than UINT_MAX to uint.\n");
9180  }
9181  else
9182  value = (unsigned int) parseval;
9183 
9184  setRandomSeed(value);
9185  return true;
9186  }
9187 
9188  MSG_INFO1(spxout, spxout << "Error parsing settings file for uint parameter <random_seed>.\n");
9189  return false;
9190  }
9191 
9192  MSG_INFO1(spxout, spxout << "Error parsing settings file: invalid parameter type <" <<
9193  paramTypeString << "> for parameter <" << paramName << "> in line " << lineNumber << ".\n");
9194 
9195  return false;
9196 }
9197 } // 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:1858
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:1679
SPxLPBase< Real > SPxLPReal
Definition: spxlp.h:36
const char * getRatiotesterName()
name of currently loaded ratiotester
Definition: soplex.cpp:5324
DVectorBase< R > _slacks
Definition: solbase.h:219
cpu or user time
Definition: soplex.h:1266
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:4972
void _changeUpperReal(const VectorReal &upper)
changes vector of upper bounds to upper and adjusts basis
Definition: soplex.cpp:8184
standard floating-point parsing
Definition: soplex.h:1227
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.
textbook ratio test without stabilization
Definition: soplex.h:1198
accuracy of conjugate gradient method in least squares scaling (higher value leads to more iterations...
Definition: soplex.h:1368
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:1311
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:1594
Basis is dual feasible.
Definition: spxbasis.h:95
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:7309
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:3709
bool GE(Real a, Real b, Real eps=Param::epsilon())
returns true iff a >= b + eps
Definition: spxdefines.h:406
void printSolutionStatistics(std::ostream &os)
prints solution statistics
Definition: soplex.cpp:7082
refactor threshold for memory growth in factorization since last refactorization
Definition: soplex.h:1365
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
Basis is not known to be dual nor primal feasible.
Definition: spxbasis.h:94
No matrix has yet been loaded.
void coSolve(Vector &x, const Vector &rhs)
Cosolves linear system with basis matrix.
Definition: spxbasis.h:730
partial multiple pricer based on Dantzig pricing
Definition: soplex.h:1182
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:7877
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:4284
Rational minAbsNonzeroRational() const
returns smallest non-zero element in absolute value
Definition: soplex.cpp:1169
static void setEpsilon(Real eps)
Definition: spxdefines.cpp:50
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:1002
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
geometric mean scaling on rows and columns, max 8 rounds
Definition: soplex.h:1147
const Settings & settings() const
returns current parameter settings
Definition: soplex.cpp:5807
upper limit on objective value
Definition: soplex.h:1329
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:8279
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
general zero tolerance
Definition: soplex.h:1308
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:1035
void setOutstream(SPxOut &newOutstream)
Definition: spxlpbase.h:126
Real _realParamValues[SoPlex::REALPARAM_COUNT]
array of current real parameter values
Definition: soplex.h:1459
void _changeRangeReal(const VectorReal &lhs, const VectorReal &rhs)
changes left- and right-hand side vectors and adjusts basis
Definition: soplex.cpp:8061
const SPxRatioTester * ratiotester() const
return loaded SPxRatioTester.
Definition: spxsolver.h:1781
type of ratio test
Definition: soplex.h:1008
void removeColReal(int i)
removes column i
Definition: soplex.cpp:1854
maximum increase of scaling factors between refinements
Definition: soplex.h:1338
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:1604
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:993
continue iterative refinement with exact basic solution if not optimal?
Definition: soplex.h:944
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:1023
automatic sync of real and rational LP
Definition: soplex.h:1217
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:1374
type of computational form, i.e., column or row representation
Definition: soplex.h:969
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:5113
bool getPrimalReal(VectorReal &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:3078
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
dual simplex algorithm, i.e., leaving for column and entering for row representation ...
Definition: soplex.h:1086
int size() const
Number of used indices.
Definition: svectorbase.h:153
pivot zero tolerance used in factorization
Definition: soplex.h:1317
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:5399
objective offset
Definition: soplex.h:1371
bool getDualRational(VectorRational &vector)
gets the dual solution vector if available; returns true on success
Definition: soplex.cpp:3453
refinement limit (-1 if unlimited)
Definition: soplex.h:984
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:1387
SPxLPRational * _rationalLP
Definition: soplex.h:1650
void printShortStatistics(std::ostream &os)
prints short statistics
Definition: soplex.cpp:7185
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:3423
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:4857
void getColsRational(int start, int end, LPColSetRational &lpcolset) const
gets columns start, ..., end
Definition: soplex.cpp:1268
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:3941
void _addColsReal(const LPColSetReal &lpcolset)
adds multiple columns to the real LP and adjusts basis
Definition: soplex.cpp:7920
Basis is optimal, i.e. dual and primal feasible.
Definition: spxbasis.h:97
primal simplex algorithm, i.e., entering for column and leaving for row representation ...
Definition: soplex.h:1083
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:7647
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:1323
steepest edge pricer with exact initialization of norms
Definition: soplex.h:1191
mode for iterative refinement strategy
Definition: soplex.h:1017
SPxGeometSC _scalerGeo8
Definition: soplex.h:1608
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:1592
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:5722
DVectorBase< R > _primalRay
Definition: solbase.h:220
greedy crash basis weighted by objective, bounds, and sides
Definition: soplex.h:1163
bool isScaled() const
Returns true if and only if the LP is scaled.
Definition: spxlpbase.h:140
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:8395
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:3468
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:1877
Real getFactorTime() const
time spent in factorizations
Definition: slufactor.h:239
primal feasibility tolerance
Definition: soplex.h:1302
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:5615
void _addRowReal(const LPRowReal &lprow)
adds a single row to the real LP and adjusts basis
Definition: soplex.cpp:7824
bool defaultValue[SoPlex::BOOLPARAM_COUNT]
array of default values for boolean parameters
Definition: soplex.h:1399
solve() aborted due to iteration limit.
Definition: spxsolver.h:213
R rhs() const
Right-hand side value.
Definition: lprowbase.h:223
only error output
Definition: soplex.h:1103
SPxScaler * _scaler
Definition: soplex.h:1629
std::string name[SoPlex::BOOLPARAM_COUNT]
array of names for boolean parameters
Definition: soplex.h:1395
#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:5415
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:1014
mode for synchronizing real and rational LP
Definition: soplex.h:1011
void _syncLPReal(bool time=true)
synchronizes real LP with rational LP, i.e., copies (rounded) rational LP into real LP...
Definition: soplex.cpp:8807
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:3153
void resetSettings(const bool quiet=false, const bool init=true)
resets default parameter settings
Definition: soplex.cpp:6537
void setValue(int i, R x)
Sets i &#39;th element to x.
Definition: ssvectorbase.h:219
void _recomputeRangeTypesRational()
recomputes range types from scratch using rational LP
Definition: soplex.cpp:8791
void syntaxError()
Definition: mpsinput.h:237
iteration limit (-1 if unlimited)
Definition: soplex.h:981
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:3211
re-optimize the original problem to get a proof (ray) of infeasibility/unboundedness?
Definition: soplex.h:956
decide according to READMODE
Definition: soplex.h:1253
SPxFastRT _ratiotesterFast
Definition: soplex.h:1622
should cycling solutions be accepted during iterative refinement?
Definition: soplex.h:935
void _disableSimplifierAndScaler()
disables simplifier and scaler
Definition: soplex.cpp:8503
bool getRowViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of constraints; returns true on success
Definition: soplex.cpp:3555
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:923
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:5129
NameSet * _rowNames
Definition: soplex.h:1822
Vector & multBaseWith(Vector &x) const
Basis-vector product.
Definition: spxbasis.cpp:1023
void _removeRowReal(int i)
removes row i and adjusts basis
Definition: soplex.cpp:8302
lower bound is finite, upper bound is infinite
Definition: soplex.h:1685
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:8669
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
void addColsRational(const LPColSetRational &lpcolset)
adds multiple columns
Definition: soplex.cpp:2148
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
minimize number of basic slack variables, i.e. more variables between bounds
Definition: soplex.h:1295
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:5283
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:966
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:1427
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:5333
void setSparsePricingFactor(Real fac)
Definition: spxsolver.h:864
display frequency
Definition: soplex.h:990
int intParam(const IntParam param) const
returns integer parameter value
Definition: soplex.cpp:5775
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:8517
geometric mean scaling on rows and columns, max 1 round
Definition: soplex.h:1144
minimum number of stalling refinements since last pivot to trigger rational factorization ...
Definition: soplex.h:1029
minimal reduction (sum of removed rows/cols) to continue simplification
Definition: soplex.h:1356
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:6507
void _changeRhsReal(const VectorReal &rhs)
changes right-hand side vector to rhs and adjusts basis
Definition: soplex.cpp:8017
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:7198
std::string name[SoPlex::REALPARAM_COUNT]
array of names for real parameters
Definition: soplex.h:1423
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:919
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
user sync of real and rational LP
Definition: soplex.h:1220
rowwise representation.
Definition: spxsolver.h:107
mode for hyper sparse pricing
Definition: soplex.h:1026
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:978
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
bound flipping ratio test for long steps in the dual simplex
Definition: soplex.h:1207
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:1453
Rational _rationalPosInfty
Definition: soplex.h:1590
number of integer parameters
Definition: soplex.h:1053
Rational _rationalOpttol
Definition: soplex.h:1593
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:1299
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:5379
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:1606
int numNonzerosRational() const
returns number of nonzeros
Definition: soplex.cpp:1160
void getObjUnscaled(VectorBase< Real > &pobj) const
Gets unscaled objective vector.
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 addRowsRational(const LPRowSetRational &lprowset)
adds multiple rows
Definition: soplex.cpp:2054
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.
row representation (lower,lhs) <= (x,Ax) <= (upper,rhs)
Definition: soplex.h:1076
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:1609
const UnitVectorRational * _unitVectorRational(const int i)
returns pointer to a constant unit vector available until destruction of the SoPlex class ...
Definition: soplex.cpp:8874
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:7687
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:8850
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
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
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:1362
Forrest-Tomlin type update.
Definition: soplex.h:1096
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:4011
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:7655
Real luFactorizationTimeReal
time for factorizing bases matrices in real precision
Definition: statistics.h:96
no solution polishing
Definition: soplex.h:1289
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:3969
Rational objValueRational()
returns the objective value if a primal solution is available
Definition: soplex.cpp:3377
void getBasis(SPxSolver::VarStatus rows[], SPxSolver::VarStatus cols[]) const
gets current basis via arrays of statuses
Definition: soplex.cpp:4115
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:1861
nothing known about basis status (possibly due to a singular basis in transformed problem) ...
Definition: spxsolver.h:196
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
returns current SPxStatus.
Definition: spxbasis.h:425
Real upper[SoPlex::REALPARAM_COUNT]
array of upper bounds for real parameter values
Definition: soplex.h:1431
decompStatus _currentProb
Definition: soplex.h:1849
declaration of types for file output
bool isPrimalFeasible() const
is stored primal solution feasible?
Definition: soplex.cpp:3006
DataArray< RangeType > _colTypes
Definition: soplex.h:1697
type of scaler
Definition: soplex.h:999
void maxObjUnscaled(VectorBase< Real > &vec) const
Returns unscaled objective vector for maximization problem.
double Real
Definition: spxdefines.h:218
Rational _rationalPosone
Definition: soplex.h:1879
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:1623
bool _isRealLPLoaded
Definition: soplex.h:1632
SLUFactorRational _rationalLUSolver
Definition: soplex.h:1651
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:8557
DVectorBase< R > _primal
Definition: solbase.h:218
number of boolean parameters
Definition: soplex.h:959
SPxEquiliSC _scalerUniequi
Definition: soplex.h:1605
#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:7176
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:8712
lower threshold in lifting (nonzero matrix coefficients with smaller absolute value will be reformula...
Definition: soplex.h:1341
bool getPrimalRayReal(VectorReal &vector)
gets the primal ray if available; returns true on success
Definition: soplex.cpp:3108
disable timing
Definition: soplex.h:1263
void getColVectorUnscaled(int i, DSVectorBase< Real > &vec) const
Gets column vector of column i.
bool hasPrimal() const
is a primal feasible solution available?
Definition: soplex.cpp:3015
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
standard Harris ratio test
Definition: soplex.h:1201
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
generic solution-based crash basis
Definition: soplex.h:1169
crash basis from a greedy solution
Definition: soplex.h:1166
DVectorBase< Real > DVectorReal
Definition: dvector.h:29
bool hasDualFarkas() const
is Farkas proof of infeasibility available?
Definition: soplex.cpp:3048
virtual const char * getName() const
get name of simplifier.
std::string description[SoPlex::INTPARAM_COUNT]
array of descriptions for integer parameters
Definition: soplex.h:1409
bool _isConsistent() const
checks consistency
Definition: soplex.cpp:7699
void _changeLowerReal(const VectorReal &lower)
changes vector of lower bounds to lower and adjusts basis
Definition: soplex.cpp:8139
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:1044
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:950
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:5085
bool _upperFinite(const RangeType &rangeType) const
checks whether RangeType corresponds to finite upper bound
Definition: soplex.cpp:7815
bool _hasBasis
Definition: soplex.h:1867
use bound flipping also for row representation?
Definition: soplex.h:947
bool hasBasis() const
is an advanced starting basis available?
Definition: soplex.cpp:4025
void _invalidateSolution()
invalidates solution
Definition: soplex.cpp:8430
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:4476
bool getDualViolationReal(Real &maxviol, Real &sumviol)
gets violation of dual multipliers; returns true on success
Definition: soplex.cpp:3317
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:5155
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:5294
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:5316
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:1050
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:1880
an error occured.
Definition: spxsolver.h:204
round scaling factors for iterative refinement to powers of two?
Definition: soplex.h:941
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:4033
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:4687
int dlcmSizeDualRational(const int base=2)
get size of least common multiple of denominators in dual solution
Definition: soplex.cpp:3983
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:1611
Statistics * _statistics
statistics since last call to solveReal() or solveRational()
Definition: soplex.h:1577
#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:996
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
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
floating-point check
Definition: soplex.h:1250
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:8331
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:8831
void printUserSettings()
print non-default parameter values
Definition: soplex.cpp:6559
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:7768
SPxSteepPR _pricerQuickSteep
Definition: soplex.h:1618
virtual int getColScaleExp(int i) const
returns scaling factor for column i
Definition: spxscaler.cpp:293
Real getEstimatedCondition()
Definition: spxbasis.h:608
int numColsRational() const
returns number of columns
Definition: soplex.cpp:1151
force iterative refinement
Definition: soplex.h:1243
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:1615
SPxParMultPR _pricerParMult
Definition: soplex.h:1616
bool getPrimalRational(VectorRational &vector)
gets the primal solution vector if available; returns true on success
Definition: soplex.cpp:3408
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:5265
RangeType _switchRangeType(const RangeType &rangeType) const
switches RANGETYPE_LOWER to RANGETYPE_UPPER and vice versa
Definition: soplex.cpp:7793
SLUFactor _slufactor
Definition: soplex.h:1603
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:5238
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:3138
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:5785
virtual Real time() const =0
~Statistics()
destructor
Definition: statistics.h:51
SPxSteepExPR _pricerSteep
Definition: soplex.h:1619
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
bool hasDual() const
is a dual feasible solution available?
Definition: soplex.cpp:3040
automatic pricer
Definition: soplex.h:1176
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:6776
const VectorReal & upperRealInternal() const
returns upper bound vector
Definition: soplex.cpp:1016
SPxLPBase< Rational > SPxLPRational
Definition: spxlp.h:37
SPxOut spxout
Definition: soplex.h:1476
infinity threshold
Definition: soplex.h:1320
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:5249
SPxDefaultRT _ratiotesterTextbook
Definition: soplex.h:1620
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
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:1588
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:5182
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
automatic choice according to number of rows and columns
Definition: soplex.h:1070
Sparse vector .A UnitVectorBase is an SVectorBase that can take only one nonzero value with value 1 b...
void _syncRationalSolution()
synchronizes real solution with rational solution, i.e., copies real solution to rational solution ...
Definition: soplex.cpp:8862
int _intParamValues[SoPlex::INTPARAM_COUNT]
array of current integer parameter values
Definition: soplex.h:1456
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
apply standard floating-point algorithm
Definition: soplex.h:1237
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:7349
store only real LP
Definition: soplex.h:1214
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
decide depending on tolerances whether to apply iterative refinement
Definition: soplex.h:1240
lower and upper bound finite, but different
Definition: soplex.h:1691
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
least square scaling
Definition: soplex.h:1150
Rational _rationalNegInfty
Definition: soplex.h:1591
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:7223
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:1350
lower bound equals upper bound
Definition: soplex.h:1694
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:1425
bool getSlacksReal(VectorReal &vector)
gets the vector of slack values if available; returns true on success
Definition: soplex.cpp:3093
#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
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:6312
void _changeLhsReal(const VectorReal &lhs)
changes left-hand side vector for constraints to lhs and adjusts basis
Definition: soplex.cpp:7974
working tolerance for feasibility in floating-point solver during iterative refinement ...
Definition: soplex.h:1332
SPxLPReal * _realLP
Definition: soplex.h:1626
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:7806
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:1041
bool loadSettingsFile(const char *filename)
reads settings file; returns true on success
Definition: soplex.cpp:6724
SPxGeometSC _scalerGeo1
Definition: soplex.h:1607
geometric mean scaling (max 8 rounds) followed by equilibrium scaling (rows and columns) ...
Definition: soplex.h:1153
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:3614
SPxDevexPR _pricerDevex
Definition: soplex.h:1617
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:1698
void _removeColReal(int i)
removes column i
Definition: soplex.cpp:8366
void _changeRowReal(int i, const LPRowReal &lprow)
replaces row i with lprow and adjusts basis
Definition: soplex.cpp:7947
void setIntegralityInformation(int ncols, int *intInfo)
pass integrality information about the variables to the solver
Definition: soplex.cpp:1133
maximize number of basic slack variables, i.e. more variables on bounds
Definition: soplex.h:1292
SPxSumST _starterSum
Definition: soplex.h:1612
bool readStringRational(const char *s, Rational &value)
read Rational from string
Definition: rational.cpp:3655
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:4155
apply rational reconstruction after each iterative refinement?
Definition: soplex.h:938
void _changeColReal(int i, const LPColReal &lpcol)
replaces column i with lpcol and adjusts basis
Definition: soplex.cpp:8110
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:1005
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:3123
SPxHarrisRT _ratiotesterHarris
Definition: soplex.h:1621
DSVectorBase< Real > DSVectorReal
Definition: dsvector.h:29
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:1335
void clearLPReal()
clears the LP
Definition: soplex.cpp:1951
equilibrium scaling on rows or columns
Definition: soplex.h:1138
Preconfigured SoPlex LP-solver.
Definition: soplex.h:89
should the dual of the complementary problem be used in the decomposition simplex?
Definition: soplex.h:929
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:1415
Real lower[SoPlex::REALPARAM_COUNT]
array of lower bounds for real parameter values
Definition: soplex.h:1429
SPxVectorST _starterVector
Definition: soplex.h:1613
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:3168
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:5352
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:1823
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:1602
const char * getGitHash()
Definition: spxgithash.cpp:23
column representation Ax - s = 0, lower <= x <= upper, lhs <= s <= rhs
Definition: soplex.h:1073
mode for a posteriori feasibility checks
Definition: soplex.h:1020
refactor threshold for nonzeros in last factorized basis matrix compared to updated basis matrix ...
Definition: soplex.h:1359
nothing known on loaded problem.
Definition: spxsolver.h:219
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:1876
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:972
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
void _recomputeRangeTypesReal()
recomputes range types from scratch using real LP
Definition: soplex.cpp:8775
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:1407
#define DEFAULT_REFACTOR_INTERVAL
default setting for LU refactorization interval
Definition: soplex.cpp:36
DataArray< UnitVectorRational *> _unitMatrixRational
Definition: soplex.h:1673
bool getDualFarkasRational(VectorRational &vector)
gets the Farkas proof if LP is infeasible; returns true on success
Definition: soplex.cpp:3483
stalling refinement limit (-1 if unlimited)
Definition: soplex.h:987
int lower[SoPlex::INTPARAM_COUNT]
array of lower bounds for int parameter values
Definition: soplex.h:1413
DataArray< SPxSolver::VarStatus > _basisStatusRows
Definition: soplex.h:1860
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
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
SPxSolver::VarStatus basisColStatus(int col) const
returns basis status for a single column
Definition: soplex.cpp:4079
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:916
int defaultValue[SoPlex::INTPARAM_COUNT]
array of default values for integer parameters
Definition: soplex.h:1411
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:4236
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:1397
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:5765
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:1047
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:910
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:3997
bool getEstimatedCondition(Real &condition)
computes an estimated condition number for the current basis matrix using the power method; returns t...
Definition: soplex.cpp:4252
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:7639
DataArray< int > _rationalLUSolverBind
Definition: soplex.h:1652
should the degeneracy be computed for each basis?
Definition: soplex.h:926
#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:1635
bool getExactCondition(Real &condition)
computes the exact condition number for the current basis matrix using the power method; returns true...
Definition: soplex.cpp:4268
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:5305
Real solveTime() const
time spent in last call to solve
Definition: soplex.cpp:5257
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
standard verbosity level
Definition: soplex.h:1112
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:1863
zero tolerance used in update of the factorization
Definition: soplex.h:1314
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:1326
both bounds are infinite
Definition: soplex.h:1682
bool getRedCostViolationReal(Real &maxviol, Real &sumviol)
gets violation of reduced costs; returns true on success
Definition: soplex.cpp:3257
BoolParam
boolean parameters
Definition: soplex.h:907
bool _hasSolReal
Definition: soplex.h:1868
bool _isSolveStopped(bool &stoppedTime, bool &stoppedIter) const
should solving process be stopped?
Definition: soplex.cpp:7727
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:8229
#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:1032
sparse pricing threshold (#violations < dimension * SPARSITY_THRESHOLD activates sparse pricing) ...
Definition: soplex.h:1347
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:3438
dual feasibility tolerance
Definition: soplex.h:1305
void _ensureRealLPLoaded()
ensures that the real LP and the basis are loaded in the solver; performs no sync ...
Definition: soplex.cpp:8530
void invalidate()
invalidate solution
Definition: solbase.h:209
void changeRowReal(int i, const LPRowReal &lprow)
replaces row i with lprow
Definition: soplex.cpp:1443
equilibrium scaling on rows and columns
Definition: soplex.h:1141
void setBasis(const SPxSolver::VarStatus rows[], const SPxSolver::VarStatus cols[])
sets starting basis via arrays of statuses
Definition: soplex.cpp:5208
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:5887
void solve(Vector &x, const Vector &rhs)
Definition: spxbasis.h:632
SolRational _solRational
Definition: soplex.h:1864
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:6624
UnitVectorBase< Real > UnitVectorReal
Definition: unitvector.h:30
std::string rationalToString(const Rational &r, const int precision)
convert rational number to string
Definition: rational.cpp:3645
Real objValueReal()
returns the objective value if a primal solution is available
Definition: soplex.cpp:3057
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:8899
void changeRhsReal(const VectorReal &rhs)
changes right-hand side vector to rhs
Definition: soplex.cpp:1500
SPxLeastSqSC _scalerLeastsq
Definition: soplex.h:1610
geometric frequency at which to apply rational reconstruction
Definition: soplex.h:1353
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
bool isRowBasic(int i) const
is the i &#39;th row vector basic ?
Definition: spxsolver.h:1290
SPxStarter * _starter
Definition: soplex.h:1630
bool _hasSolRational
Definition: soplex.h:1869
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:5744
void _enableSimplifierAndScaler()
enables simplifier and scaler according to current parameters
Definition: soplex.cpp:8445
bool setBoolParam(const BoolParam param, const bool value, const bool init=true)
sets boolean parameter value; returns true on success
Definition: soplex.cpp:5815
should LP be transformed to equality form before a rational solve?
Definition: soplex.h:913
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:7666
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:4054
the number of iterations before the decomposition simplex initialisation is terminated.
Definition: soplex.h:1038
decide according to problem size
Definition: soplex.h:1279
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:1344
void _addRowsReal(const LPRowSetReal &lprowset)
adds multiple rows to the real LP and adjusts basis
Definition: soplex.cpp:7860
int numColsReal() const
returns number of columns
Definition: soplex.cpp:859
virtual Status solve()
solve loaded LP.
Definition: spxsolve.cpp:131
LP has been proven to be primal unbounded.
Definition: spxbasis.h:98
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:1634
IntParam
integer parameters
Definition: soplex.h:963
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:1857
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:1881
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:7743
void _completeRangeTypesRational()
completes range type arrays after adding columns and/or rows
Definition: soplex.cpp:8761
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
SPxSimplifier * _simplifier
Definition: soplex.h:1628
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
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:953
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:932
Basis is primal feasible.
Definition: spxbasis.h:96
upper bound is finite, lower bound is infinite
Definition: soplex.h:1688
bool getBoundViolationRational(Rational &maxviol, Rational &sumviol)
gets violation of bounds; returns true on success
Definition: soplex.cpp:3498
LP has a usable Basis (maybe LP is changed).
Definition: spxsolver.h:217
SPxAutoPR _pricerAuto
Definition: soplex.h:1614
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
modified Harris ratio test
Definition: soplex.h:1204
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:3955
int degenPivotsPrimal
number of primal degenerate pivots
Definition: statistics.h:122
LP has been proven to be primal infeasible.
Definition: spxbasis.h:99
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
steepest edge pricer with initialization to unit norms
Definition: soplex.h:1188