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