Scippy

SCIP

Solving Constraint Integer Programs

lpi_clp.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (c) 2002-2024 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file lpi_clp.cpp
26  * @ingroup LPIS
27  * @brief LP interface for Clp
28  * @author Stefan Heinz
29  * @author Marc Pfetsch
30  * @author John Forrest
31  *
32  *
33  * Notes on this interface:
34  *
35  * - Currently, Clp (Version 1.16) supports two ways of adding rows/columns from arrays: One uses a
36  * length array that for each row/column specifies the number of nonzeros to be added. The second
37  * uses the @p beg array that gives the starting index for each row/column. We use the latter
38  * variant. Since for LPI there should be no gaps in the corresponding arrays, i.e., every entry in
39  * @p val and @a ind gives a nonzero entry, one can switch between the two formats. With the current
40  * Clp implementation both formats involve an overhead:
41  *
42  * - For the @p beg variant, Clp gets the end of the array from the last position in @p beg
43  * (i.e., the entry one after the last row/column) and we have to copy and extend @p beg for this
44  * purpose. In the matrix implementation a length information is then again computed.
45  *
46  * - For the @p length variant, Clp computes the number of elements from this length variant and
47  * there exists no matrix implementation that uses the length information, i.e., it is recomputed
48  * again.
49  *
50  * Concluding: the implementation of Clp/CoinPackeMatrix could be improved. The functions
51  * affected by this are SCIPlpiLoadColLP(), SCIPlpiAddCols(), SCIPlpiAddRows()
52  *
53  * - In former versions Clp used an "auxiliary model" that allows to save time when the model is
54  * scaled. This is discarded from version higher than 1.8.2.
55  *
56  * - Clp needs the setting of several special flags to make sure that necessary data (e.g., rays etc.)
57  * are available. If the FASTMIP option in SCIP is true, some settings that are supposed to be faster
58  * are used. We tried to use the best settings, while still working correctly. These settings probably
59  * have to be adapted to future Clp versions. Maybe more possibilities will appear.
60  *
61  * - At several places this interface corrects the return value of some Clp functions, e.g.,
62  * isProvenPrimalInfeasible(). Currently (Version 1.16) no change in the Clp functions will be made,
63  * but this might change in the future.
64  *
65  * @todo Check about using fastDual().
66  */
67 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
68 
69 
70 #include <ClpSimplex.hpp>
71 #include <ClpPrimalColumnSteepest.hpp>
72 #include <ClpDualRowSteepest.hpp>
73 #include <CoinIndexedVector.hpp>
74 #include <ClpConfig.h>
75 #ifndef CLP_VERSION
76 #include <config_clp.h>
77 #define CLP_VERSION VERSION
78 #endif
79 
80 #include <cassert>
81 #include <cstdlib>
82 #include <iostream>
83 #include <vector>
84 #include <string>
85 
86 #include "lpi/lpi.h"
87 #include "scip/bitencode.h"
88 #include "scip/pub_message.h"
89 
90 /* do defines for windows directly her to make the lpi more independent*/
91 #if defined(_WIN32) || defined(_WIN64)
92 #define snprintf _snprintf
93 #endif
94 
95 /* for debugging: alternatingly write files "debug_[p|d]_[0|1].mps" after each run - use with care! */
96 #ifdef LPI_CLP_DEBUG_WRITE_FILES
97 static int fileNr = 0;
98 #endif
99 
100 /* bound for accepting primal or dual sum of infeasibilities */
101 #define SUMINFEASBOUND 1.0e-3
102 
103 /** LP interface for Clp */
104 struct SCIP_LPi
105 {
106  ClpSimplex* clp; /**< Clp simiplex solver class */
107  int* cstat; /**< array for storing column basis status */
108  int* rstat; /**< array for storing row basis status */
109  int cstatsize; /**< size of cstat array */
110  int rstatsize; /**< size of rstat array */
111  bool startscratch; /**< start from scratch? */
112  SCIP_PRICING pricing; /**< SCIP pricing setting */
113  bool validFactorization; /**< whether we have a valid factorization in clp */
114  SCIP_Bool solved; /**< was the current LP solved? */
115  bool setFactorizationFrequency; /**< store whether the factorization frequency is set */
116  SCIP_Bool fastmip; /**< are fast mip settings turned on */
117  int lastalgorithm; /**< type of last algorithm call (0 = none, 1 = primal, -1 = dual, 2 = barrier) */
118 };
119 
120 
121 
122 
123 
124 
125 /** Definitions for storing basis status (copied from lpi_spx.cpp) */
126 typedef SCIP_DUALPACKET COLPACKET; /* each column needs two bits of information (basic/on_lower/on_upper) */
127 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE
128 typedef SCIP_DUALPACKET ROWPACKET; /* each row needs two bit of information (basic/on_lower/on_upper) */
129 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE
130 
131 /** LPi state stores basis information */
133 {
134  int ncols; /**< number of LP columns */
135  int nrows; /**< number of LP rows */
136  COLPACKET* packcstat; /**< column basis status in compressed form */
137  ROWPACKET* packrstat; /**< row basis status in compressed form */
138 };
139 
140 
141 
142 
143 /*
144  * dynamic memory arrays
145  */
146 
147 /** resizes cstat array to have at least num entries */
148 static
150  SCIP_LPI* lpi, /**< LP interface structure */
151  int num /**< minimal number of entries in array */
152  )
153 {
154  assert(lpi != NULL);
155 
156  if( num > lpi->cstatsize )
157  {
158  int newsize;
159 
160  newsize = MAX(2*lpi->cstatsize, num);
161  SCIP_ALLOC( BMSreallocMemoryArray(&lpi->cstat, newsize) );
162  lpi->cstatsize = newsize;
163  }
164  assert(num <= lpi->cstatsize);
165 
166  return SCIP_OKAY;
167 }
168 
169 /** resizes rstat array to have at least num entries */
170 static
172  SCIP_LPI* lpi, /**< LP interface structure */
173  int num /**< minimal number of entries in array */
174  )
175 {
176  assert(lpi != NULL);
177 
178  if( num > lpi->rstatsize )
179  {
180  int newsize;
181 
182  newsize = MAX(2*lpi->rstatsize, num);
183  SCIP_ALLOC( BMSreallocMemoryArray(&lpi->rstat, newsize) );
184  lpi->rstatsize = newsize;
185  }
186  assert(num <= lpi->rstatsize);
187 
188  return SCIP_OKAY;
189 }
190 
191 
192 
193 
194 /*
195  * LPi state methods
196  */
197 
198 /** returns the number of packets needed to store column packet information */
199 static
201  int ncols /**< number of columns to store */
202  )
203 {
204  return (ncols+(int)COLS_PER_PACKET-1)/(int)COLS_PER_PACKET;
205 }
206 
207 /** returns the number of packets needed to store row packet information */
208 static
210  int nrows /**< number of rows to store */
211  )
212 {
213  return (nrows+(int)ROWS_PER_PACKET-1)/(int)ROWS_PER_PACKET;
214 }
215 
216 /** store row and column basis status in a packed LPi state object */
217 static
219  SCIP_LPISTATE* lpistate, /**< pointer to LPi state data */
220  const int* cstat, /**< basis status of columns in unpacked format */
221  const int* rstat /**< basis status of rows in unpacked format */
222  )
223 {
224  assert(lpistate != 0);
225  assert(lpistate->packcstat != 0);
226  assert(lpistate->packrstat != 0);
227 
228  SCIPencodeDualBit(cstat, lpistate->packcstat, lpistate->ncols);
229  SCIPencodeDualBit(rstat, lpistate->packrstat, lpistate->nrows);
230 }
231 
232 /** unpacks row and column basis status from a packed LPi state object */
233 static
235  const SCIP_LPISTATE* lpistate, /**< pointer to LPi state data */
236  int* cstat, /**< buffer for storing basis status of columns in unpacked format */
237  int* rstat /**< buffer for storing basis status of rows in unpacked format */
238  )
239 {
240  assert(lpistate != 0);
241  assert(lpistate->packcstat != 0);
242  assert(lpistate->packrstat != 0);
243 
244  SCIPdecodeDualBit(lpistate->packcstat, cstat, lpistate->ncols);
245  SCIPdecodeDualBit(lpistate->packrstat, rstat, lpistate->nrows);
246 }
247 
248 /** creates LPi state information object */
249 static
251  SCIP_LPISTATE** lpistate, /**< pointer to LPi state */
252  BMS_BLKMEM* blkmem, /**< block memory */
253  int ncols, /**< number of columns to store */
254  int nrows /**< number of rows to store */
255  )
256 {
257  assert(lpistate != 0);
258  assert(blkmem != 0);
259  assert(ncols >= 0);
260  assert(nrows >= 0);
261 
262  SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) );
263  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum(ncols)) );
264  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum(nrows)) );
265 
266  return SCIP_OKAY;
267 }
268 
269 /** frees LPi state information */
270 static
272  SCIP_LPISTATE** lpistate, /**< pointer to LPi state information (like basis information) */
273  BMS_BLKMEM* blkmem /**< block memory */
274  )
275 {
276  assert(blkmem != 0);
277  assert(lpistate != 0);
278  assert(*lpistate != 0);
279 
280  BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum((*lpistate)->ncols));
281  BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum((*lpistate)->nrows));
282  BMSfreeBlockMemory(blkmem, lpistate);
283 }
284 
285 
286 
287 
288 
289 /*
290  * local methods
291  */
292 
293 /** marks the current LP to be unsolved */
294 static
296  SCIP_LPI* lpi /**< LP interface structure */
297  )
298 {
299  assert(lpi != NULL);
300  lpi->solved = FALSE;
301 }
302 
303 /** set factorization frequency */
304 static
306  SCIP_LPI* lpi /**< LP interface structure */
307  )
308 {
309  assert(lpi != NULL);
310 
311  /* set the factorization frequency only once */
312  if ( lpi->setFactorizationFrequency )
313  return;
314 
315  lpi->clp->defaultFactorizationFrequency();
316  lpi->setFactorizationFrequency = true;
317 }
318 
319 /** set fastmip parameters of Clp */
320 static
322  SCIP_LPI* lpi /**< LP interface structure */
323  )
324 {
325  assert(lpi != NULL);
326 
327  lpi->fastmip = TRUE;
328 
329  /* Perturbation:
330  * 50 - switch on perturbation
331  * 100 - auto perturb if takes too long (1.0e-6 largest nonzero)
332  * 101 - we are perturbed
333  * 102 - don't try perturbing again
334  * - default is 100
335  * - others are for playing
336  *
337  * for Clp 1.8 stable: 50 seems to be 10% faster than 100
338  */
339  lpi->clp->setPerturbation(50);
340 
341  /* Special options description from ClpModell.hpp:
342  * 1 - Don't keep changing infeasibility weight
343  * 2 - Keep nonLinearCost round solves
344  * 4 - Force outgoing variables to exact bound (primal)
345  * 8 - Safe to use dense initial factorization
346  * 16 - Just use basic variables for operation if column generation
347  * 32 - Create ray even in BAB
348  * 64 - Treat problem as feasible until last minute (i.e. minimize infeasibilities)
349  * 128 - Switch off all matrix sanity checks
350  * 256 - No row copy
351  * 512 - If not in values pass, solution guaranteed, skip as much as possible
352  * 1024 - In branch and bound
353  * 2048 - Don't bother to re-factorize if < 20 iterations
354  * 4096 - Skip some optimality checks
355  * 8192 - Do Primal when cleaning up primal
356  * 16384 - In fast dual (so we can switch off things)
357  * 32768 - called from Osi
358  * 65536 - keep arrays around as much as possible (also use maximumR/C)
359  * 131072 - transposeTimes is -1.0 and can skip basic and fixed
360  * 262144 - extra copy of scaled matrix
361  * 524288 - Clp fast dual
362  * 1048576 - don't need to finish dual (can return 3)
363  * 2097152 - ray even if >2 pivots AND if problem is "crunched"
364  * 4194304 - don't scale integer variables
365  * 8388608 - Idiot when not really sure about it
366  * 16777216 - zero costs!
367  * 0x1000000 - is Cbc (and in branch and bound)
368  * 0x2000000 - is in a different branch and bound
369  *
370  * Comments:
371  * 2 - Nonlinear costs are used in primal for infeasibility weight.
372  * 4 - In anti-degeneracy operations can move variables just off a bound.
373  * 8 - Means dense nucleus in factorization - normally not safe in first factorization as
374  * singularity handling is not useful. Is switched on if going from dual to primal or vv.
375  * 16 - Used for "real" column generation.
376  * 32 - Currently unclear, does not lead to produce ray
377  * 64 - Good idea, since in B&B most problems are feasible.
378  * 128 - Assumes user will not create tiny or duplicate elements.
379  * 256 - Normally Clp keeps a scaled row copy for speed. For very large problems you might want to turn it off.
380  * 512 - Means nonbasic variables should be at bounds and basis will be reasonable.
381  * 1024 - In branch and bound - makes some rays available?
382  * 2048 - Unclear.
383  * 4096 - Skip some optimality checks.
384  * 8192 - If the primal has a perturbed problem and needs to clean up, it normally uses dual - but in some cases can be better to use primal.
385  * 16384 - Used internally.
386  * 32768 - Just switches off some messages, e.g., empty problem.
387  * 65536 - Unclear.
388  * 131072 - Used internally.
389  * 262144 - Normally Clp has unscaled column copy of matrix - this makes an extra scaled copy.
390  * 524288 - Used internally.
391  * 1048576 - Only set by fastDual (used internally).
392  * 2097152 - This was fixed in 03/2018 to make sure that a ray is produced.
393  * 4194304 - Not needed for us.
394  * 8388608 - Unclear.
395  * 0x1000000 - main point: does allow use of disaster handler, but also other decisions in code
396  * 0x2000000 - main point: does allow use of disaster handler, but also other decisions in code
397  *
398  * Cbc seems to use the following special options:
399  * lpi->clp->setSpecialOptions(64|128|1024|2048|4096|32768|262144|0x01000000);
400  * Sometimes 512+8192 and 8192 or 8 are used as well.
401  */
402 
403  // default settings: 32|64|128|1024|32768|262144|2097152|0x2000000
404  // Additional flags: 512, 2048, 4096 in order to speed up things.
405  // lpi->clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
406 
407  // set default options
408  lpi->clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
409 
410  // Do not change moreSpecialOptions().
411 
412  // let memory grow only (do not shrink) - [needs specialOptions & 65536 != 0]
413  // does not seem to work
414  // lpi->clp->setPersistenceFlag(1);
415 }
416 
417 /** unset fastmip parameters of Clp (reset to default parameters) */
418 static
420  SCIP_LPI* lpi /**< LP interface structure */
421  )
422 {
423  assert(lpi != NULL);
424 
425  lpi->fastmip = FALSE;
426 
427  // reset to default value:
428  lpi->clp->setPerturbation(100);
429 
430  // set default special options (see SCIPlpiCreate())
431  lpi->clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
432 
433  // set default more special options
434  lpi->clp->setMoreSpecialOptions(8192);
435 
436  // turn off memory enlargement
437  lpi->clp->setPersistenceFlag(0);
438 }
439 
440 
441 /*
442  * LP Interface Methods
443  */
444 
445 
446 /*
447  * Miscellaneous Methods
448  */
449 
450 /**@name Miscellaneous Methods */
451 /**@{ */
452 
453 /** gets name and version of LP solver */
455  void
456  )
457 {
458  // Currently Clp has no function to get version, so we hard code it ...
459  return "Clp " CLP_VERSION;
460 }
461 
462 /** gets description of LP solver (developer, webpage, ...) */
464  void
465  )
466 {
467  return "COIN-OR Linear Programming Solver developed by J. Forrest et.al. (projects.coin-or.org/Clp)";
468 }
469 
470 /** gets pointer for LP solver - use only with great care */
472  SCIP_LPI* lpi /**< pointer to an LP interface structure */
473  )
474 {
475  assert(lpi != NULL);
476  return (void*) lpi->clp;
477 }
478 
479 /** pass integrality information to LP solver */
481  SCIP_LPI* lpi, /**< pointer to an LP interface structure */
482  int ncols, /**< length of integrality array */
483  int* intInfo /**< integrality array (0: continuous, 1: integer). May be NULL iff ncols is 0. */
484  )
485 {
486  assert(lpi != NULL);
487 
488  SCIPerrorMessage("SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
489 
490  return SCIP_LPERROR;
491 }
492 
493 /** informs about availability of a primal simplex solving method */
495  void
496  )
497 {
498  return TRUE;
499 }
500 
501 /** informs about availability of a dual simplex solving method */
503  void
504  )
505 {
506  return TRUE;
507 }
508 
509 /** informs about availability of a barrier solving method */
511  void
512  )
513 {
514  return TRUE;
515 }
516 
517 
518 /**@} */
519 
520 
521 
522 
523 /*
524  * LPI Creation and Destruction Methods
525  */
526 
527 /**@name LPI Creation and Destruction Methods */
528 /**@{ */
529 
530 /** creates an LP problem object */
532  SCIP_LPI** lpi, /**< pointer to an LP interface structure */
533  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler to use for printing messages, or NULL */
534  const char* name, /**< problem name */
535  SCIP_OBJSEN objsen /**< objective sense */
536  )
537 {
538  assert(lpi != NULL);
539  assert(name != NULL);
540 
541  SCIPdebugMessage("calling SCIPlpiCreate()\n");
542 
543  // create lpi object
544  SCIP_ALLOC( BMSallocMemory(lpi) );
545  (*lpi)->clp = new ClpSimplex();
546  (*lpi)->cstat = 0;
547  (*lpi)->rstat = 0;
548  (*lpi)->cstatsize = 0;
549  (*lpi)->rstatsize = 0;
550  (*lpi)->startscratch = true;
551  (*lpi)->pricing = SCIP_PRICING_LPIDEFAULT;
552  (*lpi)->validFactorization = false;
553  (*lpi)->setFactorizationFrequency = false;
554  (*lpi)->fastmip = FALSE;
555  (*lpi)->lastalgorithm = 0;
556  invalidateSolution(*lpi);
557 
558  // if you want to use saveModel()
559  // (*lpi)->clp->setLengthNames(255);
560 
561  // set pricing routines
562 
563  // for primal:
564  // 0 is exact devex,
565  // 1 full steepest,
566  // 2 is partial exact devex
567  // 3 switches between 0 and 2 depending on factorization
568  // 4 starts as partial dantzig/devex but then may switch between 0 and 2.
569  // - currently (Clp 1.8stable) default is 3
570  ClpPrimalColumnSteepest primalSteepest;
571  (*lpi)->clp->setPrimalColumnPivotAlgorithm(primalSteepest);
572 
573  // for dual:
574  // 0 is uninitialized,
575  // 1 full,
576  // 2 is partial uninitialized,
577  // 3 starts as 2 but may switch to 1.
578  // - currently (Clp 1.8stable) default is 3
579  ClpDualRowSteepest dualSteepest;
580  (*lpi)->clp->setDualRowPivotAlgorithm(dualSteepest);
581 
582  // set problem name
583  (*lpi)->clp->setStrParam(ClpProbName, std::string(name) );
584 
585  // set objective sense: SCIP values are the same as the ones for Clp
586  (*lpi)->clp->setOptimizationDirection(objsen);
587 
588  // turn off output by default
589  (*lpi)->clp->setLogLevel(0);
590 
591  // turn on auto scaling by default
592  (*lpi)->clp->scaling(3);
593 
594  // set default special options (similar to Cbc):
595  // 32 - Create ray even in BAB
596  // 64 - good idea to be fast
597  // 128 - Assumes user will not create tiny or duplicate elements.
598  // 1024 - In branch and bound.
599  // 32768 - Just switches off some messages, e.g., empty problem.
600  // 262144 - extra copy of scaled matrix
601  // 2097152 - ray even if >2 pivots AND if problem is "crunched"
602  // 0x2000000 - is in a different branch and bound
603  (*lpi)->clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
604 
605  /* More special options:
606  * 1 bit - if presolve says infeasible in ClpSolve return
607  * 2 bit - if presolved problem infeasible return
608  * 4 bit - keep arrays like upper_ around
609  * 8 bit - no free or superBasic variables
610  * 16 bit - if checking replaceColumn accuracy before updating
611  * 32 bit - say optimal if primal feasible!
612  * 64 bit - give up easily in dual (and say infeasible)
613  * 128 bit - no objective, 0-1 and in B&B
614  * 256 bit - in primal from dual or vice versa
615  * 512 bit - alternative use of solveType_
616  * 1024 bit - don't do row copy of factorization
617  * 2048 bit - perturb in complete fathoming
618  * 4096 bit - try more for complete fathoming
619  * 8192 bit - don't even think of using primal if user asks for dual (and vv)
620  * 16384 bit - in initialSolve so be more flexible
621  * 32768 bit - don't swap algorithms from dual if small infeasibility
622  * 65536 bit - perturb in postsolve cleanup (even if < 10000 rows)
623  * 131072 bit - initial stateDualColumn
624  * 524288 bit - stop when primal feasible
625  * 1048576 bit - don't perturb even if long time
626  * 2097152 bit - no primal in fastDual2 if feasible
627  * 4194304 bit - tolerances have been changed by code
628  * 8388608 bit - tolerances are dynamic (at first)
629  * 16777216 bit - if factorization kept can still declare optimal at once
630  */
631 
632  // set default more special options:
633  (*lpi)->clp->setMoreSpecialOptions(8192);
634 
635  // set default pricing
636  SCIP_CALL( SCIPlpiSetIntpar(*lpi, SCIP_LPPAR_PRICING, (int)(*lpi)->pricing) );
637 
638  return SCIP_OKAY;
639 }
640 
641 
642 /** deletes an LP problem object */
644  SCIP_LPI** lpi /**< pointer to an LP interface structure */
645  )
646 {
647  assert(lpi != NULL);
648  assert(*lpi != 0);
649  assert((*lpi)->clp != 0);
650 
651  SCIPdebugMessage("calling SCIPlpiFree()\n");
652 
653  /* free LP */
654  delete (*lpi)->clp;
655 
656  /* free memory */
657  BMSfreeMemoryArrayNull(&(*lpi)->cstat);
658  BMSfreeMemoryArrayNull(&(*lpi)->rstat);
659  BMSfreeMemory(lpi);
660 
661  return SCIP_OKAY;
662 }
663 
664 /**@} */
665 
666 
667 
668 
669 /*
670  * Modification Methods
671  */
672 
673 /**@name Modification Methods */
674 /**@{ */
675 
676 /** copies LP data with column matrix into LP solver */
678  SCIP_LPI* lpi, /**< LP interface structure */
679  SCIP_OBJSEN objsen, /**< objective sense */
680  int ncols, /**< number of columns */
681  const SCIP_Real* obj, /**< objective function values of columns */
682  const SCIP_Real* lb, /**< lower bounds of columns */
683  const SCIP_Real* ub, /**< upper bounds of columns */
684  char** colnames, /**< column names, or NULL */
685  int nrows, /**< number of rows */
686  const SCIP_Real* lhs, /**< left hand sides of rows */
687  const SCIP_Real* rhs, /**< right hand sides of rows */
688  char** rownames, /**< row names, or NULL */
689  int nnonz, /**< number of nonzero elements in the constraint matrix */
690  const int* beg, /**< start index of each column in ind- and val-array */
691  const int* ind, /**< row indices of constraint matrix entries */
692  const SCIP_Real* val /**< values of constraint matrix entries */
693  )
694 {
695 #ifndef NDEBUG
696  {
697  int j;
698  for( j = 0; j < nnonz; j++ )
699  assert( val[j] != 0 );
700  }
701 #endif
702 
703  SCIPdebugMessage("calling SCIPlpiLoadColLP()\n");
704 
705  assert(lpi != NULL);
706  assert(lpi->clp != NULL);
707  assert(lhs != NULL);
708  assert(rhs != NULL);
709  assert(obj != NULL);
710  assert(lb != NULL);
711  assert(ub != NULL);
712  assert(beg != NULL);
713  assert(ind != NULL);
714  assert(val != NULL);
715 
716  assert( nnonz > beg[ncols-1] );
717 
718  invalidateSolution(lpi);
719 
720  ClpSimplex* clp = lpi->clp;
721 
722  // copy beg-array
723  int* mybeg = NULL;
724  SCIP_ALLOC( BMSallocMemoryArray(&mybeg, ncols + 1) );
725  BMScopyMemoryArray(mybeg, beg, ncols);
726  mybeg[ncols] = nnonz; // add additional entry at end
727 
728  // load problem
729  clp->loadProblem(ncols, nrows, mybeg, ind, val, lb, ub, obj, lhs, rhs);
730  BMSfreeMemoryArray( &mybeg );
731 
732  // set objective sense
733  clp->setOptimizationDirection(objsen);
734 
735  // copy column and rownames if necessary
736  if ( colnames || rownames )
737  {
738  std::vector<std::string> columnNames(ncols);
739  std::vector<std::string> rowNames(nrows);
740  if (colnames)
741  {
742  for (int j = 0; j < ncols; ++j)
743  columnNames[j].assign(colnames[j]);
744  }
745  if (rownames)
746  {
747  for (int i = 0; i < ncols; ++i)
748  rowNames[i].assign(rownames[i]);
749  }
750  clp->copyNames(rowNames, columnNames);
751  }
752 
753  return SCIP_OKAY;
754 }
755 
756 
757 /** adds columns to the LP */
759  SCIP_LPI* lpi, /**< LP interface structure */
760  int ncols, /**< number of columns to be added */
761  const SCIP_Real* obj, /**< objective function values of new columns */
762  const SCIP_Real* lb, /**< lower bounds of new columns */
763  const SCIP_Real* ub, /**< upper bounds of new columns */
764  char** colnames, /**< column names, or 0 */
765  int nnonz, /**< number of nonzero elements to be added to the constraint matrix */
766  const int* beg, /**< start index of each column in ind- and val-array, or 0 if nnonz == 0 */
767  const int* ind, /**< row indices of constraint matrix entries, or 0 if nnonz == 0 */
768  const SCIP_Real* val /**< values of constraint matrix entries, or 0 if nnonz == 0 */
769  )
770 {
771  SCIPdebugMessage("calling SCIPlpiAddCols()\n");
772 
773  assert(lpi != NULL);
774  assert(lpi->clp != NULL);
775  assert(obj != NULL);
776  assert(lb != NULL);
777  assert(ub != NULL);
778  assert(nnonz == 0 || beg != NULL);
779  assert(nnonz == 0 || ind != NULL);
780  assert(nnonz == 0 || val != NULL);
781  assert(nnonz >= 0);
782  assert(ncols >= 0);
783 
784  invalidateSolution(lpi);
785 
786  // store number of columns for later
787  int numCols = lpi->clp->getNumCols();
788 
789  // copy beg-array (if not 0)
790  int* mybeg = NULL;
791  SCIP_ALLOC( BMSallocMemoryArray(&mybeg, ncols + 1) );
792 
793  // if columns are not empty
794  if ( nnonz != 0 )
795  {
796 #ifndef NDEBUG
797  {
798  int j;
799  for( j = 0; j < nnonz; j++ )
800  {
801  assert( val[j] != 0.0 );
802  /* perform check that no new rows are added - this is forbidden */
803  assert( 0 <= ind[j] /*&& ind[j] < lpi->nrows*/ );
804  }
805  }
806 #endif
807  BMScopyMemoryArray(mybeg, beg, ncols);
808  mybeg[ncols] = nnonz; // add additional entry at end
809 
810  // add columns
811  lpi->clp->addColumns(ncols, lb, ub, obj, mybeg, ind, val);
812  }
813  else
814  {
815  for (int j = 0; j <= ncols; ++j)
816  mybeg[j] = 0;
817 
818  // add empty columns
819  lpi->clp->addColumns(ncols, lb, ub, obj, mybeg, 0, 0);
820  }
821  BMSfreeMemoryArray(&mybeg);
822 
823  // copy columnnames if necessary
824  if ( colnames )
825  {
826  std::vector<std::string> columnNames(ncols);
827  for (int j = 0; j < ncols; ++j)
828  columnNames[j].assign(colnames[j]);
829  lpi->clp->copyColumnNames(columnNames, numCols, numCols + ncols);
830  }
831 
832  return SCIP_OKAY;
833 }
834 
835 
836 /** deletes all columns in the given range from LP */
838  SCIP_LPI* lpi, /**< LP interface structure */
839  int firstcol, /**< first column to be deleted */
840  int lastcol /**< last column to be deleted */
841  )
842 {
843  SCIPdebugMessage("calling SCIPlpiDelCols()\n");
844 
845  assert(lpi != NULL);
846  assert(lpi->clp != NULL);
847  assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
848 
849  invalidateSolution(lpi);
850 
851  // Current Clp version (1.8) can't delete a range of columns; we have to use deleteColumns (see SCIPlpiDelColset)
852  int num = lastcol-firstcol+1;
853  int* which = NULL;
854  SCIP_ALLOC( BMSallocMemoryArray( &which, num) );;
855 
856  // fill array with interval
857  for (int j = firstcol; j <= lastcol; ++j)
858  which[j - firstcol] = j;
859 
860  lpi->clp->deleteColumns(num, which);
861  BMSfreeMemoryArray( &which );
862 
863  return SCIP_OKAY;
864 }
865 
866 
867 /** deletes columns from SCIP_LPI; the new position of a column must not be greater that its old position */
869  SCIP_LPI* lpi, /**< LP interface structure */
870  int* dstat /**< deletion status of columns
871  * input: 1 if column should be deleted, 0 if not
872  * output: new position of column, -1 if column was deleted */
873  )
874 {
875  SCIPdebugMessage("calling SCIPlpiDelColset()\n");
876 
877  assert(lpi != NULL);
878  assert(lpi->clp != NULL);
879  assert(dstat != NULL);
880 
881  invalidateSolution(lpi);
882 
883  // transform dstat information
884  int ncols = lpi->clp->getNumCols();
885  int* which = NULL;
886  SCIP_ALLOC( BMSallocMemoryArray( &which, ncols) );
887  int cnt = 0;
888  for (int j = 0; j < ncols; ++j)
889  {
890  if ( dstat[j] == 1 )
891  which[cnt++] = j;
892  }
893  lpi->clp->deleteColumns(cnt, which);
894  BMSfreeMemoryArray(&which);
895 
896  // update dstat
897  cnt = 0;
898  for (int j = 0; j < ncols; ++j)
899  {
900  if ( dstat[j] == 1 )
901  {
902  dstat[j] = -1;
903  ++cnt;
904  }
905  else
906  dstat[j] = j - cnt;
907  }
908 
909  return SCIP_OKAY;
910 }
911 
912 
913 /** adds rows to the LP */
915  SCIP_LPI* lpi, /**< LP interface structure */
916  int nrows, /**< number of rows to be added */
917  const SCIP_Real* lhs, /**< left hand sides of new rows */
918  const SCIP_Real* rhs, /**< right hand sides of new rows */
919  char** rownames, /**< row names, or NULL */
920  int nnonz, /**< number of nonzero elements to be added to the constraint matrix */
921  const int* beg, /**< start index of each row in ind- and val-array, or NULL if nnonz == 0 */
922  const int* ind, /**< column indices of constraint matrix entries, or NULL if nnonz == 0 */
923  const SCIP_Real* val /**< values of constraint matrix entries, or NULL if nnonz == 0 */
924  )
925 {
926  SCIPdebugMessage("calling SCIPlpiAddRows()\n");
927 
928  assert(lpi != NULL);
929  assert(lpi->clp != NULL);
930  assert(lhs != NULL);
931  assert(rhs != NULL);
932  assert(nnonz == 0 || beg != NULL);
933  assert(nnonz == 0 || ind != NULL);
934  assert(nnonz == 0 || val != NULL);
935 
936  invalidateSolution(lpi);
937 
938  // store number of rows for later use
939  int numRows = lpi->clp->getNumRows();
940 
941  int* mybeg = NULL;
942  SCIP_ALLOC( BMSallocMemoryArray( &mybeg, nrows + 1) );
943 
944  if ( nnonz > 0 )
945  {
946 #ifndef NDEBUG
947  /* perform check that no new columns are added - this is likely to be a mistake */
948  int ncols = lpi->clp->getNumCols();
949  for (int j = 0; j < nnonz; ++j)
950  {
951  assert( val[j] != 0.0 );
952  assert( 0 <= ind[j] && ind[j] < ncols );
953  }
954 #endif
955 
956  // copy beg-array
957  BMScopyMemoryArray( mybeg, beg, nrows);
958  mybeg[nrows] = nnonz; // add additional entry at end
959 
960  // add rows
961  lpi->clp->addRows(nrows, lhs, rhs, mybeg, ind, val);
962  }
963  else
964  {
965  // add empty rows
966  for (int i = 0; i <= nrows; ++i)
967  mybeg[i] = 0;
968  lpi->clp->addRows(nrows, lhs, rhs, mybeg, 0, 0);
969  }
970  BMSfreeMemoryArray( &mybeg );
971 
972  // copy rownames if necessary
973  if ( rownames )
974  {
975  std::vector<std::string> rowNames(nrows);
976  for (int j = 0; j < nrows; ++j)
977  rowNames[j].assign(rownames[j]);
978  lpi->clp->copyRowNames(rowNames, numRows, numRows + nrows);
979  }
980 
981  return SCIP_OKAY;
982 }
983 
984 
985 /** deletes all rows in the given range from LP */
987  SCIP_LPI* lpi, /**< LP interface structure */
988  int firstrow, /**< first row to be deleted */
989  int lastrow /**< last row to be deleted */
990  )
991 {
992  SCIPdebugMessage("calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
993 
994  assert(lpi != NULL);
995  assert(lpi->clp != NULL);
996  assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
997 
998  invalidateSolution(lpi);
999 
1000  // Current Clp version (1.8) can't delete a range of rows; we have to use deleteRows (see SCIPlpiDelRowset)
1001  int num = lastrow-firstrow+1;
1002  int* which = NULL;
1003  SCIP_ALLOC( BMSallocMemoryArray( &which, num) );
1004 
1005  // fill array with interval
1006  for (int i = firstrow; i <= lastrow; ++i)
1007  which[i - firstrow] = i;
1008 
1009  lpi->clp->deleteRows(num, which);
1010 
1011  BMSfreeMemoryArray( &which );
1012 
1013  return SCIP_OKAY;
1014 }
1015 
1016 
1017 /** deletes rows from SCIP_LP; the new position of a row must not be greater that its old position */
1019  SCIP_LPI* lpi, /**< LP interface structure */
1020  int* dstat /**< deletion status of rows
1021  * input: 1 if row should be deleted, 0 if not
1022  * output: new position of row, -1 if row was deleted */
1023  )
1024 {
1025  SCIPdebugMessage("calling SCIPlpiDelRowset()\n");
1026 
1027  assert(lpi != NULL);
1028  assert(lpi->clp != NULL);
1029  assert(dstat != 0);
1030 
1031  invalidateSolution(lpi);
1032 
1033  // transform dstat information
1034  int nrows = lpi->clp->getNumRows();
1035  int* which = NULL;
1036  SCIP_ALLOC( BMSallocMemoryArray( &which, nrows) );
1037  int cnt = 0;
1038  for (int i = 0; i < nrows; ++i)
1039  {
1040  if ( dstat[i] == 1 )
1041  which[cnt++] = i;
1042  }
1043  lpi->clp->deleteRows(cnt, which);
1044  BMSfreeMemoryArray( &which );
1045 
1046  // update dstat
1047  cnt = 0;
1048  for (int i = 0; i < nrows; ++i)
1049  {
1050  if ( dstat[i] == 1 )
1051  {
1052  dstat[i] = -1;
1053  ++cnt;
1054  }
1055  else
1056  dstat[i] = i - cnt;
1057  }
1058 
1059  return SCIP_OKAY;
1060 }
1061 
1062 
1063 /** clears the whole LP */
1065  SCIP_LPI* lpi /**< LP interface structure */
1066  )
1067 {
1068  SCIPdebugMessage("calling SCIPlpiClear()\n");
1069 
1070  assert(lpi != NULL);
1071  assert(lpi->clp != NULL);
1072 
1073  invalidateSolution(lpi);
1074  lpi->lastalgorithm = 0;
1075 
1076  // We use the resize(0,0) to get rid of the model but keep all other settings
1077  lpi->clp->resize(0,0);
1078 
1079  return SCIP_OKAY;
1080 }
1081 
1082 
1083 /** changes lower and upper bounds of columns */
1085  SCIP_LPI* lpi, /**< LP interface structure */
1086  int ncols, /**< number of columns to change bounds for */
1087  const int* ind, /**< column indices or NULL if ncols is zero */
1088  const SCIP_Real* lb, /**< values for the new lower bounds or NULL if ncols is zero */
1089  const SCIP_Real* ub /**< values for the new upper bounds or NULL if ncols is zero */
1090  )
1091 {
1092  assert(lpi != NULL);
1093  assert(lpi->clp != NULL);
1094  assert(ncols == 0 || (ind != NULL && lb != NULL && ub != NULL));
1095 
1096  SCIPdebugMessage("calling SCIPlpiChgBounds()\n");
1097  if( ncols <= 0 )
1098  return SCIP_OKAY;
1099 
1100  invalidateSolution(lpi);
1101 
1102  ClpSimplex* clp = lpi->clp;
1103 
1104 #if SCIP_DISABLED_CODE
1105  /* The following bugfix was necessary some time ago to avoid an error in Clp and can currently be disabled: the
1106  * solution vector is modified to be set to the corresponding bounds. Remove if Clp versions have stabilized. */
1107  double* sol = lpi->clp->primalColumnSolution();
1108  const double* colLower = lpi->clp->getColLower();
1109  const double* colUpper = lpi->clp->getColUpper();
1110 #endif
1111 
1112  for (int j = 0; j < ncols; ++j)
1113  {
1114  if ( SCIPlpiIsInfinity(lpi, lb[j]) )
1115  {
1116  SCIPerrorMessage("LP Error: fixing lower bound for variable %d to infinity.\n", ind[j]);
1117  return SCIP_LPERROR;
1118  }
1119  if ( SCIPlpiIsInfinity(lpi, -ub[j]) )
1120  {
1121  SCIPerrorMessage("LP Error: fixing upper bound for variable %d to -infinity.\n", ind[j]);
1122  return SCIP_LPERROR;
1123  }
1124 
1125  clp->setColumnBounds(ind[j], lb[j], ub[j]);
1126 
1127 #if SCIP_DISABLED_CODE
1128  /* Old bugfix, not currently needed - see above */
1129  if ( sol != 0 )
1130  {
1131  if( clp->statusExists() )
1132  {
1133  assert( colLower != 0 );
1134  assert( colUpper != 0 );
1135  int k = ind[j];
1136  switch ( clp->getColumnStatus(k) )
1137  {
1138  case ClpSimplex::isFree:
1139  case ClpSimplex::superBasic:
1140  sol[k] = 0.0;
1141  break;
1142  case ClpSimplex::atUpperBound:
1143  sol[k] = colUpper[k];
1144  assert( colUpper[k] == ub[j] );
1145  break;
1146  case ClpSimplex::isFixed:
1147  case ClpSimplex::atLowerBound:
1148  sol[k] = colLower[k];
1149  assert( colLower[k] == lb[j] );
1150  break;
1151  default:;
1152  }
1153  }
1154  else
1155  { /* workaround: if there is no status, we assume something */
1156  sol[ind[j]] = 0.0;
1157  }
1158  }
1159 #endif
1160  }
1161 
1162  return SCIP_OKAY;
1163 }
1164 
1165 
1166 /** changes left and right hand sides of rows */
1168  SCIP_LPI* lpi, /**< LP interface structure */
1169  int nrows, /**< number of rows to change sides for */
1170  const int* ind, /**< row indices */
1171  const SCIP_Real* lhs, /**< new values for left hand sides */
1172  const SCIP_Real* rhs /**< new values for right hand sides */
1173  )
1174 {
1175  SCIPdebugMessage("calling SCIPlpiChgSides()\n");
1176 
1177  assert(lpi != NULL);
1178  assert(lpi->clp != NULL);
1179  assert(ind != NULL);
1180  assert(lhs != NULL);
1181  assert(rhs != NULL);
1182  if( nrows <= 0)
1183  return SCIP_OKAY;
1184 
1185  invalidateSolution(lpi);
1186 
1187  ClpSimplex* clp = lpi->clp;
1188 
1189  for (int i = 0; i < nrows; ++i)
1190  clp->setRowBounds(ind[i], lhs[i], rhs[i]);
1191 
1192  return SCIP_OKAY;
1193 }
1194 
1195 
1196 /** changes a single coefficient */
1198  SCIP_LPI* lpi, /**< LP interface structure */
1199  int row, /**< row number of coefficient to change */
1200  int col, /**< column number of coefficient to change */
1201  SCIP_Real newval /**< new value of coefficient */
1202  )
1203 {
1204  SCIPdebugMessage("calling SCIPlpiChgCoef()\n");
1205 
1206  assert(lpi != NULL);
1207  assert(lpi->clp != NULL);
1208  assert(0 <= row && row < lpi->clp->numberRows());
1209  assert(0 <= col && col < lpi->clp->numberColumns());
1210 
1211  invalidateSolution(lpi);
1212 
1213  lpi->clp->matrix()->modifyCoefficient(row, col, newval);
1214 
1215  return SCIP_OKAY;
1216 }
1217 
1218 
1219 /** changes the objective sense */
1221  SCIP_LPI* lpi, /**< LP interface structure */
1222  SCIP_OBJSEN objsen /**< new objective sense */
1223  )
1224 {
1225  SCIPdebugMessage("calling SCIPlpiChgObjsen()\n");
1226 
1227  assert(lpi != NULL);
1228  assert(lpi->clp != NULL);
1229 
1230  invalidateSolution(lpi);
1231 
1232  // set objective sense: SCIP values are the same as the ones for Clp
1233  lpi->clp->setOptimizationDirection(objsen);
1234 
1235  return SCIP_OKAY;
1236 }
1237 
1238 
1239 /** changes objective values of columns in the LP */
1241  SCIP_LPI* lpi, /**< LP interface structure */
1242  int ncols, /**< number of columns to change objective value for */
1243  const int* ind, /**< column indices to change objective value for */
1244  const SCIP_Real* obj /**< new objective values for columns */
1245  )
1246 {
1247  SCIPdebugMessage("calling SCIPlpiChgObj()\n");
1248 
1249  assert(lpi != NULL);
1250  assert(lpi->clp != NULL);
1251  assert(ind != NULL);
1252  assert(obj != NULL);
1253 
1254  invalidateSolution(lpi);
1255 
1256  ClpSimplex* clp = lpi->clp;
1257 
1258  // updates whatsChanged in Clp (bound checking in Clp)
1259  for( int j = 0; j < ncols; ++j )
1260  clp->setObjCoeff(ind[j], obj[j]); // inlined version of clp->setObjectiveCoefficient(ind[j], obj[j]);
1261 
1262  return SCIP_OKAY;
1263 }
1264 
1265 
1266 /** multiplies a row with a non-zero scalar; for negative scalars, the row's sense is switched accordingly */
1268  SCIP_LPI* lpi, /**< LP interface structure */
1269  int row, /**< row number to scale */
1270  SCIP_Real scaleval /**< scaling multiplier */
1271  )
1272 {
1273  SCIPdebugMessage("calling SCIPlpiScaleRow()\n");
1274 
1275  assert(lpi != NULL);
1276  assert(lpi->clp != NULL);
1277  assert(scaleval != 0.0);
1278  assert(0 <= row && row <= lpi->clp->numberRows() );
1279 
1280  invalidateSolution(lpi);
1281 
1282  // Note: if the scaling should be performed because of numerical stability,
1283  // there are other more effective methods in Clp to adjust the scaling values
1284  // for each row.
1285 
1286  ClpSimplex* clp = lpi->clp;
1287 
1288  // adjust the sides
1289  double* lhs = clp->rowLower();
1290  double* rhs = clp->rowUpper();
1291 
1292  double lhsval = lhs[row];
1293  if( lhsval > -COIN_DBL_MAX )
1294  lhsval *= scaleval;
1295  else if( scaleval < 0.0 )
1296  lhsval = COIN_DBL_MAX;
1297  double rhsval = rhs[row];
1298  if( rhsval < COIN_DBL_MAX)
1299  rhsval *= scaleval;
1300  else if( scaleval < 0.0 )
1301  rhsval = -COIN_DBL_MAX;
1302  if( scaleval < 0.0 )
1303  {
1304  SCIP_Real oldlhs = lhsval;
1305  lhsval = rhsval;
1306  rhsval = oldlhs;
1307  }
1308  lhs[row] = lhsval; // change values directly into Clp data!
1309  rhs[row] = rhsval;
1310 
1311  // apply scaling ...
1312 
1313  // WARNING: the following is quite expensive:
1314  // We have to loop over the matrix to find the row entries.
1315  // For columns we can do better, see @c SCIPlpiScaleCol.
1316  CoinPackedMatrix* M = clp->matrix();
1317  assert( M->getNumCols() == clp->numberColumns() );
1318 
1319  const CoinBigIndex* beg = M->getVectorStarts();
1320  const int* length = M->getVectorLengths();
1321  const int* ind = M->getIndices();
1322  double* val = M->getMutableElements();
1323 
1324  for (int j = 0; j < M->getNumCols(); ++j)
1325  {
1326  for (CoinBigIndex k = beg[j]; k < beg[j] + length[j]; ++k)
1327  {
1328  if (ind[k] == row)
1329  val[k] *= scaleval;
1330  }
1331  }
1332 
1333  return SCIP_OKAY;
1334 }
1335 
1336 
1337 /** multiplies a column with a non-zero scalar; the objective value is multiplied with the scalar, and the bounds
1338  * are divided by the scalar; for negative scalars, the column's bounds are switched
1339  */
1341  SCIP_LPI* lpi, /**< LP interface structure */
1342  int col, /**< column number to scale */
1343  SCIP_Real scaleval /**< scaling multiplier */
1344  )
1345 {
1346  SCIPdebugMessage("calling SCIPlpiScaleCol()\n");
1347 
1348  assert(lpi != NULL);
1349  assert(lpi->clp != NULL);
1350  assert(scaleval != 0.0);
1351  assert(0 <= col && col <= lpi->clp->numberColumns() );
1352 
1353  invalidateSolution(lpi);
1354 
1355  // Note: if the scaling should be performed because of numerical stability,
1356  // there are other more effective methods in Clp to adjust the scaling values
1357  // for each column.
1358 
1359  ClpSimplex* clp = lpi->clp;
1360 
1361  // adjust the objective coefficients
1362  double* objvec = clp->objective(); // we have direct access to the data of Clp!
1363  objvec[col] *= scaleval; // adjust the objective function value
1364 
1365  // adjust the bounds
1366  double* lb = clp->columnLower();
1367  double* ub = clp->columnUpper();
1368  double lbval = lb[col];
1369  double ubval = ub[col];
1370 
1371  if( lbval > -COIN_DBL_MAX )
1372  lbval /= scaleval;
1373  else if( scaleval < 0.0 )
1374  lbval = COIN_DBL_MAX;
1375  if( ubval < COIN_DBL_MAX )
1376  ubval /= scaleval;
1377  else if( scaleval < 0.0 )
1378  ubval = -COIN_DBL_MAX;
1379  if( scaleval < 0.0 )
1380  {
1381  SCIP_Real oldlb = lbval;
1382  lbval = ubval;
1383  ubval = oldlb;
1384  }
1385  lb[col] = lbval; // directly adjust values into Clp data
1386  ub[col] = ubval;
1387 
1388  // apply scaling directly to matrix (adapted from ClpPackedMatrix::reallyScale)
1389  // See also ClpModel::gutsOfScaling ...
1390  CoinPackedMatrix* M = clp->matrix();
1391  assert( M->getNumCols() == clp->numberColumns() );
1392 
1393  const CoinBigIndex* beg = M->getVectorStarts();
1394  const int* length = M->getVectorLengths();
1395  double* val = M->getMutableElements();
1396  for (CoinBigIndex k = beg[col]; k < beg[col] + length[col]; ++k)
1397  val[k] *= scaleval;
1398 
1399  return SCIP_OKAY;
1400 }
1401 
1402 
1403 
1404 /**@} */
1405 
1406 
1407 
1408 
1409 /*
1410  * Data Accessing Methods
1411  */
1412 
1413 /**@name Data Accessing Methods */
1414 /**@{ */
1415 
1416 /** gets the number of rows in the LP */
1418  SCIP_LPI* lpi, /**< LP interface structure */
1419  int* nrows /**< pointer to store the number of rows */
1420  )
1421 {
1422  SCIPdebugMessage("calling SCIPlpiGetNRows()\n");
1423 
1424  assert(lpi != NULL);
1425  assert(lpi->clp != NULL);
1426  assert(nrows != NULL);
1427 
1428  *nrows = lpi->clp->numberRows();
1429 
1430  return SCIP_OKAY;
1431 }
1432 
1433 
1434 /** gets the number of columns in the LP */
1436  SCIP_LPI* lpi, /**< LP interface structure */
1437  int* ncols /**< pointer to store the number of cols */
1438  )
1439 {
1440  SCIPdebugMessage("calling SCIPlpiGetNCols()\n");
1441 
1442  assert(lpi != NULL);
1443  assert(lpi->clp != NULL);
1444  assert(ncols != NULL);
1445 
1446  *ncols = lpi->clp->numberColumns();
1447 
1448  return SCIP_OKAY;
1449 }
1450 
1451 
1452 /** gets the number of nonzero elements in the LP constraint matrix */
1454  SCIP_LPI* lpi, /**< LP interface structure */
1455  int* nnonz /**< pointer to store the number of nonzeros */
1456  )
1457 {
1458  SCIPdebugMessage("calling SCIPlpiGetNNonz()\n");
1459 
1460  assert(lpi != NULL);
1461  assert(lpi->clp != NULL);
1462  assert(nnonz != NULL);
1463 
1464  *nnonz = lpi->clp->getNumElements();
1465 
1466  return SCIP_OKAY;
1467 }
1468 
1469 
1470 /** gets columns from LP problem object; the arrays have to be large enough to store all values
1471  * Either both, lb and ub, have to be NULL, or both have to be non-NULL,
1472  * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL.
1473  */
1475  SCIP_LPI* lpi, /**< LP interface structure */
1476  int firstcol, /**< first column to get from LP */
1477  int lastcol, /**< last column to get from LP */
1478  SCIP_Real* lb, /**< buffer to store the lower bound vector, or NULL */
1479  SCIP_Real* ub, /**< buffer to store the upper bound vector, or NULL */
1480  int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */
1481  int* beg, /**< buffer to store start index of each column in ind- and val-array, or NULL */
1482  int* ind, /**< buffer to store row indices of constraint matrix entries, or NULL */
1483  SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
1484  )
1485 {
1486  SCIPdebugMessage("calling SCIPlpiGetCols()\n");
1487 
1488  assert(lpi != NULL);
1489  assert(lpi->clp != NULL);
1490  assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1491  assert((lb != NULL && ub != NULL) || (lb == NULL && ub == NULL));
1492  assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1493 
1494  ClpSimplex* clp = lpi->clp;
1495 
1496  // get lower and upper bounds for the variables
1497  if ( lb != NULL )
1498  {
1499  const double* colLower = clp->getColLower(); // Here we can use the const versions (see SCIPchgBounds)
1500  const double* colUpper = clp->getColUpper();
1501 
1502  BMScopyMemoryArray( lb, colLower + firstcol, (lastcol - firstcol + 1));
1503  BMScopyMemoryArray( ub, colUpper + firstcol, (lastcol - firstcol + 1));
1504  }
1505 
1506  if ( nnonz != NULL )
1507  {
1508  CoinPackedMatrix* M = clp->matrix();
1509  assert( M != NULL );
1510  assert( M->getNumCols() == clp->numberColumns() );
1511 
1512  const CoinBigIndex* Mbeg = M->getVectorStarts(); // can use const versions
1513  const int* Mlength = M->getVectorLengths();
1514  const int* Mind = M->getIndices();
1515  const double* Mval = M->getElements();
1516 
1517  *nnonz = 0;
1518  // can we use memcpy for the whole set (requires that columns are stored sequentially)
1519  for (int j = firstcol; j <= lastcol; ++j)
1520  {
1521  beg[j-firstcol] = *nnonz;
1522 
1523  BMScopyMemoryArray( (ind + (*nnonz)), Mind + Mbeg[j], Mlength[j]);
1524  BMScopyMemoryArray( (val + (*nnonz)), Mval + Mbeg[j], Mlength[j]);
1525 
1526  (*nnonz) += Mlength[j];
1527  }
1528  }
1529 
1530  return SCIP_OKAY;
1531 }
1532 
1533 
1534 /** gets rows from LP problem object; the arrays have to be large enough to store all values.
1535  * Either both, lhs and rhs, have to be NULL, or both have to be non-NULL,
1536  * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL.
1537  */
1539  SCIP_LPI* lpi, /**< LP interface structure */
1540  int firstrow, /**< first row to get from LP */
1541  int lastrow, /**< last row to get from LP */
1542  SCIP_Real* lhs, /**< buffer to store left hand side vector, or NULL */
1543  SCIP_Real* rhs, /**< buffer to store right hand side vector, or NULL */
1544  int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */
1545  int* beg, /**< buffer to store start index of each row in ind- and val-array, or NULL */
1546  int* ind, /**< buffer to store column indices of constraint matrix entries, or NULL */
1547  SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
1548  )
1549 {
1550  SCIPdebugMessage("calling SCIPlpiGetRows()\n");
1551 
1552  assert(lpi != NULL);
1553  assert(lpi->clp != NULL);
1554  assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1555  assert((lhs != NULL && rhs != NULL) || (lhs == NULL && rhs == NULL));
1556  assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1557 
1558  ClpSimplex* clp = lpi->clp;
1559  if ( lhs != NULL )
1560  {
1561  const double* rowLower = clp->getRowLower(); // Here we can use the const versions (see SCIPchgSides)
1562  const double* rowUpper = clp->getRowUpper();
1563 
1564  BMScopyMemoryArray( lhs, rowLower + firstrow, (lastrow - firstrow + 1) );
1565  BMScopyMemoryArray( rhs, rowUpper + firstrow, (lastrow - firstrow + 1) );
1566  }
1567 
1568  if ( nnonz != NULL )
1569  {
1570  ClpMatrixBase* M = clp->rowCopy(); // get row view on matrix
1571  if ( M == NULL ) // can happen e.g. if no LP was solved yet ...
1572  M = clp->clpMatrix()->reverseOrderedCopy();
1573  assert( M != NULL );
1574  assert( M->getNumRows() == clp->numberRows() );
1575 
1576  const CoinBigIndex* Mbeg = M->getVectorStarts();
1577  const int* Mlength = M->getVectorLengths();
1578  const int* Mind = M->getIndices();
1579  const double* Mval = M->getElements();
1580 
1581  *nnonz = 0;
1582  for( int i = firstrow; i <= lastrow; ++i )
1583  {
1584  beg[i-firstrow] = *nnonz;
1585  for( CoinBigIndex k = Mbeg[i]; k < Mbeg[i] + Mlength[i]; ++k )
1586  {
1587  ind[*nnonz] = Mind[k];
1588  val[*nnonz] = Mval[k];
1589  (*nnonz)++;
1590  }
1591  }
1592  }
1593 
1594  return SCIP_OKAY;
1595 }
1596 
1597 
1598 /** gets column names */
1600  SCIP_LPI* lpi, /**< LP interface structure */
1601  int firstcol, /**< first column to get name from LP */
1602  int lastcol, /**< last column to get name from LP */
1603  char** colnames, /**< pointers to column names (of size at least lastcol-firstcol+1) or NULL if namestoragesize is zero */
1604  char* namestorage, /**< storage for col names or NULL if namestoragesize is zero */
1605  int namestoragesize, /**< size of namestorage (if 0, storageleft returns the storage needed) */
1606  int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) or NULL if namestoragesize is zero */
1607  )
1608 {
1609  assert(lpi != NULL);
1610  assert(lpi->clp != NULL);
1611  assert(colnames != NULL || namestoragesize == 0);
1612  assert(namestorage != NULL || namestoragesize == 0);
1613  assert(namestoragesize >= 0);
1614  assert(storageleft != NULL);
1615 
1616  SCIPerrorMessage("SCIPlpiGetColNames() has not been implemented yet.\n");
1617 
1618  return SCIP_LPERROR;
1619 }
1620 
1621 
1622 /** gets row names */
1624  SCIP_LPI* lpi, /**< LP interface structure */
1625  int firstrow, /**< first row to get name from LP */
1626  int lastrow, /**< last row to get name from LP */
1627  char** rownames, /**< pointers to row names (of size at least lastrow-firstrow+1) or NULL if namestoragesize is zero */
1628  char* namestorage, /**< storage for row names or NULL if namestoragesize is zero */
1629  int namestoragesize, /**< size of namestorage (if 0, -storageleft returns the storage needed) */
1630  int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) or NULL if namestoragesize is zero */
1631  )
1632 {
1633  assert(lpi != NULL);
1634  assert(lpi->clp != NULL);
1635  assert(rownames != NULL || namestoragesize == 0);
1636  assert(namestorage != NULL || namestoragesize == 0);
1637  assert(namestoragesize >= 0);
1638  assert(storageleft != NULL);
1639 
1640  SCIPerrorMessage("SCIPlpiGetRowNames() has not been implemented yet.\n");
1641 
1642  return SCIP_LPERROR;
1643 }
1644 
1645 
1646 /** tries to reset the internal status of the LP solver in order to ignore an instability of the last solving call */
1648  SCIP_LPI* lpi, /**< LP interface structure */
1649  SCIP_Bool* success /**< pointer to store, whether the instability could be ignored */
1650  )
1651 {
1652  SCIPdebugMessage("calling SCIPlpiIgnoreInstability()\n");
1653 
1654  assert(lpi != NULL);
1655  assert(lpi->clp != NULL);
1656  assert(success != NULL);
1657 
1658  /* Unstable situations are currently not ignored. Could fix this similar to lpi_cpx by adjusting the solution status. */
1659  *success = FALSE;
1660 
1661  return SCIP_OKAY;
1662 }
1663 
1664 
1665 /** gets the objective sense of the LP */
1667  SCIP_LPI* lpi, /**< LP interface structure */
1668  SCIP_OBJSEN* objsen /**< pointer to store objective sense */
1669  )
1670 {
1671  assert( lpi != NULL );
1672  assert( lpi->clp != NULL );
1673  assert( objsen != NULL );
1674 
1675  // Clp direction of optimization (1 - minimize, -1 - maximize, 0 - ignore)
1676  if ( lpi->clp->getObjSense() < 0 )
1677  *objsen = SCIP_OBJSEN_MAXIMIZE;
1678  else
1679  *objsen = SCIP_OBJSEN_MINIMIZE;
1680 
1681  return SCIP_OKAY;
1682 }
1683 
1684 
1685 /** gets objective coefficients from LP problem object */
1687  SCIP_LPI* lpi, /**< LP interface structure */
1688  int firstcol, /**< first column to get objective coefficient for */
1689  int lastcol, /**< last column to get objective coefficient for */
1690  SCIP_Real* vals /**< array to store objective coefficients */
1691  )
1692 {
1693  SCIPdebugMessage("calling SCIPlpiGetObj()\n");
1694 
1695  assert(lpi != NULL);
1696  assert(lpi->clp != NULL);
1697  assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1698  assert(vals != NULL);
1699 
1700  const double* obj = lpi->clp->getObjCoefficients(); // Here we can use the const versions (see SCIPchgObj)
1701 
1702  BMScopyMemoryArray(vals, obj + firstcol, (lastcol - firstcol + 1) );
1703 
1704  return SCIP_OKAY;
1705 }
1706 
1707 
1708 /** gets current bounds from LP problem object */
1710  SCIP_LPI* lpi, /**< LP interface structure */
1711  int firstcol, /**< first column to get objective value for */
1712  int lastcol, /**< last column to get objective value for */
1713  SCIP_Real* lbs, /**< array to store lower bound values, or NULL */
1714  SCIP_Real* ubs /**< array to store upper bound values, or NULL */
1715  )
1716 {
1717  SCIPdebugMessage("calling SCIPlpiGetBounds()\n");
1718 
1719  assert(lpi != NULL);
1720  assert(lpi->clp != NULL);
1721  assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1722 
1723  if ( lbs != 0 )
1724  {
1725  const double* colLower = lpi->clp->getColLower(); // Here we can use the const versions (see SCIPchgBounds)
1726  BMScopyMemoryArray( lbs, colLower + firstcol, (lastcol - firstcol + 1) );
1727  }
1728 
1729  if ( ubs != 0 )
1730  {
1731  const double* colUpper = lpi->clp->getColUpper();
1732  BMScopyMemoryArray( ubs, colUpper + firstcol, (lastcol - firstcol + 1) );
1733  }
1734 
1735  return SCIP_OKAY;
1736 }
1737 
1738 
1739 /** gets current row sides from LP problem object */
1741  SCIP_LPI* lpi, /**< LP interface structure */
1742  int firstrow, /**< first row to get sides for */
1743  int lastrow, /**< last row to get sides for */
1744  SCIP_Real* lhss, /**< array to store left hand side values, or NULL */
1745  SCIP_Real* rhss /**< array to store right hand side values, or NULL */
1746  )
1747 {
1748  SCIPdebugMessage("calling SCIPlpiGetSides()\n");
1749 
1750  assert(lpi != NULL);
1751  assert(lpi->clp != NULL);
1752  assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1753 
1754  if ( lhss != 0 )
1755  {
1756  const double* rowLower = lpi->clp->getRowLower(); // Here we can use the const versions (see SCIPchgSides)
1757  BMScopyMemoryArray( lhss, rowLower + firstrow, (lastrow - firstrow + 1) );
1758  }
1759 
1760  if ( rhss != 0 )
1761  {
1762  const double* rowUpper = lpi->clp->getRowUpper();
1763  BMScopyMemoryArray( rhss, rowUpper + firstrow, (lastrow - firstrow + 1) );
1764  }
1765 
1766  return SCIP_OKAY;
1767 }
1768 
1769 
1770 /** gets a single coefficient */
1772  SCIP_LPI* lpi, /**< LP interface structure */
1773  int row, /**< row number of coefficient */
1774  int col, /**< column number of coefficient */
1775  SCIP_Real* val /**< pointer to store the value of the coefficient */
1776  )
1777 {
1778  SCIPdebugMessage("calling SCIPlpiGetCoef()\n");
1779 
1780  assert(lpi != NULL);
1781  assert(lpi->clp != NULL);
1782  assert(0 <= col && col < lpi->clp->numberColumns());
1783  assert(0 <= row && row < lpi->clp->numberRows());
1784  assert(val != NULL);
1785 
1786  *val = lpi->clp->matrix()->getCoefficient(row, col);
1787 
1788  return SCIP_OKAY;
1789 }
1790 
1791 /**@} */
1792 
1793 
1794 
1795 
1796 /*
1797  * Solving Methods
1798  */
1799 
1800 /**@name Solving Methods */
1801 /**@{ */
1802 
1803 
1804 /** calls primal simplex to solve the LP */
1806  SCIP_LPI* lpi /**< LP interface structure */
1807  )
1808 {
1809  assert(lpi != NULL);
1810  assert(lpi->clp != NULL);
1811 
1812  SCIPdebugMessage("calling Clp primal(): %d cols, %d rows\n", lpi->clp->numberColumns(), lpi->clp->numberRows());
1813 
1814 #ifdef LPI_CLP_DEBUG_WRITE_FILES
1815  char filename[255];
1816  snprintf(filename, 255, "debug_p_%d.mps", fileNr);
1817  fileNr = fileNr % 2;
1818  SCIPlpiWriteLP(lpi, filename);
1819  SCIPdebugMessage("Wrote file <%s>\n", filename);
1820 #endif
1821 
1822  invalidateSolution(lpi);
1823 
1824  // initialize factorization freq. depending on model size - applied only once
1826 
1827  // if we want to construct a new basis
1828  if ( lpi->startscratch )
1829  {
1830  lpi->clp->allSlackBasis(true); // reset basis
1831  lpi->validFactorization = false;
1832  }
1833 
1834  /* startFinishOptions - bits
1835  * 1 - do not delete work areas and factorization at end
1836  * 2 - use old factorization if same number of rows
1837  * 4 - skip as much initialization of work areas as possible (work in progress)
1838  *
1839  * 4 does not seem to work.
1840  */
1841  int startFinishOptions = 1;
1842  if ( lpi->validFactorization )
1843  startFinishOptions = startFinishOptions | 2;
1844 
1845  /* Primal algorithm */
1846  int status = lpi->clp->primal(0, startFinishOptions);
1847 
1848 #ifdef LPI_CLP_DEBUG_WRITE_FILES
1849  char basisname[255];
1850  snprintf(basisname, 255, "debug_p_%d.bas", fileNr);
1851  SCIP_CALL( SCIPlpiWriteState(lpi, basisname) );
1852  SCIPdebugMessage("Wrote basis file <%s>\n", basisname);
1853  ++fileNr; /* not increased above! */
1854  fileNr = fileNr % 2;
1855 #endif
1856 
1857  lpi->lastalgorithm = 1;
1858  lpi->validFactorization = true;
1859  lpi->solved = TRUE;
1860 
1861  // Unfortunately the status of Clp is hard coded ...
1862  // -1 - did not run
1863  // 0 - optimal
1864  // 1 - primal infeasible
1865  // 2 - dual infeasible
1866  // 3 - stopped on iterations or time
1867  // 4 - stopped due to errors
1868  // 5 - stopped by event handler
1869  assert( status != -1 ); // did not run should not occur
1870  assert( status != 5 ); // begin stopped by event handler should not occur
1871 
1872  if ( status == 4 || status == 5 || status == -1 )
1873  return SCIP_LPERROR;
1874 
1875  return SCIP_OKAY;
1876 }
1877 
1878 
1879 /** calls dual simplex to solve the LP */
1881  SCIP_LPI* lpi /**< LP interface structure */
1882  )
1883 {
1884  assert(lpi != NULL);
1885  assert(lpi->clp != NULL);
1886 
1887  SCIPdebugMessage("calling Clp dual(): %d cols, %d rows\n", lpi->clp->numberColumns(), lpi->clp->numberRows());
1888 
1889 #ifdef LPI_CLP_DEBUG_WRITE_FILES
1890  char filename[255];
1891  snprintf(filename, 255, "debug_d_%d.mps", fileNr);
1892  SCIPlpiWriteLP(lpi, filename);
1893  SCIPdebugMessage("Wrote file <%s>\n", filename);
1894  snprintf(filename, 255, "debug_d_%d.sav", fileNr);
1895  // lpi->clp->saveModel(filename);
1896  SCIPdebugMessage("Wrote file <%s>\n", filename);
1897 #endif
1898 
1899  invalidateSolution(lpi);
1900 
1901  // intialize factorization freq. depending on model size - applied only once
1903 
1904  // if we want to construct a new basis
1905  if( lpi->startscratch )
1906  {
1907  lpi->clp->allSlackBasis(true); // reset basis
1908  lpi->validFactorization = false;
1909  }
1910 
1911  /* startFinishOptions - bits
1912  * 1 - do not delete work areas and factorization at end
1913  * 2 - use old factorization if same number of rows
1914  * 4 - skip as much initialization of work areas as possible (work in progress)
1915  *
1916  * 4 does not seem to work.
1917  */
1918  int startFinishOptions = 1;
1919  if ( lpi->validFactorization )
1920  startFinishOptions = startFinishOptions | 2;
1921 
1922  /* Dual algorithm */
1923  int status = lpi->clp->dual(0, startFinishOptions);
1924 
1925 #ifdef LPI_CLP_DEBUG_WRITE_FILES
1926  char basisname[255];
1927  snprintf(basisname, 255, "debug_d_%d.bas", fileNr);
1928  SCIP_CALL( SCIPlpiWriteState(lpi, basisname) );
1929  SCIPdebugMessage("Wrote basis file <%s>\n", basisname);
1930  ++fileNr; /* not increased above! */
1931  fileNr = fileNr % 2;
1932 #endif
1933 
1934  lpi->lastalgorithm = -1;
1935  lpi->validFactorization = true;
1936  lpi->solved = TRUE;
1937 
1938  // Unfortunately the status of Clp is hard coded ...
1939  // -1 - did not run
1940  // 0 - optimal
1941  // 1 - primal infeasible
1942  // 2 - dual infeasible
1943  // 3 - stopped on iterations or time
1944  // 4 - stopped due to errors
1945  // 5 - stopped by event handler
1946  assert( status != -1 ); // did not run should not occur
1947  assert( status != 5 ); // begin stopped by event handler should not occur
1948 
1949  if ( status == 4 || status == 5 || status == -1 )
1950  return SCIP_LPERROR;
1951 
1952  return SCIP_OKAY;
1953 }
1954 
1955 
1956 /** calls barrier or interior point algorithm to solve the LP with crossover to simplex basis */
1958  SCIP_LPI* lpi, /**< LP interface structure */
1959  SCIP_Bool crossover /**< perform crossover */
1960  )
1961 {
1962  assert(lpi != NULL);
1963  assert(lpi->clp != NULL);
1964 
1965  SCIPdebugMessage("calling Clp barrier(): %d cols, %d rows; crossover: %u\n", lpi->clp->numberColumns(), lpi->clp->numberRows(), crossover);
1966 
1967  invalidateSolution(lpi);
1968 
1969  // Check whether we have a factorization, if yes destroy it (Clp doesn't like it ...)
1970  /*
1971  if (lpi->haveFactorization)
1972  lpi->clp->finish();
1973  */
1974 
1975  // call barrier
1976 #if (CLP_VERSION_MAJOR >= 1 && CLP_VERSION_MINOR > 17) || CLP_VERSION_MAJOR >= 2
1977  int startFinishOptions = 1;
1978  int status = lpi->clp->barrier(crossover, startFinishOptions);
1979 #else
1980  int status = lpi->clp->barrier(crossover);
1981 #endif
1982 
1983  lpi->lastalgorithm = 2;
1984  lpi->solved = TRUE;
1985 
1986  // We may need to call ClpModel::status()
1987 
1988  // Unfortunately the status of Clp is hard coded ...
1989  // -1 - did not run
1990  // 0 - optimal
1991  // 1 - primal infeasible
1992  // 2 - dual infeasible
1993  // 3 - stopped on iterations or time
1994  // 4 - stopped due to errors
1995  // 5 - stopped by event handler
1996  assert( status != -1 ); // did not run should not occur
1997  assert( status != 5 ); // begin stopped by event handler should not occur
1998 
1999  if ( status == 4 || status == 5 || status == -1 )
2000  return SCIP_LPERROR;
2001 
2002  return SCIP_OKAY;
2003 }
2004 
2005 /** start strong branching - call before any strongbranching */
2007  SCIP_LPI* lpi /**< LP interface structure */
2008  )
2009 {
2010  assert(lpi != NULL);
2011  assert(lpi->clp != NULL);
2012 
2013  // currently do nothing; in the future: use code as in OSI
2014  return SCIP_OKAY;
2015 }
2016 
2017 /** end strong branching - call after any strongbranching */
2019  SCIP_LPI* lpi /**< LP interface structure */
2020  )
2021 {
2022  assert(lpi != NULL);
2023  assert(lpi->clp != NULL);
2024 
2025  // currently do nothing; in the future: use code as in OSI
2026  return SCIP_OKAY;
2027 }
2028 
2029 /** performs strong branching iterations on one arbitrary candidate */
2030 static
2032  SCIP_LPI* lpi, /**< LP interface structure */
2033  int col, /**< column to apply strong branching on */
2034  SCIP_Real psol, /**< current primal solution value of column */
2035  int itlim, /**< iteration limit for strong branchings */
2036  SCIP_Real* down, /**< stores dual bound after branching column down */
2037  SCIP_Real* up, /**< stores dual bound after branching column up */
2038  SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound;
2039  * otherwise, it can only be used as an estimate value */
2040  SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound;
2041  * otherwise, it can only be used as an estimate value */
2042  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2043  )
2044 {
2045  SCIPdebugMessage("calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2046 
2047  assert(lpi != NULL);
2048  assert(lpi->clp != NULL);
2049  assert(down != NULL);
2050  assert(up != NULL);
2051  assert(downvalid != NULL);
2052  assert(upvalid != NULL);
2053 
2054  ClpSimplex* clp = lpi->clp;
2055 
2056  // set up output arrays
2057  int ncols = clp->numberColumns();
2058  assert( 0 <= col && col < ncols );
2059  double** outputSolution = NULL;
2060  SCIP_ALLOC( BMSallocMemoryArray( &outputSolution, 2) );
2061  SCIP_ALLOC( BMSallocMemoryArray( &outputSolution[0], ncols) );
2062  SCIP_ALLOC( BMSallocMemoryArray( &outputSolution[1], ncols) );
2063 
2064  int* outputStatus = NULL;
2065  SCIP_ALLOC( BMSallocMemoryArray( &outputStatus, 2) );
2066 
2067  int* outputIterations = NULL;
2068  SCIP_ALLOC( BMSallocMemoryArray( &outputIterations, 2) );
2069 
2070  // set iteration limit
2071  int iterlimit = clp->maximumIterations();
2072  clp->setMaximumIterations(itlim);
2073 
2074  // store objective value
2075  double objval = clp->objectiveValue();
2076 
2077  // store special options for later reset
2078  int specialoptions = clp->specialOptions();
2079 
2080  // lpi->clp->setSpecialOptions(64|128|512|1024|2048|4096|32768|262144|0x02000000);
2081  // use default settings:
2082  lpi->clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2083 
2084  /* 'startfinish' options for strong branching:
2085  * 1 - do not delete work areas and factorization at end
2086  * 2 - use old factorization if same number of rows
2087  * 4 - skip as much initialization of work areas as possible
2088  * (based on whatsChanged in clpmodel.hpp) ** work in progress
2089  *
2090  * 4 does not seem to work in strong branching ...
2091  */
2092  int startFinishOptions = 1;
2093  if ( lpi->validFactorization )
2094  startFinishOptions = startFinishOptions | 2;
2095 
2096  // set new lower and upper bounds for variable
2097  *down = EPSCEIL(psol - 1.0, 1e-06);
2098  *up = EPSFLOOR(psol + 1.0, 1e-06);
2099 
2100  /* For strong branching. On input lower and upper are new bounds while
2101  * on output they are change in objective function values (>1.0e50
2102  * infeasible). Return code is
2103  * 0 if nothing interesting,
2104  * -1 if infeasible both ways and
2105  * +1 if infeasible one way (check values to see which one(s))
2106  * -2 if bad factorization
2107  * Solutions are filled in as well - even down, odd up - also status and number of iterations
2108  *
2109  * The bools are:
2110  * bool stopOnFirstInfeasible
2111  * bool alwaysFinish
2112  *
2113  * At the moment: we need alwaysFinish to get correct bounds.
2114  */
2115  int res = clp->strongBranching(1, &col, up, down, outputSolution, outputStatus, outputIterations, false, true, startFinishOptions);
2116 
2117  // reset special options
2118  clp->setSpecialOptions(specialoptions);
2119 
2120  lpi->validFactorization = true;
2121 
2122  *down += objval;
2123  *up += objval;
2124 
2125  // The bounds returned by CLP seem to be valid using the above options
2126  *downvalid = TRUE;
2127  *upvalid = TRUE;
2128 
2129  // correct iteration count
2130  if (iter)
2131  *iter = outputIterations[0] + outputIterations[1];
2132 
2133  // reset iteration limit
2134  clp->setMaximumIterations(iterlimit);
2135 
2136  // free local memory
2137  BMSfreeMemoryArray( &outputStatus );
2138  BMSfreeMemoryArray( &outputIterations );
2139  BMSfreeMemoryArray( &outputSolution[1] );
2140  BMSfreeMemoryArray( &outputSolution[0] );
2141  BMSfreeMemoryArray( &outputSolution );
2142 
2143  if ( res == -2 )
2144  return SCIP_LPERROR;
2145 
2146  return SCIP_OKAY;
2147 }
2148 
2149 /** performs strong branching iterations on given arbitrary candidates */
2150 static
2152  SCIP_LPI* lpi, /**< LP interface structure */
2153  int* cols, /**< columns to apply strong branching on */
2154  int ncols, /**< number of columns */
2155  SCIP_Real* psols, /**< fractional current primal solution values of columns */
2156  int itlim, /**< iteration limit for strong branchings */
2157  SCIP_Real* down, /**< stores dual bounds after branching columns down */
2158  SCIP_Real* up, /**< stores dual bounds after branching columns up */
2159  SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds;
2160  * otherwise, they can only be used as an estimate values */
2161  SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds;
2162  * otherwise, they can only be used as an estimate values */
2163  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2164  )
2165 {
2166  SCIPdebugMessage("calling SCIPlpiStrongbranches() on %d variables (%d iterations)\n", ncols, itlim);
2167 
2168  assert(lpi != NULL);
2169  assert(lpi->clp != NULL);
2170  assert( cols != NULL );
2171  assert( psols != NULL );
2172  assert( down != NULL );
2173  assert( up != NULL );
2174  assert( downvalid != NULL );
2175  assert( upvalid != NULL );
2176 
2177  ClpSimplex* clp = lpi->clp;
2178 
2179  // set up output arrays
2180  int n = clp->numberColumns();
2181  assert( 0 < ncols && ncols <= n );
2182  double** outputSolution = NULL;
2183  SCIP_ALLOC( BMSallocMemoryArray( &outputSolution, 2*ncols) );
2184  for (int j = 0; j < 2*ncols; ++j)
2185  {
2186  SCIP_ALLOC( BMSallocMemoryArray( &(outputSolution[j]), n) );
2187  }
2188 
2189  int* outputStatus = NULL;
2190  SCIP_ALLOC( BMSallocMemoryArray(&outputStatus, 2*ncols) );
2191 
2192  int* outputIterations = NULL;
2193  SCIP_ALLOC( BMSallocMemoryArray(&outputIterations, 2*ncols) );
2194 
2195  // set iteration limit
2196  int iterlimit = clp->maximumIterations();
2197  clp->setMaximumIterations(itlim);
2198 
2199  // store objective value
2200  double objval = clp->objectiveValue();
2201 
2202  // store special options for later reset
2203  int specialoptions = clp->specialOptions();
2204 
2205  // lpi->clp->setSpecialOptions(64|128|512|1024|2048|4096|32768|262144|0x02000000);
2206  // use default settings:
2207  lpi->clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2208 
2209  /* 'startfinish' options for strong branching:
2210  * 1 - do not delete work areas and factorization at end
2211  * 2 - use old factorization if same number of rows
2212  * 4 - skip as much initialization of work areas as possible
2213  * (based on whatsChanged in clpmodel.hpp) ** work in progress
2214  *
2215  * 4 does not seem to work in strong branching ...
2216  */
2217  int startFinishOptions = 1;
2218  if ( lpi->validFactorization )
2219  startFinishOptions = startFinishOptions | 2;
2220 
2221  // set new lower and upper bounds for variables
2222  for (int j = 0; j < ncols; ++j)
2223  {
2224  assert( 0 <= cols[j] && cols[j] < n );
2225  down[j] = EPSCEIL(psols[j] - 1.0, 1e-06);
2226  up[j] = EPSFLOOR(psols[j] + 1.0, 1e-06);
2227 
2228  // The bounds returned by CLP seem to be valid using the above options
2229  downvalid[j] = TRUE;
2230  upvalid[j] = TRUE;
2231  }
2232 
2233  /* For strong branching. On input lower and upper are new bounds while
2234  * on output they are change in objective function values (>1.0e50
2235  * infeasible). Return code is
2236  * 0 if nothing interesting,
2237  * -1 if infeasible both ways and
2238  * +1 if infeasible one way (check values to see which one(s))
2239  * -2 if bad factorization
2240  * Solutions are filled in as well - even down, odd up - also status and number of iterations
2241  *
2242  * The bools are:
2243  * bool stopOnFirstInfeasible
2244  * bool alwaysFinish
2245  *
2246  * At the moment: we need alwaysFinish to get correct bounds.
2247  */
2248  int res = clp->strongBranching(ncols, cols, up, down, outputSolution, outputStatus, outputIterations, false, true, startFinishOptions);
2249 
2250  // reset special options
2251  clp->setSpecialOptions(specialoptions);
2252 
2253  lpi->validFactorization = true;
2254 
2255  for (int j = 0; j < ncols; ++j)
2256  {
2257  down[j] += objval;
2258  up[j] += objval;
2259 
2260  // correct iteration count
2261  if (iter)
2262  *iter += outputIterations[2*j] + outputIterations[2*j+1];
2263 
2264  BMSfreeMemoryArray(&outputSolution[2*j]);
2265  BMSfreeMemoryArray(&outputSolution[2*j+1]);
2266  }
2267 
2268  // reset iteration limit
2269  clp->setMaximumIterations(iterlimit);
2270 
2271  // free local memory
2272  BMSfreeMemoryArray( &outputStatus );
2273  BMSfreeMemoryArray( &outputIterations );
2274  BMSfreeMemoryArray( &outputSolution );
2275 
2276  if ( res == -2 )
2277  return SCIP_LPERROR;
2278 
2279  return SCIP_OKAY;
2280 }
2281 
2282 /** performs strong branching iterations on one @b fractional candidate */
2284  SCIP_LPI* lpi, /**< LP interface structure */
2285  int col, /**< column to apply strong branching on */
2286  SCIP_Real psol, /**< current primal solution value of column */
2287  int itlim, /**< iteration limit for strong branchings */
2288  SCIP_Real* down, /**< stores dual bound after branching column down */
2289  SCIP_Real* up, /**< stores dual bound after branching column up */
2290  SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound;
2291  * otherwise, it can only be used as an estimate value */
2292  SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound;
2293  * otherwise, it can only be used as an estimate value */
2294  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2295  )
2296 {
2297  /* pass call on to lpiStrongbranch() */
2298  SCIP_CALL( lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter) );
2299 
2300  return SCIP_OKAY;
2301 }
2302 
2303 /** performs strong branching iterations on given @b fractional candidates */
2305  SCIP_LPI* lpi, /**< LP interface structure */
2306  int* cols, /**< columns to apply strong branching on */
2307  int ncols, /**< number of columns */
2308  SCIP_Real* psols, /**< fractional current primal solution values of columns */
2309  int itlim, /**< iteration limit for strong branchings */
2310  SCIP_Real* down, /**< stores dual bounds after branching columns down */
2311  SCIP_Real* up, /**< stores dual bounds after branching columns up */
2312  SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds;
2313  * otherwise, they can only be used as an estimate values */
2314  SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds;
2315  * otherwise, they can only be used as an estimate values */
2316  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2317  )
2318 {
2319  if ( iter != NULL )
2320  *iter = 0;
2321 
2322  /* pass call on to lpiStrongbranches() */
2323  SCIP_CALL( lpiStrongbranches(lpi, cols, ncols, psols, itlim, down, up, downvalid, upvalid, iter) );
2324 
2325  return SCIP_OKAY;
2326 }
2327 
2328 /** performs strong branching iterations on one candidate with @b integral value */
2330  SCIP_LPI* lpi, /**< LP interface structure */
2331  int col, /**< column to apply strong branching on */
2332  SCIP_Real psol, /**< current integral primal solution value of column */
2333  int itlim, /**< iteration limit for strong branchings */
2334  SCIP_Real* down, /**< stores dual bound after branching column down */
2335  SCIP_Real* up, /**< stores dual bound after branching column up */
2336  SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound;
2337  * otherwise, it can only be used as an estimate value */
2338  SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound;
2339  * otherwise, it can only be used as an estimate value */
2340  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2341  )
2342 {
2343  /* pass call on to lpiStrongbranch() */
2344  SCIP_CALL( lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter) );
2345 
2346  return SCIP_OKAY;
2347 }
2348 
2349 /** performs strong branching iterations on given candidates with @b integral values */
2351  SCIP_LPI* lpi, /**< LP interface structure */
2352  int* cols, /**< columns to apply strong branching on */
2353  int ncols, /**< number of columns */
2354  SCIP_Real* psols, /**< current integral primal solution values of columns */
2355  int itlim, /**< iteration limit for strong branchings */
2356  SCIP_Real* down, /**< stores dual bounds after branching columns down */
2357  SCIP_Real* up, /**< stores dual bounds after branching columns up */
2358  SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds;
2359  * otherwise, they can only be used as an estimate values */
2360  SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds;
2361  * otherwise, they can only be used as an estimate values */
2362  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2363  )
2364 {
2365  if ( iter != NULL )
2366  *iter = 0;
2367 
2368  /* pass call on to lpiStrongbranches() */
2369  SCIP_CALL( lpiStrongbranches(lpi, cols, ncols, psols, itlim, down, up, downvalid, upvalid, iter) );
2370 
2371  return SCIP_OKAY;
2372 }
2373 
2374 /**@} */
2375 
2376 
2377 
2378 /*
2379  * Solution Information Methods
2380  */
2381 
2382 /**@name Solution Information Methods */
2383 /**@{ */
2384 
2385 /** returns whether a solve method was called after the last modification of the LP */
2387  SCIP_LPI* lpi /**< LP interface structure */
2388  )
2389 {
2390  assert(lpi != NULL);
2391 
2392  return lpi->solved;
2393 }
2394 
2395 /** gets information about primal and dual feasibility of the current LP solution
2396  *
2397  * The feasibility information is with respect to the last solving call and it is only relevant if SCIPlpiWasSolved()
2398  * returns true. If the LP is changed, this information might be invalidated.
2399  *
2400  * Note that @a primalfeasible and @a dualfeasible should only return true if the solver has proved the respective LP to
2401  * be feasible. Thus, the return values should be equal to the values of SCIPlpiIsPrimalFeasible() and
2402  * SCIPlpiIsDualFeasible(), respectively. Note that if feasibility cannot be proved, they should return false (even if
2403  * the problem might actually be feasible).
2404  */
2406  SCIP_LPI* lpi, /**< LP interface structure */
2407  SCIP_Bool* primalfeasible, /**< pointer to store primal feasibility status */
2408  SCIP_Bool* dualfeasible /**< pointer to store dual feasibility status */
2409  )
2410 {
2411  SCIPdebugMessage("calling SCIPlpiGetSolFeasibility()\n");
2412 
2413  assert(lpi != NULL);
2414  assert(lpi->clp != NULL);
2415  assert(primalfeasible != NULL);
2416  assert(dualfeasible != NULL);
2417 
2418  if ( lpi->clp->primalFeasible() )
2419  *primalfeasible = TRUE;
2420  else
2421  *primalfeasible = FALSE;
2422 
2423  if ( lpi->clp->dualFeasible() )
2424  *dualfeasible = TRUE;
2425  else
2426  *dualfeasible = FALSE;
2427 
2428  // say feasible if deviation is small
2429  if (lpi->clp->status()==0 && ( ! (*primalfeasible) || ! (*dualfeasible)) )
2430  {
2431  if ( !(*primalfeasible) && lpi->clp->sumPrimalInfeasibilities() < SUMINFEASBOUND )
2432  {
2433  lpi->clp->setNumberPrimalInfeasibilities(0);
2434  *primalfeasible = TRUE;
2435  }
2436  if ( !(*dualfeasible) && lpi->clp->sumDualInfeasibilities() < SUMINFEASBOUND)
2437  {
2438  lpi->clp->setNumberDualInfeasibilities(0);
2439  *dualfeasible = TRUE;
2440  }
2441  }
2442 
2443  return SCIP_OKAY;
2444 }
2445 
2446 
2447 /** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point);
2448  * this does not necessarily mean, that the solver knows and can return the primal ray
2449  */
2451  SCIP_LPI* lpi /**< LP interface structure */
2452  )
2453 {
2454  SCIPdebugMessage("calling SCIPlpiExistsPrimalRay()\n");
2455 
2456  assert(lpi != NULL);
2457  assert(lpi->clp != NULL);
2458 
2459  /* Clp usually has a primal ray whenever it concludes "dual infeasible" (status == 2)
2460  * (but is not necessarily primal feasible), see ClpModel::unboundedRay(). */
2461  return ( lpi->clp->status() == 2 );
2462 }
2463 
2464 
2465 /** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point),
2466  * and the solver knows and can return the primal ray
2467  */
2469  SCIP_LPI* lpi /**< LP interface structure */
2470  )
2471 {
2472  SCIPdebugMessage("calling SCIPlpiHasPrimalRay()\n");
2473 
2474  assert(lpi != NULL);
2475  assert(lpi->clp != NULL);
2476 
2477  /* Clp usually has a primal ray whenever it concludes "dual infeasible" (status == 2)
2478  * (but is not necessarily primal feasible), see ClpModel::unboundedRay(). */
2479  if ( lpi->clp->rayExists() )
2480  {
2481  return ( lpi->clp->status() == 2 );
2482  }
2483  return FALSE;
2484 }
2485 
2486 
2487 /** returns TRUE iff LP is proven to be primal unbounded */
2489  SCIP_LPI* lpi /**< LP interface structure */
2490  )
2491 {
2492  SCIPdebugMessage("calling SCIPlpiIsPrimalUnbounded()\n");
2493 
2494  assert(lpi != NULL);
2495  assert(lpi->clp != NULL);
2496 
2497  return ( lpi->clp->isProvenDualInfeasible() && lpi->clp->primalFeasible() );
2498 }
2499 
2500 
2501 /** returns TRUE iff LP is proven to be primal infeasible */
2503  SCIP_LPI* lpi /**< LP interface structure */
2504  )
2505 {
2506  SCIPdebugMessage("calling SCIPlpiIsPrimalInfeasible()\n");
2507 
2508  assert(lpi != NULL);
2509  assert(lpi->clp != NULL);
2510 
2511  /* Should return ClpModel::isProvenPrimalInfeasible() (which returns "status == 1"), but the
2512  * following is correct (Clp will not be changed). The secondaryStatus is 1 if the dual simplex
2513  * detects an objective limit exceedence. The primal simplex has no such detection (will never
2514  * stop with objective limit exceedence). Hence we are infeasible only if status == 1 and we have
2515  * not stopped due to the objective limit. */
2516  return ( lpi->clp->status() == 1 && (lpi->clp->secondaryStatus() == 0 || lpi->clp->secondaryStatus() == 6) );
2517 }
2518 
2519 
2520 /** returns TRUE iff LP is proven to be primal feasible */
2522  SCIP_LPI* lpi /**< LP interface structure */
2523  )
2524 {
2525  SCIPdebugMessage("calling SCIPlpiIsPrimalFeasible()\n");
2526 
2527  assert(lpi != NULL);
2528  assert(lpi->clp != NULL);
2529 
2530  return ( lpi->clp->primalFeasible() );
2531 }
2532 
2533 
2534 /** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point);
2535  * this does not necessarily mean, that the solver knows and can return the dual ray
2536  */
2538  SCIP_LPI* lpi /**< LP interface structure */
2539  )
2540 {
2541  SCIPdebugMessage("calling SCIPlpiExistsDualRay()\n");
2542 
2543  assert(lpi != NULL);
2544  assert(lpi->clp != NULL);
2545 
2546  /* Clp usually has a dual ray whenever it concludes "primal infeasible" (but is not necessarily dual feasible), see
2547  * ClpModel::infeasibilityRay. Additionally check whether ray exists in order to avoid situations in which Clp cannot
2548  * provide a ray. SCIP often decides to resolve in such a case and the problem might go away. */
2549  return ( lpi->clp->status() == 1 && lpi->clp->secondaryStatus() == 0 && lpi->clp->rayExists() );
2550 }
2551 
2552 
2553 /** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point),
2554  * and the solver knows and can return the dual ray
2555  */
2557  SCIP_LPI* lpi /**< LP interface structure */
2558  )
2559 {
2560  SCIPdebugMessage("calling SCIPlpiHasDualRay()\n");
2561 
2562  assert(lpi != NULL);
2563  assert(lpi->clp != NULL);
2564 
2565  /* Clp usually has a dual ray whenever it concludes "primal infeasible" (but is not necessarily dual feasible),
2566  * see ClpModel::infeasibilityRay. Additionally check whether ray exists. */
2567  if ( lpi->clp->rayExists() )
2568  {
2569  if ( lpi->clp->status() == 1 && lpi->clp->secondaryStatus() == 0 )
2570  return TRUE;
2571  }
2572 
2573  return FALSE;
2574 }
2575 
2576 
2577 /** returns TRUE iff LP is proven to be dual unbounded */
2579  SCIP_LPI* lpi /**< LP interface structure */
2580  )
2581 {
2582  SCIPdebugMessage("calling SCIPlpiIsDualUnbounded()\n");
2583 
2584  assert(lpi != NULL);
2585  assert(lpi->clp != NULL);
2586 
2587  /* The dual seems to be unbounded if the status is 1 (primal unbounded), the secondaryStatus is
2588  * not 1 (i.e., the dual simplex has not stopped because of an objective limit exceedence), and
2589  * the dual is feasible. */
2590  return ( lpi->clp->status() == 1 && lpi->clp->secondaryStatus() == 0 && lpi->clp->dualFeasible() );
2591 }
2592 
2593 
2594 /** returns TRUE iff LP is proven to be dual infeasible */
2596  SCIP_LPI* lpi /**< LP interface structure */
2597  )
2598 {
2599  SCIPdebugMessage("calling SCIPlpiIsDualInfeasible()\n");
2600 
2601  assert(lpi != NULL);
2602  assert(lpi->clp != NULL);
2603 
2604  return ( lpi->clp->isProvenDualInfeasible() );
2605 }
2606 
2607 
2608 /** returns TRUE iff LP is proven to be dual feasible */
2610  SCIP_LPI* lpi /**< LP interface structure */
2611  )
2612 {
2613  SCIPdebugMessage("calling SCIPlpiIsDualFeasible()\n");
2614 
2615  assert(lpi != NULL);
2616  assert(lpi->clp != NULL);
2617 
2618  return ( lpi->clp->dualFeasible() );
2619 }
2620 
2621 
2622 /** returns TRUE iff LP was solved to optimality */
2624  SCIP_LPI* lpi /**< LP interface structure */
2625  )
2626 {
2627  SCIPdebugMessage("calling SCIPlpiIsOptimal()\n");
2628 
2629  assert(lpi != NULL);
2630  assert(lpi->clp != NULL);
2631 
2632  if ( SCIPlpiIsObjlimExc(lpi) )
2633  return FALSE;
2634 
2635  /* secondaryStatus == 6 means that the problem is empty */
2636  return( lpi->clp->isProvenOptimal() && (lpi->clp->secondaryStatus() == 0 || lpi->clp->secondaryStatus() == 6));
2637 }
2638 
2639 
2640 /** returns TRUE iff current LP solution is stable
2641  *
2642  * This function should return true if the solution is reliable, i.e., feasible and optimal (or proven
2643  * infeasible/unbounded) with respect to the original problem. The optimality status might be with respect to a scaled
2644  * version of the problem, but the solution might not be feasible to the unscaled original problem; in this case,
2645  * SCIPlpiIsStable() should return false.
2646  */
2648  SCIP_LPI* lpi /**< LP interface structure */
2649  )
2650 {
2651  SCIPdebugMessage("calling SCIPlpiIsStable()\n");
2652 
2653  assert(lpi != NULL);
2654  assert(lpi->clp != NULL);
2655 
2656  /* Return false if infeasible, but dual ray is not present and the algorithm type has changed. This is one of the
2657  * cases in which Clp cannot produce a ray and the hope is to get a ray by rerunning. */
2658  if ( lpi->clp->status() == 1 && lpi->lastalgorithm != lpi->clp->algorithm() && ! lpi->clp->rayExists() )
2659  return FALSE;
2660 
2661  /* We first check if status is ok, i.e., is one of the following:
2662  * 0 - optimal
2663  * 1 - primal infeasible
2664  * 2 - dual infeasible
2665  * 3 - stopped on iterations or time
2666  * 4 - stopped due to errors
2667  * 5 - stopped by event handler (virtual int ClpEventHandler::event())
2668  *
2669  * Then we check the secondary status of Clp:
2670  * 0 - none
2671  * 1 - primal infeasible because dual limit reached OR (probably primal infeasible but can't prove it - main status was 4)
2672  * 2 - scaled problem optimal - unscaled problem has primal infeasibilities
2673  * 3 - scaled problem optimal - unscaled problem has dual infeasibilities
2674  * 4 - scaled problem optimal - unscaled problem has primal and dual infeasibilities
2675  * 5 - giving up in primal with flagged variables
2676  * 6 - failed due to empty problem check
2677  * 7 - postSolve says not optimal
2678  * 8 - failed due to bad element check
2679  * 9 - status was 3 and stopped on time
2680  * 100 up - translation of enum from ClpEventHandler
2681  */
2682  SCIPdebugMessage("status: %d secondary: %d\n", lpi->clp->status(), lpi->clp->secondaryStatus());
2683  assert( 0 <= lpi->clp->status() && lpi->clp->status() <= 5 );
2684 
2685  return( (lpi->clp->status() <= 3) && (lpi->clp->secondaryStatus() <= 1 || lpi->clp->secondaryStatus() == 6 || lpi->clp->secondaryStatus() == 9) );
2686 }
2687 
2688 
2689 /** returns TRUE iff the objective limit was reached */
2691  SCIP_LPI* lpi /**< LP interface structure */
2692  )
2693 {
2694  SCIPdebugMessage("calling SCIPlpiIsObjlimExc()\n");
2695 
2696  assert(lpi != NULL);
2697  assert(lpi->clp != NULL);
2698 
2699  /* if status == 1 (primal infeasible) and secondaryStatus == 1 then Clp hit the dual bound */
2700  if ( lpi->clp->status() == 1 )
2701  {
2702  if ( lpi->clp->secondaryStatus() == 1 )
2703  return TRUE;
2704  else
2705  return FALSE;
2706  }
2707 
2708  return ( lpi->clp->isObjectiveLimitTestValid() && lpi->clp->isDualObjectiveLimitReached() );
2709 
2710  /* The above code is equivalent to the following:
2711  if ( lpi->clp->status() == 0 || (lpi->clp->status() == 1 && lpi->clp->algorithm() < 0) || (lpi->clp->status() == 2 && lpi->clp->algorithm() > 0) )
2712  {
2713  return ( lpi->clp->isPrimalObjectiveLimitReached() || lpi->clp->isDualObjectiveLimitReached() );
2714  }
2715  */
2716 }
2717 
2718 
2719 /** returns TRUE iff the iteration limit was reached */
2721  SCIP_LPI* lpi /**< LP interface structure */
2722  )
2723 {
2724  SCIPdebugMessage("calling SCIPlpiIsIterlimExc()\n");
2725 
2726  assert(lpi != NULL);
2727  assert(lpi->clp != NULL);
2728 
2729  /* status == 3 means that Clp stopped on time or iteration limit
2730  * secondary status == 9 means that status was 3 and Clp stopped on time */
2731  return ( lpi->clp->status() == 3 && lpi->clp->secondaryStatus() != 9 );
2732 }
2733 
2734 
2735 /** returns TRUE iff the time limit was reached */
2737  SCIP_LPI* lpi /**< LP interface structure */
2738  )
2739 {
2740  SCIPdebugMessage("calling SCIPlpiIsTimelimExc()\n");
2741 
2742  assert(lpi != NULL);
2743  assert(lpi->clp != NULL);
2744 
2745  /* status == 3 means that Clp stopped on time or iteration limit
2746  * secondary status == 9 means that status was 3 and Clp stopped on time */
2747  return ( lpi->clp->status() == 3 && lpi->clp->secondaryStatus() == 9 );
2748 }
2749 
2750 
2751 /** returns the internal solution status of the solver */
2753  SCIP_LPI* lpi /**< LP interface structure */
2754  )
2755 {
2756  SCIPdebugMessage("calling SCIPlpiGetInternalStatus()\n");
2757 
2758  assert(lpi != NULL);
2759  assert(lpi->clp != NULL);
2760 
2761  return lpi->clp->status();
2762 }
2763 
2764 
2765 /** gets objective value of solution */
2767  SCIP_LPI* lpi, /**< LP interface structure */
2768  SCIP_Real* objval /**< stores the objective value */
2769  )
2770 {
2771  SCIPdebugMessage("calling SCIPlpiGetObjval()\n");
2772 
2773  assert(lpi != NULL);
2774  assert(lpi->clp != NULL);
2775  assert(objval != NULL);
2776 
2777  *objval = lpi->clp->objectiveValue();
2778 
2779  return SCIP_OKAY;
2780 }
2781 
2782 
2783 /** gets primal and dual solution vectors for feasible LPs
2784  *
2785  * Before calling this function, the caller must ensure that the LP has been solved to optimality, i.e., that
2786  * SCIPlpiIsOptimal() returns true.
2787  */
2789  SCIP_LPI* lpi, /**< LP interface structure */
2790  SCIP_Real* objval, /**< stores the objective value, may be NULL if not needed */
2791  SCIP_Real* primsol, /**< primal solution vector, may be NULL if not needed */
2792  SCIP_Real* dualsol, /**< dual solution vector, may be NULL if not needed */
2793  SCIP_Real* activity, /**< row activity vector, may be NULL if not needed */
2794  SCIP_Real* redcost /**< reduced cost vector, may be NULL if not needed */
2795  )
2796 {
2797  SCIPdebugMessage("calling SCIPlpiGetSol()\n");
2798 
2799  assert(lpi != NULL);
2800  assert(lpi->clp != NULL);
2801 
2802  ClpSimplex* clp = lpi->clp;
2803  if( objval != NULL )
2804  *objval = clp->objectiveValue();
2805 
2806  if( primsol != NULL )
2807  {
2808  const double* sol = clp->getColSolution();
2809  BMScopyMemoryArray( primsol, sol, clp->numberColumns() );
2810  }
2811  if( dualsol != NULL )
2812  {
2813  const double* dsol = clp->getRowPrice();
2814  BMScopyMemoryArray( dualsol, dsol, clp->numberRows() );
2815  }
2816  if( activity != NULL )
2817  {
2818  const double* act = clp->getRowActivity();
2819  BMScopyMemoryArray( activity, act, clp->numberRows() );
2820  }
2821  if( redcost != NULL )
2822  {
2823  const double* red = clp->getReducedCost();
2824  BMScopyMemoryArray( redcost, red, clp->numberColumns() );
2825  }
2826 
2827  return SCIP_OKAY;
2828 }
2829 
2830 
2831 /** gets primal ray for unbounded LPs */
2833  SCIP_LPI* lpi, /**< LP interface structure */
2834  SCIP_Real* ray /**< primal ray */
2835  )
2836 {
2837  SCIPdebugMessage("calling SCIPlpiGetPrimalRay()\n");
2838 
2839  assert(lpi != NULL);
2840  assert(lpi->clp != NULL);
2841  assert(ray != NULL);
2842 
2843  /* Unbounded ray (NULL returned if none/wrong). Up to user to use delete [] on these arrays. */
2844  const double* clpray = lpi->clp->unboundedRay();
2845 
2846  if ( clpray == NULL )
2847  return SCIP_LPERROR;
2848 
2849  BMScopyMemoryArray(ray, clpray, lpi->clp->numberColumns());
2850 
2851  delete [] clpray;
2852 
2853  return SCIP_OKAY;
2854 }
2855 
2856 /** gets dual farkas proof for infeasibility */
2858  SCIP_LPI* lpi, /**< LP interface structure */
2859  SCIP_Real* dualfarkas /**< dual farkas row multipliers */
2860  )
2861 {
2862  SCIPdebugMessage("calling SCIPlpiGetDualfarkas()\n");
2863 
2864  assert(lpi != NULL);
2865  assert(lpi->clp != NULL);
2866  assert(dualfarkas != NULL);
2867 
2868  /* Infeasibility ray (NULL returned if none/wrong). Up to user to use delete [] on these arrays. */
2869  const double* dualray = lpi->clp->infeasibilityRay();
2870 
2871  if ( dualray == NULL )
2872  return SCIP_LPERROR;
2873 
2874  /* The dual ray returned by Clp sometimes contains large numbers. We try to scale the vector. First compute maximal
2875  * and minimal absolute values. */
2876  double minabsvalue = SCIPlpiInfinity(lpi);
2877  double maxabsvalue = 0.0;
2878  double feastol = lpi->clp->primalTolerance();
2879  for (int j = 0; j < lpi->clp->numberRows(); ++j)
2880  {
2881  double val = fabs(dualray[j]);
2882 
2883  /* only consider nonzero entries */
2884  if ( val >= feastol )
2885  {
2886  if ( val > maxabsvalue )
2887  maxabsvalue = val;
2888  if ( val < minabsvalue )
2889  minabsvalue = val;
2890  }
2891  }
2892 
2893  /* Possibly scale and also convert sign. */
2894  if ( maxabsvalue > 0.0 )
2895  {
2896  assert( 0.0 < minabsvalue && minabsvalue <= maxabsvalue );
2897 
2898  /* We try to make the maximum absolute value to be 1.0, but if the minimal absolute value would be less than the
2899  * feasibility tolerance, we adjust the factor such that it will be equal to the feasibility tolerance. */
2900  double scalingfactor = maxabsvalue;
2901  if ( minabsvalue / scalingfactor < feastol )
2902  scalingfactor = minabsvalue / feastol;
2903 
2904  for (int j = 0; j < lpi->clp->numberRows(); ++j)
2905  dualfarkas[j] = -dualray[j]/scalingfactor;
2906  }
2907  else
2908  {
2909  /* convert sign */
2910  for (int j = 0; j < lpi->clp->numberRows(); ++j)
2911  dualfarkas[j] = -dualray[j];
2912  }
2913 
2914  delete [] dualray;
2915 
2916  return SCIP_OKAY;
2917 }
2918 
2919 
2920 /** gets the number of LP iterations of the last solve call */
2922  SCIP_LPI* lpi, /**< LP interface structure */
2923  int* iterations /**< pointer to store the number of iterations of the last solve call */
2924  )
2925 {
2926  assert(lpi != NULL);
2927  assert(lpi->clp != NULL);
2928  assert(iterations != NULL);
2929 
2930  *iterations = lpi->clp->numberIterations();
2931 
2932  return SCIP_OKAY;
2933 }
2934 
2935 /** gets information about the quality of an LP solution
2936  *
2937  * Such information is usually only available, if also a (maybe not optimal) solution is available.
2938  * The LPI should return SCIP_INVALID for @p quality, if the requested quantity is not available.
2939  */
2941  SCIP_LPI* lpi, /**< LP interface structure */
2942  SCIP_LPSOLQUALITY qualityindicator, /**< indicates which quality should be returned */
2943  SCIP_Real* quality /**< pointer to store quality number */
2944  )
2945 {
2946  assert(lpi != NULL);
2947  assert(quality != NULL);
2948 
2949  *quality = SCIP_INVALID;
2950 
2951  return SCIP_OKAY;
2952 }
2953 
2954 /**@} */
2955 
2956 
2957 
2958 
2959 /*
2960  * LP Basis Methods
2961  */
2962 
2963 /**@name LP Basis Methods */
2964 /**@{ */
2965 
2966 /** gets current basis status for columns and rows; arrays must be large enough to store the basis status */
2968  SCIP_LPI* lpi, /**< LP interface structure */
2969  int* cstat, /**< array to store column basis status, or NULL */
2970  int* rstat /**< array to store row basis status, or NULL */
2971  )
2972 {
2973  SCIPdebugMessage("calling SCIPlpiGetBase()\n");
2974 
2975  assert(lpi != NULL);
2976  assert(lpi->clp != NULL);
2977 
2978  ClpSimplex* clp = lpi->clp;
2979 
2980  if( rstat != NULL )
2981  {
2982  for( int i = 0; i < clp->numberRows(); ++i )
2983  {
2984  switch ( clp->getRowStatus(i) )
2985  {
2986  case ClpSimplex::isFree:
2987  rstat[i] = SCIP_BASESTAT_ZERO;
2988  break;
2989  case ClpSimplex::basic:
2990  rstat[i] = SCIP_BASESTAT_BASIC;
2991  break;
2992  case ClpSimplex::atUpperBound:
2993  rstat[i] = SCIP_BASESTAT_UPPER;
2994  break;
2995  case ClpSimplex::atLowerBound:
2996  rstat[i] = SCIP_BASESTAT_LOWER;
2997  break;
2998  case ClpSimplex::superBasic:
2999  rstat[i] = SCIP_BASESTAT_ZERO;
3000  break;
3001  case ClpSimplex::isFixed:
3002  if (clp->getRowPrice()[i] > 0.0)
3003  rstat[i] = SCIP_BASESTAT_LOWER;
3004  else
3005  rstat[i] = SCIP_BASESTAT_UPPER;
3006  break;
3007  default:
3008  SCIPerrorMessage("invalid basis status\n");
3009  SCIPABORT();
3010  return SCIP_INVALIDDATA; /*lint !e527*/
3011  }
3012  }
3013  }
3014 
3015  if( cstat != NULL )
3016  {
3017 #ifndef NDEBUG
3018  const double* lb = clp->getColLower();
3019  const double* ub = clp->getColUpper();
3020 #endif
3021 
3022  for( int j = 0; j < clp->numberColumns(); ++j )
3023  {
3024  switch ( clp->getColumnStatus(j) )
3025  {
3026  case ClpSimplex::isFree:
3027  cstat[j] = SCIP_BASESTAT_ZERO;
3028  break;
3029  case ClpSimplex::basic:
3030  cstat[j] = SCIP_BASESTAT_BASIC;
3031  break;
3032  case ClpSimplex::atUpperBound:
3033  cstat[j] = SCIP_BASESTAT_UPPER;
3034  assert( ub[j] < COIN_DBL_MAX );
3035  break;
3036  case ClpSimplex::atLowerBound:
3037  cstat[j] = SCIP_BASESTAT_LOWER;
3038  assert( lb[j] > -COIN_DBL_MAX );
3039  break;
3040  case ClpSimplex::superBasic:
3041  cstat[j] = SCIP_BASESTAT_ZERO;
3042  break;
3043  case ClpSimplex::isFixed:
3044  if (clp->getReducedCost()[j] > 0.0)
3045  {
3046  cstat[j] = SCIP_BASESTAT_LOWER;
3047  assert( lb[j] > -COIN_DBL_MAX );
3048  }
3049  else
3050  {
3051  cstat[j] = SCIP_BASESTAT_UPPER;
3052  assert( ub[j] < COIN_DBL_MAX );
3053  }
3054  break;
3055  default: SCIPerrorMessage("invalid basis status\n");
3056  SCIPABORT();
3057  return SCIP_INVALIDDATA; /*lint !e527*/
3058  }
3059  }
3060  }
3061 
3062  return SCIP_OKAY;
3063 }
3064 
3065 
3066 /** sets current basis status for columns and rows */
3068  SCIP_LPI* lpi, /**< LP interface structure */
3069  const int* cstat, /**< array with column basis status */
3070  const int* rstat /**< array with row basis status */
3071  )
3072 {
3073  int ncols;
3074  int nrows;
3075 
3076  SCIPdebugMessage("calling SCIPlpiSetBase()\n");
3077 
3078  assert(lpi != NULL);
3079  assert(lpi->clp != NULL);
3080 
3081  SCIP_CALL( SCIPlpiGetNCols(lpi, &ncols) );
3082  SCIP_CALL( SCIPlpiGetNRows(lpi, &nrows) );
3083 
3084  assert(rstat != NULL || lpi->clp->numberRows() == 0);
3085  assert(cstat != NULL || lpi->clp->numberColumns() == 0);
3086 
3087  invalidateSolution(lpi);
3088 
3089  // Adapted from OsiClpSolverInterface::setBasisStatus
3090 
3091  ClpSimplex* clp = lpi->clp;
3092  clp->createStatus();
3093 
3094  const double* lhs = clp->getRowLower();
3095  const double* rhs = clp->getRowUpper();
3096 
3097  for( int i = 0; i < clp->numberRows(); ++i )
3098  {
3099  int status = rstat[i];
3100  assert( 0 <= status && status <= 3 );
3101  assert( lhs[i] > -COIN_DBL_MAX || status != SCIP_BASESTAT_LOWER); // can't be at lower bound
3102  assert( rhs[i] < COIN_DBL_MAX || status != SCIP_BASESTAT_UPPER); // can't be at upper bound
3103 
3104  switch ( status )
3105  {
3106  case SCIP_BASESTAT_ZERO:
3107  if ( lhs[i] <= -COIN_DBL_MAX && rhs[i] >= COIN_DBL_MAX )
3108  clp->setRowStatus(i, ClpSimplex::isFree);
3109  else
3110  clp->setRowStatus(i, ClpSimplex::superBasic);
3111  break;
3112  case SCIP_BASESTAT_BASIC:
3113  clp->setRowStatus(i, ClpSimplex::basic);
3114  break;
3115  case SCIP_BASESTAT_UPPER:
3116  clp->setRowStatus(i, ClpSimplex::atUpperBound);
3117  break;
3118  case SCIP_BASESTAT_LOWER:
3119  if ( EPSEQ(rhs[i], lhs[i], 1e-6) ) // if bounds are equal
3120  clp->setRowStatus(i, ClpSimplex::isFixed);
3121  else
3122  clp->setRowStatus(i, ClpSimplex::atLowerBound);
3123  break;
3124  default:
3125  SCIPerrorMessage("invalid basis status\n");
3126  SCIPABORT();
3127  return SCIP_INVALIDDATA; /*lint !e527*/
3128  }
3129  }
3130 
3131  const double* lb = clp->getColLower();
3132  const double* ub = clp->getColUpper();
3133 
3134  for( int j = 0; j < clp->numberColumns(); ++j )
3135  {
3136  int status = cstat[j];
3137  assert( 0 <= status && status <= 3 );
3138  assert( lb[j] > -COIN_DBL_MAX || status != SCIP_BASESTAT_LOWER); // can't be at lower bound
3139  assert( ub[j] < COIN_DBL_MAX || status != SCIP_BASESTAT_UPPER); // can't be at upper bound
3140 
3141  switch ( status )
3142  {
3143  case SCIP_BASESTAT_ZERO:
3144  if ( lb[j] <= -COIN_DBL_MAX && ub[j] >= COIN_DBL_MAX )
3145  clp->setColumnStatus(j, ClpSimplex::isFree);
3146  else
3147  clp->setColumnStatus(j, ClpSimplex::superBasic);
3148  break;
3149  case SCIP_BASESTAT_BASIC:
3150  clp->setColumnStatus(j, ClpSimplex::basic);
3151  break;
3152  case SCIP_BASESTAT_UPPER:
3153  clp->setColumnStatus(j, ClpSimplex::atUpperBound);
3154  break;
3155  case SCIP_BASESTAT_LOWER:
3156  if ( EPSEQ(ub[j], lb[j], 1e-6) )
3157  clp->setColumnStatus(j, ClpSimplex::isFixed);
3158  else
3159  clp->setColumnStatus(j, ClpSimplex::atLowerBound);
3160  break;
3161  default:
3162  SCIPerrorMessage("invalid basis status\n");
3163  SCIPABORT();
3164  return SCIP_INVALIDDATA; /*lint !e527*/
3165  }
3166  }
3167 
3168  /* Whats changed since last solve.
3169  * Is only used when startFinishOptions used in dual or primal.
3170  * Bit 1 - number of rows/columns has not changed (so work arrays valid)
3171  * 2 - matrix has not changed
3172  * 4 - if matrix has changed only by adding rows
3173  * 8 - if matrix has changed only by adding columns
3174  * 16 - row lbs not changed
3175  * 32 - row ubs not changed
3176  * 64 - column objective not changed
3177  * 128 - column lbs not changed
3178  * 256 - column ubs not changed
3179  * 512 - basis not changed (up to user to set this to 0)
3180  * top bits may be used internally
3181  */
3182  clp->setWhatsChanged(clp->whatsChanged() & (~512));
3183 
3184  return SCIP_OKAY;
3185 }
3186 
3187 
3188 /** returns the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m */
3190  SCIP_LPI* lpi, /**< LP interface structure */
3191  int* bind /**< pointer to store basis indices ready to keep number of rows entries */
3192  )
3193 {
3194  SCIPdebugMessage("calling SCIPlpiGetBasisInd()\n");
3195 
3196  assert(lpi != NULL);
3197  assert(lpi->clp != NULL);
3198  assert(bind != 0);
3199 
3200  ClpSimplex* clp = lpi->clp;
3201  int nrows = clp->numberRows();
3202  int ncols = clp->numberColumns();
3203 
3204  int* idx = NULL;
3205  SCIP_ALLOC( BMSallocMemoryArray(&idx, nrows) );
3206 
3207  /* If secondaryStatus == 6, clp says the LP is empty. Mose likely this happened, because the
3208  * matrix is empty, i.e., all rows were redundant/empty. In this case, we construct a basis
3209  * consisting of slack variables. */
3210  if ( clp->secondaryStatus() == 6 )
3211  {
3212  assert( clp->getNumElements() == 0 );
3213  for (int i = 0; i < nrows; ++i)
3214  idx[i] = ncols + i;
3215  }
3216  else
3217  clp->getBasics(idx);
3218 
3219  for (int i = 0; i < nrows; ++i)
3220  {
3221  if ( idx[i] < ncols )
3222  bind[i] = idx[i];
3223  else
3224  bind[i] = -1 - (idx[i] - ncols);
3225  }
3226 
3227  BMSfreeMemoryArray(&idx);
3228 
3229  return SCIP_OKAY;
3230 }
3231 
3232 
3233 /** get row of inverse basis matrix B^-1
3234  *
3235  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
3236  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
3237  * see also the explanation in lpi.h.
3238  *
3239  * @todo check that the result is in terms of the LP interface definition
3240  */
3242  SCIP_LPI* lpi, /**< LP interface structure */
3243  int r, /**< row number */
3244  SCIP_Real* coef, /**< pointer to store the coefficients of the row */
3245  int* inds, /**< array to store the non-zero indices, or NULL */
3246  int* ninds /**< pointer to store the number of non-zero indices, or NULL
3247  * (-1: if we do not store sparsity information) */
3248  )
3249 {
3250  SCIPdebugMessage("calling SCIPlpiGetBInvRow()\n");
3251 
3252  assert(lpi != NULL);
3253  assert(lpi->clp != NULL);
3254  assert(coef != NULL);
3255  assert( 0 <= r && r <= lpi->clp->numberRows() );
3256 
3257  /* can only return dense result */
3258  if ( ninds != NULL )
3259  *ninds = -1;
3260 
3261  ClpSimplex* clp = lpi->clp;
3262  clp->getBInvRow(r, coef);
3263 
3264  return SCIP_OKAY;
3265 }
3266 
3267 
3268 /** get column of inverse basis matrix B^-1
3269  *
3270  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
3271  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
3272  * see also the explanation in lpi.h.
3273  *
3274  * @todo check that the result is in terms of the LP interface definition
3275  */
3277  SCIP_LPI* lpi, /**< LP interface structure */
3278  int c, /**< column number of B^-1; this is NOT the number of the column in the LP;
3279  * you have to call SCIPlpiGetBasisInd() to get the array which links the
3280  * B^-1 column numbers to the row and column numbers of the LP!
3281  * c must be between 0 and nrows-1, since the basis has the size
3282  * nrows * nrows */
3283  SCIP_Real* coef, /**< pointer to store the coefficients of the column */
3284  int* inds, /**< array to store the non-zero indices, or NULL */
3285  int* ninds /**< pointer to store the number of non-zero indices, or NULL
3286  * (-1: if we do not store sparsity information) */
3287  )
3288 {
3289  SCIPdebugMessage("calling SCIPlpiGetBInvCol()\n");
3290 
3291  assert(lpi != NULL);
3292  assert(lpi->clp != NULL);
3293  assert(coef != NULL);
3294  assert( 0 <= c && c <= lpi->clp->numberRows() ); /* basis matrix is nrows * nrows */
3295 
3296  /* can only return dense result */
3297  if ( ninds != NULL )
3298  *ninds = -1;
3299 
3300  ClpSimplex* clp = lpi->clp;
3301  clp->getBInvCol(c, coef);
3302 
3303  return SCIP_OKAY;
3304 }
3305 
3306 /** get row of inverse basis matrix times constraint matrix B^-1 * A
3307  *
3308  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
3309  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
3310  * see also the explanation in lpi.h.
3311  *
3312  * @todo check that the result is in terms of the LP interface definition
3313  */
3315  SCIP_LPI* lpi, /**< LP interface structure */
3316  int r, /**< row number */
3317  const SCIP_Real* binvrow, /**< row in (A_B)^-1 from prior call to SCIPlpiGetBInvRow(), or NULL */
3318  SCIP_Real* coef, /**< vector to return coefficients of the row */
3319  int* inds, /**< array to store the non-zero indices, or NULL */
3320  int* ninds /**< pointer to store the number of non-zero indices, or NULL
3321  * (-1: if we do not store sparsity information) */
3322  )
3323 {
3324  SCIPdebugMessage("calling SCIPlpiGetBInvARow()\n");
3325 
3326  assert(lpi != NULL);
3327  assert(lpi->clp != NULL);
3328  assert(coef != NULL);
3329  assert( 0 <= r && r <= lpi->clp->numberRows() );
3330 
3331  /* can only return dense result */
3332  if ( ninds != NULL )
3333  *ninds = -1;
3334 
3335  ClpSimplex* clp = lpi->clp;
3336  clp->getBInvARow(r, coef, 0);
3337 
3338  return SCIP_OKAY;
3339 }
3340 
3341 /** get column of inverse basis matrix times constraint matrix B^-1 * A
3342  *
3343  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
3344  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
3345  * see also the explanation in lpi.h.
3346  *
3347  * @todo check that the result is in terms of the LP interface definition
3348  */
3350  SCIP_LPI* lpi, /**< LP interface structure */
3351  int c, /**< column number */
3352  SCIP_Real* coef, /**< vector to return coefficients of the column */
3353  int* inds, /**< array to store the non-zero indices, or NULL */
3354  int* ninds /**< pointer to store the number of non-zero indices, or NULL
3355  * (-1: if we do not store sparsity information) */
3356  )
3357 {
3358  SCIPdebugMessage("calling SCIPlpiGetBInvACol()\n");
3359 
3360  assert(lpi != NULL);
3361  assert(lpi->clp != NULL);
3362  assert( coef != 0 );
3363  assert( 0 <= c && c <= lpi->clp->numberColumns() );
3364 
3365  /* can only return dense result */
3366  if ( ninds != NULL )
3367  *ninds = -1;
3368 
3369  ClpSimplex* clp = lpi->clp;
3370  clp->getBInvACol(c, coef);
3371 
3372  return SCIP_OKAY;
3373 }
3374 
3375 
3376 /**@} */
3377 
3378 
3379 
3380 
3381 /*
3382  * LP State Methods
3383  */
3384 
3385 /**@name LP State Methods */
3386 /**@{ */
3387 
3388 /** stores LPi state (like basis information) into lpistate object */
3390  SCIP_LPI* lpi, /**< LP interface structure */
3391  BMS_BLKMEM* blkmem, /**< block memory */
3392  SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */
3393  )
3394 {
3395  SCIPdebugMessage("calling SCIPlpiGetState()\n");
3396 
3397  assert(blkmem != NULL);
3398  assert(lpi != NULL);
3399  assert(lpi->clp != NULL);
3400  assert(lpistate != NULL);
3401 
3402  int ncols = lpi->clp->numberColumns();
3403  int nrows = lpi->clp->numberRows();
3404  assert(ncols >= 0);
3405  assert(nrows >= 0);
3406 
3407  /* allocate lpistate data */
3408  SCIP_CALL( lpistateCreate(lpistate, blkmem, ncols, nrows) );
3409 
3410  /* allocate enough memory for storing uncompressed basis information */
3411  SCIP_CALL( ensureCstatMem(lpi, ncols) );
3412  SCIP_CALL( ensureRstatMem(lpi, nrows) );
3413 
3414  /* get unpacked basis information */
3415  SCIP_CALL( SCIPlpiGetBase(lpi, lpi->cstat, lpi->rstat) );
3416 
3417  /* pack LPi state data */
3418  (*lpistate)->ncols = ncols;
3419  (*lpistate)->nrows = nrows;
3420  lpistatePack(*lpistate, lpi->cstat, lpi->rstat);
3421 
3422  return SCIP_OKAY;
3423 }
3424 
3425 
3426 /** loads LPi state (like basis information) into solver; note that the LP might have been extended with additional
3427  * columns and rows since the state was stored with SCIPlpiGetState()
3428  */
3430  SCIP_LPI* lpi, /**< LP interface structure */
3431  BMS_BLKMEM* blkmem, /**< block memory */
3432  const SCIP_LPISTATE* lpistate /**< LPi state information (like basis information), or NULL */
3433  )
3434 { /* lint --e{715} */
3435  int lpncols;
3436  int lpnrows;
3437  int i;
3438 
3439  SCIPdebugMessage("calling SCIPlpiSetState()\n");
3440 
3441  assert(lpi != NULL);
3442  assert(lpi->clp != NULL);
3443  assert(blkmem != NULL);
3444 
3445  /* if there was no basis information available, the LPI state was not stored */
3446  if( lpistate == NULL )
3447  return SCIP_OKAY;
3448 
3449  lpncols = lpi->clp->numberColumns();
3450  lpnrows = lpi->clp->numberRows();
3451  assert(lpistate->ncols <= lpncols);
3452  assert(lpistate->nrows <= lpnrows);
3453 
3454  /* allocate enough memory for storing uncompressed basis information */
3455  SCIP_CALL( ensureCstatMem(lpi, lpncols) );
3456  SCIP_CALL( ensureRstatMem(lpi, lpnrows) );
3457 
3458  /* unpack LPi state data */
3459  lpistateUnpack(lpistate, lpi->cstat, lpi->rstat);
3460 
3461  /* extend the basis to the current LP beyond the previously existing columns */
3462  for( i = lpistate->ncols; i < lpncols; ++i )
3463  {
3464  SCIP_Real bnd = (lpi->clp->getColLower())[i];
3465  if ( SCIPlpiIsInfinity(lpi, REALABS(bnd)) )
3466  {
3467  /* if lower bound is +/- infinity -> try upper bound */
3468  bnd = (lpi->clp->getColUpper())[i];
3469  if ( SCIPlpiIsInfinity(lpi, REALABS(bnd)) )
3470  lpi->cstat[i] = SCIP_BASESTAT_ZERO; /* variable is free */
3471  else
3472  lpi->cstat[i] = SCIP_BASESTAT_UPPER; /* use finite upper bound */
3473  }
3474  else
3475  lpi->cstat[i] = SCIP_BASESTAT_LOWER; /* use finite lower bound */
3476  }
3477  for( i = lpistate->nrows; i < lpnrows; ++i )
3478  lpi->rstat[i] = SCIP_BASESTAT_BASIC;
3479 
3480  /* load basis information */
3481  SCIP_CALL( SCIPlpiSetBase(lpi, lpi->cstat, lpi->rstat) );
3482 
3483  return SCIP_OKAY;
3484 }
3485 
3486 /** clears current LPi state (like basis information) of the solver */
3488  SCIP_LPI* lpi /**< LP interface structure */
3489  )
3490 {
3491  SCIPdebugMessage("calling SCIPlpiClearState()\n");
3492 
3493  assert(lpi != NULL);
3494  assert(lpi->clp != NULL);
3495 
3496  lpi->clp->allSlackBasis(true);
3497  lpi->validFactorization = false;
3498 
3499  return SCIP_OKAY;
3500 }
3501 
3502 /** frees LPi state information */
3504  SCIP_LPI* lpi, /**< LP interface structure */
3505  BMS_BLKMEM* blkmem, /**< block memory */
3506  SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */
3507  )
3508 {
3509  SCIPdebugMessage("calling SCIPlpiFreeState()\n");
3510 
3511  assert(lpi != NULL);
3512  assert(lpistate != NULL);
3513  assert(blkmem != NULL);
3514 
3515  if ( *lpistate != NULL )
3516  lpistateFree(lpistate, blkmem);
3517 
3518  return SCIP_OKAY;
3519 }
3520 
3521 /** checks, whether the given LP state contains simplex basis information */
3523  SCIP_LPI* lpi, /**< LP interface structure */
3524  SCIP_LPISTATE* lpistate /**< LP state information (like basis information), or NULL*/
3525  )
3526 {
3527  assert(lpi != NULL);
3528  return (lpistate != NULL);
3529 }
3530 
3531 /** reads LP state (like basis information) from a file */
3533  SCIP_LPI* lpi, /**< LP interface structure */
3534  const char* fname /**< file name */
3535  )
3536 {
3537  SCIPdebugMessage("calling SCIPlpiReadState()\n");
3538  assert(lpi != NULL);
3539  assert(lpi->clp != NULL);
3540  assert(fname != NULL);
3541 
3542  /* Read a basis from the given filename,
3543  * returns -1 on file error, 0 if no values, 1 if values
3544  */
3545  if ( lpi->clp->readBasis(fname) < 0 )
3546  return SCIP_READERROR;
3547 
3548  return SCIP_OKAY;
3549 }
3550 
3551 /** writes LPi state (i.e. basis information) to a file */
3553  SCIP_LPI* lpi, /**< LP interface structure */
3554  const char* fname /**< file name */
3555  )
3556 {
3557  SCIPdebugMessage("calling SCIPlpiWriteState()\n");
3558  assert(lpi != NULL);
3559  assert(lpi->clp != NULL);
3560  assert(fname != NULL);
3561 
3562  /* Write the basis in MPS format to the specified file.
3563  * If writeValues true, writes values of structurals
3564  * (and adds VALUES to end of NAME card)
3565  *
3566  * parameters:
3567  * - filename
3568  * - bool writeValues
3569  * - int formatType (0 - normal, 1 - extra accuracy, 2 - IEEE hex)
3570  */
3571  if ( lpi->clp->writeBasis(fname, false, 0) )
3572  return SCIP_WRITEERROR;
3573 
3574  return SCIP_OKAY;
3575 }
3576 
3577 /**@} */
3578 
3579 
3580 
3581 
3582 /*
3583  * LP Pricing Norms Methods
3584  */
3585 
3586 /**@name LP Pricing Norms Methods */
3587 /**@{ */
3588 
3589 /** stores LPi pricing norms information
3590  * @todo should we store norm information?
3591  */
3593  SCIP_LPI* lpi, /**< LP interface structure */
3594  BMS_BLKMEM* blkmem, /**< block memory */
3595  SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information */
3596  )
3597 {
3598  assert(blkmem != NULL);
3599  assert(lpi != NULL);
3600  assert(lpinorms != NULL);
3601 
3602  (*lpinorms) = NULL;
3603 
3604  return SCIP_OKAY;
3605 }
3606 
3607 /** loads LPi pricing norms into solver; note that the LP might have been extended with additional
3608  * columns and rows since the state was stored with SCIPlpiGetNorms()
3609  */
3611  SCIP_LPI* lpi, /**< LP interface structure */
3612  BMS_BLKMEM* blkmem, /**< block memory */
3613  const SCIP_LPINORMS* lpinorms /**< LPi pricing norms information, or NULL */
3614  )
3615 {
3616  assert(lpinorms == NULL);
3617 
3618  /* no work necessary */
3619  return SCIP_OKAY;
3620 }
3621 
3622 /** frees pricing norms information */
3624  SCIP_LPI* lpi, /**< LP interface structure */
3625  BMS_BLKMEM* blkmem, /**< block memory */
3626  SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information, or NULL */
3627  )
3628 {
3629  assert(lpinorms == NULL);
3630 
3631  /* no work necessary */
3632  return SCIP_OKAY;
3633 }
3634 
3635 /**@} */
3636 
3637 
3638 
3639 
3640 /*
3641  * Parameter Methods
3642  */
3643 
3644 /**@name Parameter Methods */
3645 /**@{ */
3646 
3647 /** gets integer parameter of LP */
3649  SCIP_LPI* lpi, /**< LP interface structure */
3650  SCIP_LPPARAM type, /**< parameter number */
3651  int* ival /**< buffer to store the parameter value */
3652  )
3653 {
3654  SCIPdebugMessage("calling SCIPlpiGetIntpar()\n");
3655 
3656  assert(lpi != NULL);
3657  assert(lpi->clp != NULL);
3658  assert(ival != 0);
3659 
3660  switch( type )
3661  {
3663  *ival = lpi->startscratch;
3664  break;
3665  case SCIP_LPPAR_SCALING:
3666  if( lpi->clp->scalingFlag() != 0 ) // 0 -off, 1 equilibrium, 2 geometric, 3 auto, 4 dynamic(later)
3667  *ival = TRUE;
3668  else
3669  *ival = FALSE;
3670  break;
3671  case SCIP_LPPAR_PRICING:
3672  *ival = (int)lpi->pricing; // store pricing method in LPI struct
3673  break;
3674  case SCIP_LPPAR_LPINFO:
3675  *ival = lpi->clp->logLevel() > 0 ? TRUE : FALSE;
3676  break;
3677  case SCIP_LPPAR_LPITLIM:
3678  *ival = lpi->clp->maximumIterations();
3679  break;
3680  case SCIP_LPPAR_FASTMIP:
3681  *ival = lpi->fastmip;
3682  break;
3683  default:
3684  return SCIP_PARAMETERUNKNOWN;
3685  }
3686 
3687  return SCIP_OKAY;
3688 }
3689 
3690 
3691 /** sets integer parameter of LP */
3693  SCIP_LPI* lpi, /**< LP interface structure */
3694  SCIP_LPPARAM type, /**< parameter number */
3695  int ival /**< parameter value */
3696  )
3697 {
3698  SCIPdebugMessage("calling SCIPlpiSetIntpar()\n");
3699 
3700  assert(lpi != NULL);
3701  assert(lpi->clp != NULL);
3702 
3703  // Handle pricing separately ...
3704  if( type == SCIP_LPPAR_PRICING )
3705  {
3706  // for primal:
3707  // 0 is exact devex,
3708  // 1 full steepest,
3709  // 2 is partial exact devex
3710  // 3 switches between 0 and 2 depending on factorization
3711  // 4 starts as partial dantzig/devex but then may switch between 0 and 2.
3712  // - currently (Clp 1.8) default is 3
3713 
3714  // for dual:
3715  // 0 is uninitialized,
3716  // 1 full,
3717  // 2 is partial uninitialized,
3718  // 3 starts as 2 but may switch to 1.
3719  // - currently (Clp 1.8) default is 3
3720  lpi->pricing = (SCIP_PRICING)ival;
3721  int primalmode = 0;
3722  int dualmode = 0;
3723  switch( (SCIP_PRICING)ival )
3724  {
3725  case SCIP_PRICING_AUTO:
3726  primalmode = 3; dualmode = 3; break;
3727  case SCIP_PRICING_FULL:
3728  primalmode = 0; dualmode = 1; break;
3730  case SCIP_PRICING_STEEP:
3731  primalmode = 1; dualmode = 0; break;
3733  primalmode = 1; dualmode = 2; break;
3734  case SCIP_PRICING_DEVEX:
3735  primalmode = 2; dualmode = 3; break;
3736  default:
3737  SCIPerrorMessage("unkown pricing parameter %d!\n", ival);
3738  SCIPABORT();
3739  return SCIP_INVALIDDATA; /*lint !e527*/
3740  }
3741  ClpPrimalColumnSteepest primalpivot(primalmode);
3742  lpi->clp->setPrimalColumnPivotAlgorithm(primalpivot);
3743  ClpDualRowSteepest dualpivot(dualmode);
3744  lpi->clp->setDualRowPivotAlgorithm(dualpivot);
3745  return SCIP_OKAY;
3746  }
3747 
3748  switch( type )
3749  {
3751  lpi->startscratch = ival;
3752  break;
3753  case SCIP_LPPAR_SCALING:
3754  lpi->clp->scaling((ival > 0) ? 3 : 0); // 0 -off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later));
3755  break;
3756  case SCIP_LPPAR_PRICING:
3757  /* should not happen - see above */
3758  SCIPABORT();
3759  return SCIP_LPERROR; /*lint !e527*/
3760  case SCIP_LPPAR_LPINFO:
3761  assert(ival == TRUE || ival == FALSE);
3762  /* Amount of print out:
3763  * 0 - none
3764  * 1 - just final
3765  * 2 - just factorizations
3766  * 3 - as 2 plus a bit more
3767  * 4 - verbose
3768  * above that 8,16,32 etc just for selective SCIPdebug
3769  */
3770  if ( ival )
3771  lpi->clp->setLogLevel(2); // lpi->clp->setLogLevel(63);
3772  else
3773  lpi->clp->setLogLevel(0);
3774  break;
3775  case SCIP_LPPAR_LPITLIM:
3776  /* ival >= 0, 0 stop immediately */
3777  assert( ival >= 0 );
3778  lpi->clp->setMaximumIterations(ival);
3779  break;
3780  case SCIP_LPPAR_FASTMIP:
3781  assert(ival == TRUE || ival == FALSE);
3782  if( ival )
3784  else
3786  break;
3787  default:
3788  return SCIP_PARAMETERUNKNOWN;
3789  }
3790 
3791  return SCIP_OKAY;
3792 }
3793 
3794 
3795 /** gets floating point parameter of LP */
3797  SCIP_LPI* lpi, /**< LP interface structure */
3798  SCIP_LPPARAM type, /**< parameter number */
3799  SCIP_Real* dval /**< buffer to store the parameter value */
3800  )
3801 {
3802  SCIPdebugMessage("calling SCIPlpiGetRealpar()\n");
3803 
3804  assert(lpi != NULL);
3805  assert(lpi->clp != NULL);
3806  assert(dval != 0);
3807 
3808  switch( type )
3809  {
3810  case SCIP_LPPAR_FEASTOL:
3811  *dval = lpi->clp->primalTolerance();
3812  break;
3814  *dval = lpi->clp->dualTolerance();
3815  break;
3817  /* @todo add BARRIERCONVTOL parameter */
3818  return SCIP_PARAMETERUNKNOWN;
3819  case SCIP_LPPAR_OBJLIM:
3820  *dval = lpi->clp->dualObjectiveLimit();
3821  break;
3822  case SCIP_LPPAR_LPTILIM:
3823  *dval = lpi->clp->maximumSeconds();
3824  break;
3825  default:
3826  return SCIP_PARAMETERUNKNOWN;
3827  }
3828 
3829  return SCIP_OKAY;
3830 }
3831 
3832 /** sets floating point parameter of LP */
3834  SCIP_LPI* lpi, /**< LP interface structure */
3835  SCIP_LPPARAM type, /**< parameter number */
3836  SCIP_Real dval /**< parameter value */
3837  )
3838 {
3839  SCIPdebugMessage("calling SCIPlpiSetRealpar()\n");
3840  SCIPdebugMessage("setting parameter %d to value %g.\n", type, dval);
3841 
3842  assert(lpi != NULL);
3843  assert(lpi->clp != NULL);
3844 
3845  switch( type )
3846  {
3847  case SCIP_LPPAR_FEASTOL:
3848  assert( dval > 0.0 );
3849  /* 0 < dval < 1e10 */
3850  if( dval > 1e+10 )
3851  {
3852  /* however dval is required to be strictly less than 1e+10 */
3853  dval = 9e+9;
3854  }
3855 
3856  lpi->clp->setPrimalTolerance(dval);
3857  break;
3859  assert( dval > 0.0 );
3860  /* 0 < dval < 1e10 */
3861  if( dval > 1e+10 )
3862  {
3863  /* however dval is required to be strictly less than 1e+10 */
3864  dval = 9e+9;
3865  }
3866 
3867  lpi->clp->setDualTolerance(dval);
3868  break;
3870  /* @todo add BARRIERCONVTOL parameter */
3871  return SCIP_PARAMETERUNKNOWN;
3872  case SCIP_LPPAR_OBJLIM:
3873  /* no restriction on dval */
3874 
3875  lpi->clp->setDualObjectiveLimit(dval);
3876  break;
3877  case SCIP_LPPAR_LPTILIM:
3878  assert( dval > 0.0 );
3879  /* clp poses no restrictions on dval
3880  * (it handles the case dval < 0 internally and sets param to -1 meaning no time limit.)
3881  *
3882  * However for consistency we assert the timelimit to be strictly positive.
3883  */
3884 
3885  lpi->clp->setMaximumSeconds(dval);
3886  break;
3887  default:
3888  return SCIP_PARAMETERUNKNOWN;
3889  }
3890 
3891  return SCIP_OKAY;
3892 }
3893 
3894 /** interrupts the currently ongoing lp solve or disables the interrupt */
3896  SCIP_LPI* lpi, /**< LP interface structure */
3897  SCIP_Bool interrupt /**< TRUE if interrupt should be set, FALSE if it should be disabled */
3898  )
3899 {
3900  /*lint --e{715}*/
3901  assert(lpi != NULL);
3902 
3903  return SCIP_OKAY;
3904 }
3905 
3906 /**@} */
3907 
3908 
3909 
3910 
3911 /*
3912  * Numerical Methods
3913  */
3914 
3915 /**@name Numerical Methods */
3916 /**@{ */
3917 
3918 /** returns value treated as infinity in the LP solver */
3920  SCIP_LPI* lpi /**< LP interface structure */
3921  )
3922 { /* lint --e{715} */
3923  assert(lpi != NULL);
3924  SCIPdebugMessage("calling SCIPlpiInfinity()\n");
3925 
3926  return COIN_DBL_MAX;
3927 }
3928 
3929 
3930 /** checks if given value is treated as infinity in the LP solver */
3932  SCIP_LPI* lpi, /**< LP interface structure */
3933  SCIP_Real val /**< value to check */
3934  )
3935 { /* lint --e{715} */
3936  assert(lpi != NULL);
3937  SCIPdebugMessage("calling SCIPlpiIsInfinity()\n");
3938 
3939  return (val >= COIN_DBL_MAX);
3940 }
3941 
3942 /**@} */
3943 
3944 
3945 
3946 
3947 /*
3948  * File Interface Methods
3949  */
3950 
3951 /**@name File Interface Methods */
3952 /**@{ */
3953 
3954 /** returns, whether the given file exists */
3955 static
3957  const char* filename /**< file name */
3958  )
3959 {
3960  FILE* f;
3961 
3962  f = fopen(filename, "r");
3963  if( f == 0 )
3964  return FALSE;
3965 
3966  fclose(f);
3967 
3968  return TRUE;
3969 }
3970 
3971 /** reads LP from a file */
3973  SCIP_LPI* lpi, /**< LP interface structure */
3974  const char* fname /**< file name */
3975  )
3976 {
3977  SCIPdebugMessage("calling SCIPlpiReadLP()\n");
3978 
3979  assert(lpi != NULL);
3980  assert(lpi->clp != NULL);
3981  assert(fname != NULL);
3982 
3983  // WARNING: can only read mps files
3984 
3985  if ( !fileExists(fname) )
3986  return SCIP_NOFILE;
3987 
3988  /* read file in MPS format
3989  * parameters:
3990  * filename
3991  * bool keepNames
3992  * bool ignoreErrors
3993  */
3994  if ( lpi->clp->readMps(fname, true, false) )
3995  return SCIP_READERROR;
3996 
3997  return SCIP_OKAY;
3998 }
3999 
4000 /** writes LP to a file */
4002  SCIP_LPI* lpi, /**< LP interface structure */
4003  const char* fname /**< file name */
4004  )
4005 {
4006  SCIPdebugMessage("calling SCIPlpiWriteLP() - %s\n", fname);
4007 
4008  assert(lpi != NULL);
4009  assert(lpi->clp != NULL);
4010  assert(fname != NULL);
4011 
4012  /* write file in MPS format
4013  * parameters:
4014  * filename
4015  * int formatType (0 - normal, 1 - extra accuracy, 2 - IEEE hex)
4016  * int numberAcross (1 or 2 values should be specified on every data line in the MPS file)
4017  * double objSense
4018  */
4019  if ( lpi->clp->writeMps(fname, 0, 2, lpi->clp->optimizationDirection()) )
4020  return SCIP_WRITEERROR;
4021 
4022  return SCIP_OKAY;
4023 }
4024 
4025 /**@} */
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_clp.cpp:3276
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
Definition: lpi_clp.cpp:1417
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
Definition: type_lpi.h:104
#define NULL
Definition: def.h:267
#define ROWS_PER_PACKET
Definition: lpi_clp.cpp:129
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
Definition: lpi_clp.cpp:643
#define SUMINFEASBOUND
Definition: lpi_clp.cpp:101
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPISTATE *lpistate)
Definition: lpi_clp.cpp:3429
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
Definition: lpi_clp.cpp:3931
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:148
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2578
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
Definition: lpi_clp.cpp:3610
int nrows
Definition: lpi_none.c:52
ROWPACKET * packrstat
Definition: lpi_clp.cpp:137
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
Definition: lpi_clp.cpp:2857
SCIP_PRICING pricing
Definition: lpi_clp.cpp:112
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2006
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
Definition: lpi_clp.cpp:2788
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
Definition: lpi_clp.cpp:3692
enum SCIP_ObjSen SCIP_OBJSEN
Definition: type_lpi.h:45
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1805
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:471
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
Definition: lpi_clp.cpp:2967
SCIP_Bool solved
Definition: lpi_clp.cpp:114
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
Definition: bitencode.c:308
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
Definition: lpi_clp.cpp:1167
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
Definition: lpi_clp.cpp:3648
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
Definition: lpi_clp.cpp:2921
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
Definition: lpi_clp.cpp:1453
#define FALSE
Definition: def.h:94
#define EPSEQ(x, y, eps)
Definition: def.h:198
#define TRUE
Definition: def.h:93
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
Definition: lpi_clp.cpp:171
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
int rstatsize
Definition: lpi_clp.cpp:110
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
Definition: lpi_clp.cpp:3833
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2468
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lpi_clp.cpp:3592
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
Definition: lpi_clp.cpp:271
enum SCIP_LPParam SCIP_LPPARAM
Definition: type_lpi.h:73
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
Definition: lpi_clp.cpp:1435
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:123
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
Definition: lpi_clp.cpp:3532
#define SCIPdebugMessage
Definition: pub_message.h:96
SCIP_Bool SCIPlpiHasDualSolve(void)
Definition: lpi_clp.cpp:502
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
Definition: lpi_clp.cpp:1709
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1064
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
Definition: lpi_clp.cpp:2940
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
Definition: lpi_clp.cpp:1340
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
Definition: lpi_clp.cpp:1666
#define BMSfreeMemory(ptr)
Definition: memory.h:145
SCIP_RETCODE SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
Definition: lpi_clp.cpp:480
enum SCIP_Pricing SCIP_PRICING
Definition: type_lpi.h:86
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:3487
SCIP_RETCODE SCIPlpiGetCols(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lb, SCIP_Real *ub, int *nnonz, int *beg, int *ind, SCIP_Real *val)
Definition: lpi_clp.cpp:1474
bool startscratch
Definition: lpi_clp.cpp:111
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
Definition: lpi_clp.cpp:531
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_clp.cpp:3314
SCIP_RETCODE SCIPlpiAddCols(SCIP_LPI *lpi, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
Definition: lpi_clp.cpp:758
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2488
SCIP_DUALPACKET COLPACKET
Definition: lpi_clp.cpp:126
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2752
SCIP_Real feastol
Definition: lpi_cpx.c:172
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:1880
static SCIP_RETCODE lpiStrongbranches(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2151
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2647
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
Definition: lpi_clp.cpp:234
SCIP_RETCODE SCIPlpiAddRows(SCIP_LPI *lpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
Definition: lpi_clp.cpp:914
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
Definition: lpi_clp.cpp:4001
packing single and dual bit values
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:147
#define SCIPerrorMessage
Definition: pub_message.h:64
int ncols
Definition: lpi_none.c:53
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
Definition: lpi_clp.cpp:3189
SCIP_RETCODE SCIPlpiStrongbranchesFrac(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2304
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
Definition: lpi_clp.cpp:250
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lpi_clp.cpp:3503
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2502
SCIP_DUALPACKET ROWPACKET
Definition: lpi_clp.cpp:128
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
Definition: lpi_clp.cpp:1599
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2283
SCIP_RETCODE SCIPlpiStrongbranchesInt(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2350
int * rstat
Definition: lpi_clp.cpp:108
#define REALABS(x)
Definition: def.h:197
const char * SCIPlpiGetSolverDesc(void)
Definition: lpi_clp.cpp:463
int cstatsize
Definition: lpi_clp.cpp:109
#define SCIP_CALL(x)
Definition: def.h:380
SCIP_Bool SCIPlpiHasBarrierSolve(void)
Definition: lpi_clp.cpp:510
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
Definition: lpi_clp.cpp:2405
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lpi_clp.cpp:3623
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
Definition: lpi_clp.cpp:986
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
Definition: bitencode.c:238
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
Definition: lpi_clp.cpp:3972
#define EPSCEIL(x, eps)
Definition: def.h:207
bool validFactorization
Definition: lpi_clp.cpp:113
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2386
COLPACKET * packcstat
Definition: lpi_clp.cpp:136
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:465
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2450
unsigned int SCIP_DUALPACKET
Definition: bitencode.h:42
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
Definition: lpi_clp.cpp:2766
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
Definition: lpi_clp.cpp:1018
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
Definition: lpi_clp.cpp:149
#define SCIP_Bool
Definition: def.h:91
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
Definition: lpi_clp.cpp:3522
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
Definition: lpi_clp.cpp:837
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:454
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
Definition: lpi_clp.cpp:3552
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:3919
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
Definition: lpi_clp.cpp:1197
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2609
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lpi_clp.cpp:3389
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2595
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:467
static int colpacketNum(int ncols)
Definition: lpi_clp.cpp:200
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
Definition: lpi_clp.cpp:1623
static SCIP_Bool fileExists(const char *filename)
Definition: lpi_clp.cpp:3956
#define COLS_PER_PACKET
Definition: lpi_clp.cpp:127
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
Definition: lpi_clp.cpp:3067
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:134
static void invalidateSolution(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:295
int iterations
Definition: lpi_cpx.c:166
bool setFactorizationFrequency
Definition: lpi_clp.cpp:115
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2623
SCIP_Bool SCIPlpiHasPrimalSolve(void)
Definition: lpi_clp.cpp:494
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
Definition: lpi_clp.cpp:1084
static SCIP_RETCODE lpiStrongbranch(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2031
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2736
static int rowpacketNum(int nrows)
Definition: lpi_clp.cpp:209
SCIP_Real * r
Definition: circlepacking.c:59
SCIP_RETCODE SCIPlpiGetRows(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhs, SCIP_Real *rhs, int *nnonz, int *beg, int *ind, SCIP_Real *val)
Definition: lpi_clp.cpp:1538
SCIP_RETCODE SCIPlpiStrongbranchInt(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
Definition: lpi_clp.cpp:2329
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
Definition: lpi_clp.cpp:1957
#define MAX(x, y)
Definition: def.h:239
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
Definition: lpi_clp.cpp:2832
static void setFastmipClpParameters(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:321
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2018
SCIP_RETCODE SCIPlpiLoadColLP(SCIP_LPI *lpi, SCIP_OBJSEN objsen, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
Definition: lpi_clp.cpp:677
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
Definition: lpi_clp.cpp:1267
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
Definition: lpi_clp.cpp:1740
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2556
public methods for message output
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_clp.cpp:3349
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
Definition: lpi_clp.cpp:1686
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2690
#define SCIP_Real
Definition: def.h:173
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2521
#define BMSallocMemory(ptr)
Definition: memory.h:118
#define SCIP_INVALID
Definition: def.h:193
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:127
SCIP_Bool fastmip
Definition: lpi_clp.cpp:116
#define CLP_VERSION
Definition: lpi_clp.cpp:77
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
Definition: lpi_clp.cpp:1240
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2537
SCIP_MESSAGEHDLR * messagehdlr
Definition: lpi_cpx.c:184
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:451
SCIP_RETCODE SCIPlpiInterrupt(SCIP_LPI *lpi, SCIP_Bool interrupt)
Definition: lpi_clp.cpp:3895
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:2720
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
Definition: lpi_clp.cpp:1771
#define EPSFLOOR(x, eps)
Definition: def.h:206
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
Definition: lpi_clp.cpp:1220
static void unsetFastmipClpParameters(SCIP_LPI *lpi)
Definition: lpi_clp.cpp:419
int lastalgorithm
Definition: lpi_clp.cpp:117
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_clp.cpp:3241
#define SCIP_ALLOC(x)
Definition: def.h:391
#define SCIPABORT()
Definition: def.h:352
const char * SCIPlpiGetSolverName(void)
Definition: lpi_clp.cpp:454
char name[200]
Definition: lpi_xprs.c:90
int * cstat
Definition: lpi_clp.cpp:107
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
Definition: lpi_clp.cpp:218
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
Definition: lpi_clp.cpp:1647
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
Definition: lpi_clp.cpp:3796
ClpSimplex * clp
Definition: lpi_clp.cpp:106
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
Definition: lpi_clp.cpp:868