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);
707 initial, removable, NULL, NULL, NULL, NULL, NULL) );
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);
1203 TRUE,
TRUE, NULL, NULL, NULL, NULL, NULL) );
1214 #ifdef WITH_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 )
1272 TRUE,
TRUE, NULL, NULL, NULL, NULL, NULL) );
1282 #ifdef WITH_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 )
1956 assert(andconss[c] != NULL);
1965 assert((*andvars)[c] != NULL && (*nandvars)[c] > 0);
1966 assert((*resvars)[c] != NULL);
1970 SCIPsortPtrPtrInt((
void**)(*resvars), (
void**)(*andvars), (*nandvars), SCIPvarComp, (*nresvars));
1980 assert(*nandvars != NULL || *nresvars == 0);
1981 for( r = *nresvars - 1; r >= 0; --r )
1984 shouldnotbeinand[ncontainedands] = r;
1988 while( v < (*nandvars)[r] )
2004 for( a = ncontainedands - 1; a >= 0; --a )
2005 if( shouldnotbeinand[a] == pos )
2007 SCIPwarningMessage(scip,
"This should not happen here. The and-constraint with resultant variable: ");
2020 SCIPdebugMsg(scip,
"Another and-constraint contains and-resultant:");
2024 shouldnotbeinand[ncontainedands] = pos;
2030 (*nandvars)[r] = (*nandvars)[r] + (*nandvars)[pos] - 1;
2034 for( a = (*nandvars)[pos] - 1; a >= 0; --a )
2035 (*andvars)[r][(*nandvars)[r] - a - 1] = (*andvars)[pos][a];
2053 SCIPdebugMsg(scip,
"found no and-constraint-handler\n");
2055 *existandconshdlr =
FALSE;
2068 assert( linebuffer != NULL );
2069 assert( linecnt != NULL );
2072 linebuffer[0] =
'\0';
2085 assert( scip != NULL );
2086 assert( linebuffer != NULL );
2087 assert( linecnt != NULL );
2089 if( (*linecnt) > 0 )
2091 linebuffer[(*linecnt)] =
'\0';
2105 const char* extension
2108 assert(scip != NULL);
2109 assert(linebuffer != NULL);
2110 assert(linecnt != NULL);
2111 assert(extension != NULL);
2117 strncat(linebuffer, extension,
OPB_MAX_LINELEN - (
unsigned int)(*linecnt) - 1);
2118 (*linecnt) += (int) strlen(extension);
2131 int const*
const nandvars,
2136 char const*
const multisymbol,
2150 assert(scip != NULL);
2151 assert(file != NULL);
2152 assert(vars != NULL || nvars == 0);
2153 assert(resvars != NULL || nresvars == 0);
2154 assert(andvars != NULL || nandvars == NULL);
2155 assert(multisymbol != NULL);
2164 for( v = 0; v < nvars; ++v )
2193 if( topcostcons != NULL )
2196 assert(conshdlr != NULL);
2209 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2219 if( conshdlr != NULL )
2228 assert(conss != NULL || nconss == 0);
2230 for( c = 0; c < nconss; ++c )
2239 assert(cons != NULL);
2244 assert(linvars != NULL || nlinvars == 0);
2245 topcostfound =
FALSE;
2247 for( w = 0; w < nlinvars; ++w )
2250 topcostfound =
TRUE;
2253 assert(!topcostfound);
2254 topcostfound =
FALSE;
2261 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2274 if( conshdlr != NULL )
2283 assert(conss != NULL || nconss == 0);
2285 for( c = 0; c < nconss; ++c )
2294 assert(cons != NULL);
2299 assert(topvars != NULL || ntopvars == 0);
2300 topcostfound =
FALSE;
2302 for( w = 0; w < ntopvars; ++w )
2305 topcostfound =
TRUE;
2308 assert(!topcostfound);
2309 topcostfound =
FALSE;
2316 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2330 if( conshdlr != NULL )
2339 assert(conss != NULL || nconss == 0);
2341 for( c = 0; c < nconss; ++c )
2350 assert(cons != NULL);
2355 assert(topvars != NULL || ntopvars == 0);
2356 topcostfound =
FALSE;
2358 for( w = 0; w < ntopvars; ++w )
2361 topcostfound =
TRUE;
2364 assert(!topcostfound);
2365 topcostfound =
FALSE;
2372 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2386 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2398 assert(mult * 10 > mult);
2407 SCIPinfoMessage(scip, file,
"* Obj. scale : %.15g\n", objscale * mult);
2416 SCIPdebugMsg(scip,
"print objective function multiplied with %" SCIP_LONGINT_FORMAT
"\n", mult);
2418 appendBuffer(scip, file, linebuffer, &linecnt,
"min:");
2425 for( c = nresvars - 1; c > 0; --c )
2430 for( v = nvars - 1; v >= 0; --v )
2435 assert(var != NULL);
2442 assert( linecnt != 0 );
2454 assert(andvars != NULL);
2455 assert(nandvars != NULL);
2456 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] != NULL);
2457 assert(andvars[pos][nandvars[pos] - 1] != NULL);
2465 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2467 for(a = nandvars[pos] - 2; a >= 0; --a )
2472 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2479 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2484 appendBuffer(scip, file, linebuffer, &linecnt,
" ;\n");
2496 char const*
const type,
2504 int const*
const nandvars,
2507 char const*
const multisymbol
2517 assert(scip != NULL);
2518 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2519 assert(mult != NULL);
2520 assert(resvars != NULL);
2521 assert(nresvars > 0);
2522 assert(andvars != NULL && nandvars != NULL);
2527 for( v = 0; v < nvars; ++v )
2531 if( ABS(*mult) > ABS(*mult * 10) )
2539 if( ABS(*mult) > ABS(*mult * 10) )
2545 if( ABS(*mult) != 1 )
2546 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2550 for( v = nresvars - 1; v > 0; --v )
2558 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2562 for( v = 0; v < nvars; ++v )
2567 assert( var != NULL );
2576 assert(andvars != NULL);
2577 assert(nandvars != NULL);
2578 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] != NULL);
2579 assert(andvars[pos][nandvars[pos] - 1] != NULL);
2585 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)));
2592 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2594 for(a = nandvars[pos] - 2; a >= 0; --a )
2599 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2608 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2617 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2638 int const*
const nandvars,
2641 char const*
const multisymbol
2652 assert(scip != NULL);
2653 assert(vars != NULL);
2656 assert(resvars != NULL);
2657 assert(nresvars > 0);
2658 assert(andvars != NULL && nandvars != NULL);
2663 activeconstant = 0.0;
2664 nactivevars = nvars;
2676 for( v = 0; v < nactivevars; ++v )
2677 activevals[v] = 1.0;
2692 retcode =
printNLRow(scip, file,
"=", activevars, activevals, nactivevars, rhs - activeconstant, resvars,
2693 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2700 retcode =
printNLRow(scip, file,
">=", activevars, activevals, nactivevars, lhs - activeconstant, resvars,
2701 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2710 retcode =
printNLRow(scip, file,
">=", activevars, activevals, nactivevars, rhs - activeconstant, resvars,
2711 nresvars, andvars, nandvars, weight, &mult, multisymbol);
2735 const char* multisymbol
2744 assert(scip != NULL);
2745 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2746 assert(mult != NULL);
2757 for( v = 0; v < nvars; ++v )
2761 if( ABS(*mult) > ABS(*mult * 10) )
2769 if( ABS(*mult) > ABS(*mult * 10) )
2775 if( ABS(*mult) != 1 )
2776 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2782 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2786 for( v = 0; v < nvars; ++v )
2791 assert( var != NULL );
2797 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)));
2802 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2810 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2830 const char* multisymbol
2841 assert( scip != NULL );
2842 assert( vars != NULL );
2843 assert( nvars > 0 );
2844 assert( lhs <= rhs );
2849 activeconstant = 0.0;
2852 nactivevars = nvars;
2862 for( v = 0; v < nactivevars; ++v )
2863 activevals[v] = 1.0;
2878 retcode =
printRow(scip, file,
"=", activevars, activevals, nactivevars, rhs - activeconstant, weight, &mult,
2886 retcode =
printRow(scip, file,
">=", activevars, activevals, nactivevars, lhs - activeconstant, weight, &mult,
2895 retcode =
printRow(scip, file,
">=", activevars, activevals, nactivevars, rhs - activeconstant, weight, &mult,
2917 int*
const ntermvars,
2919 int const ntermvals,
2924 const char* multisymbol
2934 assert(scip != NULL);
2935 assert(strcmp(type,
"=") == 0 || strcmp(type,
">=") == 0);
2936 assert(linvars != NULL || nlinvars == 0);
2937 assert(linvals != NULL || nlinvars == 0);
2938 assert(termvars != NULL || ntermvals == 0);
2939 assert(ntermvars != NULL || ntermvals == 0);
2940 assert(termvals != NULL || ntermvals == 0);
2941 assert(negatedarrays != NULL || ntermvals == 0);
2942 assert(mult != NULL);
2953 for( v = 0; v < nlinvars; ++v )
2957 if( ABS(*mult) > ABS(*mult * 10) )
2964 for( v = 0; v < ntermvals; ++v )
2968 if( ABS(*mult) > ABS(*mult * 10) )
2976 if( ABS(*mult) > ABS(*mult * 10) )
2982 if( ABS(*mult) != 1 )
2983 SCIPinfoMessage(scip, file,
"* the following constraint is multiplied by %" SCIP_LONGINT_FORMAT
" to get integral coefficients\n", ABS(*mult) );
2986 if( indvar != NULL )
2992 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
2996 for( v = 0; v < nlinvars; ++v )
3001 assert(var != NULL);
3007 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3011 for( t = 0; t < ntermvals; ++t )
3014 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3016 for( v = 0; v < ntermvars[t]; ++v )
3020 var = termvars[t][v];
3021 assert(var != NULL);
3023 negated = negatedarrays[t][v];
3026 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3036 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3053 int*
const ntermvars,
3055 int const ntermvals,
3060 const char* multisymbol
3073 assert(scip != NULL);
3074 assert(linvars != NULL || nlinvars == 0);
3075 assert(linvals != NULL || nlinvars == 0);
3076 assert(termvars != NULL || 0 == ntermvals);
3077 assert(ntermvars != NULL || 0 == ntermvals);
3078 assert(termvals != NULL || 0 == ntermvals);
3084 activelinconstant = 0.0;
3087 nactivelinvars = nlinvars;
3088 if( nactivelinvars > 0 )
3098 activelinvars = NULL;
3099 activelinvals = NULL;
3105 assert(termvars != NULL);
3106 assert(ntermvars != NULL);
3107 assert(termvals != NULL);
3111 for( v = ntermvals - 1; v >= 0; --v )
3113 assert(ntermvars[v] > 0);
3133 activetermvars = NULL;
3134 negatedarrays = NULL;
3146 retcode =
printPBRow(scip, file,
"=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3147 ntermvars, termvals, ntermvals, negatedarrays, indvar, rhs - activelinconstant, &mult, multisymbol);
3154 retcode =
printPBRow(scip, file,
">=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3155 ntermvars, termvals, ntermvals, negatedarrays, indvar, lhs - activelinconstant, &mult, multisymbol);
3163 retcode =
printPBRow(scip, file,
">=", activelinvars, activelinvals, nactivelinvars, activetermvars,
3164 ntermvars, termvals, ntermvals, negatedarrays, indvar, rhs - activelinconstant, &mult, multisymbol);
3172 assert(negatedarrays != NULL);
3173 assert(activetermvars != NULL);
3175 for( v = 0; v < ntermvals; ++v )
3177 assert(negatedarrays[v] != NULL);
3178 assert(activetermvars[v] != NULL);
3187 if( nactivelinvars > 0 )
3208 int const*
const nandvars,
3209 char const*
const multisymbol,
3216 const char* conshdlrname;
3226 assert(scip != NULL);
3227 assert(file != NULL);
3228 assert(conss != NULL || nconss == 0);
3229 assert(vars != NULL || nvars == 0);
3230 assert(resvars != NULL || nresvars == 0);
3231 assert(andvars != NULL || nandvars == 0);
3232 assert(multisymbol != NULL);
3239 if( conshdlr != NULL )
3246 assert(indconss != NULL || nindconss == 0);
3254 assert(indconss != NULL);
3256 for( c = 0; c < nindconss; ++c )
3258 assert(indconss[c] != NULL);
3260 assert(lincons != NULL);
3271 if( conshdlr != NULL )
3278 assert(pbconss != NULL || npbconss == 0);
3287 for( c = 0; c < npbconss; ++c )
3289 assert(pbconss[c] != NULL);
3291 assert(lincons != NULL);
3309 for( c = 0; c < nconss; ++c )
3312 assert(conshdlr != NULL);
3316 if( strcmp(conshdlrname,
"pseudoboolean") == 0 )
3318 if( !pbhashmapcreated )
3322 pbhashmapcreated =
TRUE;
3326 assert(lincons != NULL);
3331 else if( strcmp(conshdlrname,
"indicator") == 0 )
3333 if( !indhashmapcreated )
3337 indhashmapcreated =
TRUE;
3341 assert(lincons != NULL);
3353 for( c = 0; c < nconss && retcode ==
SCIP_OKAY; ++c )
3360 assert(cons != NULL);
3363 assert(conshdlr != NULL);
3371 if( linconssofpbsmap != NULL )
3373 if( artcons == NULL && linconssofindicatorsmap != NULL )
3376 if( artcons == NULL )
3378 if( strcmp(conshdlrname,
"linear") == 0 )
3384 SCIPerrorMessage(
"Cannot print empty violated constraint %s, %g <= %g is not fulfilled\n",
3395 0LL, transformed, multisymbol);
3404 else if( strcmp(conshdlrname,
"setppc") == 0 )
3409 if( nconsvars == 0 )
3417 retcode =
printNonLinearCons(scip, file, consvars, NULL, nconsvars, 1.0, 1.0, resvars, nresvars,
3418 andvars, nandvars, 0LL, transformed, multisymbol);
3423 consvars, NULL, nconsvars, 1.0, 1.0, 0LL, transformed, multisymbol);
3430 consvars, NULL, nconsvars, -
SCIPinfinity(scip), 1.0, resvars, nresvars, andvars, nandvars,
3431 0LL, transformed, multisymbol);
3436 consvars, NULL, nconsvars, -
SCIPinfinity(scip), 1.0, 0LL, transformed, multisymbol);
3443 consvars, NULL, nconsvars, 1.0,
SCIPinfinity(scip), resvars, nresvars, andvars, nandvars,
3444 0LL, transformed, multisymbol);
3449 consvars, NULL, nconsvars, 1.0,
SCIPinfinity(scip), 0LL, transformed, multisymbol);
3454 else if( strcmp(conshdlrname,
"logicor") == 0 )
3463 resvars, nresvars, andvars, nandvars, 0LL, transformed, multisymbol);
3469 1.0,
SCIPinfinity(scip), 0LL, transformed, multisymbol);
3472 else if( strcmp(conshdlrname,
"knapsack") == 0 )
3479 if( nconsvars == 0 )
3485 for( v = 0; v < nconsvars; ++v )
3492 0LL, transformed, multisymbol);
3502 else if( strcmp(conshdlrname,
"varbound") == 0 )
3516 SCIPgetRhsVarbound(scip, cons), resvars, nresvars, andvars, nandvars, 0LL, transformed, multisymbol);
3527 else if( strcmp(conshdlrname,
"pseudoboolean") == 0 )
3541 assert(termvarssize >= 0);
3551 for( t = termvarssize - 1; t >= 0; --t )
3579 else if( strcmp(conshdlrname,
"indicator") == 0 )
3588 assert(indvar != NULL);
3593 assert(indvar != NULL);
3609 assert(slackvar != NULL);
3620 assert(lincons != NULL);
3634 for( v = 0; v < nconsvars; ++v )
3638 if( consvars[v] == slackvar )
3640 assert(nonbinarypos == -1);
3656 if( nonbinarypos == -1 )
3678 assert(0 <= nonbinarypos && nonbinarypos < nconsvars);
3682 consvars[nonbinarypos] = consvars[nconsvars];
3683 consvals[nonbinarypos] = consvals[nconsvars];
3689 resvars, nresvars, andvars, nandvars,
3690 weight, transformed, multisymbol);
3696 weight, transformed, multisymbol);
3705 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) );
3711 else if( strcmp(conshdlrname,
"and") == 0 )
3715 assert(existandconshdlr);
3719 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
3729 assert(cons != NULL);
3731 SCIPerrorMessage(
"Cannot print constraint %s with non-integral coefficient or sides in opb-format\n",
3737 if( linconssofpbsmap != NULL )
3742 if( linconssofindicatorsmap != NULL )
3759 char const*
const multisymbol,
3768 assert(scip != NULL);
3769 assert(file != NULL);
3770 assert(vars != NULL || nvars == 0);
3771 assert(printedfixing != NULL);
3772 assert(multisymbol != NULL);
3777 for( v = 0; v < nvars; ++v )
3784 assert( vars != NULL );
3798 assert(lb > -0.5 && ub < 1.5);
3803 if( lb > 0.5 || ub < 0.5 )
3813 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3833 int const*
const nandvars,
3835 char const*
const multisymbol,
3846 assert(scip != NULL);
3847 assert(file != NULL);
3848 assert(resvars != NULL || nresvars == 0);
3849 assert(nandvars != NULL || nresvars == 0);
3850 assert(andvars != NULL || nandvars == NULL);
3851 assert(multisymbol != NULL);
3857 for( r = nresvars - 1; r >= 0; --r )
3864 assert( resvars != NULL );
3865 resvar = resvars[r];
3880 if( lb > 0.5 || ub < 0.5 )
3886 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3892 assert( andvars != NULL && nandvars != NULL );
3893 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 );
3913 if( lb > 0.5 || ub < 0.5 )
3919 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
3931 for( r = nresvars - 1; r >= 0; --r )
3933 assert( resvars != NULL );
3934 resvar = resvars[r];
3944 assert( andvars != NULL && nandvars != NULL );
3945 assert( andvars[r] != NULL || nandvars[r] == 0 );
3950 for( v = nandvars[r] - 1; v >= 0; --v )
3952 assert( andvars[r] != NULL );
3953 assert( andvars[r][v] != NULL );
3966 else if( rhslhs == 1 )
3972 assert( andvars != NULL && nandvars != NULL );
3973 assert( andvars[r] != NULL || nandvars[r] == 0 );
3976 for( v = nandvars[r] - 1; v >= 0; --v )
3978 assert( andvars[r] != NULL );
3979 assert( andvars[r][v] != NULL );
4003 firstprinted =
FALSE;
4005 assert( andvars != NULL && nandvars != NULL );
4006 assert( andvars[r] != NULL || nandvars[r] == 0 );
4008 for( v = nandvars[r] - 1; v >= 0; --v )
4010 assert( andvars[r] != NULL );
4011 assert( andvars[r][v] != NULL );
4016 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4018 firstprinted =
TRUE;
4026 assert(transformed);
4043 assert(andvars != NULL);
4044 assert(nandvars != NULL);
4045 assert(pos >= 0 && nandvars[pos] > 0 && andvars[pos] != NULL);
4046 assert(andvars[pos][nandvars[pos] - 1] != NULL);
4053 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4055 for(a = nandvars[pos] - 2; a >= 0; --a )
4060 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4074 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4082 appendBuffer(scip, file, linebuffer, &linecnt, buffer);
4110 int const*
const nandvars,
4121 assert( scip != NULL );
4122 assert( vars != NULL || nvars == 0 );
4123 assert( conss != NULL || nconss == 0 );
4124 assert( result != NULL );
4133 SCIPinfoMessage(scip, file,
"* Variables : %d (all binary)\n", nvars);
4138 SCIPvarGetHashkey, SCIPvarIsHashkeyEq, SCIPvarGetHashkeyVal, NULL) );
4142 objsense, objscale, objoffset, multisymbol, existands, transformed) );
4145 retcode =
writeOpbConstraints(scip, file, conss, nconss, vars, nvars, resvars, nresvars, andvars, nandvars,
4146 multisymbol, existandconshdlr, existands, transformed);
4148 if( existands && (retcode ==
SCIP_OKAY) )
4174 const char* filename,
4183 opbinput.file = NULL;
4184 opbinput.linebuf[0] =
'\0';
4186 opbinput.token[0] =
'\0';
4188 opbinput.tokenbuf[0] =
'\0';
4194 opbinput.npushedtokens = 0;
4195 opbinput.linenumber = 1;
4196 opbinput.bufpos = 0;
4197 opbinput.linepos = 0;
4199 opbinput.comment =
FALSE;
4200 opbinput.endline =
FALSE;
4201 opbinput.eof =
FALSE;
4202 opbinput.haserror =
FALSE;
4203 opbinput.nproblemcoeffs = 0;
4204 opbinput.wbo =
FALSE;
4206 opbinput.nindvars = 0;
4207 #if GENCONSNAMES == TRUE 4208 opbinput.consnumber = 0;
4215 for( i = OPB_MAX_PUSHEDTOKENS - 1; i >= 0; --i )
4227 if( opbinput.nproblemcoeffs > 0 )
4229 SCIPwarningMessage(scip,
"there might be <%d> coefficients or weight out of range!\n", opbinput.nproblemcoeffs);
4233 if( opbinput.haserror )
4271 if( nvars != nbinvars && (nintvars > 0 ||
SCIPfindConshdlr(scip,
"indicator") != NULL
4297 for( v = nvars - 1; v >= 0; --v )
4309 retcode =
writeOpb(scip, file, name, transformed, objsense, objscale, objoffset, vars,
4310 nvars, conss, nconss, resvars, nresvars, andvars, nandvars, existandconshdlr, existands, result);
4321 for( v = nvars - 1; v >= 0; --v )
4322 if( !existands || !
SCIPsortedvecFindPtr((
void**)resvars, SCIPvarComp, vars[v], nresvars, &pos) )
4326 SCIPwarningMessage(scip,
"At least following variable name isn't allowed in opb format.\n");
4332 SCIPwarningMessage(scip,
"write transformed problem with generic variable names.\n");
4348 for( v = nfixedvars - 1; v >= 0; --v )
4349 if( !existands || !
SCIPsortedvecFindPtr((
void**)resvars, SCIPvarComp, vars[v], nresvars, &pos) )
4353 SCIPwarningMessage(scip,
"At least following variable name isn't allowed in opb format.\n");
4359 SCIPwarningMessage(scip,
"write transformed problem with generic variable names.\n");
4376 for( v = nvars - 1; v >= 0; --v )
4387 retcode =
writeOpb(scip, file, name, transformed, objsense, objscale, objoffset, vars,
4388 nvars, conss, nconss, resvars, nresvars, andvars, nandvars, existandconshdlr, existands, result);
4395 assert(resvars != NULL);
4396 assert(andvars != NULL);
4397 assert(nandvars != NULL);
4399 for( v = nresvars - 1; v >= 0; --v )
4401 assert(andvars[v] != NULL);
4426 assert(
scip != NULL);
4427 assert(reader != NULL);
4454 nvars, nbinvars, nintvars, nimplvars, ncontvars, fixedvars, nfixedvars, conss, nconss, genericnames, result) );
4480 "reading/" READER_NAME "/dynamicconss",
"should model constraints be subject to aging?",
4483 "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_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
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 SCIPvarGetUbOriginal(SCIP_VAR *var)
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_RETCODE writeOpbFixedVars(SCIP *const scip, FILE *const file, SCIP_VAR **vars, int nvars, SCIP_HASHTABLE *const printedfixing, char const *const multisymbol, SCIP_Bool const transformed)
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)
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)