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