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