Scippy

    SCIP

    Solving Constraint Integer Programs

    reader_zpl.c
    Go to the documentation of this file.
    1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    2/* */
    3/* This file is part of the program and library */
    4/* SCIP --- Solving Constraint Integer Programs */
    5/* */
    6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
    7/* */
    8/* Licensed under the Apache License, Version 2.0 (the "License"); */
    9/* you may not use this file except in compliance with the License. */
    10/* You may obtain a copy of the License at */
    11/* */
    12/* http://www.apache.org/licenses/LICENSE-2.0 */
    13/* */
    14/* Unless required by applicable law or agreed to in writing, software */
    15/* distributed under the License is distributed on an "AS IS" BASIS, */
    16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
    17/* See the License for the specific language governing permissions and */
    18/* limitations under the License. */
    19/* */
    20/* You should have received a copy of the Apache-2.0 license */
    21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
    22/* */
    23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    24
    25/**@file reader_zpl.c
    26 * @ingroup DEFPLUGINS_READER
    27 * @brief ZIMPL model file reader
    28 * @author Tobias Achterberg
    29 * @author Timo Berthold
    30 */
    31
    32/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    33
    34#include "scip/reader_zpl.h"
    35
    36#ifdef SCIP_WITH_ZIMPL
    37
    38#include <unistd.h>
    39#include <stdbool.h>
    40#include <string.h>
    41
    42#ifdef _MSC_VER
    43#include <direct.h>
    44#define getcwd _getcwd
    45#endif
    46
    48#include "scip/cons_indicator.h"
    49#include "scip/cons_linear.h"
    50#include "scip/cons_sos1.h"
    51#include "scip/cons_sos2.h"
    52#include "scip/pub_misc.h"
    53#include "scip/pub_nlp.h"
    54#include "scip/pub_reader.h"
    55#include "scip/pub_var.h"
    56#include "scip/scip_cons.h"
    57#include "scip/scip_exact.h"
    58#include "scip/scip_general.h"
    59#include "scip/scip_mem.h"
    60#include "scip/scip_message.h"
    61#include "scip/scip_numerics.h"
    62#include "scip/scip_param.h"
    63#include "scip/scip_prob.h"
    64#include "scip/scip_reader.h"
    65#include "scip/scip_sol.h"
    66#include "scip/scip_var.h"
    67#include "scip/cons_nonlinear.h"
    68#include "scip/struct_misc.h"
    69#include "scip/expr_pow.h"
    70#include "scip/expr_log.h"
    71#include "scip/expr_exp.h"
    72#include "scip/expr_abs.h"
    73#include "scip/expr_sum.h"
    74#include "scip/expr_trig.h"
    75#include "scip/expr_product.h"
    76#include "scip/pub_expr.h"
    77#include "scip/type_reader.h"
    78
    79#ifdef __cplusplus
    80extern "C" {
    81#endif
    82
    83/* @Note: Due to dependencies we need the following order. */
    84/* include the ZIMPL headers necessary to define the LP and MINLP construction interface */
    85#ifdef SCIP_WITH_GMP
    86#include <gmp.h>
    87#endif
    88#include "zimpl/attribute.h"
    89#include "zimpl/ratlptypes.h"
    90#include "zimpl/lint.h"
    91#include "zimpl/mme.h"
    92
    93#include "zimpl/numb.h"
    94#include "zimpl/bound.h"
    95#include "zimpl/mono.h"
    96#include "zimpl/term.h"
    97
    98#include "zimpl/xlpglue.h"
    99#include "zimpl/zimpllib.h"
    100#include "scip/rational.h"
    101#include "scip/rationalgmp.h"
    102
    103#ifdef __cplusplus
    104}
    105#endif
    106
    107/* disable warning that our callbacks, like xlp_addvar, may return NULL if there was an error earlier,
    108 * even though they were declared __attribute__((__nonnull__))
    109 */
    110#if defined(__clang__)
    111#pragma clang diagnostic ignored "-Wnonnull"
    112#endif
    113
    114#define READER_NAME "zplreader"
    115#define READER_DESC "file reader for ZIMPL model files"
    116#define READER_EXTENSION "zpl"
    117
    118/*
    119 * LP construction interface of ZIMPL
    120 */
    121
    122/* we only support ZIMPL with a version higher than 3.4.1 */
    123#if (ZIMPL_VERSION >= 341)
    124
    125/* ZIMPL does not support user data in callbacks - we have to use static variables */
    126struct
    127SCIP_ReaderData
    128{
    129 SCIP* scip; /**< scip data structure */
    130 SCIP_SOL* sol; /**< primal solution candidate */
    131 SCIP_Bool valid; /**< is the primal solution candidate valid */
    132 SCIP_Bool branchpriowarning; /**< store if the waring regarding fractional value for the branching
    133 * priority was already posted */
    134 SCIP_Bool initialconss; /**< should model constraints be marked as initial? */
    135 SCIP_Bool dynamicconss; /**< should model constraints be subject to aging? */
    136 SCIP_Bool dynamiccols; /**< should columns be added and removed dynamically to the LP? */
    137 SCIP_Bool dynamicrows; /**< should rows be added and removed dynamically to the LP? */
    138 SCIP_Bool readerror; /**< was a reading error be discovered */
    139 SCIP_RETCODE retcode; /**< store a none SCIP_OKAY return code if an error occurred */
    140};
    141
    142#if defined(SCIP_WITH_GMP) && defined(SCIP_WITH_BOOST)
    143/** convert between scips_rational and zimpl's numb type */
    144static
    145SCIP_RETCODE RcreateNumb(
    146 BMS_BLKMEM* mem,
    147 SCIP_RATIONAL** rational,
    148 const Numb* numb
    149 )
    150{
    151 mpq_t temp;
    152
    153 mpq_init(temp);
    154 numb_get_mpq(numb, temp);
    155
    156 SCIPdebug(gmp_printf("the rational is: %Qd\n",temp));
    157
    158 SCIP_CALL( SCIPrationalCreateBlockGMP(mem, rational, temp) );
    159 mpq_clear(temp);
    160
    161 return SCIP_OKAY;
    162}
    163#else
    164/** convert between scips_rational and zimpl's numb type */
    165static
    166SCIP_RETCODE RcreateNumb(
    167 BMS_BLKMEM* mem,
    168 SCIP_RATIONAL** rational,
    169 const Numb* numb
    170 )
    171{
    172 SCIP_CALL( SCIPrationalCreateBlock(mem, rational) );
    173 SCIPrationalSetReal(*rational, numb_todbl(numb));
    174 return SCIP_OKAY;
    175}
    176#endif
    177
    178/** abort the reading with an errormessage; this type of constraint is not supported
    179 * in exact solving
    180 */
    181static
    182SCIP_RETCODE abortReadIfExact(
    183 SCIP* scip, /**< scip data structure */
    184 SCIP_Bool* created, /**< store if a cons was created or NULL */
    185 const char* errmsg /**< Error Message */
    186 )
    187{
    188 if( SCIPisExact(scip) )
    189 {
    190 SCIPerrorMessage("%s\n",errmsg);
    191 if( created != NULL )
    192 (*created) = FALSE;
    193 return SCIP_ERROR;
    194 }
    195 else
    196 return SCIP_OKAY;
    197}
    198
    199/** create problem */
    200static
    201SCIP_RETCODE createProb(
    202 SCIP* scip, /**< SCIP data structure */
    203 SCIP_READERDATA* readerdata, /**< reader data */
    204 const char* name /**< name of the problem */
    205 )
    206{
    207 SCIP_Bool usestartsol;
    208
    209 /* create problem */
    211
    212 /* check if are interested in the primal solution candidate */
    213 SCIP_CALL( SCIPgetBoolParam(scip, "reading/zplreader/usestartsol", &usestartsol) );
    214
    215 if( usestartsol )
    216 {
    217 /* create primal solution */
    218 if( SCIPisExact(scip) )
    219 {
    220 SCIP_CALL( SCIPcreateSolExact(scip, &readerdata->sol, NULL) );
    221 }
    222 else
    223 {
    224 SCIP_CALL( SCIPcreateSol(scip, &readerdata->sol, NULL) );
    225 }
    226 readerdata->valid = TRUE;
    227 }
    228
    229 return SCIP_OKAY;
    230}
    231
    232/** Allocate storage for the mathematical program instance generated by ZIMPL. xlp_alloc() is the first xlpglue routine
    233 * that will be called by ZIMPL. The user_data pointer may hold an arbitray value.
    234 */
    235Lps* xlp_alloc(
    236 const char* name, /**< name of the problem */
    237 bool need_startval, /**< does ZIMPL provides a primal solution candidate */
    238 void* user_data /**< user data which was previously passed to ZIMPL */
    239 )
    240{ /*lint --e{715}*/
    241 SCIP* scip;
    242 SCIP_READERDATA* readerdata;
    243
    244 readerdata = (SCIP_READERDATA*)user_data;
    245 assert(readerdata != NULL);
    246 assert(readerdata->retcode == SCIP_OKAY);
    247 assert(!readerdata->readerror);
    248
    249 scip = readerdata->scip;
    250 assert(scip != NULL);
    251
    252 readerdata->retcode = createProb(scip, readerdata, name);
    253
    254 /* return the reader data pointer to receive it all other ZIMPL call backs */
    255 return (Lps*) readerdata;
    256}
    257
    258/** free storage for mathematical program. xlp_free() is the last xlpglue routine that will be called by Zimpl */
    259void xlp_free(
    260 Lps* lp /**< pointer to reader data */
    261 )
    262{ /*lint --e{715}*/
    263 /* nothing to be done here */
    264}
    265
    266/** does there already exists a constraint with the given name? */
    267bool xlp_conname_exists(
    268 const Lps* lp, /**< pointer to reader data */
    269 const char* conname /**< constraint name to check */
    270 )
    271{
    272 SCIP_READERDATA* readerdata;
    273
    274 readerdata = (SCIP_READERDATA*)lp;
    275 assert(readerdata != NULL);
    276
    277 /* check if constraint with the given name already exists */
    278 return (SCIPfindCons(readerdata->scip, conname) != NULL);
    279}
    280
    281/** create a SCIP expression from a ZIMPL term
    282 *
    283 * Returns *expr == NULL if could not create expression due to unsupported ZIMPL functions.
    284 */
    285static
    286SCIP_RETCODE createExpr(
    287 SCIP* scip, /**< SCIP data structure */
    288 SCIP_READERDATA* readerdata, /**< reader data */
    289 SCIP_EXPR** expr, /**< buffer to store expression */
    290 const Term* term /**< term to convert to expression */
    291 )
    292{
    293 assert(scip != NULL);
    294 assert(readerdata != NULL);
    295 assert(expr != NULL);
    296 assert(term != NULL);
    297
    298 *expr = NULL;
    299
    300 if( term_get_degree(term) == 2 )
    301 {
    302 int nlinvars;
    303 int nquadterms;
    304 SCIP_VAR** linvars;
    305 SCIP_VAR** quadvar1;
    306 SCIP_VAR** quadvar2;
    307 SCIP_Real* lincoefs;
    308 SCIP_Real* quadcoefs;
    309 Mono* monom;
    310 int i;
    311
    312 nlinvars = 0;
    313 nquadterms = 0;
    314
    315 SCIP_CALL( SCIPallocBufferArray(scip, &linvars, term_get_elements(term)) );
    316 SCIP_CALL( SCIPallocBufferArray(scip, &quadvar1, term_get_elements(term)) );
    317 SCIP_CALL( SCIPallocBufferArray(scip, &quadvar2, term_get_elements(term)) );
    318 SCIP_CALL( SCIPallocBufferArray(scip, &lincoefs, term_get_elements(term)) );
    319 SCIP_CALL( SCIPallocBufferArray(scip, &quadcoefs, term_get_elements(term)) );
    320
    321 for( i = 0; i < term_get_elements(term); ++i )
    322 {
    323 monom = term_get_element(term, i);
    324 assert(!numb_equal(mono_get_coeff(monom), numb_zero()));
    325 assert(mono_get_degree(monom) <= 2);
    326 assert(mono_get_degree(monom) > 0);
    327 if (mono_get_degree(monom) == 1)
    328 {
    329 linvars [nlinvars] = (SCIP_VAR*)mono_get_var(monom, 0);
    330 lincoefs[nlinvars] = numb_todbl(mono_get_coeff(monom));
    331 ++nlinvars;
    332 }
    333 else
    334 {
    335 assert(mono_get_degree(monom) == 2);
    336 quadvar1 [nquadterms] = (SCIP_VAR*)mono_get_var(monom, 0);
    337 quadvar2 [nquadterms] = (SCIP_VAR*)mono_get_var(monom, 1);
    338 quadcoefs[nquadterms] = numb_todbl(mono_get_coeff(monom));
    339 ++nquadterms;
    340 }
    341 }
    342
    343 SCIP_CALL( SCIPcreateExprQuadratic(scip, expr, nlinvars, linvars, lincoefs, nquadterms, quadvar1, quadvar2, quadcoefs, NULL, NULL) );
    344
    345 SCIPfreeBufferArray(scip, &linvars);
    346 SCIPfreeBufferArray(scip, &quadvar1);
    347 SCIPfreeBufferArray(scip, &quadvar2);
    348 SCIPfreeBufferArray(scip, &lincoefs);
    349 SCIPfreeBufferArray(scip, &quadcoefs);
    350 }
    351 else
    352 {
    353 SCIP_VAR** polyvars;
    354 SCIP_Real* polyexps;
    355 SCIP_HASHMAP* varexpmap;
    356 SCIP_EXPR** monomials;
    357 int nmonomials;
    358 int monomialssize;
    359 SCIP_Real* coefs;
    360 Mono* monomial;
    361 SCIP_EXPR* monomialexpr;
    362 SCIP_Bool created;
    363 int varpos;
    364 int i;
    365 int j;
    366
    367 polyvars = NULL;
    368 polyexps = NULL;
    369
    370 monomials = NULL;
    371 nmonomials = 0;
    372 monomialssize = 0;
    373 coefs = NULL;
    374 created = TRUE;
    375
    377
    378 for( i = 0; i < term_get_elements(term); ++i )
    379 {
    380 monomial = term_get_element(term, i);
    381 assert(monomial != NULL);
    382 assert(!numb_equal(mono_get_coeff(monomial), numb_zero()));
    383 assert(mono_get_degree(monomial) > 0);
    384
    385 /* allocate space in the monomials array */
    386 if( monomialssize == 0 )
    387 {
    388 monomialssize = SCIPcalcMemGrowSize(scip, 1);
    389 SCIP_CALL( SCIPallocBufferArray(scip, &monomials, monomialssize) );
    390 SCIP_CALL( SCIPallocBufferArray(scip, &coefs, monomialssize) );
    391 }
    392 else if( monomialssize < nmonomials + 1 )
    393 {
    394 monomialssize = SCIPcalcMemGrowSize(scip, nmonomials+1);
    395 SCIP_CALL( SCIPreallocBufferArray(scip, &monomials, monomialssize) );
    396 SCIP_CALL( SCIPreallocBufferArray(scip, &coefs, monomialssize) );
    397 }
    398 assert(monomials != NULL);
    399 assert(coefs != NULL);
    400
    401 /* create SCIP monomial expression */
    402 for( j = 0; j < mono_get_degree(monomial); ++j )
    403 {
    404 SCIP_Real exponent;
    405
    406 exponent = SCIPhashmapGetImageReal(varexpmap, (void*)mono_get_var(monomial, j));
    407 exponent = exponent == SCIP_INVALID ? 1.0 : exponent + 1.0;
    408
    409 SCIP_CALL( SCIPhashmapSetImageReal(varexpmap, (void*)mono_get_var(monomial, j), exponent) );
    410 }
    411
    414
    415 varpos = 0;
    416
    417 for( j = 0; j < SCIPhashmapGetNEntries(varexpmap); ++j )
    418 {
    419 SCIP_HASHMAPENTRY* entry;
    420
    421 entry = SCIPhashmapGetEntry(varexpmap, j);
    422 if( entry == NULL )
    423 continue;
    424
    425 polyvars[varpos] = (SCIP_VAR*) SCIPhashmapEntryGetOrigin(entry);
    426 polyexps[varpos] = SCIPhashmapEntryGetImageReal(entry);
    427 ++varpos;
    428 }
    429 assert(varpos == SCIPhashmapGetNElements(varexpmap));
    430 SCIPhashmapRemoveAll(varexpmap);
    431
    432 SCIP_CALL( SCIPcreateExprMonomial(scip, &monomialexpr, varpos, polyvars, polyexps, NULL, NULL) );
    433
    434 SCIPfreeBufferArrayNull(scip, &polyexps);
    435 SCIPfreeBufferArrayNull(scip, &polyvars);
    436
    437 /* add monomial to array, possibly with an extra function around it */
    438 if( mono_get_function(monomial) == MFUN_NONE )
    439 {
    440 monomials[nmonomials] = monomialexpr;
    441 coefs[nmonomials] = numb_todbl(mono_get_coeff(monomial));
    442 }
    443 else
    444 {
    445 SCIP_EXPR* cosexpr;
    446 SCIP_EXPR* prodchildren[2];
    447
    448 coefs[nmonomials] = 1.0;
    449
    450 /* nonlinear monomial with an extra function around it */
    451 switch( mono_get_function(monomial) )
    452 {
    453 case MFUN_SQRT:
    454 SCIP_CALL( SCIPcreateExprPow(scip, &monomials[nmonomials], monomialexpr, 0.5, NULL, NULL) );
    455 break;
    456 case MFUN_LOG:
    457 /* log10(x) = ln(x) / ln(10.0) */
    458 coefs[nmonomials] = 1.0 / log(10.0);
    459 SCIP_CALL( SCIPcreateExprLog(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    460 break;
    461 case MFUN_EXP:
    462 SCIP_CALL( SCIPcreateExprExp(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    463 break;
    464 case MFUN_LN:
    465 SCIP_CALL( SCIPcreateExprLog(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    466 break;
    467 case MFUN_SIN:
    468 SCIP_CALL( SCIPcreateExprSin(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    469 break;
    470 case MFUN_COS:
    471 SCIP_CALL( SCIPcreateExprCos(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    472 break;
    473 case MFUN_TAN:
    474 SCIP_CALL( SCIPcreateExprSin(scip, &prodchildren[0], monomialexpr, NULL, NULL) );
    475 SCIP_CALL( SCIPcreateExprCos(scip, &cosexpr, monomialexpr, NULL, NULL) );
    476 SCIP_CALL( SCIPcreateExprPow(scip, &prodchildren[1], cosexpr, -1.0, NULL, NULL) );
    477 SCIP_CALL( SCIPcreateExprProduct(scip, &monomials[nmonomials], 2, prodchildren, 1.0, NULL, NULL) );
    478
    479 SCIP_CALL( SCIPreleaseExpr(scip, &prodchildren[1]) );
    480 SCIP_CALL( SCIPreleaseExpr(scip, &cosexpr) );
    481 SCIP_CALL( SCIPreleaseExpr(scip, &prodchildren[0]) );
    482
    483 break;
    484 case MFUN_ABS:
    485 SCIP_CALL( SCIPcreateExprAbs(scip, &monomials[nmonomials], monomialexpr, NULL, NULL) );
    486 break;
    487 case MFUN_POW:
    488 SCIP_CALL( SCIPcreateExprPow(scip, &monomials[nmonomials], monomialexpr,
    489 numb_todbl(mono_get_coeff(monomial)), NULL, NULL) );
    490 break;
    491 case MFUN_SGNPOW:
    492 SCIP_CALL( SCIPcreateExprSignpower(scip, &monomials[nmonomials], monomialexpr,
    493 numb_todbl(mono_get_coeff(monomial)), NULL, NULL) );
    494 break;
    495 case MFUN_NONE:
    496 case MFUN_TRUE:
    497 case MFUN_FALSE:
    498 SCIPerrorMessage("ZIMPL function %d invalid here.\n", mono_get_function(monomial));
    499 created = FALSE;
    500 break;
    501 default:
    502 SCIPerrorMessage("ZIMPL function %d not supported\n", mono_get_function(monomial));
    503 created = FALSE;
    504 break;
    505 } /*lint !e788*/
    506
    507 SCIP_CALL( SCIPreleaseExpr(scip, &monomialexpr) );
    508 }
    509
    510 ++nmonomials;
    511
    512 if( !created )
    513 break;
    514 }
    515
    516 if( created )
    517 {
    518 SCIP_CALL( SCIPcreateExprSum(scip, expr, nmonomials, monomials, coefs, 0.0, NULL, NULL) );
    519 }
    520
    521 /* free memory */
    522 for( j = nmonomials - 1; j >= 0; --j )
    523 {
    524 if( monomials[j] != NULL )
    525 {
    526 SCIP_CALL( SCIPreleaseExpr(scip, &monomials[j]) );
    527 }
    528 }
    529
    531 SCIPfreeBufferArrayNull(scip, &monomials);
    532 SCIPhashmapFree(&varexpmap);
    533 }
    534
    535 return SCIP_OKAY;
    536}
    537
    538/** method creates a constraint and is called directly from ZIMPL
    539 *
    540 * @note this method is used by ZIMPL beginning from version 3.00
    541 */
    542static
    543SCIP_RETCODE addConsTerm(
    544 SCIP* scip, /**< SCIP data structure */
    545 SCIP_READERDATA* readerdata, /**< reader data */
    546 const char* name, /**< constraint name */
    547 ConType type, /**< constraint type (LHS, RHS, EQUAL, RANGE, etc) */
    548 const Numb* lhs, /**< left hand side */
    549 const Numb* rhs, /**< right hand side */
    550 unsigned int flags, /**< special constraint flags, see ratlptypes.h */
    551 const Term* term, /**< term to use */
    552 SCIP_Bool* created /**< pointer to store if a constraint was created */
    553 )
    554{
    555 SCIP_CONS* cons;
    556 SCIP_RATIONAL* ratlhs = NULL;
    557 SCIP_RATIONAL* ratrhs = NULL;
    558 SCIP_Real sciplhs;
    559 SCIP_Real sciprhs;
    560 SCIP_Bool initial;
    562 SCIP_Bool enforce;
    563 SCIP_Bool check;
    564 SCIP_Bool propagate;
    565 SCIP_Bool local;
    566 SCIP_Bool modifiable;
    567 SCIP_Bool usercut;
    568 SCIP_Bool lazycut;
    569 int i;
    570
    571 if( SCIPisExact(scip) )
    572 {
    573 /* get exact lhs and rhs */
    574 switch( type )
    575 {
    576 case CON_FREE:
    579 break;
    580 case CON_LHS:
    581 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratlhs, lhs) );
    583 break;
    584 case CON_RHS:
    585 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratrhs, rhs) );
    587 break;
    588 case CON_RANGE:
    589 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratlhs, lhs) );
    590 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratrhs, rhs) );
    591 break;
    592 case CON_EQUAL:
    593 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratlhs, lhs) );
    594 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ratrhs, rhs) );
    595 assert(SCIPrationalIsEQ(ratrhs, ratlhs));
    596 break;
    597 default:
    598 SCIPwarningMessage(scip, "invalid constraint type <%d> in ZIMPL callback xlp_addcon()\n", type);
    599 readerdata->readerror = TRUE;
    600 break;
    601 }
    602 }
    603 switch( type )
    604 {
    605 case CON_FREE:
    606 sciplhs = -SCIPinfinity(scip);
    607 sciprhs = SCIPinfinity(scip);
    608 break;
    609 case CON_LHS:
    610 sciplhs = (SCIP_Real)numb_todbl(lhs);
    611 sciprhs = SCIPinfinity(scip);
    612 break;
    613 case CON_RHS:
    614 sciplhs = -SCIPinfinity(scip);
    615 sciprhs = (SCIP_Real)numb_todbl(rhs);
    616 break;
    617 case CON_RANGE:
    618 sciplhs = (SCIP_Real)numb_todbl(lhs);
    619 sciprhs = (SCIP_Real)numb_todbl(rhs);
    620 break;
    621 case CON_EQUAL:
    622 sciplhs = (SCIP_Real)numb_todbl(lhs);
    623 sciprhs = (SCIP_Real)numb_todbl(rhs);
    624 assert(sciplhs == sciprhs); /*lint !e777*/
    625 break;
    626 default:
    627 SCIPwarningMessage(scip, "invalid constraint type <%d> in ZIMPL callback xlp_addcon()\n", type);
    628 sciplhs = (SCIP_Real)numb_todbl(lhs);
    629 sciprhs = (SCIP_Real)numb_todbl(rhs);
    630 readerdata->readerror = TRUE;
    631 break;
    632 }
    633
    634 cons = NULL;
    635
    636 /* default values */
    637 initial = readerdata->initialconss;
    638 separate = TRUE;
    639 propagate = TRUE;
    640 enforce = TRUE;
    641 check = TRUE;
    642 local = FALSE;
    643 modifiable = FALSE;
    644
    645 usercut = (flags & LP_FLAG_CON_SEPAR) != 0;
    646 lazycut = (flags & LP_FLAG_CON_CHECK) != 0;
    647
    648 /* evaluate constraint flags */
    649 if( usercut && lazycut )
    650 {
    651 initial = FALSE;
    652 separate = TRUE;
    653 check = TRUE;
    654 }
    655 else if( usercut )
    656 {
    657 initial = FALSE;
    658 separate = TRUE;
    659 check = FALSE;
    660 }
    661 else if( lazycut )
    662 {
    663 initial = FALSE;
    664 separate = FALSE;
    665 check = TRUE;
    666 }
    667
    668 if( term_is_linear(term) )
    669 {
    670 /* if the constraint gives an indicator constraint */
    671 if ( flags & LP_FLAG_CON_INDIC )
    672 {
    673 bool lhsIndCons = FALSE; /* generate lhs form for indicator constraints */
    674 bool rhsIndCons = FALSE; /* generate rhs form for indicator constraints */
    675
    676 SCIP_CALL( abortReadIfExact(scip, created,
    677 "xpl_addcon_term: exact version for indicator constraints not supported\n") );
    678
    679 /* currently indicator constraints can only handle "<=" constraints */
    680 switch( type )
    681 {
    682 case CON_LHS:
    683 lhsIndCons = TRUE;
    684 break;
    685 case CON_RHS:
    686 rhsIndCons = TRUE;
    687 break;
    688 case CON_RANGE:
    689 case CON_EQUAL:
    690 lhsIndCons = TRUE;
    691 rhsIndCons = TRUE;
    692 break;
    693 case CON_FREE:
    694 /*lint -fallthrough*/
    695 default:
    696 SCIPerrorMessage("invalid constraint type <%d> in ZIMPL callback xlp_addcon()\n", type);
    697 readerdata->readerror = TRUE;
    698 break;
    699 }
    700
    701 /* insert lhs form of indicator */
    702 if ( lhsIndCons )
    703 {
    704 SCIP_CALL( SCIPcreateConsIndicator(scip, &cons, name, NULL, 0, NULL, NULL, -sciplhs,
    705 initial, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    706 SCIP_CALL( SCIPaddCons(scip, cons) );
    707
    708 for( i = 0; i < term_get_elements(term); i++ )
    709 {
    710 SCIP_VAR* scipvar;
    711 SCIP_Real scipval;
    712 const Mono* mono = term_get_element(term, i);
    713 MFun mfun;
    714
    715 scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
    716
    717 /* check whether variable is the binary variable */
    718 mfun = mono_get_function(mono);
    719 if (mfun == MFUN_TRUE || mfun == MFUN_FALSE)
    720 {
    721 SCIP_CALL( SCIPsetBinaryVarIndicator(scip, cons, scipvar) );
    722 }
    723 else
    724 {
    725 assert(!numb_equal(mono_get_coeff(mono), numb_zero()));
    726 assert(mono_is_linear(mono));
    727
    728 scipval = -numb_todbl(mono_get_coeff(mono));
    729 SCIP_CALL( SCIPaddVarIndicator(scip, cons, scipvar, scipval) );
    730 }
    731 }
    732
    733 (*created) = TRUE;
    734 }
    735
    736 /* insert rhs form of indicator */
    737 if ( rhsIndCons )
    738 {
    739 SCIP_CALL( SCIPcreateConsIndicator(scip, &cons, name, NULL, 0, NULL, NULL, sciprhs,
    740 initial, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    741 SCIP_CALL( SCIPaddCons(scip, cons) );
    742
    743 for( i = 0; i < term_get_elements(term); i++ )
    744 {
    745 SCIP_VAR* scipvar;
    746 SCIP_Real scipval;
    747 const Mono* mono = term_get_element(term, i);
    748 MFun mfun;
    749
    750 scipvar = (SCIP_VAR*)mono_get_var(mono, 0);
    751
    752 /* check whether variable is the binary variable */
    753 mfun = mono_get_function(mono);
    754 if (mfun == MFUN_TRUE || mfun == MFUN_FALSE)
    755 {
    756 SCIP_CALL( SCIPsetBinaryVarIndicator(scip, cons, scipvar) );
    757 }
    758 else
    759 {
    760 assert(!numb_equal(mono_get_coeff(mono), numb_zero()));
    761 assert(mono_is_linear(mono));
    762
    763 scipval = numb_todbl(mono_get_coeff(mono));
    764 SCIP_CALL( SCIPaddVarIndicator(scip, cons, scipvar, scipval) );
    765 }
    766 }
    767
    768 (*created) = TRUE;
    769 }
    770 }
    771 else
    772 {
    773 if( SCIPisExact(scip) )
    774 {
    775 SCIP_VAR* scipvar;
    776 SCIP_RATIONAL* scipvalrat;
    777
    778 /* due to technical reasons, we do not add singleton constraints but immediately transform them to variable bounds */
    779 /** @todo rework this into presolving of cons_exactlinear */
    780 if( term_get_elements(term) == 1 )
    781 {
    782 SCIP_RATIONAL* quotient;
    783 SCIP_Bool isupper;
    784 SCIP_Bool consneeded;
    785
    786 consneeded = FALSE;
    787
    788 assert(!numb_equal(mono_get_coeff(term_get_element(term, 0)), numb_zero()));
    789 assert(mono_is_linear(term_get_element(term, 0)));
    790
    791 scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, 0), 0);
    792 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &scipvalrat, mono_get_coeff(term_get_element(term, 0))) );
    794
    795 if( !SCIPrationalIsInfinity(ratrhs) )
    796 {
    797 isupper = SCIPrationalIsPositive(scipvalrat);
    798 SCIPrationalDiv(quotient, ratrhs, scipvalrat);
    799
    800 if( isupper && SCIPrationalIsLT(quotient, SCIPvarGetUbGlobalExact(scipvar)) )
    801 {
    802 if( SCIPrationalIsGE(quotient, SCIPvarGetLbGlobalExact(scipvar)) )
    803 {
    804 SCIP_CALL( SCIPchgVarUbGlobalExact(scip, scipvar, quotient) );
    805 }
    806 else
    807 consneeded = TRUE;
    808 }
    809 else if( !isupper && SCIPrationalIsGT(quotient, SCIPvarGetLbGlobalExact(scipvar)) )
    810 {
    811 if( SCIPrationalIsLE(quotient, SCIPvarGetUbGlobalExact(scipvar)) )
    812 {
    813 SCIP_CALL( SCIPchgVarLbGlobalExact(scip, scipvar, quotient) );
    814 }
    815 else
    816 consneeded = TRUE;
    817 }
    818 }
    819 if( !SCIPrationalIsNegInfinity(ratlhs) )
    820 {
    821 isupper = !SCIPrationalIsPositive(scipvalrat);
    822 SCIPrationalDiv(quotient, ratlhs, scipvalrat);
    823
    824 if( isupper && SCIPrationalIsLT(quotient, SCIPvarGetUbGlobalExact(scipvar)) )
    825 {
    826 if( SCIPrationalIsGE(quotient, SCIPvarGetLbGlobalExact(scipvar)) )
    827 {
    828 SCIP_CALL( SCIPchgVarUbGlobalExact(scip, scipvar, quotient) );
    829 }
    830 else
    831 consneeded = TRUE;
    832 }
    833 else if( !isupper && SCIPrationalIsGT(quotient, SCIPvarGetLbGlobalExact(scipvar)) )
    834 {
    835 if( SCIPrationalIsLE(quotient, SCIPvarGetUbGlobalExact(scipvar)) )
    836 {
    837 SCIP_CALL( SCIPchgVarLbGlobalExact(scip, scipvar, quotient) );
    838 }
    839 else
    840 consneeded = TRUE;
    841 }
    842 }
    843
    844 if( consneeded )
    845 {
    846 SCIP_CALL( SCIPcreateConsExactLinear(scip, &cons, name, 0, NULL, NULL, ratlhs, ratrhs,
    847 initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    848 SCIP_CALL( SCIPaddCons(scip, cons) );
    849 SCIP_CALL( SCIPaddCoefExactLinear(scip, cons, scipvar, scipvalrat) );
    850 }
    851
    854 }
    855 else
    856 {
    857 SCIP_CALL( SCIPcreateConsExactLinear(scip, &cons, name, 0, NULL, NULL, ratlhs, ratrhs,
    858 initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    859 SCIP_CALL( SCIPaddCons(scip, cons) );
    860
    861 for( i = 0; i < term_get_elements(term); i++ )
    862 {
    863 assert(!numb_equal(mono_get_coeff(term_get_element(term, i)), numb_zero()));
    864 assert(mono_is_linear(term_get_element(term, i)));
    865
    866 scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, i), 0);
    867 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &scipvalrat, mono_get_coeff(term_get_element(term, i))) );
    868
    869 SCIP_CALL( SCIPaddCoefExactLinear(scip, cons, scipvar, scipvalrat) );
    871 }
    872 }
    873 }
    874 else
    875 {
    876 SCIP_CALL( SCIPcreateConsLinear(scip, &cons, name, 0, NULL, NULL, sciplhs, sciprhs,
    877 initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    878 SCIP_CALL( SCIPaddCons(scip, cons) );
    879
    880 for( i = 0; i < term_get_elements(term); i++ )
    881 {
    882 SCIP_VAR* scipvar;
    883 SCIP_Real scipval;
    884
    885 assert(!numb_equal(mono_get_coeff(term_get_element(term, i)), numb_zero()));
    886 assert(mono_is_linear(term_get_element(term, i)));
    887
    888 scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, i), 0);
    889 scipval = numb_todbl(mono_get_coeff(term_get_element(term, i)));
    890
    891 SCIP_CALL( SCIPaddCoefLinear(scip, cons, scipvar, scipval) );
    892 }
    893 }
    894 (*created) = TRUE;
    895 }
    896 }
    897 else
    898 {
    899 SCIP_EXPR* expr;
    900
    901 SCIP_CALL( abortReadIfExact(scip, created,
    902 "xpl_addcon_term: exact version for degree == 2 not supported\n") );
    903
    904 /* convert term into expression */
    905 SCIP_CALL( createExpr(scip, readerdata, &expr, term) );
    906
    907 if( expr == NULL )
    908 {
    909 /* ZIMPL term could not be represented as SCIP expression */
    910 (*created) = FALSE;
    911 }
    912 else
    913 {
    914 /* create constraint with expression */
    915 SCIP_CALL( SCIPcreateConsNonlinear(scip, &cons, name, expr, sciplhs, sciprhs,
    916 initial, separate, enforce, check, propagate, local, modifiable, readerdata->dynamicconss, readerdata->dynamicrows) );
    917 SCIP_CALL( SCIPaddCons(scip, cons) );
    918
    919 SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
    920
    921 (*created) = TRUE;
    922 }
    923 }
    924
    925 if( cons != NULL )
    926 {
    927 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
    928 }
    929
    930 if( SCIPisExact(scip) )
    931 {
    934 }
    935
    936 return SCIP_OKAY;
    937}
    938
    939/** method adds objective term and is called directly from ZIMPL
    940 *
    941 * @note this method is used by ZIMPL beginning from version 3.4.1
    942 */
    943static
    944SCIP_RETCODE addObjTerm(
    945 SCIP* scip, /**< SCIP data structure */
    946 SCIP_READERDATA* readerdata, /**< reader data */
    947 const Term* term /**< term to use */
    948 )
    949{
    950 if( term_is_linear(term) )
    951 {
    952 int i;
    953 for( i = 0; i < term_get_elements(term); i++ )
    954 {
    955 SCIP_VAR* scipvar;
    956 SCIP_Real scipval;
    957
    958 assert(!numb_equal(mono_get_coeff(term_get_element(term, i)), numb_zero()));
    959 assert(mono_is_linear(term_get_element(term, i)));
    960
    961 scipvar = (SCIP_VAR*)mono_get_var(term_get_element(term, i), 0);
    962 if( SCIPisExact(scip) )
    963 {
    964 SCIP_RATIONAL* scipvalrat;
    965 char str[SCIP_MAXSTRLEN];
    966
    967 RcreateNumb(SCIPblkmem(scip), &scipvalrat, mono_get_coeff(term_get_element(term, i)));
    968 SCIPrationalAdd(scipvalrat, scipvalrat, SCIPvarGetObjExact(scipvar));
    969
    970 SCIPdebugMessage("zimpl reader: change obj<%g> of var: add<%g> as approx", SCIPvarGetObj(scipvar),
    971 SCIPrationalGetReal(scipvalrat) );
    972 SCIPdebug(SCIPrationalToString(scipvalrat, str));
    973 SCIPdebugMessage(" (<%s> as exact) \n", str);
    974
    975 readerdata->retcode = SCIPchgVarObjExact(scip, scipvar, scipvalrat);
    976 SCIPchgVarObj(scip, scipvar, SCIPrationalGetReal(scipvalrat));
    977
    979 }
    980 else
    981 {
    982 SCIP_CALL( abortReadIfExact(scip, &(readerdata->readerror),
    983 "xlp_addobj_termr: exact version not supported.\n") );
    984
    985 scipval = numb_todbl(mono_get_coeff(term_get_element(term, i)));
    986
    987 SCIP_CALL( SCIPaddVarObj(scip, scipvar, scipval) );
    988 }
    989 }
    990 }
    991 else
    992 {
    993 /* create variable objvar, add 1*objvar to objective, and add constraint term - objvar = 0 */
    994 SCIP_EXPR* expr;
    995 SCIP_CONS* cons;
    996 SCIP_VAR* objvar;
    997
    998 SCIP_CALL( createExpr(scip, readerdata, &expr, term) );
    999
    1000 if( expr == NULL )
    1001 {
    1002 SCIPerrorMessage("Could not convert ZIMPL objective term into SCIP expression due to unsupported ZIMPL function.\n");
    1003 return SCIP_READERROR;
    1004 }
    1005
    1006 SCIP_CALL( SCIPcreateConsNonlinear(scip, &cons, "obj", expr,
    1009 readerdata->initialconss, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, readerdata->dynamicconss, FALSE) );
    1010
    1012 SCIP_CALL( SCIPaddLinearVarNonlinear(scip, cons, objvar, -1.0) );
    1013
    1014 SCIP_CALL( SCIPaddVar(scip, objvar) );
    1015 SCIP_CALL( SCIPaddCons(scip, cons) );
    1016
    1017 SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
    1018 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
    1019 SCIP_CALL( SCIPreleaseVar(scip, &objvar) );
    1020 }
    1021
    1022 if( SCIPisExact(scip) )
    1023 {
    1024 SCIP_RATIONAL* scipvalrat;
    1025
    1026 RcreateNumb(SCIPblkmem(scip), &scipvalrat, term_get_constant(term));
    1028 SCIPrationalFreeBlock(SCIPblkmem(scip), &scipvalrat);
    1029 }
    1030 else
    1031 {
    1032 SCIP_CALL( SCIPaddOrigObjoffset(scip, (SCIP_Real)numb_todbl(term_get_constant(term))) );
    1033 }
    1034
    1035 return SCIP_OKAY;
    1036}
    1037
    1038/** method creates a constraint and is called directly from ZIMPL
    1039 *
    1040 * @note this method is used by ZIMPL beginning from version 3.00
    1041 */
    1042bool xlp_addcon_term(
    1043 Lps* lp, /**< pointer to reader data */
    1044 const char* name, /**< constraint name */
    1045 ConType type, /**< constraint type (LHS, RHS, EQUAL, RANGE, etc) */
    1046 const Numb* lhs, /**< left hand side */
    1047 const Numb* rhs, /**< right hand side */
    1048 unsigned int flags, /**< special constraint flags, see ratlptypes.h */
    1049 const Term* term /**< term to use */
    1050 )
    1051{
    1052 SCIP* scip;
    1053 SCIP_READERDATA* readerdata;
    1054 SCIP_Bool created = FALSE;
    1055
    1056 readerdata = (SCIP_READERDATA*)lp;
    1057 assert(readerdata != NULL);
    1058
    1059 scip = readerdata->scip;
    1060 assert(scip != NULL);
    1061
    1062 if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
    1063 return TRUE;
    1064
    1065 readerdata->retcode = addConsTerm(scip, readerdata, name, type, lhs, rhs, flags, term, &created);
    1066
    1067 return !created;
    1068}
    1069
    1070/** adde variable */
    1071static
    1072SCIP_RETCODE addVar(
    1073 SCIP* scip, /**< SCIP data structure */
    1074 SCIP_READERDATA* readerdata, /**< reader data */
    1075 const char* name, /**< variable name */
    1076 VarClass usevarclass, /**< variable type */
    1077 const Bound* lower, /**< lower bound */
    1078 const Bound* upper, /**< upper bound */
    1079 const Numb* priority, /**< branching priority */
    1080 const Numb* startval, /**< start value for the variable within in the start solution */
    1081 Var** zplvar /**< pointer to store the created variable */
    1082 )
    1083{
    1084 SCIP_VAR* var;
    1085 SCIP_Real lb;
    1086 SCIP_Real ub;
    1087 SCIP_RATIONAL* lbrat = NULL;
    1088 SCIP_RATIONAL* ubrat = NULL;
    1089 SCIP_VARTYPE vartype;
    1090 SCIP_IMPLINTTYPE varimpltype;
    1091 SCIP_Bool initial;
    1092 SCIP_Bool removable;
    1093 int branchpriority;
    1094
    1095 if( SCIPisExact(scip) )
    1096 {
    1097 /* get exact lower bounds for exactlinear constraint handler and safe FP-values for FP-problem */
    1098 switch( bound_get_type(lower) )
    1099 {
    1100 case BOUND_VALUE:
    1101 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &lbrat, bound_get_value(lower)) );
    1103 break;
    1104 case BOUND_INFTY:
    1106 lb = SCIPinfinity(scip);
    1107 break;
    1108 case BOUND_MINUS_INFTY:
    1110 lb = -SCIPinfinity(scip);
    1111 break;
    1112 case BOUND_ERROR:
    1113 default:
    1114 SCIPerrorMessage("invalid lower bound type <%d> in ZIMPL reader\n", bound_get_type(lower));
    1116 lb = 0.0;
    1117 break;
    1118 }
    1119
    1120 /* get exact upper bounds for exactlinear constraint handler and safe FP-values for FP-problem */
    1121 switch( bound_get_type(upper) )
    1122 {
    1123 case BOUND_VALUE:
    1124 SCIP_CALL( RcreateNumb(SCIPblkmem(scip), &ubrat, bound_get_value(upper)) );
    1126 break;
    1127 case BOUND_INFTY:
    1129 ub = SCIPinfinity(scip);
    1130 break;
    1131 case BOUND_MINUS_INFTY:
    1133 ub = -SCIPinfinity(scip);
    1134 break;
    1135 case BOUND_ERROR:
    1136 default:
    1137 SCIPerrorMessage("invalid upper bound type <%d> in ZIMPL reader\n", bound_get_type(upper));
    1139 ub = 0.0;
    1140 break;
    1141 }
    1142 }
    1143 else
    1144 {
    1145 switch( bound_get_type(lower) )
    1146 {
    1147 case BOUND_VALUE:
    1148 lb = (SCIP_Real)numb_todbl(bound_get_value(lower));
    1149 break;
    1150 case BOUND_INFTY:
    1151 lb = SCIPinfinity(scip);
    1152 break;
    1153 case BOUND_MINUS_INFTY:
    1154 lb = -SCIPinfinity(scip);
    1155 break;
    1156 case BOUND_ERROR:
    1157 default:
    1158 SCIPerrorMessage("invalid lower bound type <%d> in ZIMPL reader\n", bound_get_type(lower));
    1159 lb = 0.0;
    1160 break;
    1161 }
    1162
    1163 switch( bound_get_type(upper) )
    1164 {
    1165 case BOUND_VALUE:
    1166 ub = (SCIP_Real)numb_todbl(bound_get_value(upper));
    1167 break;
    1168 case BOUND_INFTY:
    1169 ub = SCIPinfinity(scip);
    1170 break;
    1171 case BOUND_MINUS_INFTY:
    1172 ub = -SCIPinfinity(scip);
    1173 break;
    1174 case BOUND_ERROR:
    1175 default:
    1176 SCIPerrorMessage("invalid upper bound type <%d> in ZIMPL reader\n", bound_get_type(upper));
    1177 ub = 0.0;
    1178 break;
    1179 }
    1180 }
    1181
    1182 switch( usevarclass )
    1183 {
    1184 case VAR_INT:
    1185 vartype = SCIP_VARTYPE_INTEGER;
    1186 varimpltype = SCIP_IMPLINTTYPE_NONE;
    1187 break;
    1188 case VAR_IMP:
    1189 vartype = SCIP_VARTYPE_CONTINUOUS;
    1190 varimpltype = SCIP_IMPLINTTYPE_WEAK;
    1191 break;
    1192 case VAR_CON:
    1193 vartype = SCIP_VARTYPE_CONTINUOUS;
    1194 varimpltype = SCIP_IMPLINTTYPE_NONE;
    1195 break;
    1196 default:
    1197 SCIPwarningMessage(scip, "invalid variable class <%d> in ZIMPL callback xlp_addvar()\n", usevarclass);
    1198 vartype = SCIP_VARTYPE_CONTINUOUS;
    1199 readerdata->readerror = TRUE;
    1200 break;
    1201 }
    1202 initial = !(readerdata->dynamiccols);
    1203 removable = readerdata->dynamiccols;
    1204
    1205 /* create variable */
    1206 SCIPdebugMessage("zimpl reader: added new variable");
    1207 SCIP_CALL( SCIPcreateVarImpl(scip, &var, name, lb, ub, 0.0, vartype, varimpltype, initial, removable,
    1208 NULL, NULL, NULL, NULL, NULL) );
    1209
    1210 if( SCIPisExact(scip) )
    1211 {
    1212 SCIP_CALL( SCIPaddVarExactData(scip, var, lbrat, ubrat, NULL) );
    1213#ifdef SCIP_MORE_DEBUG
    1215 SCIPrationalToString(lbrat, strlb);
    1216 SCIPrationalToString(ubrat, strub);
    1217 SCIPdebugMessage("exact bounds are [%s,%s]\n", strlb, strub);
    1218#endif
    1221 }
    1222
    1223 /* add variable to the problem; we are releasing the variable later */
    1224 SCIP_CALL( SCIPaddVar(scip, var) );
    1225
    1226 if( !numb_equal(priority, numb_unknown()) )
    1227 {
    1228 if( numb_is_int(priority) )
    1229 branchpriority = numb_toint(priority);
    1230 else
    1231 {
    1232 if( !readerdata->branchpriowarning )
    1233 {
    1235 "ZIMPL reader: fractional branching priorities in input - rounding down to integer values\n");
    1236 readerdata->branchpriowarning = TRUE;
    1237 }
    1238 branchpriority = (int)numb_todbl(priority);
    1239 }
    1240
    1241 /* change the branching priority of the variable */
    1242 SCIP_CALL( SCIPchgVarBranchPriority(scip, var, branchpriority) );
    1243 }
    1244
    1245 /* check if we are willing to except a primal solution candidate */
    1246 if( readerdata->valid )
    1247 {
    1248 /* if the number is unknown we have no valid primal solution candidate */
    1249 if( numb_equal(startval, numb_unknown()) )
    1250 {
    1251 SCIPdebugMsg(scip, "primal solution candidate contains an unknown value for variable <%s>(%g)\n",
    1252 SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
    1253 readerdata->valid = FALSE;
    1254 }
    1255 else
    1256 {
    1257 assert(readerdata->sol != NULL);
    1258 SCIPdebugMsg(scip, "change solution solution <%p>: <%s> = <%g>\n",
    1259 (void*)readerdata->sol, SCIPvarGetName(var), (SCIP_Real)numb_todbl(startval));
    1260
    1261 /* set value within the primal solution candidate */
    1262 if( SCIPsolIsExact(readerdata->sol) )
    1263 {
    1264 SCIP_RATIONAL* solrat;
    1265
    1266 RcreateNumb(SCIPblkmem(scip), &solrat, startval);
    1267 SCIP_CALL( SCIPsetSolValExact(scip, readerdata->sol, var, solrat) );
    1269 }
    1270 else
    1271 {
    1272 SCIP_CALL( SCIPsetSolVal(scip, readerdata->sol, var, (SCIP_Real)numb_todbl(startval)) );
    1273 }
    1274 }
    1275 }
    1276
    1277 /* copy the variable pointer before we release the variable */
    1278 (*zplvar) = (Var*)var;
    1279
    1280 /* release variable */
    1281 SCIP_CALL( SCIPreleaseVar(scip, &var) );
    1282
    1283 return SCIP_OKAY;
    1284}
    1285
    1286/** method adds a variable; is called directly by ZIMPL */
    1287Var* xlp_addvar(
    1288 Lps* lp, /**< pointer to reader data */
    1289 const char* name, /**< variable name */
    1290 VarClass usevarclass, /**< variable type */
    1291 const Bound* lower, /**< lower bound */
    1292 const Bound* upper, /**< upper bound */
    1293 const Numb* priority, /**< branching priority */
    1294 const Numb* startval /**< start value for the variable within in the start solution */
    1295 )
    1296{ /*lint --e{715}*/
    1297 SCIP* scip;
    1298 SCIP_READERDATA* readerdata;
    1299 Var* zplvar;
    1300
    1301 readerdata = (SCIP_READERDATA*)lp;
    1302 assert(readerdata != NULL);
    1303
    1304 scip = readerdata->scip;
    1305 assert(scip != NULL);
    1306
    1307 zplvar = NULL;
    1308
    1309 if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
    1310 return NULL;
    1311
    1312 readerdata->retcode = addVar(scip, readerdata, name, usevarclass, lower, upper, priority, startval, &zplvar);
    1313
    1314 return zplvar;
    1315}
    1316
    1317/** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
    1318static
    1319SCIP_RETCODE addSOS(
    1320 SCIP* scip, /**< SCIP data structure */
    1321 SCIP_READERDATA* readerdata, /**< reader data */
    1322 const char* name, /**< constraint name */
    1323 SosType type, /**< SOS type */
    1324 const Term* term /**< terms indicating sos */
    1325 )
    1326{
    1327 SCIP_CONS* cons;
    1329 SCIP_Bool enforce;
    1330 SCIP_Bool check;
    1331 SCIP_Bool propagate;
    1332 SCIP_Bool local;
    1333 int i;
    1334
    1335 SCIP_CALL( abortReadIfExact(scip, &(readerdata->readerror),
    1336 "xlp_addsos_termr: exact version not supported.\n") );
    1337
    1338 switch( type )
    1339 {
    1340 case SOS_TYPE1:
    1341 separate = TRUE;
    1342 enforce = TRUE;
    1343 check = enforce;
    1344 propagate = TRUE;
    1345 local = FALSE;
    1346
    1347 SCIP_CALL( SCIPcreateConsSOS1(scip, &cons, name, 0, NULL, NULL,
    1348 readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    1349 SCIP_CALL( SCIPaddCons(scip, cons) );
    1350
    1351 for( i = 0; i < term_get_elements(term); i++ )
    1352 {
    1353 SCIP_VAR* var;
    1354 SCIP_Real weight;
    1355
    1356 assert( mono_is_linear(term_get_element(term, i)) );
    1357
    1358 var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
    1359 weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
    1360
    1361 SCIP_CALL( SCIPaddVarSOS1(scip, cons, var, weight) );
    1362 }
    1363 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
    1364 break;
    1365 case SOS_TYPE2:
    1366 separate = TRUE;
    1367 enforce = TRUE;
    1368 check = enforce;
    1369 propagate = TRUE;
    1370 local = FALSE;
    1371
    1372 SCIP_CALL( SCIPcreateConsSOS2(scip, &cons, name, 0, NULL, NULL,
    1373 readerdata->initialconss, separate, enforce, check, propagate, local, readerdata->dynamicconss, readerdata->dynamicrows, FALSE) );
    1374 SCIP_CALL( SCIPaddCons(scip, cons) );
    1375 for( i = 0; i < term_get_elements(term); i++ )
    1376 {
    1377 SCIP_VAR* var;
    1378 SCIP_Real weight;
    1379
    1380 assert( mono_is_linear(term_get_element(term, i)) );
    1381
    1382 var = (SCIP_VAR*) mono_get_var(term_get_element(term, i), 0);
    1383 weight = numb_todbl(mono_get_coeff(term_get_element(term, i)));
    1384
    1385 SCIP_CALL( SCIPaddVarSOS2(scip, cons, var, weight) );
    1386 }
    1387 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
    1388 break;
    1389 case SOS_ERR:
    1390 /*lint -fallthrough*/
    1391 default:
    1392 SCIPerrorMessage("invalid SOS type <%d> in ZIMPL callback xlp_addsos_term()\n", type);
    1393 readerdata->readerror = TRUE;
    1394 break;
    1395 }
    1396
    1397 return SCIP_OKAY;
    1398}
    1399
    1400/** add a SOS constraint. Add a given a Zimpl term as an SOS constraint to the mathematical program */
    1401int xlp_addsos_term(
    1402 Lps* lp, /**< pointer to reader data */
    1403 const char* name, /**< constraint name */
    1404 SosType type, /**< SOS type */
    1405 const Numb* priority, /**< priority */
    1406 const Term* term /**< terms indicating sos */
    1407 )
    1408{
    1409 /*lint --e{715}*/
    1410 SCIP* scip;
    1411 SCIP_READERDATA* readerdata;
    1412
    1413 readerdata = (SCIP_READERDATA*)lp;
    1414 assert(readerdata != NULL);
    1415
    1416 scip = readerdata->scip;
    1417 assert(scip != NULL);
    1418
    1419 if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
    1420 return TRUE;
    1421
    1422 readerdata->retcode = addSOS(scip, readerdata, name, type, term);
    1423
    1424 return 0;
    1425}
    1426
    1427/** returns the variable name */
    1428const char* xlp_getvarname(
    1429 const Lps* lp, /**< pointer to reader data */
    1430 const Var* var /**< variable */
    1431 )
    1432{
    1433#ifndef NDEBUG
    1434 SCIP* scip;
    1435 SCIP_READERDATA* readerdata;
    1436
    1437 readerdata = (SCIP_READERDATA*)lp;
    1438 assert(readerdata != NULL);
    1439
    1440 scip = readerdata->scip;
    1441 assert(scip != NULL);
    1442#endif
    1443
    1444 return SCIPvarGetName((SCIP_VAR*)var);
    1445}
    1446
    1447/** return variable type */
    1448VarClass xlp_getclass(
    1449 const Lps* lp, /**< pointer to reader data */
    1450 const Var* var /**< variable */
    1451 )
    1452{
    1453 SCIP_READERDATA* readerdata = (SCIP_READERDATA*)lp;
    1454 SCIP_VAR* scipvar = (SCIP_VAR*)var;
    1455 int implintlevel;
    1456
    1457 /* adjust border between int and imp based on the implied integral level */
    1458 assert(readerdata != NULL);
    1459 SCIPgetIntParam(readerdata->scip, "write/implintlevel", &implintlevel);
    1460 assert(implintlevel >= -2);
    1461 assert(implintlevel <= 2);
    1462
    1463 switch( SCIPvarGetType(scipvar) )
    1464 {
    1467 return (int)SCIPvarGetImplType(scipvar) <= 2 + implintlevel ? VAR_INT : VAR_IMP;
    1469 if( SCIPvarIsImpliedIntegral(scipvar) )
    1470 return (int)SCIPvarGetImplType(scipvar) > 2 - implintlevel ? VAR_INT : VAR_IMP;
    1471 break;
    1472 default:
    1473 SCIPerrorMessage("invalid SCIP variable type <%d> in ZIMPL callback xlp_getclass()\n", SCIPvarGetType(scipvar));
    1474 readerdata->readerror = TRUE;
    1475 break;
    1476 }
    1477
    1478 return VAR_CON;
    1479}
    1480
    1481/** returns lower bound */
    1482Bound* xlp_getlower(
    1483 const Lps* lp, /**< pointer to reader data */
    1484 const Var* var /**< variable */
    1485 )
    1486{
    1487 SCIP* scip;
    1488 SCIP_READERDATA* readerdata;
    1489 SCIP_VAR* scipvar;
    1490 SCIP_Real lb;
    1491 char s[SCIP_MAXSTRLEN];
    1492 BoundType boundtype;
    1493 Numb* numb;
    1494 Bound* bound;
    1495
    1496 readerdata = (SCIP_READERDATA*)lp;
    1497 assert(readerdata != NULL);
    1498
    1499 scip = readerdata->scip;
    1500 assert(scip != NULL);
    1501
    1502 if( SCIP_ERROR == abortReadIfExact(scip, NULL, "xlp_getlower: exact version not supported.\n") )
    1503 {
    1504 readerdata->readerror = TRUE;
    1505 return NULL;
    1506 }
    1507
    1508 scipvar = (SCIP_VAR*)var;
    1509 assert(scipvar != NULL);
    1510
    1511 /* collect lower bound */
    1512 lb = SCIPvarGetLbGlobal(scipvar);
    1513 numb = NULL;
    1514
    1515 /* check if lower bound is infinity */
    1516 if( SCIPisInfinity(scip, -lb) )
    1517 boundtype = BOUND_MINUS_INFTY;
    1518 else if( SCIPisInfinity(scip, lb) )
    1519 boundtype = BOUND_INFTY;
    1520 else
    1521 {
    1522 boundtype = BOUND_VALUE;
    1523
    1524 /* create double form string */
    1525 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", lb);
    1526 numb = numb_new_ascii(s);
    1527 }
    1528
    1529 /* create bound */
    1530 bound = bound_new(boundtype, numb);
    1531
    1532 if( numb != NULL )
    1533 numb_free(numb);
    1534
    1535 return bound;
    1536}
    1537
    1538/** returns upper bound */
    1539Bound* xlp_getupper(
    1540 const Lps* lp, /**< pointer to reader data */
    1541 const Var* var /**< variable */
    1542 )
    1543{
    1544 SCIP* scip;
    1545 SCIP_READERDATA* readerdata;
    1546 SCIP_VAR* scipvar;
    1547 SCIP_Real ub;
    1548 char s[SCIP_MAXSTRLEN];
    1549 BoundType boundtype;
    1550 Numb* numb;
    1551 Bound* bound;
    1552
    1553 readerdata = (SCIP_READERDATA*)lp;
    1554 assert(readerdata != NULL);
    1555
    1556 scip = readerdata->scip;
    1557 assert(scip != NULL);
    1558
    1559 if( SCIP_ERROR == abortReadIfExact(scip, NULL, "xlp_getupper: exact version not supported.\n") )
    1560 {
    1561 readerdata->readerror = TRUE;
    1562 return NULL;
    1563 }
    1564
    1565 scipvar = (SCIP_VAR*)var;
    1566 assert(scipvar != NULL);
    1567
    1568 /* collect upper bound */
    1569 ub = SCIPvarGetUbGlobal(scipvar);
    1570 numb = NULL;
    1571
    1572 /* check if upper bound is infinity */
    1573 if( SCIPisInfinity(scip, -ub) )
    1574 boundtype = BOUND_MINUS_INFTY;
    1575 else if( SCIPisInfinity(scip, ub) )
    1576 boundtype = BOUND_INFTY;
    1577 else
    1578 {
    1579 boundtype = BOUND_VALUE;
    1580 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "%.20f", ub);
    1581 numb = numb_new_ascii(s);
    1582 }
    1583
    1584 /* create ZIMPL bound */
    1585 bound = bound_new(boundtype, numb);
    1586
    1587 if (numb != NULL)
    1588 numb_free(numb);
    1589
    1590 return bound;
    1591}
    1592
    1593/** Set the name and direction of the objective function, i.e. minimization or maximization
    1594 * Coefficents of the objective function will be set to all zero.
    1595 */
    1596bool xlp_setobj(
    1597 Lps* lp, /**< pointer to reader data */
    1598 const char* name, /**< name of the objective function */
    1599 bool minimize /**< True if the problem should be minimized, False if it should be maximized */
    1600 )
    1601{
    1602 SCIP* scip;
    1603 SCIP_READERDATA* readerdata;
    1604 SCIP_OBJSENSE objsense;
    1605
    1606 readerdata = (SCIP_READERDATA*)lp;
    1607 assert(readerdata != NULL);
    1608
    1609 scip = readerdata->scip;
    1610 assert(scip != NULL);
    1611
    1612 if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
    1613 return FALSE;
    1614
    1615 objsense = (minimize ? SCIP_OBJSENSE_MINIMIZE : SCIP_OBJSENSE_MAXIMIZE);
    1616 readerdata->retcode = SCIPsetObjsense(scip, objsense);
    1617
    1618 return FALSE;
    1619}
    1620
    1621/** adds objective function */
    1622void xlp_addtoobj(
    1623 Lps* lp, /**< pointer to reader data */
    1624 const Term* term /**< objective term */
    1625 )
    1626{
    1627 SCIP* scip;
    1628 SCIP_READERDATA* readerdata;
    1629
    1630 readerdata = (SCIP_READERDATA*)lp;
    1631 assert(readerdata != NULL);
    1632
    1633 scip = readerdata->scip;
    1634 assert(scip != NULL);
    1635
    1636 if( readerdata->retcode != SCIP_OKAY || readerdata->readerror )
    1637 return;
    1638
    1639 readerdata->retcode = addObjTerm(scip, readerdata, term);
    1640}
    1641
    1642/*
    1643 * Callback methods of reader
    1644 */
    1645
    1646/** copy method for reader plugins (called when SCIP copies plugins) */
    1647static
    1648SCIP_DECL_READERCOPY(readerCopyZpl)
    1649{ /*lint --e{715}*/
    1650 assert(scip != NULL);
    1651 assert(reader != NULL);
    1652 assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
    1653
    1654 /* call inclusion method of reader */
    1656
    1657 return SCIP_OKAY;
    1658}
    1659
    1660
    1661/** problem reading method of reader */
    1662static
    1663SCIP_DECL_READERREAD(readerReadZpl)
    1664{ /*lint --e{715}*/
    1665 SCIP_READERDATA* readerdata;
    1666 SCIP_RETCODE retcode;
    1667 char oldpath[SCIP_MAXSTRLEN];
    1668 char buffer[SCIP_MAXSTRLEN];
    1669 char compextension[SCIP_MAXSTRLEN];
    1670 char namewithoutpath[SCIP_MAXSTRLEN];
    1671 char* path;
    1672 char* name;
    1673 char* extension;
    1674 char* compression;
    1675 char* paramstr;
    1676
    1677 SCIP_Bool changedir;
    1678 int i;
    1679
    1680 SCIP_CALL( SCIPgetBoolParam(scip, "reading/zplreader/changedir", &changedir) );
    1681
    1682 path = NULL;
    1683 oldpath[0] = '\0';
    1684 if( changedir )
    1685 {
    1686 /* change to the directory of the ZIMPL file, s.t. paths of data files read by the ZIMPL model are relative to
    1687 * the location of the ZIMPL file
    1688 */
    1689 (void)SCIPstrncpy(buffer, filename, SCIP_MAXSTRLEN);
    1690 SCIPsplitFilename(buffer, &path, &name, &extension, &compression);
    1691 if( compression != NULL )
    1692 (void) SCIPsnprintf(compextension, SCIP_MAXSTRLEN, ".%s", compression);
    1693 else
    1694 *compextension = '\0';
    1695 (void) SCIPsnprintf(namewithoutpath, SCIP_MAXSTRLEN, "%s.%s%s", name, extension, compextension);
    1696 if( (char*)getcwd(oldpath, SCIP_MAXSTRLEN) == NULL )
    1697 {
    1698 SCIPerrorMessage("error getting the current path\n");
    1699 return SCIP_READERROR;
    1700 }
    1701 if( path != NULL )
    1702 {
    1703 if( chdir(path) != 0 )
    1704 {
    1705 SCIPerrorMessage("error changing to directory <%s>\n", path);
    1706 return SCIP_NOFILE;
    1707 }
    1708 }
    1709 filename = namewithoutpath;
    1710 }
    1711
    1712 /* get current path for output */
    1714 {
    1715 char currentpath[SCIP_MAXSTRLEN];
    1716 if( (char*)getcwd(currentpath, SCIP_MAXSTRLEN) == NULL )
    1717 {
    1718 SCIPerrorMessage("error getting the current path\n");
    1719 return SCIP_READERROR;
    1720 }
    1721 /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
    1722 * correctly */
    1724 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "base directory for ZIMPL parsing: <%s>\n", currentpath);
    1725 /* an extra blank line should be printed separately since the buffer message handler only handle up to one line
    1726 * correctly */
    1728 }
    1729
    1730 /* allocate storage */
    1731 SCIP_CALL( SCIPallocBuffer(scip, &readerdata) );
    1732
    1733 readerdata->scip = scip;
    1734 readerdata->sol = NULL;
    1735 readerdata->valid = FALSE;
    1736 readerdata->branchpriowarning = FALSE;
    1737 readerdata->readerror = FALSE;
    1738 readerdata->retcode = SCIP_OKAY;
    1739 SCIP_CALL( SCIPgetBoolParam(scip, "reading/initialconss", &(readerdata->initialconss)) );
    1740 SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicconss", &(readerdata->dynamicconss)) );
    1741 SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamiccols", &(readerdata->dynamiccols)) );
    1742 SCIP_CALL( SCIPgetBoolParam(scip, "reading/dynamicrows", &(readerdata->dynamicrows)) );
    1743
    1744 /* get the parameter string */
    1745 SCIP_CALL( SCIPgetStringParam(scip, "reading/zplreader/parameters", &paramstr) );
    1746 if( strcmp(paramstr, "-") == 0 )
    1747 {
    1748 /* call ZIMPL parser without arguments */
    1749 if( !zpl_read(filename, FALSE, (void*)readerdata) )
    1750 readerdata->readerror = TRUE;
    1751 else
    1752 {
    1753 /* evaluate retcode */
    1754 if ( readerdata->retcode != SCIP_OKAY )
    1755 {
    1756 SCIPfreeBuffer(scip, &readerdata);
    1757 return readerdata->retcode;
    1758 }
    1759 }
    1760 }
    1761 else
    1762 {
    1763 char dummy[2] = "x";
    1764 char** argv;
    1765 int argc;
    1766 int p;
    1767 int len;
    1768
    1769 len = (int) strlen(paramstr);
    1770 SCIP_CALL( SCIPallocBufferArray(scip, &argv, len+1) );
    1771 argv[0] = dummy; /* argument 0 is irrelevant */
    1772 argc = 1;
    1773 p = 0;
    1774 while( p < len )
    1775 {
    1776 int arglen;
    1777
    1778 /* process next argument */
    1779 SCIP_CALL( SCIPallocBufferArray(scip, &argv[argc], len+1) ); /*lint !e866*/
    1780 arglen = 0;
    1781
    1782 /* skip spaces */
    1783 while( p < len && paramstr[p] == ' ' )
    1784 p++;
    1785
    1786 /* process characters */
    1787 while( p < len && paramstr[p] != ' ' )
    1788 {
    1789 switch( paramstr[p] )
    1790 {
    1791 case '"':
    1792 p++;
    1793 /* read characters as they are until the next " */
    1794 while( p < len && paramstr[p] != '"' )
    1795 {
    1796 argv[argc][arglen] = paramstr[p];
    1797 arglen++;
    1798 p++;
    1799 }
    1800 p++; /* skip final " */
    1801 break;
    1802 case '\\':
    1803 /* read next character as it is */
    1804 p++;
    1805 argv[argc][arglen] = paramstr[p];
    1806 arglen++;
    1807 p++;
    1808 break;
    1809 default:
    1810 argv[argc][arglen] = paramstr[p];
    1811 arglen++;
    1812 p++;
    1813 break;
    1814 }
    1815 }
    1816 argv[argc][arglen] = '\0';
    1817
    1818 /* check for empty argument */
    1819 if( arglen == 0 )
    1820 {
    1821 SCIPfreeBufferArray(scip, &argv[argc]);
    1822 }
    1823 else
    1824 argc++;
    1825 }
    1826
    1827 /* append file name as last argument */
    1828 SCIP_CALL( SCIPduplicateBufferArray(scip, &argv[argc], filename, (int) strlen(filename)+1) ); /*lint !e866*/
    1829 argc++;
    1830
    1831 /* display parsed arguments */
    1833 {
    1834 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL arguments:\n");
    1835 for( i = 1; i < argc; ++i )
    1836 {
    1837 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "%d: <%s>\n", i, argv[i]);
    1838 }
    1839 }
    1840
    1841 /* call ZIMPL parser with arguments */
    1842 if( !zpl_read_with_args(argv, argc, FALSE, (void*)readerdata) )
    1843 readerdata->readerror = TRUE;
    1844
    1845 /* free argument memory */
    1846 for( i = argc - 1; i >= 1; --i )
    1847 {
    1848 SCIPfreeBufferArray(scip, &argv[i]);
    1849 }
    1850 SCIPfreeBufferArray(scip, &argv);
    1851
    1852 if ( readerdata->retcode != SCIP_OKAY )
    1853 {
    1854 SCIPfreeBuffer(scip, &readerdata);
    1855 return readerdata->retcode;
    1856 }
    1857 }
    1858
    1859 if( changedir )
    1860 {
    1861 /* change directory back to old path */
    1862 if( path != NULL )
    1863 {
    1864 if( chdir(oldpath) != 0 )
    1865 {
    1866 SCIPwarningMessage(scip, "error changing back to directory <%s>\n", oldpath);
    1867 }
    1868 }
    1869 }
    1870
    1871 if( readerdata->valid )
    1872 {
    1873 SCIP_Bool stored;
    1874
    1875 assert(readerdata->sol != NULL);
    1876
    1877 stored = FALSE;
    1878
    1879 /* add primal solution to solution candidate storage, frees the solution afterwards */
    1880 SCIP_CALL( SCIPaddSolFree(scip, &readerdata->sol, &stored) );
    1881
    1882 if( stored )
    1883 {
    1884 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "ZIMPL starting solution candidate accepted\n");
    1885 }
    1886 }
    1887
    1888 *result = SCIP_SUCCESS;
    1889
    1890 /* evaluate if a reading error occurred */
    1891 if( readerdata->readerror )
    1892 retcode = SCIP_READERROR;
    1893 else
    1894 retcode = SCIP_OKAY;
    1895
    1896 /* free primal solution candidate */
    1897 if( readerdata->sol != NULL )
    1898 {
    1899 SCIP_CALL( SCIPfreeSol(scip, &readerdata->sol) );
    1900 }
    1901
    1902 /* free reader data */
    1903 SCIPfreeBuffer(scip, &readerdata);
    1904
    1905 return retcode;
    1906}
    1907
    1908
    1909#endif
    1910#endif
    1911
    1912
    1913/*
    1914 * reader specific interface methods
    1915 */
    1916
    1917/** includes the zpl file reader in SCIP */ /*lint --e{715}*/
    1919 SCIP* scip /**< SCIP data structure */
    1920 )
    1921{ /*lint --e{715}*/
    1922#ifdef SCIP_WITH_ZIMPL
    1923#if (ZIMPL_VERSION >= 341)
    1924 SCIP_READERDATA* readerdata;
    1925 SCIP_READER* reader;
    1926 char extcodename[SCIP_MAXSTRLEN];
    1927
    1928 assert(scip != NULL);
    1929
    1930 /* create zpl reader data */
    1931 readerdata = NULL;
    1932 reader = NULL;
    1933 /* include zpl reader */
    1935 assert(reader != NULL);
    1936
    1937 /* reader is safe to use in exact solving mode */
    1938 SCIPreaderMarkExact(reader);
    1939
    1940 /* set non fundamental callbacks via setter functions */
    1941 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyZpl) );
    1942 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadZpl) );
    1943
    1944 /* add zpl reader parameters */
    1946 "reading/zplreader/changedir", "should the current directory be changed to that of the ZIMPL file before parsing?",
    1947 NULL, FALSE, TRUE, NULL, NULL) );
    1949 "reading/zplreader/usestartsol", "should ZIMPL starting solutions be forwarded to SCIP?",
    1950 NULL, FALSE, TRUE, NULL, NULL) );
    1952 "reading/zplreader/parameters", "additional parameter string passed to the ZIMPL parser (or - for no additional parameters)",
    1953 NULL, FALSE, "-", NULL, NULL) );
    1954
    1955 (void) SCIPsnprintf(extcodename, SCIP_MAXSTRLEN, "ZIMPL %d.%d.%d", ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10); /*lint !e778*/
    1956 SCIP_CALL( SCIPincludeExternalCodeInformation(scip, extcodename, "Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)") );
    1957#else
    1958 assert(scip != NULL);
    1959
    1960 SCIPwarningMessage(scip, "SCIP does only support ZIMPL 3.4.1 and higher. Please update your ZIMPL version %d.%d.%d\n",
    1961 ZIMPL_VERSION/100, (ZIMPL_VERSION%100)/10, ZIMPL_VERSION%10);
    1962#endif
    1963#endif
    1964
    1965 return SCIP_OKAY;
    1966}
    static long bound
    SCIP_DECL_READERREAD(ReaderTSP::scip_read)
    Definition: ReaderTSP.cpp:211
    Constraint handler for linear constraints in their most general form, .
    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:248
    #define SCIP_MAXSTRLEN
    Definition: def.h:269
    #define SCIP_INVALID
    Definition: def.h:178
    #define SCIP_Bool
    Definition: def.h:91
    #define SCIP_Real
    Definition: def.h:156
    #define TRUE
    Definition: def.h:93
    #define FALSE
    Definition: def.h:94
    #define SCIP_CALL(x)
    Definition: def.h:355
    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 SCIPcreateConsExactLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_RATIONAL **vals, SCIP_RATIONAL *lhs, SCIP_RATIONAL *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 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:10725
    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 SCIPaddCoefExactLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_RATIONAL *val)
    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:2687
    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:3209
    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:1117
    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:3185
    void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression)
    Definition: misc.c:11073
    SCIP_RETCODE SCIPincludeReaderZpl(SCIP *scip)
    Definition: reader_zpl.c:1918
    SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
    Definition: scip_prob.c:1907
    SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
    Definition: scip_prob.c:3274
    SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
    Definition: scip_prob.c:1417
    SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
    Definition: scip_prob.c:1486
    SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
    Definition: scip_prob.c:1400
    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:119
    SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
    Definition: scip_prob.c:3525
    SCIP_RETCODE SCIPaddOrigObjoffsetExact(SCIP *scip, SCIP_RATIONAL *addval)
    Definition: scip_prob.c:1465
    void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
    Definition: misc.c:3095
    SCIP_Real SCIPhashmapGetImageReal(SCIP_HASHMAP *hashmap, void *origin)
    Definition: misc.c:3344
    SCIP_RETCODE SCIPhashmapSetImageReal(SCIP_HASHMAP *hashmap, void *origin, SCIP_Real image)
    Definition: misc.c:3434
    int SCIPhashmapGetNElements(SCIP_HASHMAP *hashmap)
    Definition: misc.c:3576
    int SCIPhashmapGetNEntries(SCIP_HASHMAP *hashmap)
    Definition: misc.c:3584
    SCIP_HASHMAPENTRY * SCIPhashmapGetEntry(SCIP_HASHMAP *hashmap, int entryidx)
    Definition: misc.c:3592
    SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
    Definition: misc.c:3061
    void * SCIPhashmapEntryGetOrigin(SCIP_HASHMAPENTRY *entry)
    Definition: misc.c:3603
    SCIP_RETCODE SCIPhashmapRemoveAll(SCIP_HASHMAP *hashmap)
    Definition: misc.c:3676
    SCIP_Real SCIPhashmapEntryGetImageReal(SCIP_HASHMAPENTRY *entry)
    Definition: misc.c:3633
    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 SCIPgetIntParam(SCIP *scip, const char *name, int *value)
    Definition: scip_param.c:269
    SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
    Definition: scip_cons.c:1173
    SCIP_Bool SCIPisExact(SCIP *scip)
    Definition: scip_exact.c:193
    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:1059
    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:1167
    SCIP_RETCODE SCIPreleaseExpr(SCIP *scip, SCIP_EXPR **expr)
    Definition: scip_expr.c:1443
    SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
    Definition: scip_general.c:769
    #define SCIPfreeBuffer(scip, ptr)
    Definition: scip_mem.h:134
    BMS_BLKMEM * SCIPblkmem(SCIP *scip)
    Definition: scip_mem.c:57
    BMS_BUFMEM * SCIPbuffer(SCIP *scip)
    Definition: scip_mem.c:72
    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 SCIPrationalCreateBlock(BMS_BLKMEM *blkmem, SCIP_RATIONAL **rational)
    Definition: rational.cpp:108
    void SCIPrationalAdd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
    Definition: rational.cpp:935
    SCIP_Real SCIPrationalGetReal(SCIP_RATIONAL *rational)
    Definition: rational.cpp:2085
    SCIP_RETCODE SCIPrationalCreateString(BMS_BLKMEM *mem, SCIP_RATIONAL **rational, const char *desc)
    Definition: rational.cpp:796
    void SCIPrationalFreeBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **rational)
    Definition: rational.cpp:461
    int SCIPrationalToString(SCIP_RATIONAL *rational, char *str, int strlen)
    Definition: rational.cpp:1743
    void SCIPrationalDiv(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
    Definition: rational.cpp:1132
    SCIP_Bool SCIPrationalIsLT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
    Definition: rational.cpp:1503
    void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
    Definition: rational.cpp:603
    SCIP_Bool SCIPrationalIsGT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
    Definition: rational.cpp:1474
    void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
    Definition: rational.cpp:473
    SCIP_Bool SCIPrationalIsPositive(SCIP_RATIONAL *rational)
    Definition: rational.cpp:1640
    SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
    Definition: rational.cpp:123
    SCIP_Bool SCIPrationalIsGE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
    Definition: rational.cpp:1512
    SCIP_Bool SCIPrationalIsInfinity(SCIP_RATIONAL *rational)
    Definition: rational.cpp:1660
    SCIP_Real SCIPrationalRoundReal(SCIP_RATIONAL *rational, SCIP_ROUNDMODE_RAT roundmode)
    Definition: rational.cpp:2110
    SCIP_Bool SCIPrationalIsNegInfinity(SCIP_RATIONAL *rational)
    Definition: rational.cpp:1670
    SCIP_Bool SCIPrationalIsEQ(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
    Definition: rational.cpp:1404
    SCIP_Bool SCIPrationalIsLE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
    Definition: rational.cpp:1521
    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:680
    SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
    Definition: scip_reader.c:195
    void SCIPreaderMarkExact(SCIP_READER *reader)
    Definition: reader.c:670
    SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
    Definition: scip_sol.c:516
    SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
    Definition: scip_sol.c:1252
    SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
    Definition: scip_sol.c:3909
    SCIP_RETCODE SCIPsetSolValExact(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_RATIONAL *val)
    Definition: scip_sol.c:1616
    SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
    Definition: scip_sol.c:1571
    SCIP_RETCODE SCIPcreateSolExact(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
    Definition: scip_sol.c:566
    SCIP_Bool SCIPsolIsExact(SCIP_SOL *sol)
    Definition: sol.c:4150
    SCIP_Real SCIPinfinity(SCIP *scip)
    SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
    SCIP_Bool SCIPvarIsImpliedIntegral(SCIP_VAR *var)
    Definition: var.c:23498
    SCIP_RETCODE SCIPaddVarExactData(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *lb, SCIP_RATIONAL *ub, SCIP_RATIONAL *obj)
    Definition: scip_var.c:299
    SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
    Definition: var.c:23900
    SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
    Definition: var.c:23453
    SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
    Definition: var.c:24142
    SCIP_RETCODE SCIPchgVarLbGlobalExact(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *newbound)
    Definition: scip_var.c:5492
    SCIP_RETCODE SCIPchgVarBranchPriority(SCIP *scip, SCIP_VAR *var, int branchpriority)
    Definition: scip_var.c:9917
    SCIP_RETCODE SCIPchgVarUbGlobalExact(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *newbound)
    Definition: scip_var.c:5467
    SCIP_RETCODE SCIPcreateVarImpl(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_IMPLINTTYPE impltype, 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:225
    const char * SCIPvarGetName(SCIP_VAR *var)
    Definition: var.c:23267
    SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
    Definition: scip_var.c:1887
    SCIP_RATIONAL * SCIPvarGetLbGlobalExact(SCIP_VAR *var)
    Definition: var.c:24130
    SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
    Definition: var.c:24120
    SCIP_IMPLINTTYPE SCIPvarGetImplType(SCIP_VAR *var)
    Definition: var.c:23463
    SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
    Definition: scip_var.c:12465
    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:184
    SCIP_RETCODE SCIPchgVarObjExact(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *newobj)
    Definition: scip_var.c:5420
    SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
    Definition: scip_var.c:5372
    SCIP_RATIONAL * SCIPvarGetObjExact(SCIP_VAR *var)
    Definition: var.c:23910
    SCIP_RATIONAL * SCIPvarGetUbGlobalExact(SCIP_VAR *var)
    Definition: var.c:24152
    SCIP_RETCODE SCIPaddVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real addobj)
    Definition: scip_var.c:5519
    int SCIPsnprintf(char *t, int len, const char *s,...)
    Definition: misc.c:10827
    int SCIPstrncpy(char *t, const char *s, int size)
    Definition: misc.c:10897
    struct BMS_BlkMem BMS_BLKMEM
    Definition: memory.h:437
    public functions to work with algebraic expressions
    #define SCIPerrorMessage
    Definition: pub_message.h:64
    #define SCIPdebug(x)
    Definition: pub_message.h:93
    #define SCIPdebugMessage
    Definition: pub_message.h:96
    public data structures and miscellaneous methods
    public methods for NLP management
    public methods for input file readers
    public methods for problem variables
    wrapper for rational number arithmetic
    wrapper for rational number arithmetic that interacts with GMP
    #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
    public methods for exact solving
    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
    static SCIP_RETCODE separate(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *sol, SCIP_RESULT *result)
    Main separation function.
    Definition: sepa_flower.c:1221
    miscellaneous datastructures
    @ SCIP_VERBLEVEL_MINIMAL
    Definition: type_message.h:59
    @ SCIP_VERBLEVEL_NORMAL
    Definition: type_message.h:60
    @ SCIP_VERBLEVEL_FULL
    Definition: type_message.h:62
    @ SCIP_OBJSENSE_MAXIMIZE
    Definition: type_prob.h:47
    @ SCIP_OBJSENSE_MINIMIZE
    Definition: type_prob.h:48
    enum SCIP_Objsense SCIP_OBJSENSE
    Definition: type_prob.h:50
    @ SCIP_R_ROUND_UPWARDS
    Definition: type_rational.h:58
    @ SCIP_R_ROUND_DOWNWARDS
    Definition: type_rational.h:57
    type definitions for input file readers
    struct SCIP_ReaderData SCIP_READERDATA
    Definition: type_reader.h:54
    #define SCIP_DECL_READERCOPY(x)
    Definition: type_reader.h:63
    @ 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
    @ SCIP_ERROR
    Definition: type_retcode.h:43
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    enum SCIP_ImplintType SCIP_IMPLINTTYPE
    Definition: type_var.h:117
    @ SCIP_IMPLINTTYPE_NONE
    Definition: type_var.h:90
    @ SCIP_IMPLINTTYPE_WEAK
    Definition: type_var.h:91
    @ SCIP_VARTYPE_INTEGER
    Definition: type_var.h:65
    @ SCIP_VARTYPE_CONTINUOUS
    Definition: type_var.h:71
    @ SCIP_VARTYPE_BINARY
    Definition: type_var.h:64
    enum SCIP_Vartype SCIP_VARTYPE
    Definition: type_var.h:73