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