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