83 #if defined(_WIN32) || defined(_WIN64) 101 #define READER_NAME "opbreader" 102 #define READER_DESC "file reader for pseudo-Boolean problem in opb format" 103 #define READER_EXTENSION "opb" 105 #define GENCONSNAMES TRUE 106 #define LINEAROBJECTIVE TRUE 111 #define INDICATORVARNAME "indicatorvar" 112 #define INDICATORSLACKVARNAME "indslack" 113 #define TOPCOSTCONSNAME "topcostcons" 118 #define OPB_MAX_LINELEN 65536 119 #define OPB_MAX_PUSHEDTOKENS 2 120 #define OPB_INIT_COEFSSIZE 8192 161 #if GENCONSNAMES == TRUE 181 assert(opbinput !=
NULL);
183 SCIPerrorMessage(
"Syntax error in line %d: %s found <%s>\n", opbinput->linenumber, msg, opbinput->token);
184 if( opbinput->linebuf[strlen(opbinput->linebuf)-1] ==
'\n' )
193 opbinput->haserror =
TRUE;
202 assert(opbinput !=
NULL);
204 return opbinput->haserror;
261 assert(hasdot !=
NULL);
262 assert(exptype !=
NULL);
264 if( isdigit((
unsigned char)c) )
266 else if( (*exptype ==
OPB_EXP_NONE) && !(*hasdot) && (c ==
'.') )
271 else if( !firstchar && (*exptype ==
OPB_EXP_NONE) && (c ==
'e' || c ==
'E') )
273 if( nextc ==
'+' || nextc ==
'-' )
278 else if( isdigit((
unsigned char)nextc) )
304 assert(opbinput !=
NULL);
307 if( !opbinput->endline && opbinput->comment )
314 (void)
SCIPfgets(opbinput->linebuf, (
int)
sizeof(opbinput->linebuf), opbinput->file);
318 opbinput->comment =
FALSE;
319 opbinput->endline =
TRUE;
326 if( opbinput->endline )
328 opbinput->linepos = 0;
329 opbinput->linenumber++;
334 if(
SCIPfgets(opbinput->linebuf, (
int)
sizeof(opbinput->linebuf), opbinput->file) ==
NULL )
337 opbinput->bufpos = 0;
344 opbinput->endline =
FALSE;
345 last = strrchr(opbinput->linebuf,
' ');
349 SCIPwarningMessage(scip,
"we read %d character from the file; these might indicates a corrupted input file!",
356 SCIPfseek(opbinput->file, -(
long) strlen(last), SEEK_CUR);
357 SCIPdebugMsg(scip,
"correct buffer, reread the last %ld characters\n", (
long) strlen(last));
364 opbinput->endline =
TRUE;
369 opbinput->comment =
FALSE;
376 commentstart = strchr(opbinput->linebuf,
commentchars[i]);
377 if( commentstart !=
NULL )
379 *commentstart =
'\0';
380 *(commentstart+1) =
'\0';
381 opbinput->comment =
TRUE;
401 *pointer1 = *pointer2;
417 assert(opbinput !=
NULL);
421 if( opbinput->npushedtokens > 0 )
423 swapPointers(&opbinput->token, &opbinput->pushedtokens[opbinput->npushedtokens-1]);
424 opbinput->npushedtokens--;
425 SCIPdebugMsg(scip,
"(line %d) read token again: '%s'\n", opbinput->linenumber, opbinput->token);
430 buf = opbinput->linebuf;
433 if( buf[opbinput->bufpos] ==
'\0' )
437 SCIPdebugMsg(scip,
"(line %d) end of file\n", opbinput->linenumber);
440 assert(opbinput->bufpos == 0);
454 if(
isValueChar(buf[opbinput->bufpos], buf[opbinput->bufpos+1],
TRUE, &hasdot, &exptype) )
462 opbinput->token[tokenlen] = buf[opbinput->bufpos];
467 while(
isValueChar(buf[opbinput->bufpos], buf[opbinput->bufpos+1],
FALSE, &hasdot, &exptype) );
476 opbinput->token[tokenlen] = buf[opbinput->bufpos];
480 if( tokenlen == 1 &&
isTokenChar(opbinput->token[0]) )
490 && (opbinput->token[tokenlen-1] ==
'<' || opbinput->token[tokenlen-1] ==
'>' || opbinput->token[tokenlen-1] ==
'=')
491 && buf[opbinput->bufpos] ==
'=' )
496 else if( opbinput->token[tokenlen-1] ==
'=' && (buf[opbinput->bufpos] ==
'<' || buf[opbinput->bufpos] ==
'>') )
498 opbinput->token[tokenlen-1] = buf[opbinput->bufpos];
504 opbinput->token[tokenlen] =
'\0';
506 SCIPdebugMsg(scip,
"(line %d) read token: '%s'\n", opbinput->linenumber, opbinput->token);
517 assert(opbinput !=
NULL);
520 swapPointers(&opbinput->pushedtokens[opbinput->npushedtokens], &opbinput->token);
521 opbinput->npushedtokens++;
530 assert(opbinput !=
NULL);
533 swapPointers(&opbinput->pushedtokens[opbinput->npushedtokens], &opbinput->tokenbuf);
534 opbinput->npushedtokens++;
543 assert(opbinput !=
NULL);
554 assert(opbinput !=
NULL);
556 if( *(opbinput->token) ==
';')
569 assert(opbinput !=
NULL);
570 assert(sign !=
NULL);
571 assert(*sign == +1 || *sign == -1);
573 if( strlen(opbinput->token) == 1 )
575 assert(opbinput->token[1] ==
'\0');
577 if( *opbinput->token ==
'+' )
579 else if( *opbinput->token ==
'-' )
597 assert(opbinput !=
NULL);
598 assert(value !=
NULL);
600 if( strcasecmp(opbinput->token,
"INFINITY") == 0 || strcasecmp(opbinput->token,
"INF") == 0 )
610 val = strtod(opbinput->token, &endptr);
611 if( endptr != opbinput->token && *endptr ==
'\0' )
614 if( strlen(opbinput->token) > 18 )
615 opbinput->nproblemcoeffs++;
630 assert(opbinput !=
NULL);
632 if( strcmp(opbinput->token,
"<") == 0 )
638 else if( strcmp(opbinput->token,
">") == 0 )
644 else if( strcmp(opbinput->token,
"=") == 0 )
661 assert(scip !=
NULL);
662 assert(opbinput !=
NULL);
664 if( strcmp(opbinput->token,
"[") == 0 )
677 assert(scip !=
NULL);
678 assert(opbinput !=
NULL);
680 if( strcmp(opbinput->token,
"]") == 0 )
700 initial = !dynamiccols;
701 removable = dynamiccols;
704 SCIPdebugMsg(scip,
"creating new variable: <%s>\n", name);
731 assert(scip !=
NULL);
732 assert(opbinput !=
NULL);
733 assert(vars !=
NULL);
734 assert(nvars !=
NULL);
735 assert(varssize !=
NULL);
736 assert(*varssize >= 0);
740 name = opbinput->token;
741 assert(name !=
NULL);
744 while(!isdigit((
unsigned char) *name ) && !
isTokenChar(*name) && !opbinput->haserror )
770 if( *nvars == *varssize )
776 (*vars)[*nvars] = var;
780 opbinput->haserror =
TRUE;
782 name = opbinput->token;
787 syntaxError(scip, opbinput,
"expected a variable name");
807 int*
const ntermcoefs,
828 assert(opbinput !=
NULL);
829 assert(name !=
NULL);
830 assert(linvars !=
NULL);
831 assert(lincoefs !=
NULL);
832 assert(nlincoefs !=
NULL);
833 assert(terms !=
NULL);
834 assert(termcoefs !=
NULL);
835 assert(ntermvars !=
NULL);
836 assert(ntermcoefs !=
NULL);
837 assert(newsection !=
NULL);
848 *isNonlinear =
FALSE;
862 if( strcmp(opbinput->token,
":") == 0 )
868 SCIPdebugMsg(scip,
"(line %d) read constraint name: '%s'\n", opbinput->linenumber, name);
873 syntaxError(scip, opbinput,
"Soft top cost line needs to be the first non-comment line, and without any objective function.\n");
880 SCIPdebugMsg(scip,
"(line %d) constraint has no name\n", opbinput->linenumber);
893 assert(
SCIPfeof( opbinput->file ) );
894 opbinput->eof =
TRUE;
915 haveweightstart =
FALSE;
916 haveweightend =
FALSE;
936 if(
isSign(opbinput, &coefsign) )
938 SCIPdebugMsg(scip,
"(line %d) read coefficient sign: %+d\n", opbinput->linenumber, coefsign);
944 if(
isValue(scip, opbinput, &coef) )
947 if( (*nlincoefs > 0 || *ntermcoefs > 0 || ntmpcoefs > 0) && !havesign )
949 syntaxError(scip, opbinput,
"expected sign ('+' or '-') or sense ('<' or '>')");
953 SCIPdebugMsg(scip,
"(line %d) read coefficient value: %g with sign %+d\n", opbinput->linenumber, coef, coefsign);
956 syntaxError(scip, opbinput,
"two consecutive values");
962 if( strcmp(name,
"soft") == 0 )
964 assert(ntmpcoefs == 0);
966 tmpcoefs[ntmpcoefs] = coefsign * coef;
974 if( *nlincoefs == 0 && *ntermcoefs == 0 && ntmpcoefs == 0 && !havesign && !havevalue && strcmp(name,
"soft") != 0 &&
isStartingSoftConstraintWeight(scip, opbinput) )
978 SCIPwarningMessage(scip,
"Found in line %d a soft constraint, without having read a starting top-cost line.\n", opbinput->linenumber);
980 haveweightstart =
TRUE;
984 if( *nlincoefs == 0 && *ntermcoefs == 0 && ntmpcoefs == 0 && havevalue && haveweightstart &&
isEndingSoftConstraintWeight(scip, opbinput) )
986 *weight = coefsign * coef;
987 SCIPdebugMsg(scip,
"(line %d) found soft constraint weight: %g\n", opbinput->linenumber, *weight);
992 haveweightend =
TRUE;
1000 if( haveweightstart != haveweightend )
1002 syntaxError(scip, opbinput,
"Wrong soft constraint.");
1007 if( strcmp(name,
"soft") == 0 )
1009 syntaxError(scip, opbinput,
"Wrong soft top cost line.");
1019 *isNonlinear =
TRUE;
1021 SCIPdebugMsg(scip,
"(line %d) found linear term: %+g", opbinput->linenumber, coefsign * coef);
1025 for( v = 0; v < ntmpvars; ++v )
1034 assert(*ntermcoefs <= termcoefssize);
1036 if( *ntermcoefs == termcoefssize )
1043 assert(*ntermcoefs < termcoefssize);
1049 (*ntermvars)[*ntermcoefs] = ntmpvars;
1052 for( --ntmpvars; ntmpvars >= 0; --ntmpvars )
1054 (*terms)[*ntermcoefs][ntmpvars] = tmpvars[ntmpvars];
1057 (*termcoefs)[*ntermcoefs] = coefsign * coef;
1062 SCIPwarningMessage(scip,
"coefficient %g in line %d not integral.\n", (*termcoefs)[*ntermcoefs], opbinput->linenumber);
1077 assert(ntmpvars == 1);
1079 SCIPdebugMsg(scip,
"(line %d) found linear term: %+g<%s>\n", opbinput->linenumber, coefsign * coef,
SCIPvarGetName(tmpvars[0]));
1082 assert(*nlincoefs <= lincoefssize);
1084 if( *nlincoefs >= lincoefssize )
1090 assert(*nlincoefs < lincoefssize);
1093 (*linvars)[*nlincoefs] = tmpvars[0];
1094 (*lincoefs)[*nlincoefs] = coefsign * coef;
1099 SCIPwarningMessage(scip,
"coefficient %g in line %d not integral.\n", (*lincoefs)[*nlincoefs], opbinput->linenumber);
1115 if( !opbinput->haserror )
1118 assert(ntmpvars == 0);
1124 assert(ntmpcoefs == 1);
1126 assert(*nlincoefs == 0 && *ntermcoefs == 0);
1129 (*lincoefs)[*nlincoefs] = tmpcoefs[0];
1158 int*
const ntermvars,
1159 int const ntermcoefs
1162 assert(scip !=
NULL);
1163 assert(opbinput !=
NULL);
1165 assert(ncoefs == 0 || (linvars !=
NULL && coefs !=
NULL));
1166 assert(ntermcoefs == 0 || (terms !=
NULL && ntermvars !=
NULL && termcoefs !=
NULL));
1174 if( strcmp(sense,
"max" ) == 0 )
1183 if( ntermcoefs > 0 )
1185 #if (LINEAROBJECTIVE == TRUE) 1193 for( t = 0; t < ntermcoefs; ++t )
1196 nvars = ntermvars[t];
1197 assert(vars !=
NULL);
1214 #ifdef SCIP_DEBUG_SOLUTION 1215 if( SCIPdebugIsMainscip(scip) )
1219 for( v = nvars - 1; v >= 0; --v )
1252 for( v = 0; v < ntermcoefs; ++v )
1254 if( termcoefs[v] < 0 )
1260 for( v = 0; v < ncoefs; ++v )
1282 #ifdef SCIP_DEBUG_SOLUTION 1283 if( SCIPdebugIsMainscip(scip) )
1288 for( t = 0; t < ntermcoefs; ++t )
1291 nvars = ntermvars[t];
1292 assert(vars !=
NULL);
1295 for( v = nvars - 1; v >= 0; --v )
1304 artval += (((val < 0.5) ? 0.0 : 1.0) * termcoefs[t]);
1316 ntermvars, termcoefs,
NULL, 0.0,
FALSE, var, 0.0, 0.0,
1330 for( v = 0; v < ncoefs; ++v )
1354 int* nNonlinearConss
1392 assert(scip !=
NULL);
1393 assert(opbinput !=
NULL);
1394 assert(nNonlinearConss !=
NULL);
1400 SCIP_CALL(
readCoefficients(scip, opbinput, name, &linvars, &lincoefs, &nlincoefs, &terms, &termcoefs, &ntermvars, &ntermcoefs, &newsection, &isNonlinear, &issoftcons, &weight) );
1402 if(
hasError(opbinput) || opbinput->eof )
1406 if( strcmp(name,
"min") == 0 || strcmp(name,
"max") == 0 )
1410 syntaxError(scip, opbinput,
"Cannot have an objective function when having soft constraints.\n");
1415 SCIP_CALL(
setObjective(scip, opbinput, name, linvars, lincoefs, nlincoefs, terms, termcoefs, ntermvars, ntermcoefs) );
1417 else if( strcmp(name,
"soft") == 0 )
1420 opbinput->wbo =
TRUE;
1421 if( nlincoefs == 0 )
1425 assert(nlincoefs == 1);
1426 opbinput->topcost = lincoefs[0];
1428 SCIPdebugMsg(scip,
"Weighted Boolean Optimization problem has topcost of %g\n", opbinput->topcost);
1430 else if( nlincoefs > 0 )
1431 syntaxError(scip, opbinput,
"expected constraint sense '=' or '>='");
1438 syntaxError(scip, opbinput,
"expected constraint sense '=' or '>='");
1446 syntaxError(scip, opbinput,
"missing right hand side");
1449 if(
isSign(opbinput, &sidesign) )
1453 syntaxError(scip, opbinput,
"missing value of right hand side");
1457 if( !
isValue(scip, opbinput, &sidevalue) )
1459 syntaxError(scip, opbinput,
"expected value as right hand side");
1462 sidevalue *= sidesign;
1467 syntaxError(scip, opbinput,
"expected endline character ';'");
1497 initial = initialconss;
1505 removable = dynamicrows;
1511 ++(opbinput->nindvars);
1520 if( ntermcoefs > 0 || issoftcons )
1522 #if GENCONSNAMES == TRUE 1524 ++(opbinput->consnumber);
1529 ntermvars, termcoefs, indvar, weight, issoftcons,
NULL, lhs, rhs,
1530 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable,
FALSE);
1536 #if GENCONSNAMES == TRUE 1538 ++(opbinput->consnumber);
1543 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable,
FALSE);
1549 SCIPdebugMsg(scip,
"(line %d) created constraint: ", opbinput->linenumber);
1554 ++(*nNonlinearConss);
1559 for( t = ntermcoefs - 1; t >= 0; --t )
1578 const char* filename
1586 assert(scip !=
NULL);
1587 assert(opbinput !=
NULL);
1590 commentstart =
NULL;
1595 if(
SCIPfgets(opbinput->linebuf, (
int)
sizeof(opbinput->linebuf), opbinput->file) ==
NULL )
1597 assert(
SCIPfeof( opbinput->file ) );
1604 commentstart = strchr(opbinput->linebuf,
commentchars[i]);
1607 if( commentstart !=
NULL )
1610 nproducts = strstr(opbinput->linebuf,
"#product= ");
1611 if( nproducts !=
NULL )
1616 nproducts += strlen(
"#product= ");
1618 pos = strtok(nproducts, delimchars);
1622 SCIPdebugMsg(scip,
"%d products supposed to be in file.\n", atoi(pos));
1625 pos = strtok (
NULL, delimchars);
1627 if( pos !=
NULL && strcmp(pos,
"sizeproduct=") == 0 )
1629 pos = strtok (
NULL, delimchars);
1642 while(commentstart !=
NULL && !stop);
1644 opbinput->linebuf[0] =
'\0';
1648 (void)
SCIPfseek(opbinput->file, 0, SEEK_SET);
1651 opbinput->file =
SCIPfopen(filename,
"r");
1662 const char* filename
1665 int nNonlinearConss;
1668 assert(scip !=
NULL);
1669 assert(opbinput !=
NULL);
1672 opbinput->file =
SCIPfopen(filename,
"r");
1673 if( opbinput->file ==
NULL )
1691 nNonlinearConss = 0;
1711 assert(nvars > 0 || vars !=
NULL);
1717 for( i = nvars - 1; i >= 0; --i )
1720 topcostvars[ntopcostvars] = vars[i];
1731 (
SCIP_Real) topcostrhs,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE) );
1763 assert( scip !=
NULL );
1764 assert( vars !=
NULL );
1765 assert( nvars > 0 );
1769 for( v = nvars - 1; v >= 0; --v )
1782 for( v = nvars - 1; v >= 0; --v )
1792 if( vars[v] ==
NULL )
1794 SCIPdebugMsg(scip,
"A variable couldn't retransformed to an original variable.\n");
1805 SCIPdebugMsg(scip,
"A variable couldn't retransformed to an original variable or a negated variable of an original variable (scalar = %g, constant = %g).\n", scalar, constant);
1829 assert(scip !=
NULL);
1830 assert(vars !=
NULL);
1831 assert(scalars !=
NULL);
1832 assert(nvars !=
NULL);
1833 assert(constant !=
NULL);
1839 if( requiredsize > *nvars )
1845 assert( requiredsize <= *nvars );
1849 for( v = 0; v < *nvars; ++v )
1853 if( vars[v] ==
NULL )
1875 assert(scip !=
NULL);
1876 assert(resvars !=
NULL);
1877 assert(nresvars !=
NULL);
1878 assert(andvars !=
NULL);
1879 assert(nandvars !=
NULL);
1880 assert(existandconshdlr !=
NULL);
1881 assert(existands !=
NULL);
1890 if( conshdlr !=
NULL )
1894 int* shouldnotbeinand;
1904 *existandconshdlr =
TRUE;
1919 for( c = norigconss - 1; c >= 0; --c )
1922 assert( conshdlr !=
NULL );
1926 andconss[nandconss] = origconss[c];
1937 assert(andconss !=
NULL || nandconss == 0);
1939 *nresvars = nandconss;
1945 assert(andconss !=
NULL);
1952 for( c = nandconss - 1; c >= 0; --c )
1954 assert(andconss[c] !=
NULL);
1962 assert((*andvars)[c] !=
NULL && (*nandvars)[c] > 0);
1963 assert((*resvars)[c] !=
NULL);
1967 SCIPsortPtrPtrInt((
void**)(*resvars), (
void**)(*andvars), (*nandvars), SCIPvarComp, (*nresvars));
1977 assert(*nandvars !=
NULL || *nresvars == 0);
1978 for( r = *nresvars - 1; r >= 0; --r )
1981 shouldnotbeinand[ncontainedands] = r;
1985 while( v < (*nandvars)[r] )
2001 for( a = ncontainedands - 1; a >= 0; --a )
2002 if( shouldnotbeinand[a] == pos )
2004 SCIPwarningMessage(scip,
"This should not happen here. The and-constraint with resultant variable: ");
2017 SCIPdebugMsg(scip,
"Another and-constraint contains and-resultant:");
2021 shouldnotbeinand[ncontainedands] = pos;
2027 (*nandvars)[r] = (*nandvars)[r] + (*nandvars)[pos] - 1;
2031 for( a = (*nandvars)[pos] - 1; a >= 0; --a )
2032 (*andvars)[r][(*nandvars)[r] - a - 1] = (*andvars)[pos][a];
2050 SCIPdebugMsg(scip,
"found no and-constraint-handler\n");
2052 *existandconshdlr =
FALSE;
2065 assert( linebuffer !=
NULL );
2066 assert( linecnt !=
NULL );
2069 linebuffer[0] =
'\0';
2082 assert( scip !=
NULL );
2083 assert( linebuffer !=
NULL );
2084 assert( linecnt !=
NULL );
2086 if( (*linecnt) > 0 )
2088 linebuffer[(*linecnt)] =
'\0';
2102 const char* extension
2105 assert(scip !=
NULL);
2106 assert(linebuffer !=
NULL);
2107 assert(linecnt !=
NULL);
2108 assert(extension !=
NULL);
2114 strncat(linebuffer, extension,
OPB_MAX_LINELEN - (
unsigned int)(*linecnt) - 1);
2115 (*linecnt) += (int) strlen(extension);
2128 int const*
const nandvars,
2133 char const*
const multisymbol,
2147 assert(scip !=
NULL);
2148 assert(file !=
NULL);
2149 assert(vars !=
NULL || nvars == 0);
2150 assert(resvars !=
NULL || nresvars == 0);
2151 assert(andvars !=
NULL || nandvars ==
NULL);
2152 assert(multisymbol !=
NULL);
2161 for( v = 0; v < nvars; ++v )
2190 if( topcostcons !=
NULL )
2193 assert(conshdlr !=
NULL);
2206 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2216 if( conshdlr !=
NULL )
2225 assert(conss !=
NULL || nconss == 0);
2227 for( c = 0; c < nconss; ++c )
2236 assert(cons !=
NULL);
2241 assert(linvars !=
NULL || nlinvars == 0);
2242 topcostfound =
FALSE;
2244 for( w = 0; w < nlinvars; ++w )
2247 topcostfound =
TRUE;
2250 assert(!topcostfound);
2251 topcostfound =
FALSE;
2258 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2271 if( conshdlr !=
NULL )
2280 assert(conss !=
NULL || nconss == 0);
2282 for( c = 0; c < nconss; ++c )
2291 assert(cons !=
NULL);
2296 assert(topvars !=
NULL || ntopvars == 0);
2297 topcostfound =
FALSE;
2299 for( w = 0; w < ntopvars; ++w )
2302 topcostfound =
TRUE;
2305 assert(!topcostfound);
2306 topcostfound =
FALSE;
2313 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2327 if( conshdlr !=
NULL )
2336 assert(conss !=
NULL || nconss == 0);
2338 for( c = 0; c < nconss; ++c )
2347 assert(cons !=
NULL);
2352 assert(topvars !=
NULL || ntopvars == 0);
2353 topcostfound =
FALSE;
2355 for( w = 0; w < ntopvars; ++w )
2358 topcostfound =
TRUE;
2361 assert(!topcostfound);
2362 topcostfound =
FALSE;
2369 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2383 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2395 assert(mult * 10 > mult);
2404 SCIPinfoMessage(scip, file,
"* Obj. scale : %.15g\n", objscale * mult);
2413 SCIPdebugMsg(scip,
"print objective function multiplied with %" SCIP_LONGINT_FORMAT
"\n", mult);
2415 appendBuffer(scip, file, linebuffer, &linecnt,
"min:");
2422 for( c = nresvars - 1; c > 0; --c )
2427 for( v = nvars - 1; v >= 0; --v )
2432 assert(var !=
NULL);
2439 assert( linecnt != 0 );
2451 assert(andvars !=
NULL);
2452 assert(nandvars !=
NULL);
2453 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] !=
NULL);
2454 assert(andvars[pos][nandvars[pos] - 1] !=
NULL);
2462 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2464 for(a = nandvars[pos] - 2; a >= 0; --a )
2469 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2476 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2481 appendBuffer(scip, file, linebuffer, &linecnt,
" ;\n");
2493 char const*
const type,
2501 int const*
const nandvars,
2504 char const*
const multisymbol
2514 assert(scip !=
NULL);
2515 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2516 assert(mult !=
NULL);
2517 assert(resvars !=
NULL);
2518 assert(nresvars > 0);
2519 assert(andvars !=
NULL && nandvars !=
NULL);
2524 for( v = 0; v < nvars; ++v )
2528 if( ABS(*mult) > ABS(*mult * 10) )
2536 if( ABS(*mult) > ABS(*mult * 10) )
2542 if( ABS(*mult) != 1 )
2543 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2547 for( v = nresvars - 1; v > 0; --v )
2555 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2559 for( v = 0; v < nvars; ++v )
2564 assert( var !=
NULL );
2573 assert(andvars !=
NULL);
2574 assert(nandvars !=
NULL);
2575 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] !=
NULL);
2576 assert(andvars[pos][nandvars[pos] - 1] !=
NULL);
2582 SCIPerrorMessage(
"Integral coefficient to big (mult = %" SCIP_LONGINT_FORMAT
", value = %g, mult*value = %g, printingvalue = %" SCIP_LONGINT_FORMAT
")for printing in opb format.\n", *mult, vals[v], vals[v] * (*mult), (
SCIP_Longint)
SCIPround(scip, vals[v] * (*mult)));
2589 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2591 for(a = nandvars[pos] - 2; a >= 0; --a )
2596 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2605 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2614 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2635 int const*
const nandvars,
2638 char const*
const multisymbol
2649 assert(scip !=
NULL);
2650 assert(vars !=
NULL);
2653 assert(resvars !=
NULL);
2654 assert(nresvars > 0);
2655 assert(andvars !=
NULL && nandvars !=
NULL);
2660 activeconstant = 0.0;
2661 nactivevars = nvars;
2673 for( v = 0; v < nactivevars; ++v )
2674 activevals[v] = 1.0;
2689 retcode =
printNLRow(scip, file,
"=", activevars, activevals, nactivevars, rhs - activeconstant, resvars,
2690 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2697 retcode =
printNLRow(scip, file,
">=", activevars, activevals, nactivevars, lhs - activeconstant, resvars,
2698 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2707 retcode =
printNLRow(scip, file,
">=", activevars, activevals, nactivevars, rhs - activeconstant, resvars,
2708 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2732 const char* multisymbol
2741 assert(scip !=
NULL);
2742 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2743 assert(mult !=
NULL);
2754 for( v = 0; v < nvars; ++v )
2758 if( ABS(*mult) > ABS(*mult * 10) )
2766 if( ABS(*mult) > ABS(*mult * 10) )
2772 if( ABS(*mult) != 1 )
2773 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2779 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2783 for( v = 0; v < nvars; ++v )
2788 assert( var !=
NULL );
2794 SCIPerrorMessage(
"Integral coefficient to big (mult = %" SCIP_LONGINT_FORMAT
", value = %g, mult*value = %g, printingvalue = %" SCIP_LONGINT_FORMAT
")for printing in opb format.\n", *mult, vals[v], vals[v] * (*mult), (
SCIP_Longint)
SCIPround(scip, vals[v] * (*mult)));
2799 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2807 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2827 const char* multisymbol
2838 assert( scip !=
NULL );
2839 assert( vars !=
NULL );
2840 assert( nvars > 0 );
2841 assert( lhs <= rhs );
2846 activeconstant = 0.0;
2849 nactivevars = nvars;
2859 for( v = 0; v < nactivevars; ++v )
2860 activevals[v] = 1.0;
2875 retcode =
printRow(scip, file,
"=", activevars, activevals, nactivevars, rhs - activeconstant, weight, &mult,
2883 retcode =
printRow(scip, file,
">=", activevars, activevals, nactivevars, lhs - activeconstant, weight, &mult,
2892 retcode =
printRow(scip, file,
">=", activevars, activevals, nactivevars, rhs - activeconstant, weight, &mult,
2914 int*
const ntermvars,
2916 int const ntermvals,
2921 const char* multisymbol
2931 assert(scip !=
NULL);
2932 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2933 assert(linvars !=
NULL || nlinvars == 0);
2934 assert(linvals !=
NULL || nlinvars == 0);
2935 assert(termvars !=
NULL || ntermvals == 0);
2936 assert(ntermvars !=
NULL || ntermvals == 0);
2937 assert(termvals !=
NULL || ntermvals == 0);
2938 assert(negatedarrays !=
NULL || ntermvals == 0);
2939 assert(mult !=
NULL);
2950 for( v = 0; v < nlinvars; ++v )
2954 if( ABS(*mult) > ABS(*mult * 10) )
2961 for( v = 0; v < ntermvals; ++v )
2965 if( ABS(*mult) > ABS(*mult * 10) )
2973 if( ABS(*mult) > ABS(*mult * 10) )
2979 if( ABS(*mult) != 1 )
2980 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2983 if( indvar !=
NULL )
2989 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2993 for( v = 0; v < nlinvars; ++v )
2998 assert(var !=
NULL);
3004 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3008 for( t = 0; t < ntermvals; ++t )
3011 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3013 for( v = 0; v < ntermvars[t]; ++v )
3017 var = termvars[t][v];
3018 assert(var !=
NULL);
3020 negated = negatedarrays[t][v];
3023 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3033 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3050 int*
const ntermvars,
3052 int const ntermvals,
3057 const char* multisymbol
3070 assert(scip !=
NULL);
3071 assert(linvars !=
NULL || nlinvars == 0);
3072 assert(linvals !=
NULL || nlinvars == 0);
3073 assert(termvars !=
NULL || 0 == ntermvals);
3074 assert(ntermvars !=
NULL || 0 == ntermvals);
3075 assert(termvals !=
NULL || 0 == ntermvals);
3081 activelinconstant = 0.0;
3084 nactivelinvars = nlinvars;
3085 if( nactivelinvars > 0 )
3095 activelinvars =
NULL;
3096 activelinvals =
NULL;
3102 assert(termvars !=
NULL);
3103 assert(ntermvars !=
NULL);
3104 assert(termvals !=
NULL);
3108 for( v = ntermvals - 1; v >= 0; --v )
3110 assert(ntermvars[v] > 0);
3130 activetermvars =
NULL;
3131 negatedarrays =
NULL;
3143 retcode =
printPBRow(scip, file,
"=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3144 ntermvars, termvals, ntermvals, negatedarrays, indvar, rhs - activelinconstant, &mult, multisymbol);
3151 retcode =
printPBRow(scip, file,
">=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3152 ntermvars, termvals, ntermvals, negatedarrays, indvar, lhs - activelinconstant, &mult, multisymbol);
3160 retcode =
printPBRow(scip, file,
">=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3161 ntermvars, termvals, ntermvals, negatedarrays, indvar, rhs - activelinconstant, &mult, multisymbol);
3169 assert(negatedarrays !=
NULL);
3170 assert(activetermvars !=
NULL);
3172 for( v = 0; v < ntermvals; ++v )
3174 assert(negatedarrays[v] !=
NULL);
3175 assert(activetermvars[v] !=
NULL);
3184 if( nactivelinvars > 0 )
3205 int const*
const nandvars,
3206 char const*
const multisymbol,
3213 const char* conshdlrname;
3223 assert(scip !=
NULL);
3224 assert(file !=
NULL);
3225 assert(conss !=
NULL || nconss == 0);
3226 assert(vars !=
NULL || nvars == 0);
3227 assert(resvars !=
NULL || nresvars == 0);
3228 assert(andvars !=
NULL || nandvars == 0);
3229 assert(multisymbol !=
NULL);
3236 if( conshdlr !=
NULL )
3243 assert(indconss !=
NULL || nindconss == 0);
3251 assert(indconss !=
NULL);
3253 for( c = 0; c < nindconss; ++c )
3255 assert(indconss[c] !=
NULL);
3257 assert(lincons !=
NULL);
3268 if( conshdlr !=
NULL )
3275 assert(pbconss !=
NULL || npbconss == 0);
3284 for( c = 0; c < npbconss; ++c )
3286 assert(pbconss[c] !=
NULL);
3288 assert(lincons !=
NULL);
3306 for( c = 0; c < nconss; ++c )
3309 assert(conshdlr !=
NULL);
3313 if( strcmp(conshdlrname,
"pseudoboolean") == 0 )
3315 if( !pbhashmapcreated )
3319 pbhashmapcreated =
TRUE;
3323 assert(lincons !=
NULL);
3328 else if( strcmp(conshdlrname,
"indicator") == 0 )
3330 if( !indhashmapcreated )
3334 indhashmapcreated =
TRUE;
3338 assert(lincons !=
NULL);
3350 for( c = 0; c < nconss && retcode ==
SCIP_OKAY; ++c )
3357 assert(cons !=
NULL);
3360 assert(conshdlr !=
NULL);
3368 if( linconssofpbsmap !=
NULL )
3370 if( artcons ==
NULL && linconssofindicatorsmap !=
NULL )
3373 if( artcons ==
NULL )
3375 if( strcmp(conshdlrname,
"linear") == 0 )
3381 SCIPerrorMessage(
"Cannot print empty violated constraint %s, %g <= %g is not fulfilled\n",
3392 0LL, transformed, multisymbol);
3401 else if( strcmp(conshdlrname,
"setppc") == 0 )
3406 if( nconsvars == 0 )
3415 andvars, nandvars, 0LL, transformed, multisymbol);
3420 consvars,
NULL, nconsvars, 1.0, 1.0, 0LL, transformed, multisymbol);
3427 consvars,
NULL, nconsvars, -
SCIPinfinity(scip), 1.0, resvars, nresvars, andvars, nandvars,
3428 0LL, transformed, multisymbol);
3433 consvars,
NULL, nconsvars, -
SCIPinfinity(scip), 1.0, 0LL, transformed, multisymbol);
3440 consvars,
NULL, nconsvars, 1.0,
SCIPinfinity(scip), resvars, nresvars, andvars, nandvars,
3441 0LL, transformed, multisymbol);
3446 consvars,
NULL, nconsvars, 1.0,
SCIPinfinity(scip), 0LL, transformed, multisymbol);
3451 else if( strcmp(conshdlrname,
"logicor") == 0 )
3460 resvars, nresvars, andvars, nandvars, 0LL, transformed, multisymbol);
3466 1.0,
SCIPinfinity(scip), 0LL, transformed, multisymbol);
3469 else if( strcmp(conshdlrname,
"knapsack") == 0 )
3476 if( nconsvars == 0 )
3482 for( v = 0; v < nconsvars; ++v )
3489 0LL, transformed, multisymbol);
3499 else if( strcmp(conshdlrname,
"varbound") == 0 )
3513 SCIPgetRhsVarbound(scip, cons), resvars, nresvars, andvars, nandvars, 0LL, transformed, multisymbol);
3524 else if( strcmp(conshdlrname,
"pseudoboolean") == 0 )
3538 assert(termvarssize >= 0);
3548 for( t = termvarssize - 1; t >= 0; --t )
3576 else if( strcmp(conshdlrname,
"indicator") == 0 )
3585 assert(indvar !=
NULL);
3590 assert(indvar !=
NULL);
3606 assert(slackvar !=
NULL);
3615 assert(lincons !=
NULL);
3627 for( v = 0; v < nconsvars; ++v )
3631 if( consvars[v] == slackvar )
3633 assert(nonbinarypos == -1);
3649 if( nonbinarypos == -1 )
3671 assert(0 <= nonbinarypos && nonbinarypos < nconsvars);
3675 consvars[nonbinarypos] = consvars[nconsvars];
3676 consvals[nonbinarypos] = consvals[nconsvars];
3682 resvars, nresvars, andvars, nandvars,
3683 weight, transformed, multisymbol);
3689 weight, transformed, multisymbol);
3698 SCIPwarningMessage(scip,
"indicator constraint <%s> will not be printed because the indicator variable has no objective value(= weight of this soft constraint)\n",
SCIPconsGetName(cons) );
3704 else if( strcmp(conshdlrname,
"and") == 0 )
3708 assert(existandconshdlr);
3712 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
3722 assert(cons !=
NULL);
3724 SCIPerrorMessage(
"Cannot print constraint %s with non-integral coefficient or sides in opb-format\n",
3730 if( linconssofpbsmap !=
NULL )
3735 if( linconssofindicatorsmap !=
NULL )
3759 assert(scip !=
NULL);
3760 assert(file !=
NULL);
3761 assert(vars !=
NULL || nvars == 0);
3762 assert(printedfixing !=
NULL);
3767 for( v = 0; v < nvars; ++v )
3772 assert( vars !=
NULL );
3785 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3805 int const*
const nandvars,
3807 char const*
const multisymbol,
3818 assert(scip !=
NULL);
3819 assert(file !=
NULL);
3820 assert(resvars !=
NULL || nresvars == 0);
3821 assert(nandvars !=
NULL || nresvars == 0);
3822 assert(andvars !=
NULL || nandvars ==
NULL);
3823 assert(multisymbol !=
NULL);
3829 for( r = nresvars - 1; r >= 0; --r )
3834 assert( resvars !=
NULL );
3835 resvar = resvars[r];
3844 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3850 assert( andvars !=
NULL && nandvars !=
NULL );
3851 assert( andvars[r] !=
NULL || nandvars[r] == 0 );
3854 for( v = nandvars[r] - 1; v >= 0; --v )
3856 assert( andvars[r] !=
NULL );
3857 assert( andvars[r][v] !=
NULL );
3865 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3877 for( r = nresvars - 1; r >= 0; --r )
3879 assert( resvars !=
NULL );
3880 resvar = resvars[r];
3890 assert( andvars !=
NULL && nandvars !=
NULL );
3891 assert( andvars[r] !=
NULL || nandvars[r] == 0 );
3896 for( v = nandvars[r] - 1; v >= 0; --v )
3898 assert( andvars[r] !=
NULL );
3899 assert( andvars[r][v] !=
NULL );
3912 else if( rhslhs == 1 )
3918 assert( andvars !=
NULL && nandvars !=
NULL );
3919 assert( andvars[r] !=
NULL || nandvars[r] == 0 );
3922 for( v = nandvars[r] - 1; v >= 0; --v )
3924 assert( andvars[r] !=
NULL );
3925 assert( andvars[r][v] !=
NULL );
3949 firstprinted =
FALSE;
3951 assert( andvars !=
NULL && nandvars !=
NULL );
3952 assert( andvars[r] !=
NULL || nandvars[r] == 0 );
3954 for( v = nandvars[r] - 1; v >= 0; --v )
3956 assert( andvars[r] !=
NULL );
3957 assert( andvars[r][v] !=
NULL );
3962 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3964 firstprinted =
TRUE;
3972 assert(transformed);
3989 assert(andvars !=
NULL);
3990 assert(nandvars !=
NULL);
3991 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] !=
NULL);
3992 assert(andvars[pos][nandvars[pos] - 1] !=
NULL);
3999 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4001 for(a = nandvars[pos] - 2; a >= 0; --a )
4006 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4020 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4028 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4056 int const*
const nandvars,
4067 assert( scip !=
NULL );
4068 assert( vars !=
NULL || nvars == 0 );
4069 assert( conss !=
NULL || nconss == 0 );
4070 assert( result !=
NULL );
4079 SCIPinfoMessage(scip, file,
"* Variables : %d (all binary)\n", nvars);
4084 SCIPvarGetHashkey, SCIPvarIsHashkeyEq, SCIPvarGetHashkeyVal,
NULL) );
4088 objsense, objscale, objoffset, multisymbol, existands, transformed) );
4091 retcode =
writeOpbConstraints(scip, file, conss, nconss, vars, nvars, resvars, nresvars, andvars, nandvars,
4092 multisymbol, existandconshdlr, existands, transformed);
4094 if( existands && (retcode ==
SCIP_OKAY) )
4120 const char* filename,
4129 opbinput.file =
NULL;
4130 opbinput.linebuf[0] =
'\0';
4132 opbinput.token[0] =
'\0';
4134 opbinput.tokenbuf[0] =
'\0';
4140 opbinput.npushedtokens = 0;
4141 opbinput.linenumber = 1;
4142 opbinput.bufpos = 0;
4143 opbinput.linepos = 0;
4145 opbinput.comment =
FALSE;
4146 opbinput.endline =
FALSE;
4147 opbinput.eof =
FALSE;
4148 opbinput.haserror =
FALSE;
4149 opbinput.nproblemcoeffs = 0;
4150 opbinput.wbo =
FALSE;
4152 opbinput.nindvars = 0;
4153 #if GENCONSNAMES == TRUE 4154 opbinput.consnumber = 0;
4161 for( i = OPB_MAX_PUSHEDTOKENS - 1; i >= 0; --i )
4173 if( opbinput.nproblemcoeffs > 0 )
4175 SCIPwarningMessage(scip,
"there might be <%d> coefficients or weight out of range!\n", opbinput.nproblemcoeffs);
4179 if( opbinput.haserror )
4242 for( v = nvars - 1; v >= 0; --v )
4254 retcode =
writeOpb(scip, file, name, transformed, objsense, objscale, objoffset, vars,
4255 nvars, conss, nconss, resvars, nresvars, andvars, nandvars, existandconshdlr, existands, result);
4266 for( v = nvars - 1; v >= 0; --v )
4267 if( !existands || !
SCIPsortedvecFindPtr((
void**)resvars, SCIPvarComp, vars[v], nresvars, &pos) )
4271 SCIPwarningMessage(scip,
"At least following variable name isn't allowed in opb format.\n");
4277 SCIPwarningMessage(scip,
"write transformed problem with generic variable names.\n");
4293 for( v = nfixedvars - 1; v >= 0; --v )
4294 if( !existands || !
SCIPsortedvecFindPtr((
void**)resvars, SCIPvarComp, vars[v], nresvars, &pos) )
4298 SCIPwarningMessage(scip,
"At least following variable name isn't allowed in opb format.\n");
4304 SCIPwarningMessage(scip,
"write transformed problem with generic variable names.\n");
4321 for( v = nvars - 1; v >= 0; --v )
4332 retcode =
writeOpb(scip, file, name, transformed, objsense, objscale, objoffset, vars,
4333 nvars, conss, nconss, resvars, nresvars, andvars, nandvars, existandconshdlr, existands, result);
4340 assert(resvars !=
NULL);
4341 assert(andvars !=
NULL);
4342 assert(nandvars !=
NULL);
4344 for( v = nresvars - 1; v >= 0; --v )
4346 assert(andvars[v] !=
NULL);
4372 assert(reader !=
NULL);
4399 nvars, nbinvars, nintvars, nimplvars, ncontvars, fixedvars, nfixedvars, conss, nconss, genericnames, result) );
4425 "reading/" READER_NAME "/dynamicconss",
"should model constraints be subject to aging?",
4428 "reading/" READER_NAME "/multisymbol",
"use '*' between coefficients and variables by writing to problem?",
enum SCIP_Result SCIP_RESULT
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPincludeReaderOpb(SCIP *scip)
#define ARTIFICIALVARNAMEPREFIX
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
static void swapTokenBuffer(OPBINPUT *opbinput)
int SCIPmemccpy(char *dest, const char *src, char stop, unsigned int cnt)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPgetBinvarRepresentative(SCIP *scip, SCIP_VAR *var, SCIP_VAR **repvar, SCIP_Bool *negated)
static SCIP_RETCODE printNLRow(SCIP *const scip, FILE *const file, char const *const type, SCIP_VAR **const vars, SCIP_Real const *const vals, int const nvars, SCIP_Real lhs, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Longint weight, SCIP_Longint *const mult, char const *const multisymbol)
Constraint handler for variable bound constraints .
static SCIP_RETCODE writeOpb(SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, int nconss, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Bool const existandconshdlr, SCIP_Bool const existands, SCIP_RESULT *result)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_RETCODE SCIPgetAndDatasPseudoboolean(SCIP *const scip, SCIP_CONS *const cons, SCIP_CONS **const andconss, SCIP_Real *const andcoefs, int *const nandconss)
static SCIP_RETCODE readCoefficients(SCIP *const scip, OPBINPUT *const opbinput, char *const name, SCIP_VAR ***linvars, SCIP_Real **lincoefs, int *const nlincoefs, SCIP_VAR ****terms, SCIP_Real **termcoefs, int **ntermvars, int *const ntermcoefs, SCIP_Bool *const newsection, SCIP_Bool *const isNonlinear, SCIP_Bool *const issoftcons, SCIP_Real *const weight)
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool isDelimChar(char c)
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)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define INDICATORSLACKVARNAME
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPprintTransProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
static SCIP_RETCODE getMaxAndConsDim(SCIP *scip, OPBINPUT *opbinput, const char *filename)
static SCIP_RETCODE getBinVarsRepresentatives(SCIP *const scip, SCIP_VAR **const vars, int const nvars, SCIP_Bool const transformed)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
constraint handler for indicator constraints
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
#define OPB_INIT_COEFSSIZE
void SCIPsortPtrPtrInt(void **ptrarray1, void **ptrarray2, int *intarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_RETCODE SCIPcreateConsPseudoboolean(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR **linvars, int nlinvars, SCIP_Real *linvals, SCIP_VAR ***terms, int nterms, int *ntermvars, SCIP_Real *termvals, SCIP_VAR *indvar, SCIP_Real weight, SCIP_Bool issoftcons, SCIP_VAR *intvar, 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_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE printPBRow(SCIP *const scip, FILE *const file, const char *type, SCIP_VAR **const linvars, SCIP_Real *const linvals, int const nlinvars, SCIP_VAR ***const termvars, int *const ntermvars, SCIP_Real *const termvals, int const ntermvals, SCIP_Bool **const negatedarrays, SCIP_VAR *const indvar, SCIP_Real lhs, SCIP_Longint *mult, const char *multisymbol)
static void pushBufferToken(OPBINPUT *opbinput)
static SCIP_DECL_READERCOPY(readerCopyOpb)
enum OpbExpType OPBEXPTYPE
Constraint handler for AND constraints, .
#define SCIPduplicateBufferArray(scip, ptr, source, num)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VAR * SCIPgetIndVarPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPreadOpb(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPdebugPrintCons(x, y, z)
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
static SCIP_RETCODE writeOpbConstraints(SCIP *const scip, FILE *const file, SCIP_CONS **const conss, int const nconss, SCIP_VAR **const vars, int const nvars, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, char const *const multisymbol, SCIP_Bool const existandconshdlr, SCIP_Bool const existands, SCIP_Bool const transformed)
int SCIPfseek(SCIP_FILE *stream, long offset, int whence)
#define SCIPdebugMsgPrint
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
static SCIP_RETCODE createVariable(SCIP *scip, SCIP_VAR **var, char *name)
static SCIP_DECL_READERREAD(readerReadOpb)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
SCIP_VAR * SCIPgetSlackVarIndicator(SCIP_CONS *cons)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Constraint handler for knapsack constraints of the form , x binary and .
static void clearBuffer(char *linebuffer, int *linecnt)
SCIP_VAR ** SCIPgetVarsAnd(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool isEndingSoftConstraintWeight(SCIP *scip, OPBINPUT *opbinput)
SCIP_RETCODE SCIPgetBinvarRepresentatives(SCIP *scip, int nvars, SCIP_VAR **vars, SCIP_VAR **repvars, SCIP_Bool *negated)
SCIP_RETCODE SCIPcreateConsAnd(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *resvar, int nvars, SCIP_VAR **vars, 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)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetResultantAnd(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
static const char delimchars[]
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_RETCODE SCIPwriteOpb(SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_VAR **fixedvars, int nfixedvars, SCIP_CONS **conss, int nconss, SCIP_Bool genericnames, SCIP_RESULT *result)
int SCIPfeof(SCIP_FILE *stream)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
struct SCIP_File SCIP_FILE
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
SCIP_Bool SCIPsortedvecFindPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *val, int len, int *pos)
const char * SCIPconsGetName(SCIP_CONS *cons)
static SCIP_Bool isEndLine(OPBINPUT *opbinput)
SCIPInterval sign(const SCIPInterval &x)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
const char * SCIPvarGetName(SCIP_VAR *var)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_RETCODE SCIPgetLinDatasWithoutAndPseudoboolean(SCIP *const scip, SCIP_CONS *const cons, SCIP_VAR **const linvars, SCIP_Real *const lincoefs, int *const nlinvars)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
int SCIPgetNLinVarsWithoutAndPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
static void pushToken(OPBINPUT *opbinput)
static SCIP_Bool isValue(SCIP *scip, OPBINPUT *opbinput, SCIP_Real *value)
int SCIPgetNOrigConss(SCIP *scip)
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_Bool isTokenChar(char c)
SCIP_Real SCIPgetLhsPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
static SCIP_RETCODE printRow(SCIP *scip, FILE *file, const char *type, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Longint weight, SCIP_Longint *mult, const char *multisymbol)
#define SCIPdebugGetSolVal(scip, var, val)
static SCIP_Bool isSign(OPBINPUT *opbinput, int *sign)
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
static const char commentchars[]
SCIP_Longint SCIPgetCapacityKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
#define SCIPallocBufferArray(scip, ptr, num)
public data structures and miscellaneous methods
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
static SCIP_Bool getNextLine(SCIP *scip, OPBINPUT *opbinput)
void SCIPprintSysError(const char *message)
enum SCIP_Objsense SCIP_OBJSENSE
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, OPBEXPTYPE *exptype)
static SCIP_RETCODE writeOpbRelevantAnds(SCIP *const scip, FILE *const file, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_HASHTABLE *const printedfixing, char const *const multisymbol, SCIP_Bool const transformed)
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNAndsPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
static SCIP_RETCODE printNonLinearCons(SCIP *const scip, FILE *const file, SCIP_VAR **const vars, SCIP_Real *const vals, int const nvars, SCIP_Real const lhs, SCIP_Real const rhs, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_Longint weight, SCIP_Bool const transformed, char const *const multisymbol)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
static void swapPointers(char **pointer1, char **pointer2)
SCIP_CONS * SCIPgetLinearConsPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
static SCIP_RETCODE readConstraints(SCIP *scip, OPBINPUT *opbinput, int *nNonlinearConss)
static void appendBuffer(SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *extension)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
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)
static SCIP_Bool isSense(OPBINPUT *opbinput, OPBSENSE *sense)
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
static SCIP_Bool getNextToken(SCIP *scip, OPBINPUT *opbinput)
SCIP_RETCODE SCIPchgVarBranchPriority(SCIP *scip, SCIP_VAR *var, int branchpriority)
#define SCIPallocMemoryArray(scip, ptr, num)
Constraint handler for linear constraints in their most general form, .
static SCIP_RETCODE computeAndConstraintInfos(SCIP *const scip, SCIP_Bool const transformed, SCIP_VAR ***resvars, int *nresvars, SCIP_VAR ****andvars, int **nandvars, SCIP_Bool *const existandconshdlr, SCIP_Bool *const existands)
static SCIP_RETCODE printPseudobooleanCons(SCIP *const scip, FILE *const file, SCIP_VAR **const linvars, SCIP_Real *const linvals, int const nlinvars, SCIP_VAR ***const termvars, int *const ntermvars, SCIP_Real *const termvals, int const ntermvals, SCIP_VAR *const indvar, SCIP_Real const lhs, SCIP_Real const rhs, SCIP_Bool transformed, const char *multisymbol)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
SCIP_VAR * SCIPgetBinaryVarIndicator(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
int SCIPgetNVars(SCIP *scip)
static SCIP_Bool hasError(OPBINPUT *opbinput)
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_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
static void writeBuffer(SCIP *scip, FILE *file, char *linebuffer, int *linecnt)
pseudo-Boolean file reader (opb format)
static const SCIP_Real scalars[]
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE getVariableOrTerm(SCIP *scip, OPBINPUT *opbinput, SCIP_VAR ***vars, int *nvars, int *varssize)
static SCIP_RETCODE writeOpbFixedVars(SCIP *const scip, FILE *const file, SCIP_VAR **vars, int nvars, SCIP_HASHTABLE *const printedfixing)
int SCIPgetNConss(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
#define OPB_MAX_PUSHEDTOKENS
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
static SCIP_RETCODE setObjective(SCIP *const scip, OPBINPUT *const opbinput, const char *sense, SCIP_VAR **const linvars, SCIP_Real *const coefs, int const ncoefs, SCIP_VAR ***const terms, SCIP_Real *const termcoefs, int *const ntermvars, int const ntermcoefs)
static void syntaxError(SCIP *scip, OPBINPUT *opbinput, const char *msg)
int SCIPgetNVarsAnd(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
int SCIPvarGetIndex(SCIP_VAR *var)
#define SCIPdebugAddSolVal(scip, var, val)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
constraint handler for pseudoboolean constraints
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE writeOpbObjective(SCIP *const scip, FILE *const file, SCIP_VAR **const vars, int const nvars, SCIP_VAR **const resvars, int const nresvars, SCIP_VAR **const *const andvars, int const *const nandvars, SCIP_OBJSENSE const objsense, SCIP_Real const objscale, SCIP_Real const objoffset, char const *const multisymbol, SCIP_Bool const existands, SCIP_Bool const transformed)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
#define BMSclearMemoryArray(ptr, num)
int SCIPfclose(SCIP_FILE *fp)
static SCIP_RETCODE readOPBFile(SCIP *scip, OPBINPUT *opbinput, const char *filename)
SCIP_CONS * SCIPgetLinearConsIndicator(SCIP_CONS *cons)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERWRITE(readerWriteOpb)
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE printLinearCons(SCIP *scip, FILE *file, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, SCIP_Longint weight, SCIP_Bool transformed, const char *multisymbol)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
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)
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
#define SCIPreallocBufferArray(scip, ptr, num)
SCIP_Real SCIPgetRhsPseudoboolean(SCIP *const scip, SCIP_CONS *const cons)
static SCIP_Bool isStartingSoftConstraintWeight(SCIP *scip, OPBINPUT *opbinput)