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