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