Scippy

SCIP

Solving Constraint Integer Programs

lpi_qso.c
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-2017 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file lpi_qso.c
17  * @brief LP interface for QSopt version >= 070303
18  * @author Daniel Espinoza
19  * @author Marc Pfetsch
20  */
21 
22 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "qsopt.h"
25 #include "scip/bitencode.h"
26 #include "lpi/lpi.h"
27 #include "scip/pub_message.h"
28 #include "scip/pub_misc.h"
29 #include <string.h>
30 
31 typedef SCIP_DUALPACKET COLPACKET; /* each column needs two bits of information (basic/on_lower/on_upper) */
32 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE
33 typedef SCIP_DUALPACKET ROWPACKET; /* each row needs two bit of information (basic/on_lower/on_upper) */
34 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE
35 
36 /** LP interface */
37 struct SCIP_LPi
38 {
39  QSprob prob; /**< LP struct pointer */
40  int solstat; /**< solution status of last optimization call */
41  int previt; /**< previous number of simplex iterations performed */
42  int rowspace; /**< current size of internal row-related arrays */
43  char* isen; /**< array of length rowspace */
44  double* irhs; /**< array of rhs rowspace */
45  double* irng; /**< array of range rowspace */
46  int* ircnt; /**< array of count rowspace */
47  int* irbeg; /**< array of beginning index rowspace */
48  int colspace; /**< current size of internal column-related arrays */
49  int* iccnt; /**< array of length colspace */
50  char* iccha; /**< array of type colspace */
51  int tbsz; /**< current size of tableau-related arrays */
52  double* itab; /**< array of length tbsz */
53  char* ibas; /**< array of length tbsz */
54  int pricing; /**< SCIP pricing option */
55  SCIP_MESSAGEHDLR* messagehdlr; /**< messagehdlr handler to printing messages, or NULL */
56 };
57 
58 /** row norms */
59 struct SCIP_LPiNorms
60 {
61  int nrows; /**< number of rows */
62  int ncols; /**< number of columns */
63  char* cstat; /**< basis status of columns */
64  char* rstat; /**< basis status of rows */
65  SCIP_Real* norms; /**< row norms */
66 };
67 
68 
69 /** solver name */
70 static char __qsstr[SCIP_MAXSTRLEN];
71 
72 
73 
74 /*
75  * local defines
76  */
77 
78 /** (feasibility) tolerance for qsopt */
79 #define FEASTOL 1e-6
80 
81 /** tolerance for testing equality */
82 #define EPSILON 1e-9
83 
84 /** print location of the calling line */
85 #define __QS_PRINTLOC__ fprintf(stderr,", in (%s:%d)\n", __FILE__, __LINE__);
86 
87 /** This macro is to print error messages and jump to the given point in the code, it also prints the
88  * file name and line where this happened. */
89 #define QS_TESTG(A,B,C) do{{ \
90  if (A){ \
91  fprintf(stderr, C); \
92  __QS_PRINTLOC__; \
93  goto B;}}}while(0)
94 
95 /** This macro is to print error messages and to exit with SCIP_LPERROR. */
96 #define QS_ERROR(A,...) do{{ \
97  if (A){ \
98  fprintf(stderr,__VA_ARGS__); \
99  __QS_PRINTLOC__; \
100  return SCIP_LPERROR;}}}while(0)
101 
102 /** Return value macro, if the value is non-zero, write to standard error the returning code and
103  * where this happened, and return SCIP_ERROR, otherwise return normal SCIP_OKAY termination code. */
104 #define QS_RETURN(A) do{ \
105  const int __RVAL__ = (A); \
106  if (__RVAL__){ \
107  fprintf(stderr,"LP Error: QSopt returned %d",__RVAL__); \
108  __QS_PRINTLOC__; \
109  return SCIP_ERROR;} \
110  return SCIP_OKAY;}while(0)
111 
112 /** Return value macro, if the value is non-zero, write to standard error the returning code and
113  * where this happened, and return SCIP_ERROR, otherwise do nothing. */
114 #define QS_CONDRET(A) do{ \
115  const int __RVAL__ = (A); \
116  if (__RVAL__){ \
117  fprintf(stderr,"LP Error: QSopt returned %d",__RVAL__); \
118  __QS_PRINTLOC__; \
119  return SCIP_LPERROR;} \
120  }while(0)
121 
122 
123 
124 /*
125  * LPi state methods
126  */
127 
128 
129 /** LPi state stores basis information */
130 struct SCIP_LPiState
131 {
132  int ncols; /**< number of LP columns */
133  int nrows; /**< number of LP rows */
134  COLPACKET* packcstat; /**< column basis status in compressed form */
135  ROWPACKET* packrstat; /**< row basis status in compressed form */
136 };
137 
138 /** returns the number of packets needed to store column packet information */
139 static
141  int ncols /**< number of columns to store */
142  )
143 {
144  return (ncols + (int)COLS_PER_PACKET-1)/(int)COLS_PER_PACKET;
145 }
146 
147 /** returns the number of packets needed to store row packet information */
148 static
150  int nrows /**< number of rows to store */
151  )
152 {
153  return (nrows + (int)ROWS_PER_PACKET-1)/(int)ROWS_PER_PACKET;
154 }
155 
156 /** store row and column basis status in a packed LPi state object */
157 static
159  SCIP_LPISTATE* lpistate, /**< pointer to LPi state data */
160  const int* cstat, /**< basis status of columns in unpacked format */
161  const int* rstat /**< basis status of rows in unpacked format */
162  )
163 {
164  assert(lpistate != NULL);
165  assert(lpistate->packcstat != NULL);
166  assert(lpistate->packrstat != NULL);
167 
168  SCIPencodeDualBit(cstat, lpistate->packcstat, lpistate->ncols);
169  SCIPencodeDualBit(rstat, lpistate->packrstat, lpistate->nrows);
170 }
171 
172 /** unpacks row and column basis status from a packed LPi state object */
173 static
175  const SCIP_LPISTATE* lpistate, /**< pointer to LPi state data */
176  int* cstat, /**< buffer for storing basis status of columns in unpacked format */
177  int* rstat /**< buffer for storing basis status of rows in unpacked format */
178  )
179 {
180  assert(lpistate != NULL);
181  assert(lpistate->packcstat != NULL);
182  assert(lpistate->packrstat != NULL);
183 
184  SCIPdecodeDualBit(lpistate->packcstat, cstat, lpistate->ncols);
185  SCIPdecodeDualBit(lpistate->packrstat, rstat, lpistate->nrows);
186 }
187 
188 /** creates LPi state information object */
189 static
191  SCIP_LPISTATE** lpistate, /**< pointer to LPi state */
192  BMS_BLKMEM* blkmem, /**< block memory */
193  int ncols, /**< number of columns to store */
194  int nrows /**< number of rows to store */
195  )
196 {
197  assert(lpistate != NULL);
198  assert(blkmem != NULL);
199  assert(ncols >= 0);
200  assert(nrows >= 0);
201 
202  SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) );
203  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum(ncols)) );
204  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum(nrows)) );
205 
206  return SCIP_OKAY;
207 }
208 
209 /** frees LPi state information */
210 static
212  SCIP_LPISTATE** lpistate, /**< pointer to LPi state information (like basis information) */
213  BMS_BLKMEM* blkmem /**< block memory */
214  )
215 {
216  assert(blkmem != NULL);
217  assert(lpistate != NULL);
218  assert(*lpistate != NULL);
219 
220  BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum((*lpistate)->ncols));
221  BMSfreeBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum((*lpistate)->nrows));
222  BMSfreeBlockMemory(blkmem, lpistate);
223 }
224 
225 
226 
227 /*
228  * local functions
229  */
230 
231 /** ensure size of column-related arrays */
232 static
234  SCIP_LPI* const lpi, /**< pointer to an LP interface structure */
235  int sz /**< size */
236  )
237 {
238  if( lpi->tbsz < sz )
239  {
240  lpi->tbsz = sz*2;
241  SCIP_ALLOC( BMSreallocMemoryArray(&(lpi->itab), lpi->tbsz) );
242  SCIP_ALLOC( BMSreallocMemoryArray(&(lpi->ibas), lpi->tbsz) );
243  }
244  return SCIP_OKAY;
245 }
246 
247 /** ensure size of column-related arrays */
248 static
250  SCIP_LPI* const lpi, /**< pointer to an LP interface structure */
251  int ncols /**< number of columns */
252  )
253 {
254  if( lpi->colspace < ncols )
255  {
256  lpi->colspace = ncols*2;
259  }
260  return SCIP_OKAY;
261 }
262 
263 /** ensure size of row-related arrays */
264 static
266  SCIP_LPI* const lpi, /**< pointer to an LP interface structure */
267  int nrows /**< number of rows */
268  )
269 {
270  if( lpi->rowspace < nrows )
271  {
272  lpi->rowspace = nrows*2;
273  SCIP_ALLOC( BMSreallocMemoryArray(&(lpi->isen), lpi->rowspace) );
274  SCIP_ALLOC( BMSreallocMemoryArray(&(lpi->irhs), lpi->rowspace) );
275  SCIP_ALLOC( BMSreallocMemoryArray(&(lpi->irng), lpi->rowspace) );
278  }
279  return SCIP_OKAY;
280 }
281 
282 /** transform lhs/rhs into qsopt format */
283 static
285  SCIP_LPI* const lpi, /**< pointer to an LP interface structure */
286  int nrows, /**< number of rows */
287  const double* const lhs, /**< left hand side */
288  const double* const rhs /**< right hand side */
289  )
290 {
291  int state;
292  register int i;
293 
294  for( i = nrows ; i-- ; )
295  {
296  state = ((lhs[i] <= -QS_MAXDOUBLE ? 1U:0U) | (rhs[i] >= QS_MAXDOUBLE ? 2U:0U));
297  lpi->ircnt[i] = 0;
298  lpi->irbeg[i] = 0;
299  switch( state )
300  {
301  case 0:
302  /* check for equations */
303  if( EPSEQ(lhs[i], rhs[i], EPSILON) )
304  {
305  lpi->isen[i] = 'E';
306  lpi->irhs[i] = lhs[i];
307  lpi->irng[i] = 0.0;
308  }
309  else
310  {
311  lpi->isen[i] = 'R';
312  lpi->irhs[i] = lhs[i];
313  lpi->irng[i] = rhs[i] - lhs[i];
314  assert(lpi->irng[i] >= 0.0);
315  }
316  break;
317  case 1:
318  lpi->isen[i] = 'L';
319  lpi->irhs[i] = rhs[i];
320  lpi->irng[i] = 0;
321  break;
322  case 2:
323  lpi->isen[i] = 'G';
324  lpi->irhs[i] = lhs[i];
325  lpi->irng[i] = 0;
326  break;
327  default:
328  SCIPerrorMessage("Error, constraint %d has no bounds!",i);
329  SCIPABORT();
330  return SCIP_INVALIDDATA; /*lint !e527*/
331  }
332  }
333  return SCIP_OKAY;
334 }
335 
336 
337 
338 
339 /*
340  * Miscellaneous Methods
341  */
342 
343 
344 /**@name Miscellaneous Methods */
345 /**@{ */
346 
347 
348 /** gets name and version of LP solver */
349 const char* SCIPlpiGetSolverName(void)
350 {
351  char* vname;
352  size_t vnamelen;
353 
354  /* need to copy string to __qsstr, since vname will be freed */
355  vname = QSversion();
356  vnamelen = strlen(vname);
357  if ( vnamelen >= SCIP_MAXSTRLEN-1 )
358  vnamelen = SCIP_MAXSTRLEN - 2;
359  memcpy(__qsstr, vname, vnamelen);
360  __qsstr[vnamelen+1] = '\0';
361  QSfree(vname);
362  return __qsstr;
363 }
364 
365 /** gets description of LP solver (developer, webpage, ...) */
367  void
368  )
369 {
370  return "Linear Programming Solver developed by D. Applegate, W. Cook, S. Dash, and M. Mevenkamp (www.isye.gatech.edu/~wcook/qsopt)";
371 }
372 
373 /** gets pointer for LP solver - use only with great care */
375  SCIP_LPI* lpi /**< pointer to an LP interface structure */
376  )
377 {
378  return (void*) lpi->prob;
379 }
380 
381 /** pass integrality information to LP solver */
383  SCIP_LPI* lpi, /**< pointer to an LP interface structure */
384  int ncols, /**< length of integrality array */
385  int* intInfo /**< integrality array (0: continuous, 1: integer) */
386  )
387 {
388  SCIPerrorMessage("SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
389  return SCIP_LPERROR;
390 }
391 
392 /**@} */
393 
394 
395 
396 
397 /*
398  * LPI Creation and Destruction Methods
399  */
400 
401 /**@name LPI Creation and Destruction Methods */
402 /**@{ */
403 
404 /** creates an LP problem object */
406  SCIP_LPI** lpi, /**< pointer to an LP interface structure */
407  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler to use for printing messages, or NULL */
408  const char* name, /**< problem name */
409  SCIP_OBJSEN objsen /**< objective sense */
410  )
411 {
412  /* QSopt only works with doubles as floating points and bool as integers */
413  assert(sizeof(SCIP_Real) == sizeof(double));
414  assert(sizeof(SCIP_Bool) == sizeof(int));
415  assert(lpi != NULL);
416 
417  SCIPdebugMessage("SCIPlpiCreate()\n");
418 
419  /* create LP */
420  SCIP_ALLOC( BMSallocMemory(lpi) );
421  memset(*lpi, 0, sizeof(struct SCIP_LPi));
422 
423  (*lpi)->prob = QScreate_prob(name, (int) objsen);
424  if ( (*lpi)->prob == NULL )
425  {
426  SCIPerrorMessage("No memory\n");
427  return SCIP_LPERROR;
428  }
429 
430  (*lpi)->rowspace = 1024;
431  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->isen),1024) );
432  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->irhs),1024) );
433  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->irng),1024) );
434  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->irbeg),1024) );
435  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->ircnt),1024) );
436 
437  (*lpi)->colspace = 1024;
438  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->iccnt), 1024) );
439  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->iccha), 1024) );
440 
441  (*lpi)->tbsz = 1024;
442  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->itab), 1024) );
443  SCIP_ALLOC( BMSallocMemoryArray(&((*lpi)->ibas), 1024) );
444 
445  (*lpi)->messagehdlr = messagehdlr;
446 
447  return SCIP_OKAY;
448 }
449 
450 /** deletes an LP problem object */
452  SCIP_LPI** lpi /**< pointer to an LP interface structure */
453  )
454 {
455  assert(lpi != NULL);
456  assert(*lpi != NULL);
457 
458  SCIPdebugMessage("SCIPlpiFree()\n");
459 
460  /* free LP */
461  QSfree_prob((*lpi)->prob);
462  BMSfreeMemoryArray( &((*lpi)->isen) );
463  BMSfreeMemoryArray( &((*lpi)->irhs) );
464  BMSfreeMemoryArray( &((*lpi)->irng) );
465  BMSfreeMemoryArray( &((*lpi)->ircnt) );
466  BMSfreeMemoryArray( &((*lpi)->irbeg) );
467  BMSfreeMemoryArray( &((*lpi)->iccnt) );
468  BMSfreeMemoryArray( &((*lpi)->iccha) );
469  BMSfreeMemoryArray( &((*lpi)->itab) );
470  BMSfreeMemoryArray( &((*lpi)->ibas) );
471 
472  /* free memory */
473  BMSfreeMemory(lpi);
474 
475  return SCIP_OKAY;
476 }
477 /**@} */
478 
479 
480 
481 
482 /*
483  * Modification Methods
484  */
485 
486 /**@name Modification Methods */
487 /**@{ */
488 
489 
490 /** copies LP data with column matrix into LP solver */
492  SCIP_LPI* lpi, /**< LP interface structure */
493  SCIP_OBJSEN objsen, /**< objective sense */
494  int ncols, /**< number of columns */
495  const SCIP_Real* obj, /**< objective function values of columns */
496  const SCIP_Real* lb, /**< lower bounds of columns */
497  const SCIP_Real* ub, /**< upper bounds of columns */
498  char** colnames, /**< column names, or NULL */
499  int nrows, /**< number of rows */
500  const SCIP_Real* lhs, /**< left hand sides of rows */
501  const SCIP_Real* rhs, /**< right hand sides of rows */
502  char** rownames, /**< row names, or NULL */
503  int nnonz, /**< number of nonzero elements in the constraint matrix */
504  const int* beg, /**< start index of each column in ind- and val-array */
505  const int* ind, /**< row indices of constraint matrix entries */
506  const SCIP_Real* val /**< values of constraint matrix entries */
507  )
508 {
509  register int i;
510  int rval;
511 
512  assert(lpi != NULL);
513  assert(lpi->prob != NULL);
514 
515  lpi->solstat = 0;
516  SCIPdebugMessage("loading LP in column format into QSopt: %d cols, %d rows\n", ncols, nrows);
517 
518  /* delete old LP */
519  SCIP_CALL( SCIPlpiClear(lpi) );
520 
521  /* set sense */
522  if( objsen == SCIP_OBJSEN_MAXIMIZE )
523  {
524  rval = QSchange_objsense(lpi->prob, QS_MAX);
525  QS_CONDRET(rval);
526  }
527  else
528  {
529  rval = QSchange_objsense(lpi->prob, QS_MIN);
530  QS_CONDRET(rval);
531  }
532 
533  /* add rows with no matrix, and then the columns, first ensure space */
534  SCIP_CALL( ensureRowMem(lpi, nrows) );
535 
536  /* convert lhs/rhs into sen/rhs/range tuples */
537  SCIP_CALL( convertSides(lpi, nrows, lhs, rhs) );
538 
539  /* now we add the rows */
540  rval = QSadd_ranged_rows(lpi->prob, nrows, lpi->ircnt, lpi->irbeg, 0, 0, lpi->irhs, lpi->isen, lpi->irng, (const char**)rownames);
541  QS_CONDRET(rval);
542 
543  /* ensure column size */
544  SCIP_CALL( ensureColMem(lpi, ncols) );
545 
546  /* compute column lengths */
547  for( i = 0; i < ncols-1; ++i )
548  {
549  lpi->iccnt[i] = beg[i+1] - beg[i];
550  assert(lpi->iccnt[i] >= 0);
551  }
552 
553  if( ncols > 0 )
554  {
555  lpi->iccnt[ncols-1] = nnonz - beg[ncols-1];
556  assert(lpi->iccnt[ncols-1] >= 0);
557  }
558 
559  /* and add the columns */
560  rval = QSadd_cols(lpi->prob, ncols, lpi->iccnt, (int*) beg, (int*) ind, (SCIP_Real*) val, (SCIP_Real*) obj,
561  (SCIP_Real*) lb, (SCIP_Real*) ub, (const char**)colnames);
562 
563  QS_RETURN(rval);
564 }
565 
566 
567 /** adds columns to the LP */
569  SCIP_LPI* lpi, /**< LP interface structure */
570  int ncols, /**< number of columns to be added */
571  const SCIP_Real* obj, /**< objective function values of new columns */
572  const SCIP_Real* lb, /**< lower bounds of new columns */
573  const SCIP_Real* ub, /**< upper bounds of new columns */
574  char** colnames, /**< column names, or NULL */
575  int nnonz, /**< number of nonzero elements to be added to the constraint matrix */
576  const int* beg, /**< start index of each column in ind- and val-array, or NULL if nnonz == 0 */
577  const int* ind, /**< row indices of constraint matrix entries, or NULL if nnonz == 0 */
578  const SCIP_Real* val /**< values of constraint matrix entries, or NULL if nnonz == 0 */
579  )
580 {
581  int rval;
582  register int i;
583  int* lbeg;
584 
585  assert( lpi != NULL );
586  assert( lpi->prob != NULL );
587  assert(obj != NULL);
588  assert(lb != NULL);
589  assert(ub != NULL);
590  assert(nnonz == 0 || beg != NULL);
591  assert(nnonz == 0 || ind != NULL);
592  assert(nnonz == 0 || val != NULL);
593  assert(nnonz >= 0);
594  assert(ncols >= 0);
595 
596  SCIPdebugMessage("adding %d columns with %d nonzeros to QSopt\n", ncols, nnonz);
597 
598  if ( ncols <= 0 )
599  return SCIP_OKAY;
600  assert( lb != NULL && ub != NULL );
601 
602  lpi->solstat = 0;
603 
604  /* ensure column size */
605  SCIP_CALL( ensureColMem(lpi, ncols) );
606 
607  /* if there are no nonzeros, we have to set up an artificial beg array */
608  if ( nnonz == 0 )
609  {
610  SCIP_ALLOC( BMSallocMemoryArray(&lbeg, ncols) );
611 
612  /* compute column lengths */
613  for( i = 0; i < ncols; ++i )
614  {
615  lpi->iccnt[i] = 0;
616  lbeg[i] = 0;
617  }
618  }
619  else
620  {
621 #ifndef NDEBUG
622  /* perform check that no new rows are added - this is forbidden */
623  int nrows;
624 
625  nrows = QSget_rowcount(lpi->prob);
626  for (i = 0; i < nnonz; ++i)
627  assert( 0 <= ind[i] && ind[i] < nrows );
628 #endif
629 
630  /* compute column lengths */
631  for( i = 0; i < ncols - 1; ++i )
632  {
633  lpi->iccnt[i] = beg[i+1] - beg[i];
634  assert(lpi->iccnt[i] >= 0);
635  }
636 
637  lpi->iccnt[ncols-1] = nnonz - beg[ncols-1];
638  assert(lpi->iccnt[ncols-1] >= 0);
639  lbeg = (int*) beg;
640  }
641 
642  /* add the columns */
643  rval = QSadd_cols(lpi->prob, ncols, lpi->iccnt, (int*) lbeg, (int*) ind, (SCIP_Real*) val, (SCIP_Real*) obj,
644  (SCIP_Real*) lb, (SCIP_Real*) ub, (const char**)colnames);
645 
646  /* possibly free space */
647  if ( nnonz == 0 )
648  {
649  BMSfreeMemoryArray(&lbeg);
650  }
651 
652  QS_RETURN(rval);
653 }
654 
655 /** deletes all columns in the given range from LP */
657  SCIP_LPI* lpi, /**< LP interface structure */
658  int firstcol, /**< first column to be deleted */
659  int lastcol /**< last column to be deleted */
660  )
661 {
662  int len;
663  int rval;
664  register int i;
665 
666  assert(lpi != NULL);
667  assert(lpi->prob != NULL);
668 
669  len = lastcol - firstcol +1;
670  lpi->solstat = 0;
671  assert(0 <= firstcol && len > 0 && lastcol < QSget_colcount(lpi->prob));
672 
673  SCIPdebugMessage("deleting %d columns from QSopt\n", len);
674 
675  SCIP_CALL( ensureColMem(lpi, len) );
676  for( i = firstcol ; i <= lastcol ; i++ )
677  lpi->iccnt[i-firstcol] = i;
678 
679  rval = QSdelete_cols(lpi->prob, len, lpi->iccnt);
680 
681  QS_RETURN(rval);
682 }
683 
684 /** deletes columns from SCIP_LP; the new position of a column must not be greater that its old position */
686  SCIP_LPI* lpi, /**< LP interface structure */
687  int* dstat /**< deletion status of columns
688  * input: 1 if column should be deleted, 0 if not
689  * output: new position of column, -1 if column was deleted */
690  )
691 {
692  int rval;
693  int ncols;
694  int ccnt;
695  register int i;
696 
697  assert(lpi != NULL);
698  assert(lpi->prob != NULL);
699 
700  ncols = QSget_colcount(lpi->prob);
701  lpi->solstat = 0;
702 
703  SCIPdebugMessage("deleting a column set from QSopt\n");
704 
705  rval = QSdelete_setcols(lpi->prob,dstat);
706  QS_CONDRET(rval);
707 
708  for( i=0, ccnt=0; i < ncols; i++ )
709  {
710  if( dstat[i] )
711  dstat[i] = -1;
712  else
713  dstat[i] = ccnt++;
714  }
715  return SCIP_OKAY;
716 }
717 
718 
719 /** adds rows to the LP */
721  SCIP_LPI* lpi, /**< LP interface structure */
722  int nrows, /**< number of rows to be added */
723  const SCIP_Real* lhs, /**< left hand sides of new rows */
724  const SCIP_Real* rhs, /**< right hand sides of new rows */
725  char** rownames, /**< row names, or NULL */
726  int nnonz, /**< number of nonzero elements to be added to the constraint matrix */
727  const int* beg, /**< start index of each row in ind- and val-array, or NULL if nnonz == 0 */
728  const int* ind, /**< column indices of constraint matrix entries, or NULL if nnonz == 0 */
729  const SCIP_Real* val /**< values of constraint matrix entries, or NULL if nnonz == 0 */
730  )
731 {
732  register int i;
733  int rval;
734 
735  assert( lpi != NULL );
736  assert( lpi->prob != NULL );
737  assert( nrows >= 0 );
738 
739  lpi->solstat = 0;
740 
741  SCIPdebugMessage("adding %d rows with %d nonzeros to QSopt\n", nrows, nnonz);
742 
743  if ( nrows <= 0 )
744  return SCIP_OKAY;
745 
746  /* add rows with no matrix, and then the columns, first ensure space */
747  SCIP_CALL( ensureRowMem(lpi, nrows) );
748 
749  /* convert lhs/rhs into sen/rhs/range tuples */
750  SCIP_CALL( convertSides(lpi, nrows, lhs, rhs) );
751 
752  /* compute row count */
753  if( nnonz > 0 )
754  {
755  assert(beg != NULL);
756  assert(ind != NULL);
757  assert(val != NULL);
758 
759 #ifndef NDEBUG
760  {
761  /* perform check that no new cols are added - this is forbidden */
762  int ncols;
763 
764  ncols = QSget_colcount(lpi->prob);
765  for (i = 0; i < nnonz; ++i)
766  assert( 0 <= ind[i] && ind[i] < ncols );
767  }
768 #endif
769 
770  for( i = 0 ; i < nrows -1 ; i++ )
771  {
772  lpi->ircnt[i] = beg[i+1] - beg[i];
773  assert(lpi->ircnt[i] >= 0);
774  }
775  if( nrows > 0 )
776  {
777  lpi->ircnt[nrows-1] = nnonz - beg[nrows-1];
778  assert(lpi->ircnt[nrows-1] >= 0);
779  }
780 
781  /* now we add the rows */
782  rval = QSadd_ranged_rows(lpi->prob, nrows, lpi->ircnt, (int*) beg, (int*) ind, (SCIP_Real*) val, lpi->irhs,
783  lpi->isen, lpi->irng, (const char**)rownames);
784  QS_ERROR(rval, "failed adding %d rows with %d non-zeros", nrows, nnonz);
785  }
786  else
787  {
788  for( i = 0; i < nrows -1; ++i )
789  {
790  lpi->ircnt[i] = 0;
791  lpi->irbeg[i] = 0;
792  }
793 
794  /* now we add the rows */
795  rval = QSadd_ranged_rows(lpi->prob, nrows, lpi->ircnt, lpi->irbeg, (int*) ind, (SCIP_Real*) val, lpi->irhs,
796  lpi->isen, lpi->irng, (const char**)rownames);
797  QS_ERROR(rval, "failed adding %d rows with %d non-zeros", nrows, nnonz);
798  }
799 
800  return SCIP_OKAY;
801 }
802 
803 /** gets column names */
805  SCIP_LPI* lpi, /**< LP interface structure */
806  int firstcol, /**< first column to get name from LP */
807  int lastcol, /**< last column to get name from LP */
808  char** colnames, /**< pointers to column names (of size at least lastcol-firstcol+1) */
809  char* namestorage, /**< storage for col names */
810  int namestoragesize, /**< size of namestorage (if 0, storageleft returns the storage needed) */
811  int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) */
812  )
813 {
814  char** cnames;
815  char* s;
816  int ncols;
817  int rval;
818  int j;
819  int sizeleft;
820 
821  assert(lpi != NULL);
822  assert(lpi->prob != NULL);
823  assert(colnames != NULL || namestoragesize == 0);
824  assert(namestorage != NULL || namestoragesize == 0);
825  assert(namestoragesize >= 0);
826  assert(storageleft != NULL);
827  assert(0 <= firstcol && firstcol <= lastcol && lastcol < QSget_colcount(lpi->prob));
828 
829  SCIPdebugMessage("getting column names %d to %d\n", firstcol, lastcol);
830 
831  ncols = QSget_colcount(lpi->prob);
832  SCIP_ALLOC( BMSallocMemoryArray(&cnames, ncols) );
833 
834  rval = QSget_colnames(lpi->prob, cnames);
835  QS_ERROR(rval, "failed getting column names");
836 
837  /* copy column names */
838  s = namestorage;
839  sizeleft = namestoragesize;
840  for( j = firstcol; j <= lastcol; ++j )
841  {
842  const char* t;
843 
844  assert( s != NULL );
845 
846  t = cnames[j];
847  if( colnames != NULL )
848  colnames[j-firstcol] = s;
849  while( *t != '\0' )
850  {
851  if( sizeleft > 0 )
852  *(s++) = *(t++);
853  --sizeleft;
854  }
855  *(s++) = '\0';
856  }
857  *storageleft = sizeleft;
858 
859  /* free space */
860  for( j = 0; j < ncols; ++j )
861  free(cnames[j]);
862 
863  return SCIP_OKAY;
864 }
865 
866 /** gets row names */
868  SCIP_LPI* lpi, /**< LP interface structure */
869  int firstrow, /**< first row to get name from LP */
870  int lastrow, /**< last row to get name from LP */
871  char** rownames, /**< pointers to row names (of size at least lastrow-firstrow+1) */
872  char* namestorage, /**< storage for row names */
873  int namestoragesize, /**< size of namestorage (if 0, -storageleft returns the storage needed) */
874  int* storageleft /**< amount of storage left (if < 0 the namestorage was not big enough) */
875  )
876 {
877  char** rnames;
878  char* s;
879  int nrows;
880  int rval;
881  int i;
882  int sizeleft;
883 
884  assert(lpi != NULL);
885  assert(lpi->prob != NULL);
886  assert(rownames != NULL || namestoragesize == 0);
887  assert(namestorage != NULL || namestoragesize == 0);
888  assert(namestoragesize >= 0);
889  assert(storageleft != NULL);
890  assert(0 <= firstrow && firstrow <= lastrow && lastrow < QSget_rowcount(lpi->prob));
891 
892  SCIPdebugMessage("getting row names %d to %d\n", firstrow, lastrow);
893 
894  nrows = QSget_rowcount(lpi->prob);
895  SCIP_ALLOC( BMSallocMemoryArray(&rnames, nrows) );
896 
897  rval = QSget_rownames(lpi->prob, rnames);
898  QS_ERROR(rval, "failed getting row names");
899 
900  s = namestorage;
901  sizeleft = namestoragesize;
902  for( i = firstrow; i <= lastrow; ++i )
903  {
904  const char* t;
905 
906  assert( s != NULL );
907 
908  t = rnames[i];
909  if( rownames != NULL )
910  rownames[i-firstrow] = s;
911  while( *t != '\0' )
912  {
913  if( sizeleft > 0 )
914  *(s++) = *(t++);
915  --sizeleft;
916  }
917  *(s++) = '\0';
918  }
919  *storageleft = sizeleft;
920 
921  /* free space */
922  for( i = 0; i < nrows; ++i )
923  free(rnames[i]);
924 
925  return SCIP_OKAY;
926 }
927 
928 /** deletes all rows in the given range from LP */
930  SCIP_LPI* lpi, /**< LP interface structure */
931  int firstrow, /**< first row to be deleted */
932  int lastrow /**< last row to be deleted */
933  )
934 {
935  const int len = lastrow - firstrow +1;
936  int rval;
937  register int i;
938 
939  assert(lpi != NULL);
940  assert(lpi->prob != NULL);
941 
942  lpi->solstat = 0;
943  assert(0 <= firstrow && len > 0 && lastrow < QSget_rowcount (lpi->prob));
944 
945  SCIPdebugMessage("deleting %d rows from QSopt\n", len);
946 
947  SCIP_CALL( ensureRowMem(lpi, len) );
948  for( i = firstrow; i <= lastrow; i++ )
949  lpi->ircnt[i-firstrow] = i;
950  rval = QSdelete_rows(lpi->prob, len, lpi->ircnt);
951 
952  QS_RETURN(rval);
953 }
954 
955 
956 /** deletes rows from SCIP_LP; the new position of a row must not be greater that its old position */
958  SCIP_LPI* lpi, /**< LP interface structure */
959  int* dstat /**< deletion status of rows
960  * input: 1 if row should be deleted, 0 if not
961  * output: new position of row, -1 if row was deleted */
962  )
963 {
964  int rval;
965  int nrows;
966  int ccnt;
967  int ndel = 0;
968  register int i;
969 
970  assert(lpi != NULL);
971  assert(lpi->prob != NULL);
972 
973  nrows = QSget_rowcount(lpi->prob);
974  lpi->solstat = 0;
975 
976  for( i = 0; i < nrows; ++i )
977  {
978  if( dstat[i] == 1 )
979  ndel++;
980  }
981 
982  SCIPdebugMessage("deleting a row set from QSopt (%d)\n", ndel);
983 
984  rval = QSdelete_setrows(lpi->prob,dstat);
985  QS_CONDRET(rval);
986 
987  for( i=0, ccnt=0; i < nrows; i++ )
988  {
989  if( dstat[i] )
990  dstat[i] = -1;
991  else
992  dstat[i] = ccnt++;
993  }
994  return SCIP_OKAY;
995 }
996 
997 /** clears the whole LP */
999  SCIP_LPI* lpi /**< LP interface structure */
1000  )
1001 {
1002  register int i;
1003  int ncols;
1004  int nrows;
1005  int rval;
1006 
1007  assert(lpi != NULL);
1008  assert(lpi->prob != NULL);
1009 
1010  SCIPdebugMessage("clearing QSopt LP\n");
1011  lpi->solstat = 0;
1012 
1013  ncols = QSget_colcount(lpi->prob);
1014  nrows = QSget_rowcount(lpi->prob);
1015  if( ncols >= 1 )
1016  {
1017  SCIP_CALL( ensureColMem(lpi,ncols) );
1018  for( i = 0; i < ncols; ++i )
1019  lpi->iccnt[i] = i;
1020  rval = QSdelete_cols(lpi->prob, ncols, lpi->iccnt);
1021  QS_CONDRET(rval);
1022  }
1023 
1024  if( nrows >= 1 )
1025  {
1026  SCIP_CALL( ensureRowMem(lpi, nrows) );
1027  for( i = 0; i < nrows; ++i )
1028  lpi->ircnt[i] = i;
1029  rval = QSdelete_rows(lpi->prob, nrows, lpi->ircnt);
1030  QS_CONDRET(rval);
1031  }
1032  return SCIP_OKAY;
1033 }
1034 
1035 
1036 /** changes lower and upper bounds of columns */
1038  SCIP_LPI* lpi, /**< LP interface structure */
1039  int ncols, /**< number of columns to change bounds for */
1040  const int* ind, /**< column indices */
1041  const SCIP_Real* lb, /**< values for the new lower bounds */
1042  const SCIP_Real* ub /**< values for the new upper bounds */
1043  )
1044 {
1045  register int i;
1046  int rval;
1047 
1048  assert(lpi != NULL);
1049  assert(lpi->prob != NULL);
1050  assert(ncols == 0 || (ind != NULL && lb != NULL && ub != NULL));
1051 
1052  lpi->solstat = 0;
1053 
1054  SCIPdebugMessage("changing %d bounds in QSopt\n", ncols);
1055 
1056  for (i = 0; i < ncols; ++i)
1057  {
1058  SCIPdebugPrintf(" col %d: [%g,%g]\n", ind[i], lb[i], ub[i]);
1059 
1060  if ( SCIPlpiIsInfinity(lpi, lb[i]) )
1061  {
1062  SCIPerrorMessage("LP Error: fixing lower bound for variable %d to infinity.\n", ind[i]);
1063  return SCIP_LPERROR;
1064  }
1065  if ( SCIPlpiIsInfinity(lpi, -ub[i]) )
1066  {
1067  SCIPerrorMessage("LP Error: fixing upper bound for variable %d to -infinity.\n", ind[i]);
1068  return SCIP_LPERROR;
1069  }
1070  }
1071 
1072  SCIP_CALL(ensureColMem(lpi, ncols));
1073  for( i = 0; i < ncols; ++i )
1074  lpi->iccha[i] = 'L';
1075 
1076  rval = QSchange_bounds(lpi->prob, ncols, (int*) ind, lpi->iccha, (SCIP_Real*) lb);
1077  QS_CONDRET(rval);
1078 
1079  for( i = 0; i < ncols; ++i )
1080  lpi->iccha[i] = 'U';
1081 
1082  rval = QSchange_bounds(lpi->prob, ncols, (int*) ind, lpi->iccha, (SCIP_Real*) ub);
1083 
1084  QS_RETURN(rval);
1085 }
1086 
1087 /** changes left and right hand sides of rows */
1089  SCIP_LPI* lpi, /**< LP interface structure */
1090  int nrows, /**< number of rows to change sides for */
1091  const int* ind, /**< row indices */
1092  const SCIP_Real* lhs, /**< new values for left hand sides */
1093  const SCIP_Real* rhs /**< new values for right hand sides */
1094  )
1095 {
1096  register int i;
1097  int rval;
1098 
1099  assert(lpi != NULL);
1100  assert(lpi->prob != NULL);
1101 
1102  lpi->solstat = 0;
1103  SCIPdebugMessage("changing %d sides in QSopt\n", nrows);
1104 
1105  SCIP_CALL( ensureRowMem(lpi, nrows) );
1106 
1107  /* convert lhs/rhs into sen/rhs/range tuples */
1108  SCIP_CALL( convertSides(lpi, nrows, lhs, rhs) );
1109 
1110  /* now we change all rows */
1111  for( i = 0; i < nrows; ++i )
1112  {
1113  rval = QSchange_sense(lpi->prob, ind[i], lpi->isen[i]);
1114  QS_CONDRET(rval);
1115 
1116  rval = QSchange_rhscoef(lpi->prob, ind[i], lpi->irhs[i]);
1117  QS_CONDRET(rval);
1118 
1119  if( lpi->isen[i] == 'R' )
1120  {
1121  rval = QSchange_range(lpi->prob, ind[i], lpi->irng[i]);
1122  QS_CONDRET(rval);
1123  }
1124  }
1125 
1126  return SCIP_OKAY;
1127 }
1128 
1129 /** changes a single coefficient */
1131  SCIP_LPI* lpi, /**< LP interface structure */
1132  int row, /**< row number of coefficient to change */
1133  int col, /**< column number of coefficient to change */
1134  SCIP_Real newval /**< new value of coefficient */
1135  )
1136 {
1137  int rval;
1138 
1139  assert(lpi != NULL);
1140  assert(lpi->prob != NULL);
1141 
1142  lpi->solstat = 0;
1143 
1144  SCIPdebugMessage("changing coefficient row %d, column %d in QSopt to %g\n", row, col, newval);
1145 
1146  rval = QSchange_coef(lpi->prob, row, col, newval);
1147 
1148  QS_RETURN(rval);
1149 }
1150 
1151 /** changes the objective sense */
1153  SCIP_LPI* lpi, /**< LP interface structure */
1154  SCIP_OBJSEN objsen /**< new objective sense */
1155  )
1156 {
1157  int rval;
1158 
1159  assert(lpi != NULL);
1160  assert(lpi->prob != NULL);
1161 
1162  lpi->solstat = 0;
1163  SCIPdebugMessage("changing objective sense in QSopt to %d\n", objsen);
1164 
1165  /* set sense */
1166  if( objsen == SCIP_OBJSEN_MAXIMIZE )
1167  {
1168  rval = QSchange_objsense(lpi->prob, QS_MAX);
1169  QS_CONDRET(rval);
1170  }
1171  else
1172  {
1173  rval = QSchange_objsense(lpi->prob, QS_MIN);
1174  QS_CONDRET(rval);
1175  }
1176  return SCIP_OKAY;
1177 }
1178 
1179 /** changes objective values of columns in the LP */
1181  SCIP_LPI* lpi, /**< LP interface structure */
1182  int ncols, /**< number of columns to change objective value for */
1183  const int* ind, /**< column indices to change objective value for */
1184  const SCIP_Real* obj /**< new objective values for columns */
1185  )
1186 {
1187  register int i;
1188  int rval;
1189 
1190  assert(lpi != NULL);
1191  assert(lpi->prob != NULL);
1192 
1193  lpi->solstat = 0;
1194  SCIPdebugMessage("changing %d objective values in QSopt\n", ncols);
1195 
1196  for( i = 0; i < ncols; ++i )
1197  {
1198  rval = QSchange_objcoef(lpi->prob, ind[i], obj[i]);
1199  QS_CONDRET(rval);
1200  }
1201  return SCIP_OKAY;
1202 }
1203 
1204 /** multiplies a row with a non-zero scalar; for negative scalars, the row's sense is switched accordingly */
1206  SCIP_LPI* lpi, /**< LP interface structure */
1207  int row, /**< row number to scale */
1208  SCIP_Real scaleval /**< scaling multiplier */
1209  )
1210 {
1211  register int i;
1212  int rowlist[1];
1213  int* rowcnt = NULL, *rowbeg = NULL, *rowind = NULL;
1214  double* rowval = NULL, *rhs = NULL, *range = NULL;
1215  char* sense = NULL;
1216  int rval;
1217 
1218  assert(lpi != NULL);
1219  assert(lpi->prob != NULL);
1220 
1221  lpi->solstat = 0;
1222  SCIPdebugMessage("scaling row %d with factor %g in QSopt\n", row, scaleval);
1223 
1224  rowlist[0] = row;
1225  /* get row */
1226  rval = QSget_ranged_rows_list(lpi->prob, 1, rowlist, &rowcnt, &rowbeg, &rowind, &rowval, &rhs, &sense, &range, 0);
1227  QS_TESTG(rval, CLEANUP, " ");
1228 
1229  /* change all coefficients in the constraint */
1230  for( i = 0; i < rowcnt[0]; ++i )
1231  {
1232  rval = QSchange_coef(lpi->prob, row, rowind[i], rowval[i] * scaleval);
1233  QS_TESTG(rval, CLEANUP, " ");
1234  }
1235 
1236  /* if we have a positive scalar, we just scale rhs and range */
1237  if( scaleval >= 0 )
1238  {
1239  rval = QSchange_rhscoef(lpi->prob, row, rhs[0] * scaleval);
1240  QS_TESTG(rval, CLEANUP, " ");
1241  if( sense[0] == 'R' )
1242  {
1243  rval = QSchange_range(lpi->prob, row, range[0] * scaleval);
1244  QS_TESTG(rval, CLEANUP, " ");
1245  }
1246  }
1247  /* otherwise, we must change everything */
1248  else
1249  {
1250  switch( sense[0] )
1251  {
1252  case 'E':
1253  rval = QSchange_rhscoef(lpi->prob, row, rhs[0]*scaleval);
1254  QS_TESTG(rval, CLEANUP, " ");
1255  break;
1256  case 'L':
1257  rval = QSchange_rhscoef(lpi->prob, row, rhs[0]*scaleval);
1258  QS_TESTG(rval, CLEANUP, " ");
1259  rval = QSchange_sense(lpi->prob, row, 'G');
1260  QS_TESTG(rval, CLEANUP, " ");
1261  break;
1262  case 'G':
1263  rval = QSchange_rhscoef(lpi->prob, row, rhs[0]*scaleval);
1264  QS_TESTG(rval, CLEANUP, " ");
1265  rval = QSchange_sense(lpi->prob, row, 'L');
1266  QS_TESTG(rval, CLEANUP, " ");
1267  break;
1268  case 'R':
1269  rhs[0] = (rhs[0] + range[0]) * scaleval;
1270  range[0] = fabs(scaleval) * range[0];
1271  rval = QSchange_rhscoef(lpi->prob, row, rhs[0]);
1272  QS_TESTG(rval, CLEANUP, " ");
1273  rval = QSchange_range(lpi->prob, row, range[0]);
1274  QS_TESTG(rval, CLEANUP, " ");
1275  break;
1276  default:
1277  SCIPerrorMessage("Impossible! received sense %c (not E L G R)", sense[0]);
1278  rval = 1;
1279  goto CLEANUP;
1280  }
1281  }
1282 
1283  /* now we must free all received arrays */
1284  /* ending */
1285  CLEANUP:
1286  if( rowcnt != NULL )
1287  QSfree(rowcnt);
1288  if( rowbeg != NULL )
1289  QSfree(rowbeg);
1290  if( rowind != NULL )
1291  QSfree(rowind);
1292  if( rowval != NULL )
1293  QSfree(rowval);
1294  if( rhs != NULL )
1295  QSfree(rhs);
1296  if( sense != NULL )
1297  QSfree(sense);
1298  if( range != NULL )
1299  QSfree(range);
1300 
1301  QS_RETURN(rval);
1302 }
1303 
1304 /** multiplies a column with a non-zero scalar; the objective value is multiplied with the scalar, and the bounds
1305  * are divided by the scalar; for negative scalars, the column's bounds are switched
1306  */
1308  SCIP_LPI* lpi, /**< LP interface structure */
1309  int col, /**< column number to scale */
1310  SCIP_Real scaleval /**< scaling multiplier */
1311  )
1312 {
1313  register int i;
1314  int collist[1];
1315  int* colcnt=0;
1316  int* colbeg=0;
1317  int* colind=0;
1318  double* colval=0;
1319  double* lb=0;
1320  double* ub=0;
1321  double* obj=0;
1322  int rval;
1323 
1324  assert(lpi != NULL);
1325  assert(lpi->prob != NULL);
1326 
1327  lpi->solstat = 0;
1328  SCIPdebugMessage("scaling column %d with factor %g in QSopt\n", col, scaleval);
1329 
1330  /* get the column */
1331  collist[0] = col;
1332  rval = QSget_columns_list(lpi->prob, 1, collist, &colcnt, &colbeg, &colind, &colval, &obj, &lb, &ub, 0);
1333  QS_TESTG(rval, CLEANUP, " ");
1334 
1335  /* scale column coefficients */
1336  for( i = 0; i < colcnt[0]; ++i )
1337  {
1338  rval = QSchange_coef(lpi->prob, colind[i], col, colval[i]*scaleval);
1339  QS_TESTG(rval, CLEANUP, " ");
1340  }
1341 
1342  /* scale objective value */
1343  rval = QSchange_objcoef(lpi->prob, col, obj[0]*scaleval);
1344  QS_TESTG(rval, CLEANUP, " ");
1345 
1346  /* scale column bounds */
1347  if( scaleval < 0 )
1348  {
1349  scaleval = -scaleval;
1350  obj[0] = lb[0];
1351  lb[0] = -ub[0];
1352  ub[0] = -obj[0];
1353  }
1354  if( lb[0] > -QS_MAXDOUBLE )
1355  lb[0] *= scaleval;
1356  if( ub[0] < QS_MAXDOUBLE )
1357  ub[0] *= scaleval;
1358 
1359  if( lb[0] < -QS_MAXDOUBLE )
1360  lb[0] = -QS_MAXDOUBLE;
1361  if( ub[0] > QS_MAXDOUBLE )
1362  ub[0] = QS_MAXDOUBLE;
1363 
1364  rval = QSchange_bound(lpi->prob, col, 'L', lb[0]);
1365  QS_TESTG(rval, CLEANUP, " ");
1366  rval = QSchange_bound(lpi->prob, col, 'U', ub[0]);
1367  QS_TESTG(rval, CLEANUP, " ");
1368 
1369  /* ending */
1370  CLEANUP:
1371  if( colcnt != NULL )
1372  QSfree(colcnt);
1373  if( colbeg != NULL )
1374  QSfree(colbeg);
1375  if( colind != NULL )
1376  QSfree(colind);
1377  if( colval != NULL )
1378  QSfree(colval);
1379  if( obj != NULL )
1380  QSfree(obj);
1381  if( lb != NULL )
1382  QSfree(lb);
1383  if( ub != NULL )
1384  QSfree(ub);
1385 
1386  QS_RETURN(rval);
1387 }
1388 /**@} */
1389 
1390 
1391 
1392 
1393 /*
1394  * Data Accessing Methods
1395  */
1396 
1397 /**@name Data Accessing Methods */
1398 /**@{ */
1399 
1400 /** gets the number of rows in the LP */
1402  SCIP_LPI* lpi, /**< LP interface structure */
1403  int* nrows /**< pointer to store the number of rows */
1404  )
1405 {
1406  assert(lpi != NULL);
1407  assert(lpi->prob != NULL);
1408  assert(nrows != NULL);
1409 
1410  SCIPdebugMessage("getting number of rows\n");
1411 
1412  *nrows = QSget_rowcount(lpi->prob);
1413 
1414  return SCIP_OKAY;
1415 }
1416 
1417 /** gets the number of columns in the LP */
1419  SCIP_LPI* lpi, /**< LP interface structure */
1420  int* ncols /**< pointer to store the number of cols */
1421  )
1422 {
1423  assert(lpi != NULL);
1424  assert(lpi->prob != NULL);
1425  assert(ncols != NULL);
1426 
1427  SCIPdebugMessage("getting number of columns\n");
1428 
1429  *ncols = QSget_colcount(lpi->prob);
1430 
1431  return SCIP_OKAY;
1432 }
1433 
1434 /** gets the number of nonzero elements in the LP constraint matrix */
1436  SCIP_LPI* lpi, /**< LP interface structure */
1437  int* nnonz /**< pointer to store the number of nonzeros */
1438  )
1439 {
1440  assert(lpi != NULL);
1441  assert(lpi->prob != NULL);
1442 
1443  SCIPdebugMessage("getting number of columns\n");
1444 
1445  *nnonz = QSget_nzcount(lpi->prob);
1446 
1447  return SCIP_OKAY;
1448 }
1449 
1450 /** gets columns from LP problem object; the arrays have to be large enough to store all values
1451  * Either both, lb and ub, have to be NULL, or both have to be non-NULL,
1452  * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL.
1453  */
1455  SCIP_LPI* lpi, /**< LP interface structure */
1456  int firstcol, /**< first column to get from LP */
1457  int lastcol, /**< last column to get from LP */
1458  SCIP_Real* lb, /**< buffer to store the lower bound vector, or NULL */
1459  SCIP_Real* ub, /**< buffer to store the upper bound vector, or NULL */
1460  int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */
1461  int* beg, /**< buffer to store start index of each column in ind- and val-array, or NULL */
1462  int* ind, /**< buffer to store column indices of constraint matrix entries, or NULL */
1463  SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
1464  )
1465 {
1466  int len;
1467  register int i;
1468  double* lval = NULL;
1469  double* llb = NULL;
1470  double* lub = NULL;
1471  int rval;
1472  int* lcnt = NULL;
1473  int* lbeg = NULL;
1474  int* lind = NULL;
1475 
1476  assert(lpi != NULL);
1477  assert(lpi->prob != NULL);
1478  assert(0 <= firstcol && firstcol <= lastcol && lastcol < QSget_colcount(lpi->prob));
1479  assert((lb == NULL && ub == NULL) || (lb != NULL && ub != NULL));
1480  assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1481 
1482  SCIPdebugMessage("getting columns %d to %d\n", firstcol, lastcol);
1483 
1484  /* build col-list */
1485  len = lastcol - firstcol + 1;
1486  assert( len > 0 );
1487  SCIP_CALL( ensureColMem(lpi, len) );
1488  for( i = 0; i < len; ++i )
1489  lpi->iccnt[i] = i + firstcol;
1490 
1491  /* get data from qsopt */
1492  rval = QSget_columns_list(lpi->prob, len, lpi->iccnt, nnonz ? (&lcnt) : 0, nnonz ? (&lbeg) : 0, nnonz ? (&lind) : 0,
1493  nnonz ? (&lval) : 0, 0, lb ? (&llb) : 0, lb ? (&lub) : 0, 0);
1494 
1495  QS_TESTG(rval, CLEANUP, " ");
1496 
1497  /* store in the user-provided data */
1498  if( nnonz )
1499  {
1500  assert( beg != NULL && lbeg != NULL );
1501  assert( ind != NULL && lind != NULL );
1502  assert( val != NULL && lval != NULL );
1503  assert( lcnt != NULL );
1504 
1505  *nnonz = lbeg[len-1] + lcnt[len-1];
1506  for( i = 0 ; i < len ; i++ )
1507  beg[i] = lbeg[i];
1508  for( i = 0; i < *nnonz; ++i )
1509  {
1510  ind[i] = lind[i];
1511  val[i] = lval[i];
1512  }
1513  }
1514  if( lb )
1515  {
1516  assert( llb != NULL );
1517  assert( lub != NULL );
1518  assert( ub != NULL );
1519 
1520  for( i = 0; i < len; ++i )
1521  {
1522  lb[i] = llb[i];
1523  ub[i] = lub[i];
1524  }
1525  }
1526 
1527  CLEANUP:
1528  if( lval != NULL )
1529  QSfree(lval);
1530  if( lub != NULL )
1531  QSfree(lub);
1532  if( llb != NULL )
1533  QSfree(llb);
1534  if( lind != NULL )
1535  QSfree(lind);
1536  if( lbeg != NULL )
1537  QSfree(lbeg);
1538  if( lcnt != NULL )
1539  QSfree(lcnt);
1540 
1541  QS_RETURN(rval);
1542 }
1543 
1544 /** gets rows from LP problem object; the arrays have to be large enough to store all values.
1545  * Either both, lhs and rhs, have to be NULL, or both have to be non-NULL,
1546  * either nnonz, beg, ind, and val have to be NULL, or all of them have to be non-NULL.
1547  */
1549  SCIP_LPI* lpi, /**< LP interface structure */
1550  int firstrow, /**< first row to get from LP */
1551  int lastrow, /**< last row to get from LP */
1552  SCIP_Real* lhs, /**< buffer to store left hand side vector, or NULL */
1553  SCIP_Real* rhs, /**< buffer to store right hand side vector, or NULL */
1554  int* nnonz, /**< pointer to store the number of nonzero elements returned, or NULL */
1555  int* beg, /**< buffer to store start index of each row in ind- and val-array, or NULL */
1556  int* ind, /**< buffer to store row indices of constraint matrix entries, or NULL */
1557  SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
1558  )
1559 {
1560  const int len = lastrow - firstrow + 1;
1561  register int i;
1562  double* lval = NULL;
1563  double* lrhs = NULL;
1564  double* lrng = NULL;
1565  int rval;
1566  int* lcnt = NULL;
1567  int* lbeg = NULL;
1568  int* lind = NULL;
1569  char* lsense = NULL;
1570 
1571  assert(lpi != NULL);
1572  assert(lpi->prob != NULL);
1573  assert(0 <= firstrow && firstrow <= lastrow && lastrow < QSget_rowcount (lpi->prob));
1574  assert((lhs == NULL && rhs == NULL) || (rhs != NULL && lhs != NULL));
1575  assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1576 
1577  SCIPdebugMessage("getting rows %d to %d\n", firstrow, lastrow);
1578 
1579  /* build row-list */
1580  SCIP_CALL( ensureRowMem(lpi, len) );
1581  for( i = 0; i < len; ++i )
1582  lpi->ircnt[i] = i + firstrow;
1583 
1584  /* get data from qsopt */
1585  rval = QSget_ranged_rows_list(lpi->prob, len, lpi->ircnt, nnonz ? (&lcnt) : 0, nnonz ? (&lbeg) : 0, nnonz ? (&lind) : 0,
1586  nnonz ? (&lval) : 0, rhs ? (&lrhs) : 0, rhs ? (&lsense) : 0, rhs ? (&lrng) : 0, 0);
1587  QS_TESTG(rval, CLEANUP, " ");
1588 
1589  /* store in the user-provided data */
1590  if( nnonz )
1591  {
1592  assert( beg != NULL && lbeg != NULL );
1593  assert( ind != NULL && lind != NULL );
1594  assert( val != NULL && lval != NULL );
1595  assert( lcnt != NULL );
1596 
1597  *nnonz = lbeg[len-1] + lcnt[len-1];
1598  for( i = 0 ; i < len; i++ )
1599  beg[i] = lbeg[i];
1600  for( i = 0; i < *nnonz; ++i )
1601  {
1602  ind[i] = lind[i];
1603  val[i] = lval[i];
1604  }
1605  }
1606  if( rhs )
1607  {
1608  assert( lhs != NULL && lrhs != NULL );
1609  assert( lrng != NULL );
1610  assert( lsense != NULL );
1611 
1612  for( i = 0; i < len; ++i )
1613  {
1614  switch( lsense[i] )
1615  {
1616  case 'R':
1617  lhs[i] = lrhs[i];
1618  rhs[i] = lrhs[i] + lrng[i];
1619  break;
1620  case 'E':
1621  lhs[i] = rhs[i] = lrhs[i];
1622  break;
1623  case 'L':
1624  rhs[i] = lrhs[i];
1625  lhs[i] = -QS_MAXDOUBLE;
1626  break;
1627  case 'G':
1628  lhs[i] = lrhs[i];
1629  rhs[i] = QS_MAXDOUBLE;
1630  break;
1631  default:
1632  SCIPerrorMessage("Unknown sense %c from QSopt", lsense[i]);
1633  SCIPABORT();
1634  return SCIP_INVALIDDATA; /*lint !e527*/
1635  }
1636  }
1637  }
1638 
1639  CLEANUP:
1640  if( lsense != NULL )
1641  QSfree(lsense);
1642  if( lrng != NULL )
1643  QSfree(lrng);
1644  if( lrhs != NULL )
1645  QSfree(lrhs);
1646  if( lval != NULL )
1647  QSfree(lval);
1648  if( lind != NULL )
1649  QSfree(lind);
1650  if( lbeg != NULL )
1651  QSfree(lbeg);
1652  if( lcnt != NULL )
1653  QSfree(lcnt);
1654 
1655  QS_RETURN(rval);
1656 }
1657 
1658 /** gets the objective sense of the LP */
1660  SCIP_LPI* lpi, /**< LP interface structure */
1661  SCIP_OBJSEN* objsen /**< pointer to store objective sense */
1662  )
1663 { /*lint --e{715}*/
1664  SCIPerrorMessage("SCIPlpiGetObjsen() has not been implemented yet.\n");
1665  return SCIP_LPERROR;
1666 }
1667 
1668 /** gets objective coefficients from LP problem object */
1670  SCIP_LPI* lpi, /**< LP interface structure */
1671  int firstcol, /**< first column to get objective coefficient for */
1672  int lastcol, /**< last column to get objective coefficient for */
1673  SCIP_Real* vals /**< array to store objective coefficients */
1674  )
1675 { /*lint --e{715}*/
1676  int len;
1677  int rval;
1678  register int i;
1679 
1680  assert(lpi != NULL);
1681  assert(lpi->prob != NULL);
1682  assert(0 <= firstcol && firstcol <= lastcol && lastcol < QSget_colcount (lpi->prob));
1683 
1684  SCIPdebugMessage("getting objective values %d to %d\n", firstcol, lastcol);
1685 
1686  /* build col-list */
1687  len = lastcol - firstcol + 1;
1688  SCIP_CALL(ensureColMem(lpi,len));
1689  for( i = 0; i < len; ++i )
1690  lpi->iccnt[i] = i + firstcol;
1691 
1692  /* get data from qsopt */
1693  rval = QSget_obj_list(lpi->prob, len, lpi->iccnt, vals);
1694 
1695  QS_RETURN(rval);
1696 }
1697 
1698 /** gets current bounds from LP problem object */
1700  SCIP_LPI* lpi, /**< LP interface structure */
1701  int firstcol, /**< first column to get objective value for */
1702  int lastcol, /**< last column to get objective value for */
1703  SCIP_Real* lbs, /**< array to store lower bound values, or NULL */
1704  SCIP_Real* ubs /**< array to store upper bound values, or NULL */
1705  )
1706 {
1707  const int len = lastcol - firstcol + 1;
1708  int rval;
1709  register int i;
1710 
1711  assert(lpi != NULL);
1712  assert(lpi->prob != NULL);
1713  assert(0 <= firstcol && firstcol <= lastcol&& lastcol < QSget_colcount (lpi->prob));
1714 
1715  SCIPdebugMessage("getting bound values %d to %d\n", firstcol, lastcol);
1716 
1717  /* build col-list */
1718  SCIP_CALL(ensureColMem(lpi,len));
1719  for( i = 0; i < len; ++i )
1720  lpi->iccnt[i] = i + firstcol;
1721 
1722  /* get data from qsopt */
1723  rval = QSget_bounds_list(lpi->prob, len, lpi->iccnt, lbs, ubs);
1724 
1725  QS_RETURN(rval);
1726 }
1727 
1728 /** gets current row sides from LP problem object */
1730  SCIP_LPI* lpi, /**< LP interface structure */
1731  int firstrow, /**< first row to get sides for */
1732  int lastrow, /**< last row to get sides for */
1733  SCIP_Real* lhss, /**< array to store left hand side values, or NULL */
1734  SCIP_Real* rhss /**< array to store right hand side values, or NULL */
1735  )
1736 {
1737  const int len = lastrow - firstrow + 1;
1738  register int i;
1739  double* lrhs=0, *lrng=0;
1740  int rval;
1741  char* lsense=0;
1742 
1743  assert(lpi != NULL);
1744  assert(lpi->prob != NULL);
1745  assert(0 <= firstrow && firstrow <= lastrow && lastrow < QSget_rowcount (lpi->prob));
1746  assert(rhss != NULL);
1747  assert(lhss != NULL);
1748 
1749  SCIPdebugMessage("getting row sides %d to %d\n", firstrow, lastrow);
1750 
1751  /* build row-list */
1752  SCIP_CALL( ensureRowMem(lpi, len) );
1753  for( i = 0; i < len; ++i )
1754  lpi->ircnt[i] = i + firstrow;
1755 
1756  /* get data from qsopt */
1757  rval = QSget_ranged_rows_list(lpi->prob, len, lpi->ircnt, 0, 0, 0, 0, &lrhs, &lsense, &lrng, 0);
1758  QS_TESTG(rval, CLEANUP, " ");
1759 
1760  /* store in the user-provided data */
1761  for( i = 0; i < len; ++i )
1762  {
1763  switch( lsense[i] )
1764  {
1765  case 'R':
1766  lhss[i] = lrhs[i];
1767  rhss[i] = lrhs[i] + lrng[i];
1768  break;
1769  case 'E':
1770  lhss[i] = rhss[i] = lrhs[i];
1771  break;
1772  case 'L':
1773  rhss[i] = lrhs[i];
1774  lhss[i] = -QS_MAXDOUBLE;
1775  break;
1776  case 'G':
1777  lhss[i] = lrhs[i];
1778  rhss[i] = QS_MAXDOUBLE;
1779  break;
1780  default:
1781  SCIPerrorMessage("Unknown sense %c from QSopt", lsense[i]);
1782  SCIPABORT();
1783  return SCIP_INVALIDDATA; /*lint !e527*/
1784  }
1785  }
1786 
1787  CLEANUP:
1788  if( lsense != NULL )
1789  QSfree(lsense);
1790  if( lrng != NULL )
1791  QSfree(lrng);
1792  if( lrhs != NULL )
1793  QSfree(lrhs);
1794 
1795  QS_RETURN(rval);
1796 }
1797 
1798 /** gets a single coefficient */
1800  SCIP_LPI* lpi, /**< LP interface structure */
1801  int row, /**< row number of coefficient */
1802  int col, /**< column number of coefficient */
1803  SCIP_Real* val /**< pointer to store the value of the coefficient */
1804  )
1805 {
1806  int rval;
1807 
1808  assert(lpi != NULL);
1809  assert(lpi->prob != NULL);
1810 
1811  SCIPdebugMessage("getting coefficient of row %d col %d\n", row, col);
1812 
1813  rval = QSget_coef(lpi->prob, row, col, val);
1814 
1815  QS_RETURN(rval);
1816 }
1817 
1818 /**@} */
1819 
1820 
1821 
1822 
1823 /*
1824  * Solving Methods
1825  */
1826 
1827 /**@name Solving Methods */
1828 /**@{ */
1829 
1830 /** calls primal simplex to solve the LP */
1832  SCIP_LPI* lpi /**< LP interface structure */
1833  )
1834 {
1835  int rval;
1836 
1837  assert(lpi != NULL);
1838  assert(lpi->prob != NULL);
1839 
1840  SCIPdebugMessage("calling QSopt primal simplex: %d cols, %d rows, %d nz\n", QSget_colcount(lpi->prob),
1841  QSget_rowcount(lpi->prob), QSget_nzcount(lpi->prob));
1842 
1843  rval = QSopt_primal(lpi->prob, &(lpi->solstat));
1844 
1845  QS_RETURN(rval);
1846 }
1847 
1848 /** calls dual simplex to solve the LP */
1850  SCIP_LPI* lpi /**< LP interface structure */
1851  )
1852 {
1853  int rval;
1854 
1855  assert(lpi != NULL);
1856  assert(lpi->prob != NULL);
1857 
1858  SCIPdebugMessage("calling QSopt dual simplex: %d cols, %d rows, %d nz\n", QSget_colcount(lpi->prob),
1859  QSget_rowcount(lpi->prob), QSget_nzcount(lpi->prob));
1860 
1861  rval = QSopt_dual(lpi->prob, &(lpi->solstat));
1862 
1863  QS_RETURN(rval);
1864 }
1865 
1866 /** calls barrier or interior point algorithm to solve the LP with crossover to simplex basis */
1868  SCIP_LPI* lpi, /**< LP interface structure */
1869  SCIP_Bool crossover /**< perform crossover */
1870  )
1871 { /*lint --e{715}*/
1872  return SCIPlpiSolveDual(lpi);
1873 }
1874 
1875 /** start strong branching - call before any strong branching */
1877  SCIP_LPI* lpi /**< LP interface structure */
1878  )
1879 { /*lint --e{715}*/
1880  /* currently do nothing */
1881  return SCIP_OKAY;
1882 }
1883 
1884 /** end strong branching - call after any strong branching */
1886  SCIP_LPI* lpi /**< LP interface structure */
1887  )
1888 { /*lint --e{715}*/
1889  /* currently do nothing */
1890  return SCIP_OKAY;
1891 }
1892 
1893 /** performs strong branching iterations on one @b fractional candidate */
1895  SCIP_LPI* lpi, /**< LP interface structure */
1896  int col, /**< column to apply strong branching on */
1897  SCIP_Real psol, /**< fractional current primal solution value of column */
1898  int itlim, /**< iteration limit for strong branchings */
1899  SCIP_Real* down, /**< stores dual bound after branching column down */
1900  SCIP_Real* up, /**< stores dual bound after branching column up */
1901  SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound;
1902  * otherwise, it can only be used as an estimate value */
1903  SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound;
1904  * otherwise, it can only be used as an estimate value */
1905  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
1906  )
1907 {
1908  int rval;
1909  int nit;
1910 
1911  assert(lpi != NULL);
1912  assert(lpi->prob != NULL);
1913  assert(down != NULL);
1914  assert(up != NULL);
1915  assert(downvalid != NULL);
1916  assert(upvalid != NULL);
1917 
1918  SCIPdebugMessage("calling QSopt strong branching on variable %d with fractional value (%d it lim)\n", col, itlim);
1919 
1920  /* results of QSopt are valid in any case */
1921  *downvalid = TRUE;
1922  *upvalid = TRUE;
1923 
1924  assert( ! EPSISINT(psol, FEASTOL) );
1925 
1926  /* call QSopt */
1927  rval = QSopt_strongbranch(lpi->prob, 1, &col, &psol, down, up, itlim, QS_MAXDOUBLE);
1928  QS_CONDRET(rval);
1929 
1930  rval = QSget_itcnt(lpi->prob, 0, 0, 0, 0, &nit);
1931  QS_CONDRET(rval);
1932 
1933  if( iter )
1934  *iter = nit - lpi->previt;
1935  lpi->previt = nit;
1936 
1937  return SCIP_OKAY;
1938 }
1939 
1940 /** performs strong branching iterations on given @b fractional candidates */
1942  SCIP_LPI* lpi, /**< LP interface structure */
1943  int* cols, /**< columns to apply strong branching on */
1944  int ncols, /**< number of columns */
1945  SCIP_Real* psols, /**< fractional current primal solution values of columns */
1946  int itlim, /**< iteration limit for strong branchings */
1947  SCIP_Real* down, /**< stores dual bounds after branching columns down */
1948  SCIP_Real* up, /**< stores dual bounds after branching columns up */
1949  SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds;
1950  * otherwise, they can only be used as an estimate values */
1951  SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds;
1952  * otherwise, they can only be used as an estimate values */
1953  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
1954  )
1955 {
1956  int rval;
1957  int nit;
1958  int j;
1959 
1960  assert(lpi != NULL);
1961  assert(lpi->prob != NULL);
1962  assert(cols != NULL);
1963  assert(psols != NULL);
1964  assert(down != NULL);
1965  assert(up != NULL);
1966  assert(downvalid != NULL);
1967  assert(upvalid != NULL);
1968 
1969  SCIPdebugMessage("calling QSopt strong branching on %d variables with fractional value (%d it lim)\n", ncols, itlim);
1970 
1971  /* results of QSopt are valid in any case */
1972  for( j = 0; j < ncols; ++j )
1973  {
1974  downvalid[j] = TRUE;
1975  upvalid[j] = TRUE;
1976  assert( ! EPSISINT(psols[j], FEASTOL) );
1977  }
1978 
1979  /* call QSopt */
1980  rval = QSopt_strongbranch(lpi->prob, ncols, cols, psols, down, up, itlim, QS_MAXDOUBLE);
1981  QS_CONDRET(rval);
1982 
1983  rval = QSget_itcnt(lpi->prob, 0, 0, 0, 0, &nit);
1984  QS_CONDRET(rval);
1985 
1986  if( iter )
1987  *iter = nit - lpi->previt;
1988  lpi->previt = nit;
1989 
1990  return SCIP_OKAY;
1991 }
1992 
1993 /** performs strong branching iterations on one candidate with @b integral value */
1995  SCIP_LPI* lpi, /**< LP interface structure */
1996  int col, /**< column to apply strong branching on */
1997  SCIP_Real psol, /**< current integral primal solution value of column */
1998  int itlim, /**< iteration limit for strong branchings */
1999  SCIP_Real* down, /**< stores dual bound after branching column down */
2000  SCIP_Real* up, /**< stores dual bound after branching column up */
2001  SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound;
2002  * otherwise, it can only be used as an estimate value */
2003  SCIP_Bool* upvalid, /**< stores whether the returned up value is a valid dual bound;
2004  * otherwise, it can only be used as an estimate value */
2005  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2006  )
2007 {
2008  int rval;
2009  SCIP_Real objval;
2010 
2011  assert(lpi != NULL);
2012  assert(lpi->prob != NULL);
2013  assert(down != NULL);
2014  assert(up != NULL);
2015  assert(downvalid != NULL);
2016  assert(upvalid != NULL);
2017 
2018  SCIPdebugMessage("calling QSopt strong branching on variable %d with integral value (%d it lim)\n", col, itlim);
2019 
2020  assert(EPSISINT(psol, FEASTOL));
2021 
2022  /* QSopt cannot directly strong branch on integral values! We thus return the current objective
2023  * value for both cases. Could also implement a manual search as in lpi_cpx.c
2024  */
2025  rval = QSget_objval(lpi->prob, &objval);
2026  QS_CONDRET(rval);
2027 
2028  *down = objval;
2029  *up = objval;
2030  *downvalid = TRUE;
2031  *upvalid = TRUE;
2032 
2033  if( iter )
2034  *iter = 0;
2035 
2036  return SCIP_OKAY;
2037 }
2038 
2039 /** performs strong branching iterations on given candidates with @b integral values */
2041  SCIP_LPI* lpi, /**< LP interface structure */
2042  int* cols, /**< columns to apply strong branching on */
2043  int ncols, /**< number of columns */
2044  SCIP_Real* psols, /**< current integral primal solution values of columns */
2045  int itlim, /**< iteration limit for strong branchings */
2046  SCIP_Real* down, /**< stores dual bounds after branching columns down */
2047  SCIP_Real* up, /**< stores dual bounds after branching columns up */
2048  SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds;
2049  * otherwise, they can only be used as an estimate values */
2050  SCIP_Bool* upvalid, /**< stores whether the returned up values are a valid dual bounds;
2051  * otherwise, they can only be used as an estimate values */
2052  int* iter /**< stores total number of strong branching iterations, or -1; may be NULL */
2053  )
2054 { /*lint --e{715}*/
2055  int rval;
2056  SCIP_Real objval;
2057  int j;
2058 
2059  assert(lpi != NULL);
2060  assert(lpi->prob != NULL);
2061  assert(down != NULL);
2062  assert(up != NULL);
2063  assert(downvalid != NULL);
2064  assert(upvalid != NULL);
2065 
2066  SCIPdebugMessage("calling QSopt strong branching on %d variables with integral value (%d it lim)\n", ncols, itlim);
2067 
2068  /* QSopt cannot directly strong branch on integral values! We thus return the current objective
2069  * value for all cases. Could also implement a manual search as in lpi_cpx.c
2070  */
2071  rval = QSget_objval(lpi->prob, &objval);
2072  QS_CONDRET(rval);
2073 
2074  for( j = 0; j < ncols; ++j )
2075  {
2076  assert(EPSISINT(psols[j], FEASTOL));
2077  down[j] = objval;
2078  up[j] = objval;
2079  downvalid[j] = TRUE;
2080  upvalid[j] = TRUE;
2081  }
2082 
2083  if( iter )
2084  *iter = 0;
2085 
2086  return SCIP_OKAY;
2087 }
2088 /**@} */
2089 
2090 
2091 
2092 
2093 /*
2094  * Solution Information Methods
2095  */
2096 
2097 /**@name Solution Information Methods */
2098 /**@{ */
2099 
2100 /** returns whether a solve method was called after the last modification of the LP */
2102  SCIP_LPI* lpi /**< LP interface structure */
2103  )
2104 {
2105  assert(lpi!=NULL);
2106  assert(lpi->prob!=NULL);
2107 
2108  (void) QSget_status(lpi->prob, &(lpi->solstat));
2109 
2110  return (lpi->solstat != 0 && lpi->solstat != QS_LP_MODIFIED);
2111 }
2112 
2113 /** gets information about primal and dual feasibility of the current LP solution */
2115  SCIP_LPI* lpi, /**< LP interface structure */
2116  SCIP_Bool* primalfeasible, /**< stores primal feasibility status */
2117  SCIP_Bool* dualfeasible /**< stores dual feasibility status */
2118  )
2119 {
2120  assert(lpi != NULL);
2121  assert(lpi->prob != NULL);
2122 
2123  SCIPdebugMessage("getting solution feasibility\n");
2124 
2125  (void) QSget_status(lpi->prob, &(lpi->solstat));
2126 
2127  if( lpi->solstat == QS_LP_OPTIMAL || lpi->solstat == QS_LP_UNBOUNDED )
2128  *primalfeasible = 1;
2129 
2130  if( lpi->solstat == QS_LP_OPTIMAL || lpi->solstat == QS_LP_INFEASIBLE || lpi->solstat == QS_LP_OBJ_LIMIT )
2131  *dualfeasible = 1;
2132 
2133  return SCIP_OKAY;
2134 }
2135 
2136 /** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point);
2137  * this does not necessarily mean, that the solver knows and can return the primal ray
2138  */
2140  SCIP_LPI* lpi /**< LP interface structure */
2141  )
2142 {
2143  assert(lpi != NULL);
2144  assert(lpi->prob != NULL);
2145 
2146  SCIPdebugMessage("checking primal ray existence\n");
2147 
2148  (void) QSget_status(lpi->prob, &(lpi->solstat));
2149 
2150  return (lpi->solstat == QS_LP_UNBOUNDED);
2151 }
2152 
2153 /** returns TRUE iff LP is proven to have a primal unbounded ray (but not necessary a primal feasible point),
2154  * and the solver knows and can return the primal ray
2155  */
2157  SCIP_LPI* lpi /**< LP interface structure */
2158  )
2159 {
2160  assert(lpi != NULL);
2161  assert(lpi->prob != NULL);
2162 
2163  SCIPdebugMessage("checking for primal ray\n");
2164 
2165  /* the current version of QSopt cannot give a primal certificate of unboundedness */
2166  return FALSE;
2167 }
2168 
2169 /** returns TRUE iff LP is proven to be primal unbounded */
2171  SCIP_LPI* lpi /**< LP interface structure */
2172  )
2173 {
2174  assert(lpi != NULL);
2175  assert(lpi->prob != NULL);
2176 
2177  SCIPdebugMessage("checking for primal unboundedness\n");
2178 
2179  (void) QSget_status(lpi->prob, &(lpi->solstat));
2180 
2181  return (lpi->solstat == QS_LP_UNBOUNDED);
2182 }
2183 
2184 /** returns TRUE iff LP is proven to be primal infeasible */
2186  SCIP_LPI* lpi /**< LP interface structure */
2187  )
2188 {
2189  assert(lpi != NULL);
2190  assert(lpi->prob != NULL);
2191 
2192  SCIPdebugMessage("checking for primal infeasibility\n");
2193 
2194  (void) QSget_status(lpi->prob, &(lpi->solstat));
2195 
2196  return (lpi->solstat == QS_LP_INFEASIBLE);
2197 }
2198 
2199 /** returns TRUE iff LP is proven to be primal feasible */
2201  SCIP_LPI* lpi /**< LP interface structure */
2202  )
2203 {
2204  assert(lpi != NULL);
2205  assert(lpi->prob != NULL);
2206 
2207  SCIPdebugMessage("checking for primal feasibility\n");
2208 
2209  (void) QSget_status(lpi->prob, &(lpi->solstat));
2210 
2211  return (lpi->solstat == QS_LP_OPTIMAL || lpi->solstat == QS_LP_UNBOUNDED);
2212 }
2213 
2214 /** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point);
2215  * this does not necessarily mean, that the solver knows and can return the dual ray
2216  */
2218  SCIP_LPI* lpi /**< LP interface structure */
2219  )
2220 {
2221  assert(lpi != NULL);
2222  assert(lpi->prob != NULL);
2223 
2224  SCIPdebugMessage("checking for dual ray availability\n");
2225 
2226  (void) QSget_status(lpi->prob, &(lpi->solstat));
2227 
2228  return (lpi->solstat == QS_LP_INFEASIBLE);
2229 }
2230 
2231 /** returns TRUE iff LP is proven to have a dual unbounded ray (but not necessary a dual feasible point),
2232  * and the solver knows and can return the dual ray
2233  */
2235  SCIP_LPI* lpi /**< LP interface structure */
2236  )
2237 {
2238  assert(lpi != NULL);
2239  assert(lpi->prob != NULL);
2240 
2241  SCIPdebugMessage("checking for dual ray availability\n");
2242 
2243  (void) QSget_status(lpi->prob, &(lpi->solstat));
2244 
2245  return (lpi->solstat == QS_LP_INFEASIBLE);
2246 }
2247 
2248 /** returns TRUE iff LP is dual unbounded */
2250  SCIP_LPI* lpi /**< LP interface structure */
2251  )
2252 {
2253  assert(lpi != NULL);
2254  assert(lpi->prob != NULL);
2255 
2256  SCIPdebugMessage("checking for dual unboundedness\n");
2257 
2258  (void) QSget_status(lpi->prob, &(lpi->solstat));
2259 
2260  return (lpi->solstat == QS_LP_INFEASIBLE);
2261 }
2262 
2263 /** returns TRUE iff LP is dual infeasible */
2265  SCIP_LPI* lpi /**< LP interface structure */
2266  )
2267 {
2268  assert(lpi != NULL);
2269  assert(lpi->prob != NULL);
2270 
2271  SCIPdebugMessage("checking for dual infeasibility\n");
2272 
2273  (void) QSget_status(lpi->prob, &(lpi->solstat));
2274 
2275  return (lpi->solstat == QS_LP_UNBOUNDED);
2276 }
2277 
2278 /** returns TRUE iff LP is proven to be dual feasible */
2280  SCIP_LPI* lpi /**< LP interface structure */
2281  )
2282 {
2283  assert(lpi != NULL);
2284  assert(lpi->prob != NULL);
2285 
2286  SCIPdebugMessage("checking for dual feasibility\n");
2287 
2288  (void) QSget_status(lpi->prob, &(lpi->solstat));
2289 
2290  return (lpi->solstat == QS_LP_OPTIMAL || lpi->solstat == QS_LP_OBJ_LIMIT);
2291 }
2292 
2293 /** returns TRUE iff LP was solved to optimality */
2295  SCIP_LPI* lpi /**< LP interface structure */
2296  )
2297 {
2298  assert(lpi != NULL);
2299  assert(lpi->prob != NULL);
2300 
2301  SCIPdebugMessage("checking for optimality\n");
2302 
2303  (void) QSget_status(lpi->prob, &(lpi->solstat));
2304 
2305  return (lpi->solstat == QS_LP_OPTIMAL);
2306 }
2307 
2308 /** returns TRUE iff current LP basis is stable */
2310  SCIP_LPI* lpi /**< LP interface structure */
2311  )
2312 {
2313  assert(lpi != NULL);
2314  assert(lpi->prob != NULL);
2315 
2316  SCIPdebugMessage("checking for numerical stability\n");
2317 
2318  (void) QSget_status(lpi->prob, &(lpi->solstat));
2319 
2320  return (lpi->solstat != QS_LP_NUMERR);
2321 }
2322 
2323 /** returns TRUE iff the objective limit was reached */
2325  SCIP_LPI* lpi /**< LP interface structure */
2326  )
2327 {
2328  assert(lpi != NULL);
2329  assert(lpi->prob != NULL);
2330 
2331  SCIPdebugMessage("checking for objective limit exceeded\n");
2332 
2333  (void) QSget_status(lpi->prob, &(lpi->solstat));
2334 
2335  return (lpi->solstat == QS_LP_OBJ_LIMIT);
2336 }
2337 
2338 /** returns TRUE iff the iteration limit was reached */
2340  SCIP_LPI* lpi /**< LP interface structure */
2341  )
2342 {
2343  assert(lpi != NULL);
2344  assert(lpi->prob != NULL);
2345 
2346  SCIPdebugMessage("checking for iteration limit exceeded\n");
2347 
2348  (void) QSget_status(lpi->prob, &(lpi->solstat));
2349 
2350  return (lpi->solstat == QS_LP_ITER_LIMIT);
2351 }
2352 
2353 /** returns TRUE iff the time limit was reached */
2355  SCIP_LPI* lpi /**< LP interface structure */
2356  )
2357 {
2358  assert(lpi != NULL);
2359  assert(lpi->prob != NULL);
2360 
2361  SCIPdebugMessage("checking for time limit exceeded\n");
2362 
2363  (void) QSget_status(lpi->prob, &(lpi->solstat));
2364 
2365  return (lpi->solstat == QS_LP_TIME_LIMIT);
2366 }
2367 
2368 /** returns the internal solution status of the solver */
2370  SCIP_LPI* lpi /**< LP interface structure */
2371  )
2372 {
2373  assert(lpi != NULL);
2374  assert(lpi->prob != NULL);
2375 
2376  SCIPdebugMessage("getting internal solution status\n");
2377 
2378  (void) QSget_status(lpi->prob, &(lpi->solstat));
2379 
2380  return lpi->solstat;
2381 }
2382 
2383 /** tries to reset the internal status of the LP solver in order to ignore an instability of the last solving call */
2385  SCIP_LPI* lpi, /**< LP interface structure */
2386  SCIP_Bool* success /**< pointer to store, whether the instability could be ignored */
2387  )
2388 {
2389  assert(lpi != NULL);
2390  assert(lpi->prob != NULL);
2391 
2392  SCIPdebugMessage("ignore instability (will fail)\n");
2393 
2394  /* it seems that in QSopt this does not make much sense */
2395  *success = FALSE;
2396 
2397  return SCIP_OKAY;
2398 }
2399 
2400 /** gets objective value of solution */
2402  SCIP_LPI* lpi, /**< LP interface structure */
2403  SCIP_Real* objval /**< stores the objective value */
2404  )
2405 {
2406  int rval;
2407 
2408  assert(lpi != NULL);
2409  assert(lpi->prob != NULL);
2410 
2411  SCIPdebugMessage("getting solution's objective value\n");
2412 
2413  rval = QSget_objval(lpi->prob, objval);
2414 
2415  QS_RETURN(rval);
2416 }
2417 
2418 /** gets primal and dual solution vectors */
2420  SCIP_LPI* lpi, /**< LP interface structure */
2421  SCIP_Real* objval, /**< stores the objective value, may be NULL if not needed */
2422  SCIP_Real* primsol, /**< primal solution vector, may be NULL if not needed */
2423  SCIP_Real* dualsol, /**< dual solution vector, may be NULL if not needed */
2424  SCIP_Real* activity, /**< row activity vector, may be NULL if not needed */
2425  SCIP_Real* redcost /**< reduced cost vector, may be NULL if not needed */
2426  )
2427 {
2428  int rval;
2429  int nrows;
2430  register int i;
2431 
2432 #ifdef SCIP_DEBUG
2433  int stat, ncols, sense;
2434  char *icstat, *irstat;
2435 #endif
2436 
2437  assert(lpi != NULL);
2438  assert(lpi->prob != NULL);
2439 
2440  SCIPdebugMessage("getting solution\n");
2441 
2442  nrows = QSget_rowcount(lpi->prob);
2443  SCIP_CALL( ensureRowMem(lpi, nrows) );
2444 
2445  rval = QSget_solution(lpi->prob, objval, primsol, dualsol, lpi->irng, redcost);
2446  QS_CONDRET(rval);
2447 
2448 #if 0
2449 #ifdef SCIP_DEBUG
2450  QSget_status(lpi->prob, &stat);
2451  rval = QSget_objsense(lpi->prob, &sense);
2452  if( stat == QS_LP_OPTIMAL )
2453  {
2454  ncols = QSget_colcount(lpi->prob);
2455  QS_CONDRET(rval);
2456 
2457  SCIP_CALL(ensureTabMem(lpi,nrows+ncols));
2458  icstat = lpi->ibas;
2459  irstat = lpi->ibas+ncols;
2460 
2461  rval = QSget_basis_array(lpi->prob,icstat, irstat);
2462  QS_CONDRET(rval);
2463 
2464  for( i = ncols ; i-- ; )
2465  {
2466  switch( icstat[i] )
2467  {
2468  case QS_COL_BSTAT_BASIC:
2469  case QS_COL_BSTAT_FREE:
2470  if( fabs(redcost[i])> FEASTOL )
2471  {
2472  SCIPerrorMessage("stat col[%d] = %c, rd[%d] = %lg sense %d\n", i, icstat[i], i, redcost[i]*sense, sense);
2473  SCIPABORT();
2474  return SCIP_INVALIDDATA; /*lint !e527*/
2475  }
2476  break;
2477  case QS_COL_BSTAT_UPPER:
2478  if( redcost[i]*sense > FEASTOL )
2479  {
2480  SCIPerrorMessage("stat col[%d] = %c, rd[%d] = %lg sense %d\n", i, icstat[i], i, redcost[i]*sense, sense);
2481  SCIPABORT();
2482  return SCIP_INVALIDDATA; /*lint !e527*/
2483  }
2484  break;
2485  case QS_COL_BSTAT_LOWER:
2486  if( redcost[i]*sense < -FEASTOL )
2487  {
2488  SCIPerrorMessage("stat col[%d] = %c, rd[%d] = %lg sense %d\n", i, icstat[i], i, redcost[i]*sense, sense);
2489  SCIPABORT();
2490  return SCIP_INVALIDDATA; /*lint !e527*/
2491  }
2492  break;
2493  default:
2494  SCIPerrorMessage("unknown stat col[%d] = %c, rd[%d] = %lg\n", i, icstat[i], i, redcost[i]*sense);
2495  SCIPABORT();
2496  return SCIP_INVALIDDATA; /*lint !e527*/
2497  }
2498  }
2499  }
2500  else
2501  {
2502  SCIPerrorMessage("Getting solution with stat %d (not optimal)\n", stat);
2503  }
2504 #endif
2505 #endif
2506 
2507  rval = QSget_rhs(lpi->prob, lpi->irhs);
2508  QS_CONDRET(rval);
2509  rval = QSget_senses(lpi->prob, lpi->isen);
2510  QS_CONDRET(rval);
2511 
2512  /* build back the activity */
2513  if( activity )
2514  {
2515  for( i = 0; i < nrows; ++i )
2516  {
2517  switch( lpi->isen[i] )
2518  {
2519  case 'R':
2520  case 'E':
2521  case 'G':
2522  activity[i] = lpi->irhs[i] + lpi->irng[i];
2523  break;
2524  case 'L':
2525  activity[i] = lpi->irhs[i] - lpi->irng[i];
2526  break;
2527  default:
2528  SCIPerrorMessage("unknown sense %c\n", lpi->isen[i]);
2529  SCIPABORT();
2530  return SCIP_INVALIDDATA; /*lint !e527*/
2531  }
2532  }
2533  }
2534 
2535  return SCIP_OKAY;
2536 }
2537 
2538 /** gets primal ray for unbounded LPs */
2540  SCIP_LPI* lpi, /**< LP interface structure */
2541  SCIP_Real* ray /**< primal ray */
2542  )
2543 { /*lint --e{715}*/
2544  assert(lpi != NULL);
2545  assert(lpi->prob != NULL);
2546 
2547  SCIPerrorMessage("SCIPlpiGetPrimalRay() not supported by QSopt.\n");
2548 
2549  return SCIP_LPERROR;
2550 }
2551 
2552 /** gets dual Farkas proof for infeasibility */
2554  SCIP_LPI* lpi, /**< LP interface structure */
2555  SCIP_Real* dualfarkas /**< dual Farkas row multipliers */
2556  )
2557 {
2558  int rval;
2559 
2560  assert(lpi != NULL);
2561  assert(lpi->prob != NULL);
2562  assert(dualfarkas != NULL);
2563 
2564  SCIPdebugMessage("calling QSopt dual Farkas: %d cols, %d rows, %d non zeros\n", QSget_colcount (lpi->prob),
2565  QSget_rowcount(lpi->prob), QSget_nzcount(lpi->prob));
2566 
2567  rval = QSget_infeas_array(lpi->prob, dualfarkas);
2568 
2569  QS_RETURN(rval);
2570 }
2571 
2572 /** gets the number of LP iterations of the last solve call */
2574  SCIP_LPI* lpi, /**< LP interface structure */
2575  int* iterations /**< pointer to store the number of iterations of the last solve call */
2576  )
2577 {
2578  int rval;
2579  int nit;
2580 
2581  assert(lpi != NULL);
2582  assert(lpi->prob != NULL);
2583 
2584  rval = QSget_itcnt(lpi->prob, 0, 0, 0, 0, &nit);
2585  QS_CONDRET(rval);
2586 
2587  *iterations = nit - lpi->previt;
2588  lpi->previt = nit;
2589 
2590  return SCIP_OKAY;
2591 }
2592 
2593 /** gets information about the quality of an LP solution
2594  *
2595  * Such information is usually only available, if also a (maybe not optimal) solution is available.
2596  * The LPI should return SCIP_INVALID for @p quality, if the requested quantity is not available.
2597  */
2599  SCIP_LPI* lpi, /**< LP interface structure */
2600  SCIP_LPSOLQUALITY qualityindicator, /**< indicates which quality should be returned */
2601  SCIP_Real* quality /**< pointer to store quality number */
2602  )
2603 { /*lint --e{715}*/
2604  assert(lpi != NULL);
2605  assert(quality != NULL);
2606 
2607  *quality = SCIP_INVALID;
2608 
2609  return SCIP_OKAY;
2610 }
2611 
2612 /**@} */
2613 
2614 
2615 
2616 
2617 /*
2618  * LP Basis Methods
2619  */
2620 
2621 /**@name LP Basis Methods */
2622 /**@{ */
2623 
2624 /** gets current basis status for columns and rows; arrays must be large enough to store the basis status */
2626  SCIP_LPI* lpi, /**< LP interface structure */
2627  int* cstat, /**< array to store column basis status, or NULL */
2628  int* rstat /**< array to store row basis status, or NULL */
2629  )
2630 {
2631  int rval;
2632  int ncols;
2633  int nrows;
2634  char* icstat;
2635  char* irstat;
2636  register int i;
2637 
2638  assert(lpi != NULL);
2639  assert(lpi->prob != NULL);
2640 
2641  SCIPdebugMessage("saving QSopt basis into %p/%p\n", (void*)cstat, (void*)rstat);
2642 
2643  ncols = QSget_colcount(lpi->prob);
2644  nrows = QSget_rowcount(lpi->prob);
2645 
2646  SCIP_CALL( ensureTabMem(lpi, nrows + ncols) );
2647  SCIP_CALL( ensureRowMem(lpi, nrows) );
2648 
2649  /* get senses */
2650  rval = QSget_senses(lpi->prob, lpi->isen);
2651  QS_CONDRET(rval);
2652 
2653  /* get basis */
2654  icstat = lpi->ibas;
2655  irstat = lpi->ibas + ncols;
2656  rval = QSget_basis_array(lpi->prob, icstat, irstat);
2657  QS_CONDRET(rval);
2658 
2659  /* Now we must transform QSopt codes into SCIP codes.
2660  * We have the following cases:
2661  * 'G': b <= ax -> b = ax - s, s >= 0
2662  * 'L': ax <= b -> b = ax + s, s >= 0
2663  * 'R': b <= ax <= c -> c - b = ax + s, 0 <= s <= c - b
2664  */
2665  for( i = 0; i < nrows; ++i )
2666  {
2667  switch( irstat[i] )
2668  {
2669  case QS_ROW_BSTAT_LOWER:
2670  if ( lpi->isen[i] == 'L' )
2671  rstat[i] = (char) SCIP_BASESTAT_UPPER;
2672  else
2673  rstat[i] = (char) SCIP_BASESTAT_LOWER;
2674  break;
2675  case QS_ROW_BSTAT_BASIC:
2676  rstat[i] = (char) SCIP_BASESTAT_BASIC;
2677  break;
2678  case QS_ROW_BSTAT_UPPER:
2679  rstat[i] = (char) SCIP_BASESTAT_UPPER;
2680  break;
2681  default:
2682  SCIPerrorMessage("Unknown row basic status %c", rstat[i]);
2683  SCIPABORT();
2684  return SCIP_INVALIDDATA; /*lint !e527*/
2685  }
2686  }
2687  for( i = 0; i < ncols; ++i )
2688  {
2689  switch( icstat[i] )
2690  {
2691  case QS_COL_BSTAT_LOWER:
2692  cstat[i] = (char) SCIP_BASESTAT_LOWER;
2693  break;
2694  case QS_COL_BSTAT_BASIC:
2695  cstat[i] = (char) SCIP_BASESTAT_BASIC;
2696  break;
2697  case QS_COL_BSTAT_UPPER:
2698  cstat[i] = (char) SCIP_BASESTAT_UPPER;
2699  break;
2700  case QS_COL_BSTAT_FREE:
2701  cstat[i] = (char) SCIP_BASESTAT_ZERO;
2702  break;
2703  default:
2704  SCIPerrorMessage("Unknown column basic status %c", cstat[i]);
2705  SCIPABORT();
2706  return SCIP_INVALIDDATA; /*lint !e527*/
2707  }
2708  }
2709  return SCIP_OKAY;
2710 }
2711 
2712 /** sets current basis status for columns and rows */
2714  SCIP_LPI* lpi, /**< LP interface structure */
2715  const int* cstat, /**< array with column basis status */
2716  const int* rstat /**< array with row basis status */
2717  )
2718 {
2719  int rval;
2720  int ncols;
2721  int nrows;
2722  register int i;
2723  char* icstat;
2724  char* irstat;
2725 
2726  assert(lpi != NULL);
2727  assert(lpi->prob != NULL);
2728 
2729  SCIPdebugMessage("loading basis %p/%p into QSopt\n", (void*)cstat, (void*)rstat);
2730 
2731  ncols = QSget_colcount(lpi->prob);
2732  nrows = QSget_rowcount(lpi->prob);
2733 
2734  SCIP_CALL( ensureTabMem(lpi, ncols) );
2735  SCIP_CALL( ensureRowMem(lpi, nrows) );
2736 
2737  /* get senses */
2738  rval = QSget_senses(lpi->prob, lpi->isen);
2739  QS_CONDRET(rval);
2740 
2741  icstat = lpi->ibas;
2742  irstat = lpi->ibas + ncols;
2743 
2744  /* now we must transform QSopt codes into SCIP codes */
2745  for( i = 0; i < nrows; ++i )
2746  {
2747  switch( rstat[i] )
2748  {
2749  case SCIP_BASESTAT_LOWER:
2750  irstat[i] = QS_ROW_BSTAT_LOWER;
2751  break;
2752  case SCIP_BASESTAT_BASIC:
2753  irstat[i] = QS_ROW_BSTAT_BASIC;
2754  break;
2755  case SCIP_BASESTAT_UPPER:
2756  if ( lpi->isen[i] == 'L' )
2757  irstat[i] = QS_ROW_BSTAT_LOWER;
2758  else
2759  irstat[i] = QS_ROW_BSTAT_UPPER;
2760  break;
2761  default:
2762  SCIPerrorMessage("Unknown row basic status %d", rstat[i]);
2763  SCIPABORT();
2764  return SCIP_INVALIDDATA; /*lint !e527*/
2765  }
2766  }
2767  for( i = 0; i < ncols; ++i )
2768  {
2769  switch( cstat[i] )
2770  {
2771  case SCIP_BASESTAT_LOWER:
2772  icstat[i] = QS_COL_BSTAT_LOWER;
2773  break;
2774  case SCIP_BASESTAT_BASIC:
2775  icstat[i] = QS_COL_BSTAT_BASIC;
2776  break;
2777  case SCIP_BASESTAT_UPPER:
2778  icstat[i] = QS_COL_BSTAT_UPPER;
2779  break;
2780  case SCIP_BASESTAT_ZERO:
2781  icstat[i] = QS_COL_BSTAT_FREE;
2782  break;
2783  default:
2784  SCIPerrorMessage("Unknown column basic status %d", cstat[i]);
2785  SCIPABORT();
2786  return SCIP_INVALIDDATA; /*lint !e527*/
2787  }
2788  }
2789 
2790  /* set the basis */
2791  rval = QSload_basis_array(lpi->prob, icstat, irstat);
2792  QS_RETURN(rval);
2793 }
2794 
2795 /** returns the indices of the basic columns and rows; basic column n gives value n, basic row m gives value -1-m */
2797  SCIP_LPI* lpi, /**< LP interface structure */
2798  int* bind /**< pointer to store basis indices ready to keep number of rows entries */
2799  )
2800 {
2801  int nrows;
2802  int ncols;
2803  int stat;
2804  register int i;
2805 
2806  assert(lpi!=NULL);
2807  assert(lpi->prob!=NULL);
2808 
2809  SCIPdebugMessage("getting basis information\n");
2810 
2811  nrows = QSget_rowcount(lpi->prob);
2812  ncols = QSget_colcount(lpi->prob);
2813 
2814  QS_CONDRET( QSget_status(lpi->prob, &stat) );
2815  if ( stat == QS_LP_UNSOLVED || stat == QS_LP_MODIFIED || stat == QS_LP_NUMERR )
2816  {
2817  QS_CONDRET( QSopt_dual(lpi->prob, &(lpi->solstat)) );
2818  }
2819 
2820  QS_CONDRET( QSget_basis_order(lpi->prob, bind) );
2821 
2822  /* transform QSopt basis header into SCIP format */
2823  for( i = 0; i < nrows; ++i )
2824  {
2825  if( bind[i] >= ncols )
2826  bind[i] = -(bind[i] - ncols) - 1;
2827  }
2828 
2829  return SCIP_OKAY;
2830 }
2831 
2832 /** get dense row of inverse basis matrix B^-1
2833  *
2834  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
2835  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
2836  * see also the explanation in lpi.h.
2837  *
2838  * @todo check that the result is in terms of the LP interface definition
2839  */
2841  SCIP_LPI* lpi, /**< LP interface structure */
2842  int r, /**< row number */
2843  SCIP_Real* coef, /**< pointer to store the coefficients of the row */
2844  int* inds, /**< array to store the non-zero indices */
2845  int* ninds /**< pointer to store the number of non-zero indices
2846  * (-1: if we do not store sparsity informations) */
2847  )
2848 { /*lint --e{715} */
2849  int nrows;
2850  int rval;
2851  int i;
2852 
2853  assert(lpi!=NULL);
2854  assert(lpi->prob!=NULL);
2855 
2856  nrows = QSget_rowcount(lpi->prob);
2857  assert( 0 <= r && r < nrows );
2858 
2859  SCIPdebugMessage("getting binv-row %d from Qsopt %d cols, %d rows, %d nonz\n", r, QSget_colcount(lpi->prob),
2860  QSget_rowcount(lpi->prob), QSget_nzcount(lpi->prob));
2861 
2862  /* can only return dense result */
2863  if ( ninds != NULL )
2864  *ninds = -1;
2865 
2866  rval = QSget_binv_row(lpi->prob, r, coef);
2867 
2868  for (i = 0; i < nrows; i++)
2869  coef[i] *= -1.0;
2870 
2871  QS_RETURN(rval);
2872 }
2873 
2874 /** get dense column of inverse basis matrix B^-1
2875  *
2876  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
2877  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
2878  * see also the explanation in lpi.h.
2879  *
2880  * @todo check that the result is in terms of the LP interface definition
2881  */
2883  SCIP_LPI* lpi, /**< LP interface structure */
2884  int c, /**< column number of B^-1; this is NOT the number of the column in the LP;
2885  * you have to call SCIPlpiGetBasisInd() to get the array which links the
2886  * B^-1 column numbers to the row and column numbers of the LP!
2887  * c must be between 0 and nrows-1, since the basis has the size
2888  * nrows * nrows */
2889  SCIP_Real* coef, /**< pointer to store the coefficients of the column */
2890  int* inds, /**< array to store the non-zero indices */
2891  int* ninds /**< pointer to store the number of non-zero indices
2892  * (-1: if we do not store sparsity informations) */
2893  )
2894 { /*lint --e{715} */
2895  assert(lpi!=NULL);
2896  assert(lpi->prob!=NULL);
2897 
2898  SCIPerrorMessage("SCIPlpiGetBInvCol() not supported by QSopt.\n");
2899 
2900  /* QSopt does not provide an interface for this yet */
2901  return SCIP_LPERROR;
2902 }
2903 
2904 /** get dense row of inverse basis matrix times constraint matrix B^-1 * A
2905  *
2906  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
2907  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
2908  * see also the explanation in lpi.h.
2909  *
2910  * @todo check that the result is in terms of the LP interface definition
2911  */
2913  SCIP_LPI* lpi, /**< LP interface structure */
2914  int r, /**< row number */
2915  const SCIP_Real* binvrow, /**< row in (A_B)^-1 from prior call to SCIPlpiGetBInvRow(), or NULL */
2916  SCIP_Real* coef, /**< vector to return coefficients */
2917  int* inds, /**< array to store the non-zero indices */
2918  int* ninds /**< pointer to store the number of non-zero indices
2919  * (-1: if we do not store sparsity informations) */
2920  )
2921 { /*lint --e{715} */
2922  int rval;
2923  int ncols;
2924  int nrows;
2925  int i;
2926 
2927  assert(lpi != NULL);
2928  assert(lpi->prob != NULL);
2929 
2930  SCIPdebugMessage("getting binva-row %d\n", r);
2931 
2932  /* can only return dense result */
2933  if ( ninds != NULL )
2934  *ninds = -1;
2935 
2936  ncols = QSget_colcount(lpi->prob);
2937  nrows = QSget_rowcount(lpi->prob);
2938 
2939  SCIP_CALL( ensureTabMem(lpi, nrows + ncols) );
2940 
2941  rval = QSget_tableau_row(lpi->prob, r, lpi->itab);
2942  QS_CONDRET(rval);
2943 
2944  /* copy local information to the outside */
2945  memcpy(coef, lpi->itab, sizeof(double)*ncols);
2946 
2947  for (i = 0; i < ncols; ++i)
2948  coef[i] *= -1.0;
2949 
2950  return SCIP_OKAY;
2951 }
2952 
2953 /** get dense column of inverse basis matrix times constraint matrix B^-1 * A
2954  *
2955  * @note The LP interface defines slack variables to have coefficient +1. This means that if, internally, the LP solver
2956  * uses a -1 coefficient, then rows associated with slacks variables whose coefficient is -1, should be negated;
2957  * see also the explanation in lpi.h.
2958  *
2959  * @todo check that the result is in terms of the LP interface definition
2960  */
2962  SCIP_LPI* lpi, /**< LP interface structure */
2963  int c, /**< column number */
2964  SCIP_Real* coef, /**< vector to return coefficients */
2965  int* inds, /**< array to store the non-zero indices */
2966  int* ninds /**< pointer to store the number of non-zero indices
2967  * (-1: if we do not store sparsity informations) */
2968  )
2969 { /*lint --e{715} */
2970  assert(lpi!=NULL);
2971  assert(lpi->prob!=NULL);
2972 
2973  SCIPerrorMessage("SCIPlpiGetBInvACol() not supported by QSopt.\n");
2974 
2975  /* QSopt does not provide an interface for this yet */
2976  return SCIP_LPERROR;
2977 }
2978 
2979 /**@} */
2980 
2981 
2982 
2983 
2984 /*
2985  * LP State Methods
2986  */
2987 
2988 /**@name LP State Methods */
2989 /**@{ */
2990 
2991 /** stores LPi state (like basis information) into lpistate object */
2993  SCIP_LPI* lpi, /**< LP interface structure */
2994  BMS_BLKMEM* blkmem, /**< block memory */
2995  SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */
2996  )
2997 {
2998  int ncols, nrows;
2999 
3000  assert(lpi != NULL);
3001  assert(lpi->prob != NULL);
3002  assert(blkmem != NULL);
3003  assert(lpistate != NULL);
3004 
3005  ncols = QSget_colcount(lpi->prob);
3006  nrows = QSget_rowcount(lpi->prob);
3007 
3008  assert(ncols >= 0);
3009  assert(nrows >= 0);
3010 
3011  /* allocate lpistate data */
3012  SCIP_CALL( lpistateCreate(lpistate, blkmem, ncols, nrows));
3013  SCIPdebugMessage("storing QSopt LPI state in %p (%d cols, %d rows)\n", (void*)*lpistate, ncols, nrows);
3014 
3015  /* get unpacked basis information from QSopt */
3016  SCIP_CALL( ensureColMem(lpi, ncols) );
3017  SCIP_CALL( ensureRowMem(lpi, nrows) );
3018  SCIP_CALL( SCIPlpiGetBase(lpi, lpi->iccnt, lpi->ircnt) );
3019 
3020  /* pack LPi state data */
3021  (*lpistate)->ncols = ncols;
3022  (*lpistate)->nrows = nrows;
3023  lpistatePack(*lpistate, lpi->iccnt, lpi->ircnt);
3024 
3025  return SCIP_OKAY;
3026 }
3027 
3028 /** loads LPi state (like basis information) into solver; note that the LP might have been extended with additional
3029  * columns and rows since the state was stored with SCIPlpiGetState()
3030  */
3032  SCIP_LPI* lpi, /**< LP interface structure */
3033  BMS_BLKMEM* blkmem, /**< block memory */
3034  const SCIP_LPISTATE* lpistate /**< LPi state information (like basis information) */
3035  )
3036 { /*lint --e{715} */
3037  char* icstat;
3038  char* irstat;
3039  int i;
3040  int ncols;
3041  int nrows;
3042  int rval;
3043 
3044  assert(lpi != NULL);
3045  assert(lpi->prob != NULL);
3046 
3047  /* if there was no basis information available, LPI state was not stored */
3048  if( lpistate == NULL )
3049  return SCIP_OKAY;
3050 
3051  /* continue test */
3052  ncols = QSget_colcount(lpi->prob);
3053  nrows = QSget_rowcount(lpi->prob);
3054 
3055  assert(ncols >= 0);
3056  assert(nrows >= 0);
3057  assert(lpistate->ncols <= ncols);
3058  assert(lpistate->nrows <= nrows);
3059 
3060  SCIPdebugMessage("loading LPI state %p (%d cols, %d rows) into QSopt LP with %d cols and %d rows\n", (void*)lpistate, lpistate->ncols,
3061  lpistate->nrows, ncols, nrows);
3062 
3063  if( lpistate->ncols == 0 || lpistate->nrows == 0 )
3064  return SCIP_OKAY;
3065 
3066  /* allocate enough memory for storing uncompressed basis information */
3067  SCIP_CALL( ensureColMem(lpi, ncols) );
3068  SCIP_CALL( ensureRowMem(lpi, nrows) );
3069  SCIP_CALL( ensureTabMem(lpi, nrows + ncols) );
3070 
3071  icstat = lpi->ibas;
3072  irstat = lpi->ibas + ncols;
3073 
3074  /* get senses */
3075  rval = QSget_senses(lpi->prob, lpi->isen);
3076  QS_CONDRET(rval);
3077 
3078  /* unpack LPi state data */
3079  lpistateUnpack(lpistate, lpi->iccnt, lpi->ircnt);
3080 
3081  /* extend the basis to the current LP beyond the previously existing columns */
3082  for( i = lpistate->ncols; i < ncols; ++i )
3083  {
3084  SCIP_Real lb;
3085  SCIP_Real ub;
3086 
3087  /* get bounds from qsopt */
3088  rval = QSget_bounds_list(lpi->prob, 1, &i, &lb, &ub);
3089  QS_CONDRET(rval);
3090  if ( SCIPlpiIsInfinity(lpi, REALABS(lb)) )
3091  {
3092  /* if lower bound is +/- infinity -> try upper bound */
3093  if ( SCIPlpiIsInfinity(lpi, REALABS(ub)) )
3094  lpi->iccnt[i] = (int) SCIP_BASESTAT_ZERO; /* variable is free */
3095  else
3096  lpi->iccnt[i] = (int) SCIP_BASESTAT_UPPER; /* use finite upper bound */
3097  }
3098  else
3099  lpi->iccnt[i] = (int) SCIP_BASESTAT_LOWER; /* use finite lower bound */
3100  }
3101  for( i = lpistate->nrows; i < nrows; ++i ) /*lint !e850*/
3102  lpi->ircnt[i] = (int) SCIP_BASESTAT_BASIC;
3103 
3104  /* convert the loaded basis into QSopt format */
3105  for( i = 0; i < nrows; ++i )
3106  {
3107  switch( lpi->ircnt[i] )
3108  {
3109  case SCIP_BASESTAT_LOWER:
3110  irstat[i] = QS_ROW_BSTAT_LOWER;
3111  break;
3112  case SCIP_BASESTAT_BASIC:
3113  irstat[i] = QS_ROW_BSTAT_BASIC;
3114  break;
3115  case SCIP_BASESTAT_UPPER:
3116  if ( lpi->isen[i] == 'L' )
3117  irstat[i] = QS_ROW_BSTAT_LOWER;
3118  else
3119  irstat[i] = QS_ROW_BSTAT_UPPER;
3120  break;
3121  default:
3122  SCIPerrorMessage("Unknown row basic status %d", lpi->ircnt[i]);
3123  SCIPABORT();
3124  return SCIP_INVALIDDATA; /*lint !e527*/
3125  }
3126  }
3127 
3128  for( i = 0; i < ncols; ++i )
3129  {
3130  switch( lpi->iccnt[i] )
3131  {
3132  case SCIP_BASESTAT_LOWER:
3133  icstat[i] = QS_COL_BSTAT_LOWER;
3134  break;
3135  case SCIP_BASESTAT_BASIC:
3136  icstat[i] = QS_COL_BSTAT_BASIC;
3137  break;
3138  case SCIP_BASESTAT_UPPER:
3139  icstat[i] = QS_COL_BSTAT_UPPER;
3140  break;
3141  case SCIP_BASESTAT_ZERO:
3142  icstat[i] = QS_COL_BSTAT_FREE;
3143  break;
3144  default:
3145  SCIPerrorMessage("Unknown column basic status %d", lpi->iccnt[i]);
3146  SCIPABORT();
3147  return SCIP_INVALIDDATA; /*lint !e527*/
3148  }
3149  }
3150 
3151  /* set the basis */
3152  rval = QSload_basis_array(lpi->prob, icstat, irstat);
3153  QS_RETURN(rval);
3154 }
3155 
3156 /** clears current LPi state (like basis information) of the solver */
3158  SCIP_LPI* lpi /**< LP interface structure */
3159  )
3160 {
3161  int ncols;
3162  int nrows;
3163  int* cstat;
3164  int* rstat;
3165  int i;
3166 
3167  assert( lpi != NULL );
3168  assert( lpi->prob != NULL );
3169 
3170  SCIPdebugMessage("SCIPlpiClearState()\n");
3171 
3172  ncols = QSget_colcount(lpi->prob);
3173  nrows = QSget_rowcount(lpi->prob);
3174 
3175  if ( ncols == 0 || nrows == 0 )
3176  return SCIP_OKAY;
3177 
3178  SCIP_ALLOC( BMSallocMemoryArray(&cstat, ncols) );
3179  SCIP_ALLOC( BMSallocMemoryArray(&rstat, nrows) );
3180 
3181  for (i = 0; i < ncols; ++i)
3182  cstat[i] = (char) SCIP_BASESTAT_LOWER;
3183  for (i = 0; i < nrows; ++i)
3184  rstat[i] = (char) SCIP_BASESTAT_BASIC;
3185 
3186  SCIP_CALL( SCIPlpiSetBase(lpi, cstat, rstat) );
3187 
3188  BMSfreeMemoryArray(&cstat);
3189  BMSfreeMemoryArray(&rstat);
3190 
3191  return SCIP_OKAY;
3192 }
3193 
3194 /** frees LPi state information */
3196  SCIP_LPI* lpi, /**< LP interface structure */
3197  BMS_BLKMEM* blkmem, /**< block memory */
3198  SCIP_LPISTATE** lpistate /**< pointer to LPi state information (like basis information) */
3199  )
3200 {
3201  assert(lpi != NULL);
3202  assert(lpistate != NULL);
3203 
3204  if( *lpistate != NULL )
3205  lpistateFree(lpistate, blkmem);
3206 
3207  return SCIP_OKAY;
3208 }
3209 
3210 /** checks, whether the given LP state contains simplex basis information */
3212  SCIP_LPI* lpi, /**< LP interface structure */
3213  SCIP_LPISTATE* lpistate /**< LP state information (like basis information) */
3214  )
3215 { /*lint --e{715} */
3216  return (lpistate != NULL);
3217 }
3218 
3219 /** reads LP state (like basis information from a file */
3221  SCIP_LPI* lpi, /**< LP interface structure */
3222  const char* fname /**< file name */
3223  )
3224 {
3225  int rval;
3226 
3227  assert(lpi != NULL);
3228  assert(lpi->prob != NULL);
3229 
3230  SCIPdebugMessage("reading QSopt LP state from file <%s>\n", fname);
3231 
3232  rval = QSread_and_load_basis(lpi->prob, fname);
3233  if( rval )
3234  {
3235  SCIPerrorMessage("Error while loading basis from file <%s>.\n", fname);
3236  return SCIP_READERROR;
3237  }
3238 
3239  return SCIP_OKAY;
3240 }
3241 
3242 /** writes LP state (like basis information) to a file */
3244  SCIP_LPI* lpi, /**< LP interface structure */
3245  const char* fname /**< file name */
3246  )
3247 {
3248  QSbas bas;
3249  int rval;
3250 
3251  assert(lpi != NULL);
3252  assert(lpi->prob != NULL);
3253 
3254  SCIPdebugMessage("writing QSopt LP state to file <%s>\n", fname);
3255 
3256  bas = QSget_basis(lpi->prob);
3257  QS_ERROR(bas == 0, "Could not get basis from problem."); /*lint !e820*/
3258  assert(bas);
3259 
3260  rval = QSwrite_basis(lpi->prob, bas, fname);
3261  QSfree(bas);
3262  if( rval )
3263  {
3264  SCIPerrorMessage("Could not write basis to file <%s>.\n", fname);
3265  return SCIP_WRITEERROR;
3266  }
3267 
3268  return SCIP_OKAY;
3269 }
3270 
3271 /**@} */
3272 
3273 
3274 
3275 
3276 /*
3277  * LP Pricing Norms Methods
3278  */
3279 
3280 /**@name LP Pricing Norms Methods */
3281 /**@{ */
3282 
3283 /** stores LPi pricing norms information
3284  * @todo should we store norm information?
3285  */
3287  SCIP_LPI* lpi, /**< LP interface structure */
3288  BMS_BLKMEM* blkmem, /**< block memory */
3289  SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information */
3290  )
3291 { /*lint --e{715} */
3292  int ncols;
3293  int nrows;
3294  int rval;
3295 
3296  assert( lpi != NULL );
3297  assert( lpi->prob != NULL );
3298  assert( lpinorms != NULL );
3299 
3300  ncols = QSget_colcount(lpi->prob);
3301  nrows = QSget_rowcount(lpi->prob);
3302 
3303  /* allocate lpinorms data */
3304  SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpinorms) );
3305  (*lpinorms)->ncols = ncols;
3306  (*lpinorms)->nrows = nrows;
3307 
3308  if ( QStest_row_norms(lpi->prob) )
3309  {
3310  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpinorms)->cstat, ncols) );
3311  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpinorms)->rstat, nrows) );
3312  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpinorms)->norms, nrows) );
3313 
3314  rval = QSget_basis_and_row_norms_array(lpi->prob, (*lpinorms)->cstat, (*lpinorms)->rstat, (*lpinorms)->norms);
3315  QS_CONDRET(rval);
3316  }
3317  else
3318  {
3319  (*lpinorms)->cstat = NULL;
3320  (*lpinorms)->rstat = NULL;
3321  (*lpinorms)->norms = NULL;
3322  }
3323 
3324  return SCIP_OKAY;
3325 }
3326 
3327 /** loads LPi pricing norms into solver; note that the LP might have been extended with additional
3328  * columns and rows since the state was stored with SCIPlpiGetNorms()
3329  */
3331  SCIP_LPI* lpi, /**< LP interface structure */
3332  BMS_BLKMEM* blkmem, /**< block memory */
3333  const SCIP_LPINORMS* lpinorms /**< LPi pricing norms information */
3334  )
3335 { /*lint --e{715} */
3336  int ncols;
3337  int nrows;
3338  int rval;
3339 
3340  assert( lpi != NULL );
3341  assert( lpi->prob != NULL );
3342  assert( lpinorms != NULL );
3343 
3344  if ( lpinorms->norms == NULL )
3345  return SCIP_OKAY;
3346 
3347  ncols = QSget_colcount(lpi->prob);
3348  nrows = QSget_rowcount(lpi->prob);
3349  if ( nrows != lpinorms->nrows || ncols != lpinorms->ncols )
3350  return SCIP_OKAY;
3351 
3352  /* load row norms */
3353  assert( lpinorms->cstat != NULL && lpinorms->rstat != NULL && lpinorms->norms != NULL );
3354  rval = QSload_basis_and_row_norms_array(lpi->prob, lpinorms->cstat, lpinorms->rstat, lpinorms->norms);
3355 
3356  QS_RETURN(rval);
3357 }
3358 
3359 /** frees pricing norms information */
3361  SCIP_LPI* lpi, /**< LP interface structure */
3362  BMS_BLKMEM* blkmem, /**< block memory */
3363  SCIP_LPINORMS** lpinorms /**< pointer to LPi pricing norms information */
3364  )
3365 { /*lint --e{715} */
3366  assert( lpinorms != NULL );
3367 
3368  if ( (*lpinorms)->norms != NULL )
3369  {
3370  assert( (*lpinorms)->cstat != NULL && (*lpinorms)->rstat != NULL );
3371  BMSfreeBlockMemoryArray(blkmem, &(*lpinorms)->norms, (*lpinorms)->nrows);
3372  BMSfreeBlockMemoryArray(blkmem, &(*lpinorms)->rstat, (*lpinorms)->nrows);
3373  BMSfreeBlockMemoryArray(blkmem, &(*lpinorms)->cstat, (*lpinorms)->ncols);
3374  }
3375  BMSfreeBlockMemory(blkmem, lpinorms);
3376 
3377  return SCIP_OKAY;
3378 }
3379 
3380 /**@} */
3381 
3382 
3383 
3384 
3385 /*
3386  * Parameter Methods
3387  */
3388 
3389 /**@name Parameter Methods */
3390 /**@{ */
3391 
3392 /** gets integer parameter of LP */
3394  SCIP_LPI* lpi, /**< LP interface structure */
3395  SCIP_LPPARAM type, /**< parameter number */
3396  int* ival /**< buffer to store the parameter value */
3397  )
3398 {
3399  int rval = 0;
3400 
3401  assert(lpi != NULL);
3402  assert(lpi->prob != NULL);
3403  assert(ival != NULL);
3404 
3405  SCIPdebugMessage("getting int parameter %d\n", type);
3406 
3407  switch( type )
3408  {
3410  case SCIP_LPPAR_FASTMIP:
3411  case SCIP_LPPAR_PRESOLVING:
3412  return SCIP_PARAMETERUNKNOWN;
3413  case SCIP_LPPAR_SCALING:
3414  rval = QSget_param(lpi->prob, QS_PARAM_SIMPLEX_SCALING, ival);
3415  assert((*ival) == 0 || (*ival) == 1);
3416 
3417  break;
3418  case SCIP_LPPAR_PRICING:
3419  *ival = lpi->pricing;
3420  break;
3421  case SCIP_LPPAR_LPINFO:
3422  rval = QSget_param(lpi->prob, QS_PARAM_SIMPLEX_DISPLAY, ival);
3423  if( *ival )
3424  *ival = TRUE;
3425  else
3426  *ival = FALSE;
3427  break;
3428  case SCIP_LPPAR_LPITLIM:
3429  rval = QSget_param(lpi->prob, QS_PARAM_SIMPLEX_MAX_ITERATIONS, ival);
3430  break;
3431  default:
3432  return SCIP_PARAMETERUNKNOWN;
3433  } /*lint !e788*/
3434 
3435  QS_RETURN(rval);
3436 }
3437 
3438 /** sets integer parameter of LP */
3440  SCIP_LPI* lpi, /**< LP interface structure */
3441  SCIP_LPPARAM type, /**< parameter number */
3442  int ival /**< parameter value */
3443  )
3444 {
3445  int rval = 0;
3446 
3447  assert(lpi != NULL);
3448  assert(lpi->prob != NULL);
3449 
3450  SCIPdebugMessage("setting int parameter %d to %d\n", type, ival);
3451 
3452  switch( type )
3453  {
3454  case SCIP_LPPAR_SCALING:
3455  if( ival == 0 )
3456  rval = QSset_param(lpi->prob, QS_PARAM_SIMPLEX_SCALING, 0);
3457  else
3458  rval = QSset_param(lpi->prob, QS_PARAM_SIMPLEX_SCALING, 1);
3459  break;
3460  case SCIP_LPPAR_PRICING:
3461  lpi->pricing = ival;
3462  switch( ival )
3463  {
3464  case SCIP_PRICING_AUTO:
3466  case SCIP_PRICING_FULL:
3467  case SCIP_PRICING_STEEP:
3469  rval = QSset_param(lpi->prob, QS_PARAM_PRIMAL_PRICING, QS_PRICE_PSTEEP);
3470  rval += QSset_param(lpi->prob, QS_PARAM_DUAL_PRICING, QS_PRICE_DSTEEP);
3471  break;
3472  case SCIP_PRICING_PARTIAL:
3473  rval = QSset_param(lpi->prob,QS_PARAM_PRIMAL_PRICING,QS_PRICE_PMULTPARTIAL);
3474  rval += QSset_param(lpi->prob,QS_PARAM_DUAL_PRICING,QS_PRICE_DMULTPARTIAL);
3475  break;
3476  case SCIP_PRICING_DEVEX:
3477  rval = QSset_param(lpi->prob,QS_PARAM_PRIMAL_PRICING,QS_PRICE_PDEVEX);
3478  rval += QSset_param(lpi->prob,QS_PARAM_DUAL_PRICING,QS_PRICE_DDEVEX);
3479  break;
3480  default:
3481  return SCIP_LPERROR;
3482  }
3483  break;
3484  case SCIP_LPPAR_LPINFO:
3485  if( ival )
3486  rval = QSset_param(lpi->prob, QS_PARAM_SIMPLEX_DISPLAY, 1);
3487  else
3488  rval = QSset_param(lpi->prob, QS_PARAM_SIMPLEX_DISPLAY, 0);
3489  break;
3490  case SCIP_LPPAR_LPITLIM:
3491  rval = QSset_param(lpi->prob, QS_PARAM_SIMPLEX_MAX_ITERATIONS, ival);
3492  break;
3493  default:
3494  return SCIP_PARAMETERUNKNOWN;
3495  } /*lint !e788*/
3496 
3497  QS_RETURN(rval);
3498 }
3499 
3500 /** gets floating point parameter of LP */
3502  SCIP_LPI* lpi, /**< LP interface structure */
3503  SCIP_LPPARAM type, /**< parameter number */
3504  SCIP_Real* dval /**< buffer to store the parameter value */
3505  )
3506 {
3507  int rval = 0;
3508 
3509  assert(lpi != NULL);
3510  assert(lpi->prob != NULL);
3511  assert(dval != NULL);
3512 
3513  SCIPdebugMessage("getting real parameter %d\n", type);
3514 
3515  switch( type )
3516  {
3517  case SCIP_LPPAR_LOBJLIM:
3518  rval = QSget_param_double(lpi->prob, QS_PARAM_OBJLLIM, dval);
3519  break;
3520  case SCIP_LPPAR_UOBJLIM:
3521  rval = QSget_param_double(lpi->prob, QS_PARAM_OBJULIM, dval);
3522  break;
3523  case SCIP_LPPAR_LPTILIM:
3524  rval = QSget_param_double(lpi->prob, QS_PARAM_SIMPLEX_MAX_TIME, dval);
3525  break;
3526  default:
3527  case SCIP_LPPAR_MARKOWITZ:
3530  case SCIP_LPPAR_FEASTOL:
3531  return SCIP_PARAMETERUNKNOWN;
3532  } /*lint !e788*/
3533 
3534  QS_RETURN(rval);
3535 }
3536 
3537 /** sets floating point parameter of LP */
3539  SCIP_LPI* lpi, /**< LP interface structure */
3540  SCIP_LPPARAM type, /**< parameter number */
3541  SCIP_Real dval /**< parameter value */
3542  )
3543 {
3544  int rval = 0;
3545 
3546  assert(lpi != NULL);
3547  assert(lpi->prob != NULL);
3548 
3549  SCIPdebugMessage("setting real parameter %d to %g\n", type, dval);
3550 
3551  switch( type )
3552  {
3553  case SCIP_LPPAR_LPTILIM:
3554  rval = QSset_param_double(lpi->prob, QS_PARAM_SIMPLEX_MAX_TIME, dval);
3555  break;
3556  case SCIP_LPPAR_LOBJLIM:
3557  rval = QSset_param_double(lpi->prob, QS_PARAM_OBJLLIM, dval);
3558  break;
3559  case SCIP_LPPAR_UOBJLIM:
3560  rval = QSset_param_double(lpi->prob, QS_PARAM_OBJULIM, dval);
3561  break;
3562  case SCIP_LPPAR_FEASTOL:
3565  case SCIP_LPPAR_MARKOWITZ:
3566  default:
3567  return SCIP_PARAMETERUNKNOWN;
3568  } /*lint !e788*/
3569 
3570  QS_RETURN(rval);
3571 }
3572 
3573 /**@} */
3574 
3575 
3576 
3577 
3578 /*
3579  * Numerical Methods
3580  */
3581 
3582 /**@name Numerical Methods */
3583 /**@{ */
3584 
3585 /** returns value treated as infinity in the LP solver */
3587  SCIP_LPI* lpi /**< LP interface structure */
3588  )
3589 { /*lint --e{715} */
3590  return QS_MAXDOUBLE;
3591 }
3592 
3593 /** checks if given value is treated as infinity in the LP solver */
3595  SCIP_LPI* lpi, /**< LP interface structure */
3596  SCIP_Real val /**< value to be checked for infinity */
3597  )
3598 { /*lint --e{715} */
3599  return (val >= QS_MAXDOUBLE);
3600 }
3601 
3602 /**@} */
3603 
3604 
3605 
3606 
3607 /*
3608  * File Interface Methods
3609  */
3610 
3611 /**@name File Interface Methods */
3612 /**@{ */
3613 
3614 /** reads LP from a file */
3616  SCIP_LPI* lpi, /**< LP interface structure */
3617  const char* fname /**< file name */
3618  )
3619 {
3620  assert(lpi != NULL);
3621  assert(lpi->prob != NULL);
3622 
3623  SCIPdebugMessage("reading LP from file <%s>\n", fname);
3624 
3625  if( lpi->prob != NULL )
3626  QSfree_prob(lpi->prob);
3627 
3628  lpi->solstat = 0;
3629  lpi->previt = 0;
3630 
3631  lpi->prob = QSread_prob(fname, "LP");
3632  if( lpi->prob == 0 )
3633  return SCIP_READERROR;
3634 
3635  return SCIP_OKAY;
3636 }
3637 
3638 /** writes LP to a file */
3640  SCIP_LPI* lpi, /**< LP interface structure */
3641  const char* fname /**< file name */
3642  )
3643 {
3644  assert(lpi != NULL);
3645  assert(lpi->prob != NULL);
3646 
3647  SCIPdebugMessage("writing LP to file <%s>\n", fname);
3648 
3649  if( QSwrite_prob (lpi->prob, fname, "LP") )
3650  return SCIP_WRITEERROR;
3651 
3652  return SCIP_OKAY;
3653 }
3654 
3655 /**@} */
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
Definition: lpi_qso.c:158
static SCIP_RETCODE ensureColMem(SCIP_LPI *const lpi, int ncols)
Definition: lpi_qso.c:249
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
Definition: lpi_qso.c:3501
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
Definition: lpi_qso.c:2200
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
Definition: lpi_qso.c:3393
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
Definition: type_lpi.h:94
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
Definition: lpi_qso.c:1885
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_qso.c:2840
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
Definition: lpi_qso.c:867
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
Definition: lpi_qso.c:2354
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
Definition: lpi_qso.c:2217
char * cstat
Definition: lpi_qso.c:63
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
Definition: lpi_qso.c:656
static SCIP_RETCODE convertSides(SCIP_LPI *const lpi, int nrows, const double *const lhs, const double *const rhs)
Definition: lpi_qso.c:284
int nrows
Definition: lpi_none.c:39
ROWPACKET * packrstat
Definition: lpi_clp.cpp:125
SCIP_PRICING pricing
Definition: lpi_clp.cpp:101
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
Definition: lpi_qso.c:3439
#define EPSILON
Definition: lpi_qso.c:82
SCIP_RETCODE SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
Definition: lpi_qso.c:382
static SCIP_RETCODE ensureTabMem(SCIP_LPI *const lpi, int sz)
Definition: lpi_qso.c:233
#define SCIP_MAXSTRLEN
Definition: def.h:215
enum SCIP_ObjSen SCIP_OBJSEN
Definition: type_lpi.h:36
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_qso.c:1548
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
Definition: lpi_qso.c:1088
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
Definition: bitencode.c:298
#define QS_ERROR(A,...)
Definition: lpi_qso.c:96
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
Definition: lpi_qso.c:2539
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
Definition: lpi_qso.c:1180
#define FALSE
Definition: def.h:64
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
Definition: lpi_qso.c:2294
#define EPSEQ(x, y, eps)
Definition: def.h:160
#define EPSISINT(x, eps)
Definition: def.h:172
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
Definition: lpi_qso.c:3615
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_DUALPACKET COLPACKET
Definition: lpi_qso.c:31
enum SCIP_LPParam SCIP_LPPARAM
Definition: type_lpi.h:63
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
Definition: lpi_qso.c:2279
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:78
#define SCIPdebugMessage
Definition: pub_message.h:77
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
Definition: lpi_qso.c:1876
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
Definition: lpi_qso.c:174
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
Definition: lpi_qso.c:1037
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
Definition: lpi_qso.c:2598
#define BMSfreeMemory(ptr)
Definition: memory.h:100
#define QS_TESTG(A, B, C)
Definition: lpi_qso.c:89
int * ircnt
Definition: lpi_qso.c:46
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
Definition: lpi_qso.c:2573
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
Definition: lpi_qso.c:1130
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
Definition: lpi_qso.c:1729
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
Definition: lpi_qso.c:3330
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
Definition: lpi_qso.c:1307
char * ibas
Definition: lpi_qso.c:53
SCIP_DUALPACKET COLPACKET
Definition: lpi_clp.cpp:114
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_qso.c:568
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
Definition: lpi_qso.c:2625
int * irbeg
Definition: lpi_qso.c:47
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
Definition: lpi_qso.c:190
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lpi_qso.c:3360
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_qso.c:1994
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
Definition: lpi_qso.c:2401
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
Definition: lpi_qso.c:1699
packing single and dual bit values
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:102
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
Definition: lpi_qso.c:1831
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
Definition: lpi_qso.c:2713
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
Definition: lpi_qso.c:957
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
Definition: lpi_qso.c:3286
int ncols
Definition: lpi_none.c:40
#define SCIPdebugPrintf
Definition: pub_message.h:80
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
Definition: lpi_qso.c:1849
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
Definition: lpi_qso.c:3157
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
Definition: lpi_qso.c:998
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
Definition: lpi_qso.c:1799
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
Definition: lpi_qso.c:2156
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
Definition: lpi_qso.c:2309
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
Definition: lpi_qso.c:3220
SCIP_DUALPACKET ROWPACKET
Definition: lpi_clp.cpp:116
SCIP_Real * norms
Definition: lpi_qso.c:65
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
Definition: lpi_qso.c:2170
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
Definition: lpi_qso.c:2264
#define NULL
Definition: lpi_spx1.cpp:137
int * rstat
Definition: lpi_clp.cpp:97
#define REALABS(x)
Definition: def.h:159
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
Definition: lpi_qso.c:451
static SCIP_RETCODE ensureRowMem(SCIP_LPI *const lpi, int nrows)
Definition: lpi_qso.c:265
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
Definition: lpi_qso.c:1669
#define SCIP_CALL(x)
Definition: def.h:306
double * irng
Definition: lpi_qso.c:45
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
Definition: lpi_qso.c:3243
int colspace
Definition: lpi_qso.c:48
int rowspace
Definition: lpi_qso.c:42
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
Definition: lpi_qso.c:2796
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
Definition: lpi_qso.c:3594
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_qso.c:1941
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
Definition: bitencode.c:228
static int rowpacketNum(int nrows)
Definition: lpi_qso.c:149
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
Definition: lpi_qso.c:3211
COLPACKET * packcstat
Definition: lpi_clp.cpp:124
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:419
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
Definition: lpi_qso.c:929
unsigned int SCIP_DUALPACKET
Definition: bitencode.h:33
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_qso.c:491
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
Definition: lpi_qso.c:1418
public data structures and miscellaneous methods
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPISTATE *lpistate)
Definition: lpi_qso.c:3031
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
Definition: lpi_qso.c:1152
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lpi_qso.c:3195
#define SCIP_Bool
Definition: def.h:61
int solstat
Definition: lpi_cpx.c:140
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:408
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
Definition: lpi_qso.c:2234
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
Definition: lpi_qso.c:1401
#define QS_CONDRET(A)
Definition: lpi_qso.c:114
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
Definition: lpi_qso.c:3538
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:421
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_qso.c:2912
int tbsz
Definition: lpi_qso.c:51
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
Definition: lpi_qso.c:2114
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
Definition: lpi_qso.c:374
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
Definition: lpi_qso.c:2101
int * iccnt
Definition: lpi_qso.c:49
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
Definition: lpi_qso.c:1205
#define ROWS_PER_PACKET
Definition: lpi_qso.c:34
int previt
Definition: lpi_qso.c:41
int iterations
Definition: lpi_cpx.c:157
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_qso.c:720
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
Definition: lpi_qso.c:2992
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
Definition: lpi_qso.c:405
QSprob prob
Definition: lpi_qso.c:39
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_qso.c:1894
#define COLS_PER_PACKET
Definition: lpi_qso.c:32
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
Definition: lpi_qso.c:2139
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
Definition: lpi_qso.c:2384
double * itab
Definition: lpi_qso.c:52
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
Definition: lpi_qso.c:1867
char * isen
Definition: lpi_qso.c:43
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
Definition: lpi_qso.c:804
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_qso.c:2040
#define QS_RETURN(A)
Definition: lpi_qso.c:104
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
Definition: lpi_qso.c:685
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
Definition: lpi_qso.c:2249
const char * SCIPlpiGetSolverDesc(void)
Definition: lpi_qso.c:366
public methods for message output
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
Definition: lpi_qso.c:1659
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
Definition: lpi_qso.c:2369
#define SCIP_Real
Definition: def.h:135
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
Definition: lpi_qso.c:1435
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_qso.c:1454
#define BMSallocMemory(ptr)
Definition: memory.h:74
#define SCIP_INVALID
Definition: def.h:155
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:82
char * rstat
Definition: lpi_qso.c:64
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
Definition: lpi_qso.c:2185
SCIP_MESSAGEHDLR * messagehdlr
Definition: lpi_cpx.c:175
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_qso.c:2961
char * iccha
Definition: lpi_qso.c:50
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:406
int pricing
Definition: lpi_qso.c:54
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
Definition: lpi_qso.c:3639
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
Definition: lpi_qso.c:2324
double * irhs
Definition: lpi_qso.c:44
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
Definition: lpi_qso.c:2553
#define SCIP_ALLOC(x)
Definition: def.h:317
#define SCIPABORT()
Definition: def.h:278
SCIP_DUALPACKET ROWPACKET
Definition: lpi_qso.c:33
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
Definition: lpi_qso.c:2339
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
Definition: lpi_qso.c:211
char name[200]
Definition: lpi_xprs.c:74
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
Definition: lpi_qso.c:2882
int * cstat
Definition: lpi_clp.cpp:96
const char * SCIPlpiGetSolverName(void)
Definition: lpi_qso.c:349
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
Definition: lpi_qso.c:3586
static int colpacketNum(int ncols)
Definition: lpi_qso.c:140
#define FEASTOL
Definition: lpi_qso.c:79
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
Definition: lpi_qso.c:2419