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  SCIP_Real objoffset;
712 
713  if( term_is_linear(term) )
714  {
715  int i;
716  for( i = 0; i < term_get_elements(term); i++ )
717  {
718  SCIP_VAR* scipvar;
719  SCIP_Real scipval;
720 
721  assert(!numb_equal(mono_get_coeff(term_get_element(term, i)), numb_zero()));
722  assert(mono_is_linear(term_get_element(term, i)));
723 
724  scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, i), 0);
725  scipval = numb_todbl(mono_get_coeff(term_get_element(term, i)));
726 
727  SCIP_CALL( SCIPaddVarObj(scip, scipvar, scipval) );
728  }
729  }
730  else
731  {
732  /* create variable objvar, add 1*objvar to objective, and add constraint term - objvar = 0 */
733  SCIP_EXPR* expr;
734  SCIP_CONS* cons;
735  SCIP_VAR* objvar;
736 
737  SCIP_CALL( createExpr(scip, readerdata, &expr, term) );
738 
739  if( expr == NULL )
740  {
741  SCIPerrorMessage("Could not convert ZIMPL objective term into SCIP expression due to unsupported ZIMPL function.\n");
742  return SCIP_READERROR;
743  }
744 
745  SCIP_CALL( SCIPcreateConsNonlinear(scip, &cons, "obj", expr,
746  SCIPgetObjsense(scip) == SCIP_OBJSENSE_MINIMIZE ? -SCIPinfinity(scip) : 0.0,
747  SCIPgetObjsense(scip) == SCIP_OBJSENSE_MAXIMIZE ? SCIPinfinity(scip) : 0.0,
748  readerdata->initialconss, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, readerdata->dynamicconss, FALSE) );
749 
750  SCIP_CALL( SCIPcreateVarBasic(scip, &objvar, "objvar", -SCIPinfinity(scip), SCIPinfinity(scip), 1.0, SCIP_VARTYPE_CONTINUOUS) );
751  SCIP_CALL( SCIPaddLinearVarNonlinear(scip, cons, objvar, -1.0) );
752 
753  SCIP_CALL( SCIPaddVar(scip, objvar) );
754  SCIP_CALL( SCIPaddCons(scip, cons) );
755 
756  SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
757  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
758  SCIP_CALL( SCIPreleaseVar(scip, &objvar) );
759  }
760 
761  objoffset = numb_todbl(term_get_constant(term));
762  SCIP_CALL( SCIPaddOrigObjoffset(scip, objoffset) );
763 
764  return SCIP_OKAY;
765 }
766 
767 /** method creates a constraint and is called directly from ZIMPL
768  *
769  * @note this method is used by ZIMPL beginning from version 3.00
770  */
771 bool xlp_addcon_term(
772  Lps* data, /**< pointer to reader data */
773  const char* name, /**< constraint name */
774  ConType type, /**< constraint type (LHS, RHS, EQUAL, RANGE, etc) */
775  const Numb* lhs, /**< left hand side */
776  const Numb* rhs, /**< right hand side */
777  unsigned int flags, /**< special constraint flags, see ratlptypes.h */
778  const Term* term /**< term to use */
779  )
780 {
781  SCIP* scip;
782  SCIP_READERDATA* readerdata;
783  SCIP_Bool created = FALSE;
784 
785  readerdata = (SCIP_READERDATA*)data;
786  assert(readerdata != NULL);
787 
788  scip = readerdata->scip;
789  assert(scip != NULL);
790 
791  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
792  return TRUE;
793 
794  readerdata->retcode = addConsTerm(scip, readerdata, name, type, lhs, rhs, flags, term, &created);
795 
796  return !created;
797 }
798 
799 /** adde variable */
800 static
801 SCIP_RETCODE addVar(
802  SCIP* scip, /**< SCIP data structure */
803  SCIP_READERDATA* readerdata, /**< reader data */
804  const char* name, /**< variable name */
805  VarClass usevarclass, /**< variable type */
806  const Bound* lower, /**< lower bound */
807  const Bound* upper, /**< upper bound */
808  const Numb* priority, /**< branching priority */
809  const Numb* startval, /**< start value for the variable within in the start solution */
810  Var** zplvar /**< pointer to store the created variable */
811  )
812 {
813  SCIP_VAR* var;
814  SCIP_Real lb;
815  SCIP_Real ub;
816  SCIP_VARTYPE vartype;
817  SCIP_Bool initial;
818  SCIP_Bool removable;
819  int branchpriority;
820 
821  switch( bound_get_type(lower) )
822  {
823  case BOUND_VALUE:
824  lb = (SCIP_Real)numb_todbl(bound_get_value(lower));
825  break;
826  case BOUND_INFTY:
827  lb = SCIPinfinity(scip);
828  break;
829  case BOUND_MINUS_INFTY:
830  lb = -SCIPinfinity(scip);
831  break;
832  case BOUND_ERROR:
833  default:
834  SCIPerrorMessage("invalid lower bound type <%d> in ZIMPL reader\n", bound_get_type(lower));
835  lb = 0.0;
836  break;
837  }
838 
839  switch( bound_get_type(upper) )
840  {
841  case BOUND_VALUE:
842  ub = (SCIP_Real)numb_todbl(bound_get_value(upper));
843  break;
844  case BOUND_INFTY:
845  ub = SCIPinfinity(scip);
846  break;
847  case BOUND_MINUS_INFTY:
848  ub = -SCIPinfinity(scip);
849  break;
850  case BOUND_ERROR:
851  default:
852  SCIPerrorMessage("invalid upper bound type <%d> in ZIMPL reader\n", bound_get_type(upper));
853  ub = 0.0;
854  break;
855  }
856 
857  switch( usevarclass )
858  {
859  case VAR_CON:
860  vartype = SCIP_VARTYPE_CONTINUOUS;
861  break;
862  case VAR_INT:
863  vartype = SCIP_VARTYPE_INTEGER;
864  break;
865  case VAR_IMP:
866  vartype = SCIP_VARTYPE_IMPLINT;
867  break;
868  default:
869  SCIPwarningMessage(scip, "invalid variable class <%d> in ZIMPL callback xlp_addvar()\n", usevarclass);
870  vartype = SCIP_VARTYPE_CONTINUOUS;
871  readerdata->readerror = TRUE;
872  break;
873  }
874  initial = !(readerdata->dynamiccols);
875  removable = readerdata->dynamiccols;
876 
877  /* create variable */
878  SCIP_CALL( SCIPcreateVar(scip, &var, name, lb, ub, 0.0, vartype, initial, removable, NULL, NULL, NULL, NULL, NULL) );
879 
880  /* add variable to the problem; we are releasing the variable later */
881  SCIP_CALL( SCIPaddVar(scip, var) );
882 
883  if( !numb_equal(priority, numb_unknown()) )
884  {
885  if( numb_is_int(priority) )
886  branchpriority = numb_toint(priority);
887  else
888  {
889  if( !readerdata->branchpriowarning )
890  {
892  "ZIMPL reader: fractional branching priorities in input - rounding down to integer values\n");
893  readerdata->branchpriowarning = TRUE;
894  }
895  branchpriority = (int)numb_todbl(priority);
896  }
897 
898  /* change the branching priority of the variable */
899  SCIP_CALL( SCIPchgVarBranchPriority(scip, var, branchpriority) );
900  }
901 
902  /* check if we are willing to except a primal solution candidate */
903  if( readerdata->valid )
904  {
905  /* if the number is unknown we have no valid primal solution candidate */
906  if( numb_equal(startval, numb_unknown()) )
907  {
908  SCIPdebugMsg(scip, "primal solution candidate contains an unknown value for variable <%s>(%g)\n",
909  SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
910  readerdata->valid = FALSE;
911  }
912  else
913  {
914  assert(readerdata->sol != NULL);
915  SCIPdebugMsg(scip, "change solution solution <%p>: <%s> = <%g>\n",
916  (void*)readerdata->sol, SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
917 
918  /* set value within the primal solution candidate */
919  SCIP_CALL( SCIPsetSolVal(scip, readerdata->sol, var, (SCIP_Real)numb_todbl(startval)) );
920  }
921  }
922 
923  /* copy the variable pointer before we release the variable */
924  (*zplvar) = (Var*)var;
925 
926  /* release variable */
927  SCIP_CALL( SCIPreleaseVar(scip, &var) );
928 
929  return SCIP_OKAY;
930 }
931 
932 /** method adds a variable; is called directly by ZIMPL */
933 Var* xlp_addvar(
934  Lps* data, /**< pointer to reader data */
935  const char* name, /**< variable name */
936  VarClass usevarclass, /**< variable type */
937  const Bound* lower, /**< lower bound */
938  const Bound* upper, /**< upper bound */
939  const Numb* priority, /**< branching priority */
940  const Numb* startval /**< start value for the variable within in the start solution */
941  )
942 { /*lint --e{715}*/
943  SCIP* scip;
944  SCIP_READERDATA* readerdata;
945  Var* zplvar;
946 
947  readerdata = (SCIP_READERDATA*)data;
948  assert(readerdata != NULL);
949 
950  scip = readerdata->scip;
951  assert(scip != NULL);
952 
953  zplvar = NULL;
954 
955  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
956  return NULL;
957 
958  readerdata->retcode = addVar(scip, readerdata, name, usevarclass, lower, upper, priority, startval, &zplvar);
959 
960  return zplvar;
961 }
962 
963 /** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
964 static
965 SCIP_RETCODE addSOS(
966  SCIP* scip, /**< SCIP data structure */
967  SCIP_READERDATA* readerdata, /**< reader data */
968  const char* name, /**< constraint name */
969  SosType type, /**< SOS type */
970  const Term* term /**< terms indicating sos */
971  )
972 {
973  SCIP_CONS* cons;
974  SCIP_Bool separate;
975  SCIP_Bool enforce;
976  SCIP_Bool check;
977  SCIP_Bool propagate;
978  SCIP_Bool local;
979  int i;
980 
981  switch( type )
982  {
983  case SOS_TYPE1:
984  separate = TRUE;
985  enforce = TRUE;
986  check = enforce;
987  propagate = TRUE;
988  local = FALSE;
989 
990  SCIP_CALL( SCIPcreateConsSOS1(scip, &cons, name, 0, NULL, NULL,
991  readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
992  SCIP_CALL( SCIPaddCons(scip, cons) );
993 
994  for( i = 0; i < term_get_elements(term); i++ )
995  {
996  SCIP_VAR* var;
997  SCIP_Real weight;
998 
999  assert( mono_is_linear(term_get_element(term, i)) );
1000 
1001  var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
1002  weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
1003 
1004  SCIP_CALL( SCIPaddVarSOS1(scip, cons, var, weight) );
1005  }
1006  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1007  break;
1008  case SOS_TYPE2:
1009  separate = TRUE;
1010  enforce = TRUE;
1011  check = enforce;
1012  propagate = TRUE;
1013  local = FALSE;
1014 
1015  SCIP_CALL( SCIPcreateConsSOS2(scip, &cons, name, 0, NULL, NULL,
1016  readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
1017  SCIP_CALL( SCIPaddCons(scip, cons) );
1018  for( i = 0; i < term_get_elements(term); i++ )
1019  {
1020  SCIP_VAR* var;
1021  SCIP_Real weight;
1022 
1023  assert( mono_is_linear(term_get_element(term, i)) );
1024 
1025  var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
1026  weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
1027 
1028  SCIP_CALL( SCIPaddVarSOS2(scip, cons, var, weight) );
1029  }
1030  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
1031  break;
1032  case SOS_ERR:
1033  /*lint -fallthrough*/
1034  default:
1035  SCIPerrorMessage("invalid SOS type <%d> in ZIMPL callback xlp_addsos_term()\n", type);
1036  readerdata->readerror = TRUE;
1037  break;
1038  }
1039 
1040  return SCIP_OKAY;
1041 }
1042 
1043 /** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
1044 int xlp_addsos_term(
1045  Lps* data, /**< pointer to reader data */
1046  const char* name, /**< constraint name */
1047  SosType type, /**< SOS type */
1048  const Numb* priority, /**< priority */
1049  const Term* term /**< terms indicating sos */
1050  )
1051 {
1052  /*lint --e{715}*/
1053  SCIP* scip;
1054  SCIP_READERDATA* readerdata;
1055 
1056  readerdata = (SCIP_READERDATA*)data;
1057  assert(readerdata != NULL);
1058 
1059  scip = readerdata->scip;
1060  assert(scip != NULL);
1061 
1062  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1063  return TRUE;
1064 
1065  readerdata->retcode = addSOS(scip, readerdata, name, type, term);
1066 
1067  return 0;
1068 }
1069 
1070 /** returns the variable name */
1071 const char* xlp_getvarname(
1072  const Lps* data, /**< pointer to reader data */
1073  const Var* var /**< variable */
1074  )
1075 {
1076 #ifndef NDEBUG
1077  SCIP* scip;
1078  SCIP_READERDATA* readerdata;
1079 
1080  readerdata = (SCIP_READERDATA*)data;
1081  assert(readerdata != NULL);
1082 
1083  scip = readerdata->scip;
1084  assert(scip != NULL);
1085 #endif
1086 
1087  return SCIPvarGetName((SCIP_VAR*)var);
1088 }
1089 
1090 /** return variable type */
1091 VarClass xlp_getclass(
1092  const Lps* data, /**< pointer to reader data */
1093  const Var* var /**< variable */
1094  )
1095 {
1096  SCIP_READERDATA* readerdata;
1097  SCIP_VAR* scipvar;
1098 
1099  readerdata = (SCIP_READERDATA*)data;
1100  assert(readerdata != NULL);
1101 
1102  scipvar = (SCIP_VAR*)var;
1103  switch( SCIPvarGetType(scipvar) )
1104  {
1105  case SCIP_VARTYPE_BINARY:
1106  case SCIP_VARTYPE_INTEGER:
1107  return VAR_INT;
1108  case SCIP_VARTYPE_IMPLINT:
1109  return VAR_IMP;
1111  return VAR_CON;
1112  default:
1113  SCIPerrorMessage("invalid SCIP variable type <%d> in ZIMPL callback xlp_getclass()\n", SCIPvarGetType(scipvar));
1114  readerdata->readerror = TRUE;
1115  break;
1116  }
1117 
1118  return VAR_CON;
1119 }
1120 
1121 /** returns lower bound */
1122 Bound* xlp_getlower(
1123  const Lps* data, /**< pointer to reader data */
1124  const Var* var /**< variable */
1125  )
1126 {
1127  SCIP* scip;
1128  SCIP_READERDATA* readerdata;
1129  SCIP_VAR* scipvar;
1130  SCIP_Real lb;
1131  char s[SCIP_MAXSTRLEN];
1132  BoundType boundtype;
1133  Numb* numb;
1134  Bound* bound;
1135 
1136  readerdata = (SCIP_READERDATA*)data;
1137  assert(readerdata != NULL);
1138 
1139  scip = readerdata->scip;
1140  assert(scip != NULL);
1141 
1142  scipvar = (SCIP_VAR*)var;
1143  assert(scipvar != NULL);
1144 
1145  /* collect lower bound */
1146  lb = SCIPvarGetLbGlobal(scipvar);
1147  numb = NULL;
1148 
1149  /* check if lower bound is infinity */
1150  if( SCIPisInfinity(scip, -lb) )
1151  boundtype = BOUND_MINUS_INFTY;
1152  else if( SCIPisInfinity(scip, lb) )
1153  boundtype = BOUND_INFTY;
1154  else
1155  {
1156  boundtype = BOUND_VALUE;
1157 
1158  /* create double form string */
1159  (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", lb);
1160  numb = numb_new_ascii(s);
1161  }
1162 
1163  /* create bound */
1164  bound = bound_new(boundtype, numb);
1165 
1166  if( numb != NULL )
1167  numb_free(numb);
1168 
1169  return bound;
1170 }
1171 
1172 /** returns upper bound */
1173 Bound* xlp_getupper(
1174  const Lps* data, /**< pointer to reader data */
1175  const Var* var /**< variable */
1176  )
1177 {
1178  SCIP* scip;
1179  SCIP_READERDATA* readerdata;
1180  SCIP_VAR* scipvar;
1181  SCIP_Real ub;
1182  char s[SCIP_MAXSTRLEN];
1183  BoundType boundtype;
1184  Numb* numb;
1185  Bound* bound;
1186 
1187  readerdata = (SCIP_READERDATA*)data;
1188  assert(readerdata != NULL);
1189 
1190  scip = readerdata->scip;
1191  assert(scip != NULL);
1192 
1193  scipvar = (SCIP_VAR*)var;
1194  assert(scipvar != NULL);
1195 
1196  /* collect upper bound */
1197  ub = SCIPvarGetUbGlobal(scipvar);
1198  numb = NULL;
1199 
1200  /* check if upper bound is infinity */
1201  if( SCIPisInfinity(scip, -ub) )
1202  boundtype = BOUND_MINUS_INFTY;
1203  else if( SCIPisInfinity(scip, ub) )
1204  boundtype = BOUND_INFTY;
1205  else
1206  {
1207  boundtype = BOUND_VALUE;
1208  (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", ub);
1209  numb = numb_new_ascii(s);
1210  }
1211 
1212  /* create ZIMPL bound */
1213  bound = bound_new(boundtype, numb);
1214 
1215  if (numb != NULL)
1216  numb_free(numb);
1217 
1218  return bound;
1219 }
1220 
1221 /** Set the name and direction of the objective function, i.e. minimization or maximization
1222  * Coefficents of the objective function will be set to all zero.
1223  */
1224 bool xlp_setobj(
1225  Lps* data, /**< pointer to reader data */
1226  const char* name, /**< name of the objective function */
1227  bool minimize /**< True if the problem should be minimized, False if it should be maximized */
1228  )
1229 {
1230  SCIP* scip;
1231  SCIP_READERDATA* readerdata;
1232  SCIP_OBJSENSE objsense;
1233 
1234  readerdata = (SCIP_READERDATA*)data;
1235  assert(readerdata != NULL);
1236 
1237  scip = readerdata->scip;
1238  assert(scip != NULL);
1239 
1240  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1241  return FALSE;
1242 
1243  objsense = (minimize ? SCIP_OBJSENSE_MINIMIZE : SCIP_OBJSENSE_MAXIMIZE);
1244  readerdata->retcode = SCIPsetObjsense(scip, objsense);
1245 
1246  return FALSE;
1247 }
1248 
1249 /** adds objective function */
1250 void xlp_addtoobj(
1251  Lps* data, /**< pointer to reader data */
1252  const Term* term /**< objective term */
1253  )
1254 {
1255  SCIP* scip;
1256  SCIP_READERDATA* readerdata;
1257 
1258  readerdata = (SCIP_READERDATA*)data;
1259  assert(readerdata != NULL);
1260 
1261  scip = readerdata->scip;
1262  assert(scip != NULL);
1263 
1264  if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
1265  return;
1266 
1267  readerdata->retcode = addObjTerm(scip, readerdata, term);
1268 }
1269 
1270 /*
1271  * Callback methods of reader
1272  */
1273 
1274 /** copy method for reader plugins (called when SCIP copies plugins) */
1275 static
1276 SCIP_DECL_READERCOPY(readerCopyZpl)
1277 { /*lint --e{715}*/
1278  assert(scip != NULL);
1279  assert(reader != NULL);
1280  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
1281 
1282  /* call inclusion method of reader */
1284 
1285  return SCIP_OKAY;
1286 }
1287 
1288 
1289 /** problem reading method of reader */
1290 static
1291 SCIP_DECL_READERREAD(readerReadZpl)
1292 { /*lint --e{715}*/
1293  SCIP_READERDATA* readerdata;
1294  SCIP_RETCODE retcode;
1295  char oldpath[SCIP_MAXSTRLEN];
1296  char buffer[SCIP_MAXSTRLEN];
1297  char compextension[SCIP_MAXSTRLEN];
1298  char namewithoutpath[SCIP_MAXSTRLEN];
1299  char* path;
1300  char* name;
1301  char* extension;
1302  char* compression;
1303  char* paramstr;
1304 
1305  SCIP_Bool changedir;
1306  int i;
1307 
1308  SCIP_CALL( SCIPgetBoolParam(scip, "reading/zplreader/changedir", &changedir) );
1309 
1310  path = NULL;
1311  oldpath[0] = '\0';
1312  if( changedir )
1313  {
1314  /* change to the directory of the ZIMPL file, s.t. paths of data files read by the ZIMPL model are relative to
1315  * the location of the ZIMPL file
1316  */
1317  (void)SCIPstrncpy(buffer, filename, SCIP_MAXSTRLEN);
1318  SCIPsplitFilename(buffer, &path, &name, &extension, &compression);
1319  if( compression != NULL )
1320  (void) SCIPsnprintf(compextension, SCIP_MAXSTRLEN, ".%s", compression);
1321  else
1322  *compextension = '\0';
1323  (void) SCIPsnprintf(namewithoutpath, SCIP_MAXSTRLEN, "%s.%s%s", name, extension, compextension);
1324  if( (char*)getcwd(oldpath, SCIP_MAXSTRLEN) == NULL )
1325  {
1326  SCIPerrorMessage("error getting the current path\n");
1327  return SCIP_READERROR;
1328  }
1329  if( path != NULL )
1330  {
1331  if( chdir(path) != 0 )
1332  {
1333  SCIPerrorMessage("error changing to directory <%s>\n", path);
1334  return SCIP_NOFILE;
1335  }
1336  }
1337  filename = namewithoutpath;
1338  }
1339 
1340  /* get current path for output */
1342  {
1343  char currentpath[SCIP_MAXSTRLEN];
1344  if( (char*)getcwd(currentpath, SCIP_MAXSTRLEN) == NULL )
1345  {
1346  SCIPerrorMessage("error getting the current path\n");
1347  return SCIP_READERROR;
1348  }
1349  /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
1350  * correctly */
1352  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "base directory for ZIMPL parsing: <%s>\n", currentpath);
1353  /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
1354  * correctly */
1356  }
1357 
1358  /* allocate storage */
1359  SCIP_CALL( SCIPallocBuffer(scip, &readerdata) );
1360 
1361  readerdata->scip = scip;
1362  readerdata->sol = NULL;
1363  readerdata->valid = FALSE;
1364  readerdata->branchpriowarning = FALSE;
1365  readerdata->readerror = FALSE;
1366  readerdata->retcode = SCIP_OKAY;
1367  SCIP_CALL( SCIPgetBoolParam(scip, "reading/initialconss", &(readerdata->initialconss)) );
1368  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &(readerdata->dynamicconss)) );
1369  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &(readerdata->dynamiccols)) );
1370  SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &(readerdata->dynamicrows)) );
1371 
1372  /* get the parameter string */
1373  SCIP_CALL( SCIPgetStringParam(scip, "reading/zplreader/parameters", &paramstr) );
1374  if( strcmp(paramstr, "-") == 0 )
1375  {
1376  /* call ZIMPL parser without arguments */
1377  if( !zpl_read(filename, TRUE, (void*)readerdata) )
1378  readerdata->readerror = TRUE;
1379  else
1380  {
1381  /* evaluate retcode */
1382  if ( readerdata->retcode != SCIP_OKAY )
1383  {
1384  SCIPfreeBuffer(scip, &readerdata);
1385  return readerdata->retcode;
1386  }
1387  }
1388  }
1389  else
1390  {
1391  char dummy[2] = "x";
1392  char** argv;
1393  int argc;
1394  int p;
1395  int len;
1396 
1397  len = (int) strlen(paramstr);
1398  SCIP_CALL( SCIPallocBufferArray(scip, &argv, len+1) );
1399  argv[0] = dummy; /* argument 0 is irrelevant */
1400  argc = 1;
1401  p = 0;
1402  while( p < len )
1403  {
1404  int arglen;
1405 
1406  /* process next argument */
1407  SCIP_CALL( SCIPallocBufferArray(scip, &argv[argc], len+1) ); /*lint !e866*/
1408  arglen = 0;
1409 
1410  /* skip spaces */
1411  while( p < len && paramstr[p] == ' ' )
1412  p++;
1413 
1414  /* process characters */
1415  while( p < len && paramstr[p] != ' ' )
1416  {
1417  switch( paramstr[p] )
1418  {
1419  case '"':
1420  p++;
1421  /* read characters as they are until the next " */
1422  while( p < len && paramstr[p] != '"' )
1423  {
1424  argv[argc][arglen] = paramstr[p];
1425  arglen++;
1426  p++;
1427  }
1428  p++; /* skip final " */
1429  break;
1430  case '\\':
1431  /* read next character as it is */
1432  p++;
1433  argv[argc][arglen] = paramstr[p];
1434  arglen++;
1435  p++;
1436  break;
1437  default:
1438  argv[argc][arglen] = paramstr[p];
1439  arglen++;
1440  p++;
1441  break;
1442  }
1443  }
1444  argv[argc][arglen] = '\0';
1445 
1446  /* check for empty argument */
1447  if( arglen == 0 )
1448  {
1449  SCIPfreeBufferArray(scip, &argv[argc]);
1450  }
1451  else
1452  argc++;
1453  }
1454 
1455  /* append file name as last argument */
1456  SCIP_CALL( SCIPduplicateBufferArray(scip, &argv[argc], filename, (int) strlen(filename)+1) ); /*lint !e866*/
1457  argc++;
1458 
1459  /* display parsed arguments */
1460  if( SCIPgetVerbLevel(scip) >= SCIP_VERBLEVEL_FULL )
1461  {
1462  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL arguments:\n");
1463  for( i = 1; i < argc; ++i )
1464  {
1465  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "%d: <%s>\n", i, argv[i]);
1466  }
1467  }
1468 
1469  /* call ZIMPL parser with arguments */
1470  if( !zpl_read_with_args(argv, argc, TRUE, (void*)readerdata) )
1471  readerdata->readerror = TRUE;
1472 
1473  /* free argument memory */
1474  for( i = argc - 1; i >= 1; --i )
1475  {
1476  SCIPfreeBufferArray(scip, &argv[i]);
1477  }
1478  SCIPfreeBufferArray(scip, &argv);
1479 
1480  if ( readerdata->retcode != SCIP_OKAY )
1481  {
1482  SCIPfreeBuffer(scip, &readerdata);
1483  return readerdata->retcode;
1484  }
1485  }
1486 
1487  if( changedir )
1488  {
1489  /* change directory back to old path */
1490  if( path != NULL )
1491  {
1492  if( chdir(oldpath) != 0 )
1493  {
1494  SCIPwarningMessage(scip, "error changing back to directory <%s>\n", oldpath);
1495  }
1496  }
1497  }
1498 
1499  if( readerdata->valid )
1500  {
1501  SCIP_Bool stored;
1502 
1503  assert(readerdata->sol != NULL);
1504 
1505  stored = FALSE;
1506 
1507  /* add primal solution to solution candidate storage, frees the solution afterwards */
1508  SCIP_CALL( SCIPaddSolFree(scip, &readerdata->sol, &stored) );
1509 
1510  if( stored )
1511  {
1512  SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL starting solution candidate accepted\n");
1513  }
1514  }
1515 
1516  *result = SCIP_SUCCESS;
1517 
1518  /* evaluate if a reading error occurred */
1519  if( readerdata->readerror )
1520  retcode = SCIP_READERROR;
1521  else
1522  retcode = SCIP_OKAY;
1523 
1524  /* free primal solution candidate */
1525  if( readerdata->sol != NULL )
1526  {
1527  SCIP_CALL( SCIPfreeSol(scip, &readerdata->sol) );
1528  }
1529 
1530  /* free reader data */
1531  SCIPfreeBuffer(scip, &readerdata);
1532 
1533  return retcode;
1534 }
1535 
1536 
1537 #endif
1538 #endif
1539 
1540 
1541 /*
1542  * reader specific interface methods
1543  */
1544 
1545 /** includes the zpl file reader in SCIP */ /*lint --e{715}*/
1547  SCIP* scip /**< SCIP data structure */
1548  )
1549 { /*lint --e{715}*/
1550 #ifdef SCIP_WITH_ZIMPL
1551 #if (ZIMPL_VERSION >= 341)
1552  SCIP_READERDATA* readerdata;
1553  SCIP_READER* reader;
1554  char extcodename[SCIP_MAXSTRLEN];
1555 
1556  assert(scip != NULL);
1557 
1558  /* create zpl reader data */
1559  readerdata = NULL;
1560  reader = NULL;
1561  /* include zpl reader */
1562  SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, readerdata) );
1563  assert(reader != NULL);
1564 
1565  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyZpl) );
1566  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadZpl) );
1567 
1568  /* add zpl reader parameters */
1570  "reading/zplreader/changedir", "should the current directory be changed to that of the ZIMPL file before parsing?",
1571  NULL, FALSE, TRUE, NULL, NULL) );
1573  "reading/zplreader/usestartsol", "should ZIMPL starting solutions be forwarded to SCIP?",
1574  NULL, FALSE, TRUE, NULL, NULL) );
1576  "reading/zplreader/parameters", "additional parameter string passed to the ZIMPL parser (or - for no additional parameters)",
1577  NULL, FALSE, "-", NULL, NULL) );
1578 
1579  (void) SCIPsnprintf(extcodename, SCIP_MAXSTRLEN, "ZIMPL %d.%d.%d", ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10); /*lint !e778*/
1580  SCIP_CALL( SCIPincludeExternalCodeInformation(scip, extcodename, "Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)"));
1581 #else
1582  assert(scip != NULL);
1583 
1584  SCIPwarningMessage(scip, "SCIP does only support ZIMPL 3.4.1 and higher. Please update your ZIMPL version %d.%d.%d\n",
1585  ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10);
1586 #endif
1587 #endif
1588 
1589  return SCIP_OKAY;
1590 }
SCIP_RETCODE SCIPincludeReaderZpl(SCIP *scip)
Definition: reader_zpl.c:1546
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_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
Definition: scip_prob.c:1289
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