Scippy

SCIP

Solving Constraint Integer Programs

reader_zpl.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 reader_zpl.c
17  * @brief ZIMPL model file reader
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "scip/reader_zpl.h"
25 
26 #ifdef WITH_ZIMPL
27 
28 #include <assert.h>
29 #include <unistd.h>
30 #include <string.h>
31 
32 #include "scip/cons_linear.h"
33 #include "scip/cons_sos1.h"
34 #include "scip/cons_sos2.h"
35 #include "scip/cons_indicator.h"
36 #include "scip/cons_quadratic.h"
37 #include "scip/cons_nonlinear.h"
38 #include "scip/pub_misc.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* @Note: Due to dependencies we need the following order. */
45 /* include the ZIMPL headers necessary to define the LP and MINLP construction interface */
46 #include "zimpl/bool.h"
47 #include "zimpl/ratlptypes.h"
48 #include "zimpl/mme.h"
49 
50 #include "zimpl/numb.h"
51 #include "zimpl/bound.h"
52 #include "zimpl/mono.h"
53 #include "zimpl/term.h"
54 
55 #include "zimpl/xlpglue.h"
56 #include "zimpl/zimpllib.h"
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #define READER_NAME "zplreader"
63 #define READER_DESC "file reader for ZIMPL model files"
64 #define READER_EXTENSION "zpl"
65 
66 /*
67  * LP construction interface of ZIMPL
68  */
69 
70 /* we only support ZIMPL with a version higher than 3.2.0 */
71 #if (ZIMPL_VERSION >= 320)
72 
73 /* ZIMPL does not support user data in callbacks - we have to use static variables */
74 struct
75 SCIP_ReaderData
76 {
77  SCIP* scip; /**< scip data structure */
78  SCIP_SOL* sol; /**< primal solution candidate */
79  SCIP_Bool valid; /**< is the primal solution candidate valid */
80  SCIP_Bool branchpriowarning; /**< store if the waring regarding fractional value for the branching
81  * priority was already posted */
82  SCIP_Bool initialconss; /**< should model constraints be marked as initial? */
83  SCIP_Bool dynamicconss; /**< should model constraints be subject to aging? */
84  SCIP_Bool dynamiccols; /**< should columns be added and removed dynamically to the LP? */
85  SCIP_Bool dynamicrows; /**< should rows be added and removed dynamically to the LP? */
86  SCIP_Bool readerror; /**< was a reading error be discovered */
87  SCIP_RETCODE retcode; /**< store a none SCIP_OKAY return code if an error occurred */
88 };
89 
90 /** create problem */
91 static
92 SCIP_RETCODE createProb(
93  SCIP* scip, /**< SCIP data structure */
94  SCIP_READERDATA* readerdata, /**< reader data */
95  const char* name /**< name of the problem */
96  )
97 {
98  SCIP_Bool usestartsol;
99 
100  /* create problem */
101  SCIP_CALL( SCIPcreateProb(scip, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
102 
103  /* check if are interested in the primal solution candidate */
104  SCIP_CALL( SCIPgetBoolParam(scip, "reading/zplreader/usestartsol", &usestartsol) );
105 
106  if( usestartsol )
107  {
108  /* create primal solution */
109  SCIP_CALL( SCIPcreateSol(scip, &readerdata->sol, NULL) );
110  readerdata->valid = TRUE;
111  }
112 
113  return SCIP_OKAY;
114 }
115 
116 /** Allocate storage for the mathematical program instance generated by ZIMPL. xlp_alloc() is the first xlpglue routine
117  * that will be called by ZIMPL. The user_data pointer may hold an arbitray value.
118  */
119 Lps* xlp_alloc(
120  const char* name, /**< name of the problem */
121  Bool need_startval, /**< does ZIMPL provides a primal solution candidate */
122  void* user_data /**< user data which was previously passed to ZIMPL */
123  )
124 { /*lint --e{715}*/
125  SCIP* scip;
126  SCIP_READERDATA* readerdata;
127 
128  readerdata = (SCIP_READERDATA*)user_data;
129  assert(readerdata != NULL);
130  assert(readerdata->retcode == SCIP_OKAY);
131  assert(!readerdata->readerror);
132 
133  scip = readerdata->scip;
134  assert(scip != NULL);
135 
136  readerdata->retcode = createProb(scip, readerdata, name);
137 
138  /* return the reader data pointer to receive it all other ZIMPL call backs */
139  return (Lps*) readerdata;
140 }
141 
142 /** free storage for mathematical program. xlp_free() is the last xlpglue routine that will be called by Zimpl */
143 void xlp_free(
144  Lps* data /**< pointer to reader data */
145  )
146 { /*lint --e{715}*/
147  /* nothing to be done here */
148 }
149 
150 /** does there already exists a constraint with the given name? */
151 Bool xlp_conname_exists(
152  const Lps* data, /**< pointer to reader data */
153  const char* name /**< constraint name to check */
154  )
155 {
156  SCIP_READERDATA* readerdata;
157 
158  readerdata = (SCIP_READERDATA*)data;
159  assert(readerdata != NULL);
160 
161  /* check if constraint with the given name already exists */
162  return (SCIPfindCons(readerdata->scip, name) != NULL);
163 }
164 
165 
166 /** method creates a constraint and is called directly from ZIMPL
167  *
168  * @note this method is used by ZIMPL beginning from version 3.00
169  */
170 static
171 SCIP_RETCODE addConsTerm(
172  SCIP* scip, /**< SCIP data structure */
173  SCIP_READERDATA* readerdata, /**< reader data */
174  const char* name, /**< constraint name */
175  ConType type, /**< constraint type (LHS, RHS, EQUAL, RANGE, etc) */
176  const Numb* lhs, /**< left hand side */
177  const Numb* rhs, /**< right hand side */
178  unsigned int flags, /**< special constraint flags, see ratlptypes.h */
179  const Term* term, /**< term to use */
180  SCIP_Bool* created /**< pointer to store if a constraint was created */
181  )
182 {
183  SCIP_CONS* cons;
184  SCIP_Real sciplhs;
185  SCIP_Real sciprhs;
186  SCIP_Bool initial;
187  SCIP_Bool separate;
188  SCIP_Bool enforce;
189  SCIP_Bool check;
190  SCIP_Bool propagate;
191  SCIP_Bool local;
192  SCIP_Bool modifiable;
193  SCIP_Bool usercut;
194  SCIP_Bool lazycut;
195  int i;
196 
197  switch( type )
198  {
199  case CON_FREE:
200  sciplhs = -SCIPinfinity(scip);
201  sciprhs = SCIPinfinity(scip);
202  break;
203  case CON_LHS:
204  sciplhs = (SCIP_Real)numb_todbl(lhs);
205  sciprhs = SCIPinfinity(scip);
206  break;
207  case CON_RHS:
208  sciplhs = -SCIPinfinity(scip);
209  sciprhs = (SCIP_Real)numb_todbl(rhs);
210  break;
211  case CON_RANGE:
212  sciplhs = (SCIP_Real)numb_todbl(lhs);
213  sciprhs = (SCIP_Real)numb_todbl(rhs);
214  break;
215  case CON_EQUAL:
216  sciplhs = (SCIP_Real)numb_todbl(lhs);
217  sciprhs = (SCIP_Real)numb_todbl(rhs);
218  assert(sciplhs == sciprhs); /*lint !e777*/
219  break;
220  default:
221  SCIPwarningMessage(scip, "invalid constraint type <%d> in ZIMPL callback xlp_addcon()\n", type);
222  sciplhs = (SCIP_Real)numb_todbl(lhs);
223  sciprhs = (SCIP_Real)numb_todbl(rhs);
224  readerdata->readerror = TRUE;
225  break;
226  }
227 
228  cons = NULL;
229 
230  /* default values */
231  initial = readerdata->initialconss;
232  separate = TRUE;
233  propagate = TRUE;
234  enforce = TRUE;
235  check = TRUE;
236  local = FALSE;
237  modifiable = FALSE;
238 
239  usercut = (flags & LP_FLAG_CON_SEPAR) != 0;
240  lazycut = (flags & LP_FLAG_CON_CHECK) != 0;
241 
242  /* evaluate constraint flags */
243  if( usercut && lazycut )
244  {
245  initial = FALSE;
246  separate = TRUE;
247  check = TRUE;
248  }
249  else if( usercut )
250  {
251  initial = FALSE;
252  separate = TRUE;
253  check = FALSE;
254  }
255  else if( lazycut )
256  {
257  initial = FALSE;
258  separate = FALSE;
259  check = TRUE;
260  }
261 
262  if( term_is_linear(term) )
263  {
264  /* if the constraint gives an indicator constraint */
265  if ( flags & LP_FLAG_CON_INDIC )
266  {
267  Bool lhsIndCons = FALSE; /* generate lhs form for indicator constraints */
268  Bool rhsIndCons = FALSE; /* generate rhs form for indicator constraints */
269 
270  /* currently indicator constraints can only handle "<=" constraints */
271  switch( type )
272  {
273  case CON_LHS:
274  lhsIndCons = TRUE;
275  break;
276  case CON_RHS:
277  rhsIndCons = TRUE;
278  break;
279  case CON_RANGE:
280  case CON_EQUAL:
281  lhsIndCons = TRUE;
282  rhsIndCons = TRUE;
283  break;
284  case CON_FREE:
285  /*lint -fallthrough*/
286  default:
287  SCIPerrorMessage("invalid constraint type <%d> in ZIMPL callback xlp_addcon()\n", type);
288  readerdata->readerror = TRUE;
289  break;
290  }
291 
292  /* insert lhs form of indicator */
293  if ( lhsIndCons )
294  {
295  SCIP_CALL( SCIPcreateConsIndicator(scip, &cons, name, NULL, 0, NULL, NULL, -sciplhs,
296  initial, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
297  SCIP_CALL( SCIPaddCons(scip, cons) );
298 
299  for( i = 0; i < term_get_elements(term); i++ )
300  {
301  SCIP_VAR* scipvar;
302  SCIP_Real scipval;
303  const Mono* mono = term_get_element(term, i);
304  MFun mfun;
305 
306  scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
307 
308  /* check whether variable is the binary variable */
309  mfun = mono_get_function(mono);
310  if (mfun == MFUN_TRUE || mfun == MFUN_FALSE)
311  {
312  scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
313  SCIP_CALL( SCIPsetBinaryVarIndicator(scip, cons, scipvar) );
314  }
315  else
316  {
317  assert(!numb_equal(mono_get_coeff(mono), numb_zero()));
318  assert(mono_is_linear(mono));
319 
320  scipval = -numb_todbl(mono_get_coeff(mono));
321  SCIP_CALL( SCIPaddVarIndicator(scip, cons, scipvar, scipval) );
322  }
323  }
324 
325  (*created) = TRUE;
326  }
327 
328  /* insert rhs form of indicator */
329  if ( rhsIndCons )
330  {
331  SCIP_CALL( SCIPcreateConsIndicator(scip, &cons, name, NULL, 0, NULL, NULL, sciprhs,
332  initial, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
333  SCIP_CALL( SCIPaddCons(scip, cons) );
334 
335  for( i = 0; i < term_get_elements(term); i++ )
336  {
337  SCIP_VAR* scipvar;
338  SCIP_Real scipval;
339  const Mono* mono = term_get_element(term, i);
340  MFun mfun;
341 
342  scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
343 
344  /* check whether variable is the binary variable */
345  mfun = mono_get_function(mono);
346  if (mfun == MFUN_TRUE || mfun == MFUN_FALSE)
347  {
348  scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
349  SCIP_CALL( SCIPsetBinaryVarIndicator(scip, cons, scipvar) );
350  }
351  else
352  {
353  assert(!numb_equal(mono_get_coeff(mono), numb_zero()));
354  assert(mono_is_linear(mono));
355 
356  scipval = numb_todbl(mono_get_coeff(mono));
357  SCIP_CALL( SCIPaddVarIndicator(scip, cons, scipvar, scipval) );
358  }
359  }
360 
361  (*created) = TRUE;
362  }
363  }
364  else
365  {
366  SCIP_CALL( SCIPcreateConsLinear(scip, &cons, name, 0, NULL, NULL, sciplhs, sciprhs,
367  initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
368  SCIP_CALL( SCIPaddCons(scip, cons) );
369 
370  for( i = 0; i < term_get_elements(term); i++ )
371  {
372  SCIP_VAR* scipvar;
373  SCIP_Real scipval;
374 
375  assert(!numb_equal(mono_get_coeff(term_get_element(term, i)), numb_zero()));
376  assert(mono_is_linear(term_get_element(term, i)));
377 
378  scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, i), 0);
379  scipval = numb_todbl(mono_get_coeff(term_get_element(term, i)));
380 
381  SCIP_CALL( SCIPaddCoefLinear(scip, cons, scipvar, scipval) );
382  }
383 
384  (*created) = TRUE;
385  }
386  }
387  else if( term_get_degree(term) == 2 )
388  {
389  int nlinvars;
390  int nquadterms;
391  SCIP_VAR** linvars;
392  SCIP_VAR** quadvar1;
393  SCIP_VAR** quadvar2;
394  SCIP_Real* lincoefs;
395  SCIP_Real* quadcoefs;
396  Mono* monom;
397 
398  nlinvars = 0;
399  nquadterms = 0;
400 
401  SCIP_CALL( SCIPallocBufferArray(scip, &linvars, term_get_elements(term)) );
402  SCIP_CALL( SCIPallocBufferArray(scip, &quadvar1, term_get_elements(term)) );
403  SCIP_CALL( SCIPallocBufferArray(scip, &quadvar2, term_get_elements(term)) );
404  SCIP_CALL( SCIPallocBufferArray(scip, &lincoefs, term_get_elements(term)) );
405  SCIP_CALL( SCIPallocBufferArray(scip, &quadcoefs, term_get_elements(term)) );
406 
407  for( i = 0; i < term_get_elements(term); ++i )
408  {
409  monom = term_get_element(term, i);
410  assert(!numb_equal(mono_get_coeff(monom), numb_zero()));
411  assert(mono_get_degree(monom) <= 2);
412  assert(mono_get_degree(monom) > 0);
413  if (mono_get_degree(monom) == 1)
414  {
415  linvars [nlinvars] = (SCIP_VAR*)mono_get_var(monom, 0);
416  lincoefs[nlinvars] = numb_todbl(mono_get_coeff(monom));
417  ++nlinvars;
418  }
419  else
420  {
421  assert(mono_get_degree(monom) == 2);
422  quadvar1 [nquadterms] = (SCIP_VAR*)mono_get_var(monom, 0);
423  quadvar2 [nquadterms] = (SCIP_VAR*)mono_get_var(monom, 1);
424  quadcoefs[nquadterms] = numb_todbl(mono_get_coeff(monom));
425  ++nquadterms;
426  }
427  }
428 
429  SCIP_CALL( SCIPcreateConsQuadratic(scip, &cons, name, nlinvars, linvars, lincoefs, nquadterms, quadvar1, quadvar2, quadcoefs, sciplhs, sciprhs,
430  initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows) );
431  SCIP_CALL( SCIPaddCons(scip, cons) );
432 
433  SCIPfreeBufferArray(scip, &linvars);
434  SCIPfreeBufferArray(scip, &quadvar1);
435  SCIPfreeBufferArray(scip, &quadvar2);
436  SCIPfreeBufferArray(scip, &lincoefs);
437  SCIPfreeBufferArray(scip, &quadcoefs);
438 
439  (*created) = TRUE;
440  }
441  else
442  {
443  SCIP_VAR** polyvars;
444  int npolyvars;
445  int polyvarssize;
446  SCIP_HASHMAP* polyvarmap;
447  SCIP_VAR** vars;
448  int nvars;
449  int varssize;
450  SCIP_HASHMAP* varmap;
451  SCIP_EXPRDATA_MONOMIAL** simplemonomials;
452  int nsimplemonomials;
453  int simplemonomialssize;
454  SCIP_EXPR** extramonomials;
455  SCIP_Real* extracoefs;
456  int nextramonomials;
457  int extramonomialssize;
458  Mono* monomial;
459  int varpos;
460  int j;
461 
462  (*created) = TRUE;
463 
464  vars = NULL;
465  nvars = 0;
466  varssize = 0;
467  varmap = NULL;
468 
469  polyvars = NULL;
470  npolyvars = 0;
471  polyvarssize = 0;
472 
473  simplemonomials = NULL;
474  nsimplemonomials = 0;
475  simplemonomialssize = 0;
476 
477  extramonomials = NULL;
478  extracoefs = NULL;
479  nextramonomials = 0;
480  extramonomialssize = 0;
481 
482  SCIP_CALL( SCIPhashmapCreate(&varmap, SCIPblkmem(scip), SCIPcalcMemGrowSize(scip, 10)) );
483  SCIP_CALL( SCIPhashmapCreate(&polyvarmap, SCIPblkmem(scip), SCIPcalcMemGrowSize(scip, 10)) );
484 
485  for( i = 0; i < term_get_elements(term); ++i )
486  {
487  monomial = term_get_element(term, i);
488  assert(monomial != NULL);
489  assert(!numb_equal(mono_get_coeff(monomial), numb_zero()));
490  assert(mono_get_degree(monomial) > 0);
491 
492  if( mono_get_function(monomial) == MFUN_NONE )
493  {
494  /* nonlinear monomial without extra function around it */
495  SCIP_Real one;
496 
497  one = 1.0;
498 
499  /* create SCIP monomial */
500  if( simplemonomialssize == 0 )
501  {
502  simplemonomialssize = SCIPcalcMemGrowSize(scip, 1);
503  SCIP_CALL( SCIPallocBufferArray(scip, &simplemonomials, simplemonomialssize) );
504  }
505  else if( simplemonomialssize < nsimplemonomials + 1 )
506  {
507  simplemonomialssize = SCIPcalcMemGrowSize(scip, nsimplemonomials+1);
508  SCIP_CALL( SCIPreallocBufferArray(scip, &simplemonomials, simplemonomialssize) );
509  }
510  assert(simplemonomials != NULL);
511  SCIP_CALL( SCIPexprCreateMonomial(SCIPblkmem(scip), &simplemonomials[nsimplemonomials], numb_todbl(mono_get_coeff(monomial)), 0, NULL, NULL) );
512 
513  for( j = 0; j < mono_get_degree(monomial); ++j )
514  {
515  /* get variable index in polyvars; add to polyvars if not existing yet */
516  if( !SCIPhashmapExists(polyvarmap, (void*)mono_get_var(monomial, j)) ) /*lint !e826*/
517  {
518  if( polyvarssize == 0 )
519  {
520  polyvarssize = SCIPcalcMemGrowSize(scip, 1);
521  SCIP_CALL( SCIPallocBufferArray(scip, &polyvars, polyvarssize) );
522  }
523  else if( polyvarssize < npolyvars + 1 )
524  {
525  polyvarssize = SCIPcalcMemGrowSize(scip, npolyvars+1);
526  SCIP_CALL( SCIPreallocBufferArray(scip, &polyvars, polyvarssize) );
527  }
528  assert(polyvars != NULL);
529 
530  polyvars[npolyvars] = (SCIP_VAR*)mono_get_var(monomial, j); /*lint !e826*/
531  ++npolyvars;
532  varpos = npolyvars-1;
533  SCIP_CALL( SCIPhashmapInsert(polyvarmap, (void*)mono_get_var(monomial, j), (void*)(size_t)varpos) ); /*lint !e826*/
534  }
535  else
536  {
537  varpos = (int)(size_t)SCIPhashmapGetImage(polyvarmap, (void*)mono_get_var(monomial, j)); /*lint !e826*/
538  }
539  assert(polyvars != NULL);
540  assert(polyvars[varpos] == (SCIP_VAR*)mono_get_var(monomial, j));
541 
542  SCIP_CALL( SCIPexprAddMonomialFactors(SCIPblkmem(scip), simplemonomials[nsimplemonomials], 1, &varpos, &one) );
543  }
544  SCIPexprMergeMonomialFactors(simplemonomials[nsimplemonomials], 0.0);
545 
546  ++nsimplemonomials;
547  }
548  else
549  {
550  /* nonlinear monomial with extra function around it, put into new expression */
551  SCIP_EXPR** children;
552  SCIP_EXPR* expr;
553  SCIP_EXPROP op;
554  SCIP_Real coef;
555  SCIP_Real argdbl;
556  int argint;
557 
558  coef = 1.0;
559  argint = 0;
560  argdbl = 0.0;
561  switch( mono_get_function(monomial) )
562  {
563  case MFUN_SQRT:
564  op = SCIP_EXPR_SQRT;
565  break;
566  case MFUN_LOG:
567  /* log10(x) = ln(x) / ln(10.0) */
568  op = SCIP_EXPR_LOG;
569  coef = 1.0 / log(10.0);
570  break;
571  case MFUN_EXP:
572  op = SCIP_EXPR_EXP;
573  break;
574 #if ZIMPL_VERSION >= 330
575  case MFUN_LN:
576  op = SCIP_EXPR_LOG;
577  break;
578  /*
579  case MFUN_SIN:
580  op = SCIP_EXPR_SIN;
581  break;
582  case MFUN_COS:
583  op = SCIP_EXPR_COS;
584  break;
585  case MFUN_TAN:
586  op = SCIP_EXPR_TAN;
587  break;
588  */
589  case MFUN_ABS:
590  op = SCIP_EXPR_ABS;
591  break;
592  case MFUN_SGN:
593  op = SCIP_EXPR_SIGN;
594  break;
595  case MFUN_POW:
596  if( numb_is_int(mono_get_coeff(monomial)) )
597  {
598  op = SCIP_EXPR_INTPOWER;
599  argint = numb_toint(mono_get_coeff(monomial));
600  }
601  else
602  {
603  op = SCIP_EXPR_REALPOWER;
604  argdbl = numb_todbl(mono_get_coeff(monomial));
605  }
606  break;
607  case MFUN_SGNPOW:
608  op = SCIP_EXPR_SIGNPOWER;
609  argdbl = numb_todbl(mono_get_coeff(monomial));
610  break;
611 #endif
612  case MFUN_NONE:
613  case MFUN_TRUE:
614  case MFUN_FALSE:
615  SCIPerrorMessage("ZIMPL function %d invalid here.\n", mono_get_function(monomial));
616  (*created) = FALSE;
617  break;
618 #if ZIMPL_VERSION >= 330
619  case MFUN_SIN:
620  case MFUN_COS:
621  case MFUN_TAN:
622 #endif
623  default:
624  SCIPerrorMessage("ZIMPL function %d not supported\n", mono_get_function(monomial));
625  (*created) = FALSE;
626  break;
627  } /*lint !e788*/
628  if( !(*created) )
629  break;
630 
631  if( extramonomialssize == 0 )
632  {
633  extramonomialssize = SCIPcalcMemGrowSize(scip, 1);
634  SCIP_CALL( SCIPallocBufferArray(scip, &extramonomials, extramonomialssize) );
635  SCIP_CALL( SCIPallocBufferArray(scip, &extracoefs, extramonomialssize) );
636  }
637  else if( extramonomialssize < nextramonomials + 1 )
638  {
639  extramonomialssize = SCIPcalcMemGrowSize(scip, nextramonomials+1);
640  SCIP_CALL( SCIPreallocBufferArray(scip, &extramonomials, extramonomialssize) );
641  SCIP_CALL( SCIPreallocBufferArray(scip, &extracoefs, extramonomialssize) );
642  }
643  assert(extracoefs != NULL);
644  assert(extramonomials != NULL);
645  extracoefs[nextramonomials] = coef;
646 
647  /* create children expressions */
648  SCIP_CALL( SCIPallocBufferArray(scip, &children, mono_get_degree(monomial)) );
649  for( j = 0; j < mono_get_degree(monomial); ++j )
650  {
651  /* get variable index in vars; add to vars if not existing yet */
652  if( !SCIPhashmapExists(varmap, (void*)mono_get_var(monomial, j)) ) /*lint !e826*/
653  {
654  if( varssize == 0 )
655  {
656  varssize = SCIPcalcMemGrowSize(scip, 1);
657  SCIP_CALL( SCIPallocBufferArray(scip, &vars, varssize) );
658  }
659  else if( varssize < nvars + 1 )
660  {
661  varssize = SCIPcalcMemGrowSize(scip, nvars+1);
662  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, varssize) );
663  }
664  assert(vars != NULL);
665 
666  vars[nvars] = (SCIP_VAR*)mono_get_var(monomial, j); /*lint !e826*/
667  ++nvars;
668  varpos = nvars-1;
669  SCIP_CALL( SCIPhashmapInsert(varmap, (void*)mono_get_var(monomial, j), (void*)(size_t)varpos) ); /*lint !e826*/
670  }
671  else
672  {
673  varpos = (int)(size_t)SCIPhashmapGetImage(varmap, (void*)mono_get_var(monomial, j)); /*lint !e826*/
674  }
675  assert(vars != NULL);
676  assert(vars[varpos] == (SCIP_VAR*)mono_get_var(monomial, j));
677 
678  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &children[j], SCIP_EXPR_VARIDX, varpos) );
679  }
680 
681  /* create expression for product of variables */
682  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &expr, SCIP_EXPR_PRODUCT, mono_get_degree(monomial), children) );
683 
684  /* create expression for function of product of variables */
685  if( op == SCIP_EXPR_INTPOWER ) /*lint !e644 */
686  {
687  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &extramonomials[nextramonomials], op, expr, argint) ); /*lint !e644*/
688  }
689  else if( op == SCIP_EXPR_REALPOWER || op == SCIP_EXPR_SIGNPOWER )
690  {
691  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &extramonomials[nextramonomials], op, expr, argdbl) ); /*lint !e644*/
692  }
693  else
694  {
695  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &extramonomials[nextramonomials], op, expr) ); /*lint !e644*/
696  }
697 
698  ++nextramonomials;
699 
700  SCIPfreeBufferArray(scip, &children);
701  }
702  }
703 
704  if( *created )
705  {
706  SCIP_EXPRTREE* exprtree;
707  SCIP_EXPR* polynomial;
708  SCIP_EXPR** children;
709  int nchildren;
710 
711  assert(polyvars != NULL || npolyvars == 0);
712 
713  nchildren = npolyvars + nextramonomials;
714  SCIP_CALL( SCIPallocBufferArray(scip, &children, nchildren) );
715  /* add polynomial variables to vars
716  * create children expressions for polynomial variables
717  */
718  for( i = 0; i < npolyvars; ++i )
719  {
720  /* get variable index in vars; add to vars if not existing yet */
721  if( !SCIPhashmapExists(varmap, (void*)polyvars[i]) ) /*lint !e613*/
722  {
723  if( varssize == 0 )
724  {
725  varssize = SCIPcalcMemGrowSize(scip, 1);
726  SCIP_CALL( SCIPallocBufferArray(scip, &vars, varssize) );
727  }
728  else if( varssize < nvars + 1 )
729  {
730  varssize = SCIPcalcMemGrowSize(scip, nvars+1);
731  SCIP_CALL( SCIPreallocBufferArray(scip, &vars, varssize) );
732  }
733  assert(vars != NULL);
734 
735  vars[nvars] = polyvars[i]; /*lint !e613*/
736  ++nvars;
737  varpos = nvars-1;
738  SCIP_CALL( SCIPhashmapInsert(varmap, (void*)polyvars[i], (void*)(size_t)varpos) ); /*lint !e613*/
739  }
740  else
741  {
742  varpos = (int)(size_t)SCIPhashmapGetImage(varmap, (void*)polyvars[i]); /*lint !e613*/
743  }
744  assert(vars[varpos] == polyvars[i]); /*lint !e613*/
745 
746  SCIP_CALL( SCIPexprCreate(SCIPblkmem(scip), &children[i], SCIP_EXPR_VARIDX, varpos) ); /*lint !e866*/
747  }
748 
749  /* add simple monomials as additional children */
750  BMScopyMemoryArray(&children[npolyvars], extramonomials, nextramonomials); /*lint !e866*/
751 
752  assert(extracoefs != NULL || nextramonomials == 0);
753  assert(extramonomials != NULL || nextramonomials == 0);
754 
755  /* create polynomial expression including simple monomials */
756  SCIP_CALL( SCIPexprCreatePolynomial(SCIPblkmem(scip), &polynomial, nchildren, children, nsimplemonomials, simplemonomials, 0.0, FALSE) );
757  /* add extra monomials */
758  for( i = 0; i < nextramonomials; ++i )
759  {
760  SCIP_EXPRDATA_MONOMIAL* monomialdata;
761  int childidx;
762  SCIP_Real exponent;
763 
764  childidx = npolyvars + i;
765  exponent = 1.0;
766  SCIP_CALL( SCIPexprCreateMonomial(SCIPblkmem(scip), &monomialdata, extracoefs[i], 1, &childidx, &exponent) ); /*lint !e613*/
767  SCIP_CALL( SCIPexprAddMonomials(SCIPblkmem(scip), polynomial, 1, &monomialdata, FALSE) );
768  }
769 
770  SCIPfreeBufferArray(scip, &children);
771 
772  /* create expression tree */
773  SCIP_CALL( SCIPexprtreeCreate(SCIPblkmem(scip), &exprtree, polynomial, nvars, 0, NULL) );
774  SCIP_CALL( SCIPexprtreeSetVars(exprtree, nvars, vars) );
775 
776  /* create constraint */
777  SCIP_CALL( SCIPcreateConsNonlinear(scip, &cons, name, 0, NULL, NULL, 1, &exprtree, NULL, sciplhs, sciprhs,
778  initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
779  SCIP_CALL( SCIPexprtreeFree(&exprtree) );
780  SCIP_CALL( SCIPaddCons(scip, cons) );
781  }
782 
783  /* free memory */
784  SCIPhashmapFree(&varmap);
785  SCIPfreeBufferArrayNull(scip, &vars);
786  SCIPhashmapFree(&polyvarmap);
787  SCIPfreeBufferArrayNull(scip, &polyvars);
788  SCIPfreeBufferArrayNull(scip, &simplemonomials);
789  SCIPfreeBufferArrayNull(scip, &extramonomials);
790  SCIPfreeBufferArrayNull(scip, &extracoefs);
791  }
792 
793  if( cons != NULL )
794  {
795  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
796  }
797 
798  return SCIP_OKAY;
799 }
800 
801 /** method creates a constraint and is called directly from ZIMPL
802  *
803  * @note this method is used by ZIMPL beginning from version 3.00
804  */
805 Bool xlp_addcon_term(
806  Lps* data, /**< pointer to reader data */
807  const char* name, /**< constraint name */
808  ConType type, /**< constraint type (LHS, RHS, EQUAL, RANGE, etc) */
809  const Numb* lhs, /**< left hand side */
810  const Numb* rhs, /**< right hand side */
811  unsigned int flags, /**< special constraint flags, see ratlptypes.h */
812  const Term* term /**< term to use */
813  )
814 {
815  SCIP* scip;
816  SCIP_READERDATA* readerdata;
817  SCIP_Bool created = FALSE;
818 
819  readerdata = (SCIP_READERDATA*)data;
820  assert(readerdata != NULL);
821 
822  scip = readerdata->scip;
823  assert(scip != NULL);
824 
825  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
826  return TRUE;
827 
828  readerdata->retcode = addConsTerm(scip, readerdata, name, type, lhs, rhs, flags, term, &created);
829 
830  return !created;
831 }
832 
833 /** adde variable */
834 static
835 SCIP_RETCODE addVar(
836  SCIP* scip, /**< SCIP data structure */
837  SCIP_READERDATA* readerdata, /**< reader data */
838  const char* name, /**< variable name */
839  VarClass usevarclass, /**< variable type */
840  const Bound* lower, /**< lower bound */
841  const Bound* upper, /**< upper bound */
842  const Numb* priority, /**< branching priority */
843  const Numb* startval, /**< start value for the variable within in the start solution */
844  Var** zplvar /**< pointer to store the created variable */
845  )
846 {
847  SCIP_VAR* var;
848  SCIP_Real lb;
849  SCIP_Real ub;
850  SCIP_VARTYPE vartype;
851  SCIP_Bool initial;
852  SCIP_Bool removable;
853  int branchpriority;
854 
855  switch( bound_get_type(lower) )
856  {
857  case BOUND_VALUE:
858  lb = (SCIP_Real)numb_todbl(bound_get_value(lower));
859  break;
860  case BOUND_INFTY:
861  lb = SCIPinfinity(scip);
862  break;
863  case BOUND_MINUS_INFTY:
864  lb = -SCIPinfinity(scip);
865  break;
866  case BOUND_ERROR:
867  default:
868  SCIPerrorMessage("invalid lower bound type <%d> in ZIMPL reader\n", bound_get_type(lower));
869  lb = 0.0;
870  break;
871  }
872 
873  switch( bound_get_type(upper) )
874  {
875  case BOUND_VALUE:
876  ub = (SCIP_Real)numb_todbl(bound_get_value(upper));
877  break;
878  case BOUND_INFTY:
879  ub = SCIPinfinity(scip);
880  break;
881  case BOUND_MINUS_INFTY:
882  ub = -SCIPinfinity(scip);
883  break;
884  case BOUND_ERROR:
885  default:
886  SCIPerrorMessage("invalid upper bound type <%d> in ZIMPL reader\n", bound_get_type(upper));
887  ub = 0.0;
888  break;
889  }
890 
891  switch( usevarclass )
892  {
893  case VAR_CON:
894  vartype = SCIP_VARTYPE_CONTINUOUS;
895  break;
896  case VAR_INT:
897  vartype = SCIP_VARTYPE_INTEGER;
898  break;
899  case VAR_IMP:
900  vartype = SCIP_VARTYPE_IMPLINT;
901  break;
902  default:
903  SCIPwarningMessage(scip, "invalid variable class <%d> in ZIMPL callback xlp_addvar()\n", usevarclass);
904  vartype = SCIP_VARTYPE_CONTINUOUS;
905  readerdata->readerror = TRUE;
906  break;
907  }
908  initial = !(readerdata->dynamiccols);
909  removable = readerdata->dynamiccols;
910 
911  /* create variable */
912  SCIP_CALL( SCIPcreateVar(scip, &var, name, lb, ub, 0.0, vartype, initial, removable, NULL, NULL, NULL, NULL, NULL) );
913 
914  /* add variable to the problem; we are releasing the variable later */
915  SCIP_CALL( SCIPaddVar(scip, var) );
916 
917  if( !numb_equal(priority, numb_unknown()) )
918  {
919  if( numb_is_int(priority) )
920  branchpriority = numb_toint(priority);
921  else
922  {
923  if( !readerdata->branchpriowarning )
924  {
926  "ZIMPL reader: fractional branching priorities in input - rounding down to integer values\n");
927  readerdata->branchpriowarning = TRUE;
928  }
929  branchpriority = (int)numb_todbl(priority);
930  }
931 
932  /* change the branching priority of the variable */
933  SCIP_CALL( SCIPchgVarBranchPriority(scip, var, branchpriority) );
934  }
935 
936  /* check if we are willing to except a primal solution candidate */
937  if( readerdata->valid )
938  {
939  /* if the number is unknown we have no valid primal solution candidate */
940  if( numb_equal(startval, numb_unknown()) )
941  {
942  SCIPdebugMsg(scip, "primal solution candidate contains an unknown value for variable <%s>(%g)\n",
943  SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
944  readerdata->valid = FALSE;
945  }
946  else
947  {
948  assert(readerdata->sol != NULL);
949  SCIPdebugMsg(scip, "change solution solution <%p>: <%s> = <%g>\n",
950  (void*)readerdata->sol, SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
951 
952  /* set value within the primal solution candidate */
953  SCIP_CALL( SCIPsetSolVal(scip, readerdata->sol, var, (SCIP_Real)numb_todbl(startval)) );
954  }
955  }
956 
957  /* copy the variable pointer before we release the variable */
958  (*zplvar) = (Var*)var;
959 
960  /* release variable */
961  SCIP_CALL( SCIPreleaseVar(scip, &var) );
962 
963  return SCIP_OKAY;
964 }
965 
966 /** method adds a variable; is called directly by ZIMPL */
967 Var* xlp_addvar(
968  Lps* data, /**< pointer to reader data */
969  const char* name, /**< variable name */
970  VarClass usevarclass, /**< variable type */
971  const Bound* lower, /**< lower bound */
972  const Bound* upper, /**< upper bound */
973  const Numb* priority, /**< branching priority */
974  const Numb* startval /**< start value for the variable within in the start solution */
975  )
976 { /*lint --e{715}*/
977  SCIP* scip;
978  SCIP_READERDATA* readerdata;
979  Var* zplvar;
980 
981  readerdata = (SCIP_READERDATA*)data;
982  assert(readerdata != NULL);
983 
984  scip = readerdata->scip;
985  assert(scip != NULL);
986 
987  zplvar = NULL;
988 
989  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
990  return NULL;
991 
992  readerdata->retcode = addVar(scip, readerdata, name, usevarclass, lower, upper, priority, startval, &zplvar);
993 
994  return zplvar;
995 }
996 
997 /** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
998 static
999 SCIP_RETCODE addSOS(
1000  SCIP* scip, /**< SCIP data structure */
1001  SCIP_READERDATA* readerdata, /**< reader data */
1002  const char* name, /**< constraint name */
1003  SosType type, /**< SOS type */
1004  const Term* term /**< terms indicating sos */
1005  )
1006 {
1007  SCIP_CONS* cons;
1008  SCIP_Bool separate;
1009  SCIP_Bool enforce;
1010  SCIP_Bool check;
1011  SCIP_Bool propagate;
1012  SCIP_Bool local;
1013  int i;
1014 
1015  switch( type )
1016  {
1017  case SOS_TYPE1:
1018  separate = TRUE;
1019  enforce = TRUE;
1020  check = enforce;
1021  propagate = TRUE;
1022  local = FALSE;
1023 
1024  SCIP_CALL( SCIPcreateConsSOS1(scip, &cons, name, 0, NULL, NULL,
1025  readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
1026  SCIP_CALL( SCIPaddCons(scip, cons) );
1027 
1028  for( i = 0; i < term_get_elements(term); i++ )
1029  {
1030  SCIP_VAR* var;
1031  SCIP_Real weight;
1032 
1033  assert( mono_is_linear(term_get_element(term, i)) );
1034 
1035  var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
1036  weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
1037 
1038  SCIP_CALL( SCIPaddVarSOS1(scip, cons, var, weight) );
1039  }
1040  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1041  break;
1042  case SOS_TYPE2:
1043  separate = TRUE;
1044  enforce = TRUE;
1045  check = enforce;
1046  propagate = TRUE;
1047  local = FALSE;
1048 
1049  SCIP_CALL( SCIPcreateConsSOS2(scip, &cons, name, 0, NULL, NULL,
1050  readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
1051  SCIP_CALL( SCIPaddCons(scip, cons) );
1052  for( i = 0; i < term_get_elements(term); i++ )
1053  {
1054  SCIP_VAR* var;
1055  SCIP_Real weight;
1056 
1057  assert( mono_is_linear(term_get_element(term, i)) );
1058 
1059  var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
1060  weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
1061 
1062  SCIP_CALL( SCIPaddVarSOS2(scip, cons, var, weight) );
1063  }
1064  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1065  break;
1066  case SOS_ERR:
1067  /*lint -fallthrough*/
1068  default:
1069  SCIPerrorMessage("invalid SOS type <%d> in ZIMPL callback xlp_addsos_term()\n", type);
1070  readerdata->readerror = TRUE;
1071  break;
1072  }
1073 
1074  return SCIP_OKAY;
1075 }
1076 
1077 /** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
1078 Bool xlp_addsos_term(
1079  Lps* data, /**< pointer to reader data */
1080  const char* name, /**< constraint name */
1081  SosType type, /**< SOS type */
1082  const Numb* priority, /**< priority */
1083  const Term* term /**< terms indicating sos */
1084  )
1085 {
1086  /*lint --e{715}*/
1087  SCIP* scip;
1088  SCIP_READERDATA* readerdata;
1089 
1090  readerdata = (SCIP_READERDATA*)data;
1091  assert(readerdata != NULL);
1092 
1093  scip = readerdata->scip;
1094  assert(scip != NULL);
1095 
1096  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1097  return TRUE;
1098 
1099  readerdata->retcode = addSOS(scip, readerdata, name, type, term);
1100 
1101  return FALSE;
1102 }
1103 
1104 /** returns the variable name */
1105 const char* xlp_getvarname(
1106  const Lps* data, /**< pointer to reader data */
1107  const Var* var /**< variable */
1108  )
1109 {
1110 #ifndef NDEBUG
1111  SCIP* scip;
1112  SCIP_READERDATA* readerdata;
1113 
1114  readerdata = (SCIP_READERDATA*)data;
1115  assert(readerdata != NULL);
1116 
1117  scip = readerdata->scip;
1118  assert(scip != NULL);
1119 #endif
1120 
1121  return SCIPvarGetName((SCIP_VAR*)var);
1122 }
1123 
1124 /** return variable type */
1125 VarClass xlp_getclass(
1126  const Lps* data, /**< pointer to reader data */
1127  const Var* var /**< variable */
1128  )
1129 {
1130  SCIP_READERDATA* readerdata;
1131  SCIP_VAR* scipvar;
1132 
1133  readerdata = (SCIP_READERDATA*)data;
1134  assert(readerdata != NULL);
1135 
1136  scipvar = (SCIP_VAR*)var;
1137  switch( SCIPvarGetType(scipvar) )
1138  {
1139  case SCIP_VARTYPE_BINARY:
1140  case SCIP_VARTYPE_INTEGER:
1141  return VAR_INT;
1142  case SCIP_VARTYPE_IMPLINT:
1143  return VAR_IMP;
1145  return VAR_CON;
1146  default:
1147  SCIPerrorMessage("invalid SCIP variable type <%d> in ZIMPL callback xlp_getclass()\n", SCIPvarGetType(scipvar));
1148  readerdata->readerror = TRUE;
1149  break;
1150  }
1151 
1152  return VAR_CON;
1153 }
1154 
1155 /** returns lower bound */
1156 Bound* xlp_getlower(
1157  const Lps* data, /**< pointer to reader data */
1158  const Var* var /**< variable */
1159  )
1160 {
1161  SCIP* scip;
1162  SCIP_READERDATA* readerdata;
1163  SCIP_VAR* scipvar;
1164  SCIP_Real lb;
1165  char s[SCIP_MAXSTRLEN];
1166  BoundType boundtype;
1167  Numb* numb;
1168  Bound* bound;
1169 
1170  readerdata = (SCIP_READERDATA*)data;
1171  assert(readerdata != NULL);
1172 
1173  scip = readerdata->scip;
1174  assert(scip != NULL);
1175 
1176  scipvar = (SCIP_VAR*)var;
1177  assert(scipvar != NULL);
1178 
1179  /* collect lower bound */
1180  lb = SCIPvarGetLbGlobal(scipvar);
1181  numb = NULL;
1182 
1183  /* check if lower bound is infinity */
1184  if( SCIPisInfinity(scip, -lb) )
1185  boundtype = BOUND_MINUS_INFTY;
1186  else if( SCIPisInfinity(scip, lb) )
1187  boundtype = BOUND_INFTY;
1188  else
1189  {
1190  boundtype = BOUND_VALUE;
1191 
1192  /* create double form string */
1193  (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", lb);
1194  numb = numb_new_ascii(s);
1195  }
1196 
1197  /* create bound */
1198  bound = bound_new(boundtype, numb);
1199 
1200  if( numb != NULL )
1201  numb_free(numb);
1202 
1203  return bound;
1204 }
1205 
1206 /** returns upper bound */
1207 Bound* xlp_getupper(
1208  const Lps* data, /**< pointer to reader data */
1209  const Var* var /**< variable */
1210  )
1211 {
1212  SCIP* scip;
1213  SCIP_READERDATA* readerdata;
1214  SCIP_VAR* scipvar;
1215  SCIP_Real ub;
1216  char s[SCIP_MAXSTRLEN];
1217  BoundType boundtype;
1218  Numb* numb;
1219  Bound* bound;
1220 
1221  readerdata = (SCIP_READERDATA*)data;
1222  assert(readerdata != NULL);
1223 
1224  scip = readerdata->scip;
1225  assert(scip != NULL);
1226 
1227  scipvar = (SCIP_VAR*)var;
1228  assert(scipvar != NULL);
1229 
1230  /* collect upper bound */
1231  ub = SCIPvarGetUbGlobal(scipvar);
1232  numb = NULL;
1233 
1234  /* check if upper bound is infinity */
1235  if( SCIPisInfinity(scip, -ub) )
1236  boundtype = BOUND_MINUS_INFTY;
1237  else if( SCIPisInfinity(scip, ub) )
1238  boundtype = BOUND_INFTY;
1239  else
1240  {
1241  boundtype = BOUND_VALUE;
1242  (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", ub);
1243  numb = numb_new_ascii(s);
1244  }
1245 
1246  /* create ZIMPL bound */
1247  bound = bound_new(boundtype, numb);
1248 
1249  if (numb != NULL)
1250  numb_free(numb);
1251 
1252  return bound;
1253 }
1254 
1255 /* set the name of the objective function */
1256 void xlp_objname(
1257  Lps* data, /**< pointer to reader data */
1258  const char* name /**< name of the objective function */
1259  )
1260 { /*lint --e{715}*/
1261  /* nothing to be done */
1262 }
1263 
1264 /* set the name of the objective function */
1265 void xlp_setdir(
1266  Lps* data, /**< pointer to reader data */
1267  Bool minimize /**<True if the problem should be minimized, False if it should be maximized */
1268  )
1269 {
1270  SCIP* scip;
1271  SCIP_READERDATA* readerdata;
1272  SCIP_OBJSENSE objsense;
1273 
1274  readerdata = (SCIP_READERDATA*)data;
1275  assert(readerdata != NULL);
1276 
1277  scip = readerdata->scip;
1278  assert(scip != NULL);
1279 
1280  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1281  return;
1282 
1283  objsense = (minimize ? SCIP_OBJSENSE_MINIMIZE : SCIP_OBJSENSE_MAXIMIZE);
1284  readerdata->retcode = SCIPsetObjsense(scip, objsense);
1285 }
1286 
1287 /** changes objective coefficient of a variable */
1288 void xlp_addtocost(
1289  Lps* data, /**< pointer to reader data */
1290  Var* var, /**< variable */
1291  const Numb* cost /**< objective coefficient */
1292  )
1293 {
1294  SCIP* scip;
1295  SCIP_READERDATA* readerdata;
1296  SCIP_VAR* scipvar;
1297  SCIP_Real scipval;
1298 
1299  readerdata = (SCIP_READERDATA*)data;
1300  assert(readerdata != NULL);
1301 
1302  scip = readerdata->scip;
1303  assert(scip != NULL);
1304 
1305  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1306  return;
1307 
1308  scipvar = (SCIP_VAR*)var;
1309  assert(scipvar != NULL);
1310  scipval = numb_todbl(cost);
1311 
1312  readerdata->retcode = SCIPchgVarObj(scip, scipvar, SCIPvarGetObj(scipvar) + scipval);
1313 }
1314 
1315 /*
1316  * Callback methods of reader
1317  */
1318 
1319 /** copy method for reader plugins (called when SCIP copies plugins) */
1320 static
1321 SCIP_DECL_READERCOPY(readerCopyZpl)
1322 { /*lint --e{715}*/
1323  assert(scip != NULL);
1324  assert(reader != NULL);
1325  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
1326 
1327  /* call inclusion method of reader */
1329 
1330  return SCIP_OKAY;
1331 }
1332 
1333 
1334 /** problem reading method of reader */
1335 static
1336 SCIP_DECL_READERREAD(readerReadZpl)
1337 { /*lint --e{715}*/
1338  SCIP_READERDATA* readerdata;
1339  SCIP_RETCODE retcode;
1340  char oldpath[SCIP_MAXSTRLEN];
1341  char buffer[SCIP_MAXSTRLEN];
1342  char compextension[SCIP_MAXSTRLEN];
1343  char namewithoutpath[SCIP_MAXSTRLEN];
1344  char* path;
1345  char* name;
1346  char* extension;
1347  char* compression;
1348  char* paramstr;
1349 
1350  SCIP_Bool changedir;
1351  int i;
1352 
1353  SCIP_CALL( SCIPgetBoolParam(scip, "reading/zplreader/changedir", &changedir) );
1354 
1355  path = NULL;
1356  oldpath[0] = '\0';
1357  if( changedir )
1358  {
1359  /* change to the directory of the ZIMPL file, s.t. paths of data files read by the ZIMPL model are relative to
1360  * the location of the ZIMPL file
1361  */
1362  (void)strncpy(buffer, filename, SCIP_MAXSTRLEN-1);
1363  buffer[SCIP_MAXSTRLEN-1] = '\0';
1364  SCIPsplitFilename(buffer, &path, &name, &extension, &compression);
1365  if( compression != NULL )
1366  (void) SCIPsnprintf(compextension, SCIP_MAXSTRLEN, ".%s", compression);
1367  else
1368  *compextension = '\0';
1369  (void) SCIPsnprintf(namewithoutpath, SCIP_MAXSTRLEN, "%s.%s%s", name, extension, compextension);
1370  if( (char*)getcwd(oldpath, SCIP_MAXSTRLEN) == NULL )
1371  {
1372  SCIPerrorMessage("error getting the current path\n");
1373  return SCIP_READERROR;
1374  }
1375  if( path != NULL )
1376  {
1377  if( chdir(path) != 0 )
1378  {
1379  SCIPerrorMessage("error changing to directory <%s>\n", path);
1380  return SCIP_NOFILE;
1381  }
1382  }
1383  filename = namewithoutpath;
1384  }
1385 
1386  /* get current path for output */
1388  {
1389  char currentpath[SCIP_MAXSTRLEN];
1390  if( (char*)getcwd(currentpath, SCIP_MAXSTRLEN) == NULL )
1391  {
1392  SCIPerrorMessage("error getting the current path\n");
1393  return SCIP_READERROR;
1394  }
1395  /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
1396  * correctly */
1397  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "\n");
1398  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "base directory for ZIMPL parsing: <%s>\n", currentpath);
1399  /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
1400  * correctly */
1401  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "\n");
1402  }
1403 
1404  /* allocate storage */
1405  SCIP_CALL( SCIPallocBuffer(scip, &readerdata) );
1406 
1407  readerdata->scip = scip;
1408  readerdata->sol = NULL;
1409  readerdata->valid = FALSE;
1410  readerdata->branchpriowarning = FALSE;
1411  readerdata->readerror = FALSE;
1412  readerdata->retcode = SCIP_OKAY;
1413  SCIP_CALL( SCIPgetBoolParam(scip, "reading/initialconss", &(readerdata->initialconss)) );
1414  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &(readerdata->dynamicconss)) );
1415  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &(readerdata->dynamiccols)) );
1416  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &(readerdata->dynamicrows)) );
1417 
1418  /* get the parameter string */
1419  SCIP_CALL( SCIPgetStringParam(scip, "reading/zplreader/parameters", &paramstr) );
1420  if( strcmp(paramstr, "-") == 0 )
1421  {
1422  /* call ZIMPL parser without arguments */
1423  if( !zpl_read(filename, TRUE, (void*)readerdata) )
1424  readerdata->readerror = TRUE;
1425  else
1426  {
1427  /* evaluate retcode */
1428  if ( readerdata->retcode != SCIP_OKAY )
1429  {
1430  SCIPfreeBuffer(scip, &readerdata);
1431  return readerdata->retcode;
1432  }
1433  }
1434  }
1435  else
1436  {
1437  char dummy[2] = "x";
1438  char** argv;
1439  int argc;
1440  int p;
1441  int len;
1442 
1443  len = (int) strlen(paramstr);
1444  SCIP_CALL( SCIPallocBufferArray(scip, &argv, len+1) );
1445  argv[0] = dummy; /* argument 0 is irrelevant */
1446  argc = 1;
1447  p = 0;
1448  while( p < len )
1449  {
1450  int arglen;
1451 
1452  /* process next argument */
1453  SCIP_CALL( SCIPallocBufferArray(scip, &argv[argc], len+1) ); /*lint !e866*/
1454  arglen = 0;
1455 
1456  /* skip spaces */
1457  while( p < len && paramstr[p] == ' ' )
1458  p++;
1459 
1460  /* process characters */
1461  while( p < len && paramstr[p] != ' ' )
1462  {
1463  switch( paramstr[p] )
1464  {
1465  case '"':
1466  p++;
1467  /* read characters as they are until the next " */
1468  while( p < len && paramstr[p] != '"' )
1469  {
1470  argv[argc][arglen] = paramstr[p];
1471  arglen++;
1472  p++;
1473  }
1474  p++; /* skip final " */
1475  break;
1476  case '\\':
1477  /* read next character as it is */
1478  p++;
1479  argv[argc][arglen] = paramstr[p];
1480  arglen++;
1481  p++;
1482  break;
1483  default:
1484  argv[argc][arglen] = paramstr[p];
1485  arglen++;
1486  p++;
1487  break;
1488  }
1489  }
1490  argv[argc][arglen] = '\0';
1491 
1492  /* check for empty argument */
1493  if( arglen == 0 )
1494  {
1495  SCIPfreeBufferArray(scip, &argv[argc]);
1496  }
1497  else
1498  argc++;
1499  }
1500 
1501  /* append file name as last argument */
1502  SCIP_CALL( SCIPduplicateBufferArray(scip, &argv[argc], filename, (int) strlen(filename)+1) ); /*lint !e866*/
1503  argc++;
1504 
1505  /* display parsed arguments */
1506  if( SCIPgetVerbLevel(scip) >= SCIP_VERBLEVEL_FULL )
1507  {
1508  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL arguments:\n");
1509  for( i = 1; i < argc; ++i )
1510  {
1511  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "%d: <%s>\n", i, argv[i]);
1512  }
1513  }
1514 
1515  /* call ZIMPL parser with arguments */
1516  if( !zpl_read_with_args(argv, argc, TRUE, (void*)readerdata) )
1517  readerdata->readerror = TRUE;
1518 
1519  /* free argument memory */
1520  for( i = argc - 1; i >= 1; --i )
1521  {
1522  SCIPfreeBufferArray(scip, &argv[i]);
1523  }
1524  SCIPfreeBufferArray(scip, &argv);
1525 
1526  if ( readerdata->retcode != SCIP_OKAY )
1527  {
1528  SCIPfreeBuffer(scip, &readerdata);
1529  return readerdata->retcode;
1530  }
1531  }
1532 
1533  if( changedir )
1534  {
1535  /* change directory back to old path */
1536  if( path != NULL )
1537  {
1538  if( chdir(oldpath) != 0 )
1539  {
1540  SCIPwarningMessage(scip, "error changing back to directory <%s>\n", oldpath);
1541  }
1542  }
1543  }
1544 
1545  if( readerdata->valid )
1546  {
1547  SCIP_Bool stored;
1548 
1549  assert(readerdata->sol != NULL);
1550 
1551  stored = FALSE;
1552 
1553  /* add primal solution to solution candidate storage, frees the solution afterwards */
1554  SCIP_CALL( SCIPaddSolFree(scip, &readerdata->sol, &stored) );
1555 
1556  if( stored )
1557  {
1558  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL starting solution candidate accepted\n");
1559  }
1560  }
1561 
1562  *result = SCIP_SUCCESS;
1563 
1564  /* evaluate if a reading error occurred */
1565  if( readerdata->readerror )
1566  retcode = SCIP_READERROR;
1567  else
1568  retcode = SCIP_OKAY;
1569 
1570  /* free primal solution candidate */
1571  if( readerdata->sol != NULL )
1572  {
1573  SCIP_CALL( SCIPfreeSol(scip, &readerdata->sol) );
1574  }
1575 
1576  /* free reader data */
1577  SCIPfreeBuffer(scip, &readerdata);
1578 
1579  return retcode;
1580 }
1581 
1582 
1583 #endif
1584 #endif
1585 
1586 
1587 /*
1588  * reader specific interface methods
1589  */
1590 
1591 /** includes the zpl file reader in SCIP */
1593  SCIP* scip /**< SCIP data structure */
1594  )
1595 {
1596 #ifdef WITH_ZIMPL
1597 #if (ZIMPL_VERSION >= 320)
1598  SCIP_READERDATA* readerdata;
1599  SCIP_READER* reader;
1600  char extcodename[SCIP_MAXSTRLEN];
1601 
1602  /* create zpl reader data */
1603  readerdata = NULL;
1604  reader = NULL;
1605  /* include zpl reader */
1606  SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, readerdata) );
1607  assert(reader != NULL);
1608 
1609  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyZpl) );
1610  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadZpl) );
1611 
1612  /* add zpl reader parameters */
1614  "reading/zplreader/changedir", "should the current directory be changed to that of the ZIMPL file before parsing?",
1615  NULL, FALSE, TRUE, NULL, NULL) );
1617  "reading/zplreader/usestartsol", "should ZIMPL starting solutions be forwarded to SCIP?",
1618  NULL, FALSE, TRUE, NULL, NULL) );
1620  "reading/zplreader/parameters", "additional parameter string passed to the ZIMPL parser (or - for no additional parameters)",
1621  NULL, FALSE, "-", NULL, NULL) );
1622 
1623  (void) SCIPsnprintf(extcodename, SCIP_MAXSTRLEN, "ZIMPL %d.%d.%d", ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10); /*lint !e778*/
1624  SCIP_CALL( SCIPincludeExternalCodeInformation(scip, extcodename, "Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)"));
1625 #else
1626  SCIPwarningMessage(scip, "SCIP does only support ZIMPL 3.2.0 and higher. Please update your ZIMPL version %d.%d.%d\n",
1627  ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10);
1628 #endif
1629 #endif
1630 
1631  return SCIP_OKAY;
1632 }
SCIP_RETCODE SCIPincludeReaderZpl(SCIP *scip)
Definition: reader_zpl.c:1592
SCIP_RETCODE SCIPgetStringParam(SCIP *scip, const char *name, char **value)
Definition: scip.c:4527
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17276
#define SCIP_MAXSTRLEN
Definition: def.h:259
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: scip.c:40584
SCIP_RETCODE SCIPaddVarIndicator(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
Definition: scip.c:9936
int SCIPcalcMemGrowSize(SCIP *scip, int num)
Definition: scip.c:46807
static long bound
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos2.c:2394
SCIP_RETCODE SCIPexprCreateMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial, SCIP_Real coef, int nfactors, int *childidxs, SCIP_Real *exponents)
Definition: expr.c:7035
void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression)
Definition: misc.c:10200
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:515
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip.c:18760
constraint handler for indicator constraints
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
#define READER_NAME
Definition: reader_bnd.c:46
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:47022
SCIP_VERBLEVEL SCIPgetVerbLevel(SCIP *scip)
Definition: scip.c:1384
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPexprtreeSetVars(SCIP_EXPRTREE *tree, int nvars, SCIP_VAR **vars)
Definition: nlp.c:111
#define READER_DESC
Definition: reader_bnd.c:47
SCIP_RETCODE SCIPaddStringParam(SCIP *scip, const char *name, const char *desc, char **valueptr, SCIP_Bool isadvanced, const char *defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4376
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip.h:22628
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
SCIP_RETCODE SCIPexprtreeCreate(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **tree, SCIP_EXPR *root, int nvars, int nparams, SCIP_Real *params)
Definition: expr.c:8771
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
#define SCIPdebugMsg
Definition: scip.h:455
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateConsQuadratic(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable)
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3025
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17286
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip.c:11060
SCIP_RETCODE SCIPexprAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
Definition: expr.c:6667
#define SCIPerrorMessage
Definition: pub_message.h:45
enum SCIP_ExprOp SCIP_EXPROP
Definition: type_expr.h:89
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip.c:12585
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Definition: cons_sos1.c:10477
#define SCIPallocBuffer(scip, ptr)
Definition: scip.h:22618
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip.h:22633
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46725
ZIMPL model file reader.
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
constraint handler for quadratic constraints
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip.c:4432
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
Definition: scip.c:12761
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_RETCODE SCIPexprCreatePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
Definition: expr.c:6632
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip.c:1360
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip.c:21847
void SCIPexprMergeMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real eps)
Definition: expr.c:6956
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:37
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip.c:38765
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip.c:5264
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:41
constraint handler for nonlinear constraints
SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op,...)
Definition: expr.c:5973
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:38529
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
SCIP_RETCODE SCIPexprtreeFree(SCIP_EXPRTREE **tree)
Definition: expr.c:8852
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip.c:17613
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:116
SCIPInterval log(const SCIPInterval &x)
SCIP_RETCODE SCIPchgVarBranchPriority(SCIP *scip, SCIP_VAR *var, int branchpriority)
Definition: scip.c:25279
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47033
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip.c:5302
#define SCIP_DECL_READERCOPY(x)
Definition: type_reader.h:46
SCIP_RETCODE SCIPsetBinaryVarIndicator(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *binvar)
SCIP_RETCODE SCIPcreateConsIndicator(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *binvar, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
#define SCIPfreeBuffer(scip, ptr)
Definition: scip.h:22630
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip.c:11486
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:27755
#define SCIP_Real
Definition: def.h:149
constraint handler for SOS type 1 constraints
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *nonlincoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_DECL_READERREAD(ReaderTSP::scip_read)
Definition: ReaderTSP.cpp:150
SCIP_RETCODE SCIPexprAddMonomialFactors(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, int nfactors, int *childidxs, SCIP_Real *exponents)
Definition: expr.c:6862
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip.c:5350
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
Definition: scip.c:9628
SCIP_RETCODE SCIPcreateConsSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_sos1.c:10340
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
constraint handler for SOS type 2 constraints
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: cons_sos2.c:2295
#define READER_EXTENSION
Definition: reader_bnd.c:48
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:2874
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4239
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37872
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip.h:22624