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