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