35 #include "scip/cons_alldifferent.h" 50 #define READER_NAME "fznreader" 51 #define READER_DESC "file reader for FlatZinc format" 52 #define READER_EXTENSION "fzn" 55 #define FZN_BUFFERLEN 8192 56 #define FZN_MAX_PUSHEDTOKENS 1 121 struct SCIP_ReaderData
140 #define CREATE_CONSTRAINT(x) SCIP_RETCODE x (SCIP* scip, FZNINPUT* fzninput, const char* fname, char** ftokens, int nftokens, SCIP_Bool* created) 221 assert(constant !=
NULL);
222 return (
void*) constant->name;
243 for( i = 0; i < nelements; ++i )
276 if( strlen(token) == 1 && *token == c )
290 if( strlen(name) == 4 && strncmp(name,
"true", 4) == 0 )
295 else if( strlen(name) == 1 && strncmp(name,
"1", 1) == 0 )
301 else if( strlen(name) == 5 && strncmp(name,
"false", 5) == 0 )
306 else if( strlen(name) == 1 && strncmp(name,
"0", 1) == 0 )
326 if( strlen(name) == 0 || !isalpha((
unsigned char)name[0]) )
332 if( !isalnum((
unsigned char)name[i]) && name[i] !=
'_' )
350 assert(hasdot !=
NULL);
351 assert(exptype !=
NULL);
353 if( isdigit((
unsigned char)c) )
355 else if( firstchar && (c ==
'+' || c ==
'-') )
357 else if( (*exptype ==
FZN_EXP_NONE) && !(*hasdot) && (c ==
'.') && (isdigit((
unsigned char)nextc)))
362 else if( !firstchar && (*exptype ==
FZN_EXP_NONE) && (c ==
'e' || c ==
'E') )
364 if( nextc ==
'+' || nextc ==
'-' )
369 else if( isdigit((
unsigned char)nextc) )
392 assert(token1 !=
NULL);
393 assert(token2 !=
NULL);
395 if( strlen(token1) != strlen(token2) )
398 return !strncmp(token1, token2, strlen(token2) );
412 assert(fzninput !=
NULL);
415 if( !fzninput->endline && fzninput->comment )
422 (void)
SCIPfgets(fzninput->linebuf, (
int)
sizeof(fzninput->linebuf), fzninput->file);
426 fzninput->comment =
FALSE;
427 fzninput->endline =
TRUE;
435 if( fzninput->endline )
437 fzninput->linepos = 0;
438 fzninput->linenumber++;
443 if(
SCIPfgets(fzninput->linebuf, (
int)
sizeof(fzninput->linebuf), fzninput->file) ==
NULL )
446 fzninput->bufpos = 0;
453 fzninput->endline =
FALSE;
454 last = strrchr(fzninput->linebuf,
' ');
458 SCIPwarningMessage(scip,
"we read %d characters from the file; this might indicate a corrupted input file!\n",
465 SCIPfseek(fzninput->file, -(
long) strlen(last), SEEK_CUR);
466 SCIPdebugMsg(scip,
"correct buffer, reread the last %ld characters\n", (
long) strlen(last));
473 fzninput->endline =
TRUE;
477 fzninput->comment =
FALSE;
484 commentstart = strchr(fzninput->linebuf,
commentchars[i]);
485 if( commentstart !=
NULL )
487 *commentstart =
'\0';
488 *(commentstart+1) =
'\0';
489 fzninput->comment =
TRUE;
510 assert(fzninput !=
NULL);
514 if( fzninput->comment && !
getNextLine(scip, fzninput) )
516 SCIPdebugMsg(scip,
"(line %d) end of file\n", fzninput->linenumber);
521 if( fzninput->npushedtokens > 0 )
523 SCIPswapPointers((
void**)&fzninput->token, (
void**)&fzninput->pushedtokens[fzninput->npushedtokens-1]);
524 fzninput->npushedtokens--;
525 SCIPdebugMsg(scip,
"(line %d) read token again: '%s'\n", fzninput->linenumber, fzninput->token);
530 buf = fzninput->linebuf;
533 if( buf[fzninput->bufpos] ==
'\0' )
537 SCIPdebugMsg(scip,
"(line %d) end of file\n", fzninput->linenumber);
540 assert(fzninput->bufpos == 0);
554 if( buf[fzninput->bufpos] ==
'.' && buf[fzninput->bufpos+1] ==
'.')
558 fzninput->bufpos += 2;
559 fzninput->linepos += 2;
560 fzninput->token[0] =
'.';
561 fzninput->token[1] =
'.';
563 else if(
isValueChar(buf[fzninput->bufpos], buf[fzninput->bufpos+1],
TRUE, &hasdot, &exptype) )
571 fzninput->token[tokenlen] = buf[fzninput->bufpos];
577 while(
isValueChar(buf[fzninput->bufpos], buf[fzninput->bufpos+1],
FALSE, &hasdot, &exptype) );
579 fzninput->hasdot = hasdot;
588 fzninput->token[tokenlen] = buf[fzninput->bufpos];
594 if(tokenlen == 1 && fzninput->token[0] ==
':' && buf[fzninput->bufpos] ==
':')
596 fzninput->token[tokenlen] = buf[fzninput->bufpos];
603 if( tokenlen == 1 &&
isTokenChar(fzninput->token[0]) )
610 fzninput->token[tokenlen] =
'\0';
612 SCIPdebugMsg(scip,
"(line %d) read token: '%s'\n", fzninput->linenumber, fzninput->token);
623 assert(fzninput !=
NULL);
626 SCIPswapPointers((
void**)&fzninput->pushedtokens[fzninput->npushedtokens], (
void**)&fzninput->token);
627 fzninput->npushedtokens++;
636 assert(fzninput !=
NULL);
638 return isChar(fzninput->token,
';');
651 assert(value !=
NULL);
653 val = strtod(token, &endptr);
654 if( endptr != token && *endptr ==
'\0' )
675 assert(fzninput !=
NULL);
677 SCIPerrorMessage(
"Syntax error in line %d: %s found <%s>\n", fzninput->linenumber, msg, fzninput->token);
680 fzninput->haserror =
TRUE;
689 assert(fzninput !=
NULL);
691 return (fzninput->haserror || !fzninput->valid);
703 (*readerdata)->vararrays =
NULL;
704 (*readerdata)->nvararrays = 0;
705 (*readerdata)->vararrayssize = 0;
720 nvararrays = readerdata->nvararrays;
721 vararrayssize = readerdata->vararrayssize;
723 if( vararrayssize == nvararrays )
725 if( vararrayssize == 0 )
737 readerdata->vararrayssize = vararrayssize;
752 nvararrays = fzninput->nvararrays;
753 vararrayssize = fzninput->vararrayssize;
755 if( vararrayssize == nvararrays )
757 if( vararrayssize == 0 )
769 fzninput->vararrayssize = vararrayssize;
784 nconstarrays = fzninput->nconstarrays;
785 constarrayssize = fzninput->constarrayssize;
787 if( constarrayssize == nconstarrays )
789 if( constarrayssize == 0 )
791 constarrayssize = 100;
796 constarrayssize *= 2;
801 fzninput->constarrayssize = constarrayssize;
864 (*target)->ndims = source->ndims;
865 (*target)->size = source->ndims;
896 (*vararray)->nvars = nvars;
897 (*vararray)->type = type;
944 for( c = 0; c < fzninput->nvararrays; ++c )
946 vararray = fzninput->vararrays[c];
970 SCIPdebugMsg(scip,
"create constant array <%s>\n", name);
981 (*constarray)->nconstants = nconstants;
982 (*constarray)->type = type;
994 SCIPdebugMsg(scip,
"free constant array <%s>\n", (*constarray)->name);
1018 for( c = 0; c < fzninput->nconstarrays; ++c )
1020 constarray = fzninput->constarrays[c];
1043 nvararrays = readerdata->nvararrays;
1046 assert(nvararrays < readerdata->vararrayssize);
1066 vararray->info = info;
1067 vararray->nvars = 1;
1068 vararray->type = type;
1070 readerdata->vararrays[nvararrays] = vararray;
1071 readerdata->nvararrays++;
1091 nvararrays = readerdata->nvararrays;
1094 assert(nvararrays < readerdata->vararrayssize);
1099 readerdata->vararrays[nvararrays] = vararray;
1100 readerdata->nvararrays++;
1120 nvararrays = fzninput->nvararrays;
1123 assert(nvararrays < fzninput->vararrayssize);
1128 fzninput->vararrays[nvararrays] = vararray;
1129 fzninput->nvararrays++;
1148 nconstarrays = fzninput->nconstarrays;
1151 assert(nconstarrays < fzninput->constarrayssize);
1156 fzninput->constarrays[nconstarrays] = constarray;
1157 fzninput->nconstarrays++;
1183 SCIP_CALL(
SCIPcreateConsQuadratic(scip, &cons, name, nlinvars, linvars, lincoefs, nquadterms, quadvars1, quadvars2, quadcoefs, lhs, rhs,
1227 const char* consname,
1247 if( vars[nvars] !=
NULL )
1252 else if( !
isValue(name1, &value1) )
1257 assert(constant !=
NULL);
1259 value1 = constant->value;
1263 if( vars[nvars] !=
NULL )
1268 else if( !
isValue(name2, &value2) )
1273 assert(constant !=
NULL);
1275 value2 = constant->value;
1279 lhs += (value2 - value1);
1282 rhs += (value2 - value1);
1284 SCIP_CALL(
createLinearCons(scip, consname, nvars, vars, vals, lhs, rhs, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
1301 assert(
isChar(fzninput->token,
'[') );
1306 syntaxError(scip, fzninput,
"expecting array index expression");
1317 if( constant ==
NULL )
1318 syntaxError(scip, fzninput,
"unknown index name");
1321 assert(constant->type ==
FZN_INT);
1322 *idx = (int) constant->value;
1325 else if(
isValue(fzninput->token, &value) )
1327 assert( fzninput->hasdot ==
FALSE );
1331 syntaxError(scip, fzninput,
"expecting array index expression");
1342 assert(scip !=
NULL);
1343 assert(fzninput !=
NULL);
1349 syntaxError(scip, fzninput,
"expecting more tokens");
1362 syntaxError(scip, fzninput,
"expecting at least a semicolon to close the statement");
1367 if(
isChar(fzninput->token,
'[') )
1376 syntaxError(scip, fzninput,
"expecting token <]>");
1425 *lhs = sidevalue + 1.0;
1430 *rhs = sidevalue - 1.0;
1433 syntaxError(scip, fzninput,
"unknown relation in constraint identifier name");
1435 SCIPdebugMsg(scip,
"lhs = %g, rhs = %g\n", *lhs, *rhs);
1449 assert(selements > 0);
1460 if(selements == *nelements)
1503 syntaxError(scip, fzninput,
"expected left side of range");
1508 if( !
isValue(fzninput->token, lb) )
1510 syntaxError(scip, fzninput,
"expected lower bound value");
1530 syntaxError(scip, fzninput,
"expected upper bound value");
1535 if( fzninput->hasdot != (*type ==
FZN_FLOAT) )
1537 SCIPwarningMessage(scip,
"lower bound and upper bound mismatch in value type, assume %s variable type\n",
1538 fzninput->hasdot ?
"an integer" :
"a continuous");
1562 (*info)->size = size;
1567 syntaxError(scip, fzninput,
"expecting <(> after <output_array>");
1575 if( fzninput->haserror )
1580 if( nelements == size )
1585 (*info)->size = size;
1589 (*info)->lbs[nelements] = (int) lb;
1590 (*info)->ubs[nelements] = (int) ub;
1594 (*info)->ndims = nelements;
1613 if( output !=
NULL )
1619 syntaxError(scip, fzninput,
"expecting colon <:>");
1626 syntaxError(scip, fzninput,
"expecting identifier name");
1638 syntaxError(scip, fzninput,
"expected at least a semicolon to close statement");
1643 if(
equalTokens(scip, fzninput->token,
"output_var") && output !=
NULL )
1645 else if(
equalTokens(scip, fzninput->token,
"output_array") && output !=
NULL)
1648 assert(info !=
NULL);
1655 while( !
isChar(fzninput->token,
'=') );
1689 else if(
equalTokens(scip, fzninput->token,
"float") )
1691 else if(
equalTokens(scip, fzninput->token,
"int") )
1693 else if(
equalTokens(scip, fzninput->token,
"set") ||
isChar(fzninput->token,
'{') )
1696 fzninput->valid =
FALSE;
1707 if( fzninput->haserror )
1723 const char* assignment
1739 if( linkVar ==
NULL )
1744 fixvalue = realvalue;
1745 else if( constant !=
NULL )
1746 fixvalue = constant->value;
1749 syntaxError(scip, fzninput,
"assignment is not recognizable");
1754 SCIP_CALL(
createLinearCons(scip,
"fixing", 1, &var, vals, fixvalue, fixvalue, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
1764 SCIP_CALL(
createLinearCons(scip,
"link", 2, vars, vals, 0.0, 0.0, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
1780 const char* assignment
1791 if( *constant !=
NULL )
1794 if( type != (*constant)->type )
1800 value = (*constant)->value;
1812 syntaxError(scip, fzninput,
"assignment is not recognizable");
1819 (*constant)->type = type;
1821 (*constant)->value = value;
1824 if( fzninput->sconstants == fzninput->nconstants )
1826 assert(fzninput->sconstants > 0);
1827 fzninput->sconstants *= 2;
1831 assert(fzninput->sconstants > fzninput->nconstants);
1832 fzninput->constants[fzninput->nconstants] = *constant;
1833 fzninput->nconstants++;
1853 syntaxError(scip, fzninput,
"expected keyword <of>");
1859 syntaxError(scip, fzninput,
"expected more tokens");
1870 *isvararray =
FALSE;
1874 parseType(scip, fzninput, type, lb, ub);
1887 assert(scip !=
NULL);
1888 assert(fzninput !=
NULL);
1889 assert(*nelements >= 0);
1890 assert(selements >= *nelements);
1895 syntaxError(scip, fzninput,
"expected token <[>");
1906 syntaxError(scip, fzninput,
"expected token <]>");
1925 syntaxError(scip, fzninput,
"expected token <[> for array dimension");
1930 parseRange(scip, fzninput, &type, &left, &right);
1932 if( fzninput->haserror )
1935 if( type !=
FZN_INT || left != 1.0 || right <= 0.0 )
1937 syntaxError(scip, fzninput,
"invalid array dimension format");
1941 *nelements = (int) right;
1945 syntaxError(scip, fzninput,
"expected token <]> for array dimension");
1965 assert(scip !=
NULL);
1966 assert(fzninput !=
NULL);
1981 syntaxError(scip, fzninput,
"unknown variable type");
1986 SCIP_CALL(
SCIPcreateVar(scip, &varcopy, name, lb, ub, 0.0, vartype, !(fzninput->dynamiccols), fzninput->dynamiccols,
NULL,
NULL,
NULL,
NULL,
NULL) );
2030 for( v = 0; v < nvars; ++v )
2040 syntaxError(scip, fzninput,
"expected semicolon");
2044 if(
isChar(fzninput->token,
'=') )
2056 for( v = 0; v < nvars && !
hasError(fzninput); ++v )
2104 syntaxError(scip, fzninput,
"expected token <=>");
2116 for( c = 0; c < nconstants; ++c )
2140 fzninput->comment =
TRUE;
2162 assert(scip !=
NULL);
2163 assert(fzninput !=
NULL);
2173 assert(
hasError(fzninput) || nelements > 0);
2186 assert(!output || info !=
NULL);
2191 SCIPdebugMsg(scip,
"found <%s> array named <%s> of type <%s> and size <%d> with bounds [%g,%g] (output %u)\n",
2192 isvararray ?
"variable" :
"constant", name,
2193 type ==
FZN_BOOL ?
"bool" : type ==
FZN_INT ?
"integer" :
"float", nelements, lb, ub, output);
2221 assert(scip !=
NULL);
2222 assert(fzninput !=
NULL);
2227 parseType(scip, fzninput, &type, &lb, &ub);
2251 syntaxError(scip, fzninput,
"expected semicolon");
2255 if(
isChar(fzninput->token,
'=') )
2281 assert(scip !=
NULL);
2282 assert(fzninput !=
NULL);
2295 syntaxError(scip, fzninput,
"expected token <=>");
2314 const char* assignment
2317 if(
isValue(assignment, value) )
2328 if( constant ==
NULL )
2335 syntaxError(scip, fzninput,
"unknown constant name");
2341 syntaxError(scip, fzninput,
"expected fixed variable");
2345 (*value) = constant->value;
2348 syntaxError(scip, fzninput,
"expected constant expression");
2363 assert(*nvals <= sizevals);
2368 syntaxError(scip, fzninput,
"expected constant array");
2373 if(
isChar(fzninput->token,
'[') )
2390 if( sizevals <= *nvals + nelements )
2395 for( c = 0; c < nelements && !
hasError(fzninput); ++c )
2397 parseValue(scip, fzninput, &value, elements[c]);
2400 (*vals)[(*nvals)] = value;
2416 if( constarray !=
NULL )
2419 if( sizevals <= *nvals + constarray->nconstants )
2424 for( c = 0; c < constarray->nconstants; ++c )
2426 (*vals)[(*nvals)] = constarray->constants[c]->value;
2438 vararray =
findVararray(scip, fzninput, fzninput->token);
2440 if( vararray ==
NULL )
2442 syntaxError(scip, fzninput,
"unknown constants array name");
2447 if( sizevals <= *nvals + vararray->nvars )
2452 for( c = 0; c < vararray->nvars; ++c )
2456 var = vararray->vars[c];
2457 assert(var !=
NULL);
2466 syntaxError(scip, fzninput,
"variable array contains unfixed variable");
2489 assert(*nvars <= sizevars);
2494 syntaxError(scip, fzninput,
"expected constant array");
2498 if(
isChar(fzninput->token,
'[') )
2511 if( sizevars <= *nvars + nelements )
2516 for( v = 0; v < nelements; ++v )
2520 if( (*vars)[(*nvars)] ==
NULL )
2532 if( constant !=
NULL )
2535 value = constant->value;
2537 else if(!
isValue(elements[v], &value) )
2541 tmptoken = fzninput->token;
2542 fzninput->token = elements[v];
2543 syntaxError(scip, fzninput,
"expected variable name or constant");
2545 fzninput->token = tmptoken;
2562 vararray =
findVararray(scip, fzninput, fzninput->token);
2564 if( vararray !=
NULL )
2566 assert(vararray !=
NULL);
2569 if( sizevars <= *nvars + vararray->nvars )
2574 for( v = 0; v < vararray->nvars; ++v )
2576 (*vars)[(*nvars)] = vararray->vars[v];
2581 syntaxError(scip, fzninput,
"unknown variable array name");
2603 assert(nelements == 3);
2617 for( v = 0; v < 3; ++v )
2623 if( vars[v] ==
NULL )
2625 parseValue(scip, fzninput, &vals[v], elements[v]);
2633 if( vars[0] !=
NULL && vars[1] !=
NULL )
2639 if( vars[2] !=
NULL )
2644 SCIP_CALL(
createQuadraticCons(scip, name, 1, &vars[2], &linval, 1, &vars[0], &vars[1], &quadval, rhs, rhs,
2645 fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
2650 SCIP_CALL(
createQuadraticCons(scip, name, 0,
NULL,
NULL, 1, &vars[0], &vars[1], &quadval, rhs, rhs,
2651 fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows));
2654 else if( vars[0] !=
NULL || vars[1] !=
NULL )
2660 if( vars[0] ==
NULL )
2669 if( vars[2] !=
NULL )
2681 SCIP_CALL(
createLinearCons(scip, name, nvars, vars, vals, rhs, rhs, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
2688 rhs = rhs - vals[0]*vals[1];
2691 if( vars[2] !=
NULL )
2695 SCIP_CALL(
createLinearCons(scip, name, 1, &vars[2], &val, rhs, rhs, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
2739 assert(nelements == 3 || nelements == 2);
2757 if( vars[nvars] ==
NULL )
2759 parseValue(scip, fzninput, &value, elements[0]);
2772 if( vars[nvars] ==
NULL )
2774 parseValue(scip, fzninput, &value, elements[1]);
2799 if( vars[nvars] ==
NULL )
2801 parseValue(scip, fzninput, &value, elements[2]);
2813 SCIP_CALL(
createLinearCons(scip, name, nvars, vars, vals, rhs, rhs, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
2844 assert(nnames == 2);
2868 assert(fzninput !=
NULL);
2886 assert(fzninput !=
NULL);
2892 fzninput->valid =
FALSE;
2903 assert(fzninput !=
NULL);
2909 fzninput->valid =
FALSE;
2920 assert(fzninput !=
NULL);
2956 for( v = 0; v < nvars; ++v )
2960 if( vars[v] ==
NULL )
3003 fzninput->valid =
FALSE;
3033 fzninput->valid =
FALSE;
3102 fzninput->valid =
FALSE;
3117 assert(fzninput !=
NULL);
3123 fzninput->valid =
FALSE;
3142 if( strlen(ftokens[nftokens - 1]) != 2 && nftokens != 2 )
3149 fzninput->valid =
FALSE;
3157 fzninput->valid =
FALSE;
3165 SCIPwarningMessage(
scip,
"constraints with '<' or '>' relation and continuous variables are not supported\n");
3166 fzninput->valid =
FALSE;
3179 assert(nftokens == 3);
3232 SCIP_CALL(
createLinearCons(
scip, fname, nvars, vars, vals, lhs, rhs, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
3241 assert(nftokens == 2);
3247 assert(nftokens == 2);
3252 assert(nftokens == 2);
3277 assert(fzninput !=
NULL);
3294 SCIP_CALL( SCIPcreateConsAlldifferent(
scip, &cons, fname, nvars, vars,
3318 int* durations =
NULL;
3319 int* demands =
NULL;
3331 assert(fzninput !=
NULL);
3362 for( i = 0; i < ndurations; ++i )
3363 durations[i] = (
int)vals[i];
3378 for( i = 0; i < ndemads; ++i )
3379 demands[i] = (
int)vals[i];
3395 capacity = (int)val;
3397 assert(nvars == ndurations);
3398 assert(nvars == ndemads);
3425 createCoercionOpCons,
3427 createLogicalOpCons,
3429 createComparisonOpCons,
3430 createAlldifferentOpCons,
3431 createCumulativeOpCons
3456 assert(scip !=
NULL);
3457 assert(fzninput !=
NULL);
3472 SCIP_CALL(
createLinearCons(scip,
"fixing", 1, &var, vals, 1.0, 1.0, fzninput->initialconss, fzninput->dynamicconss, fzninput->dynamicrows) );
3479 syntaxError(scip, fzninput,
"expected constraint identifier name");
3486 syntaxError(scip, fzninput,
"expected token <(>");
3496 while( token !=
NULL )
3507 assert(token ==
NULL || tokens[0] !=
NULL);
3508 for( i = 0; i < ntokens; ++i )
3519 SCIP_CALL( constypes[c](scip, fzninput, fname, tokens, ntokens, &created) );
3523 if( !
hasError(fzninput) && !created )
3525 fzninput->valid =
FALSE;
3530 for( i = ntokens - 1; i >= 0 ; --i )
3537 syntaxError(scip, fzninput,
"expected token <)>");
3549 assert(scip !=
NULL);
3550 assert(fzninput !=
NULL);
3556 syntaxError(scip, fzninput,
"expected solving specification");
3567 syntaxError(scip, fzninput,
"expected more tokens");
3569 while( !
equalTokens(scip, fzninput->token,
"satisfy")
3570 && !
equalTokens(scip, fzninput->token,
"minimize")
3571 && !
equalTokens(scip, fzninput->token,
"maximize") );
3574 if(
equalTokens(scip, fzninput->token,
"satisfy") )
3576 SCIPdebugMsg(scip,
"detected a satisfiability problem\n");
3584 if(
equalTokens(scip, fzninput->token,
"minimize") )
3587 SCIPdebugMsg(scip,
"detected a minimization problem\n");
3591 assert(
equalTokens(scip, fzninput->token,
"maximize"));
3593 SCIPdebugMsg(scip,
"detected a maximization problem\n");
3608 else if( constant !=
NULL )
3610 SCIPdebugMsg(scip,
"optimizing a constant is equal to a satisfiability problem!\n");
3612 else if(
equalTokens(scip, name,
"int_float_lin") )
3632 syntaxError(scip, fzninput,
"expected token <(>");
3643 syntaxError(scip, fzninput,
"expected token <,>");
3655 syntaxError(scip, fzninput,
"expected token <,>");
3667 syntaxError(scip, fzninput,
"expected token <,>");
3672 assert(nvars <= nvals);
3681 syntaxError(scip, fzninput,
"expected token <)>");
3686 assert( nvars == nvals );
3688 for( v = 0; v < nvars; ++v )
3699 syntaxError(scip, fzninput,
"unknown identifier expression for a objective function");
3712 const char* filename
3715 assert(scip !=
NULL);
3716 assert(readerdata !=
NULL);
3717 assert(fzninput !=
NULL);
3720 fzninput->file =
SCIPfopen(filename,
"r");
3721 if( fzninput->file ==
NULL )
3741 if(
equalTokens(scip, fzninput->token,
"predicate") )
3746 else if(
equalTokens(scip, fzninput->token,
"array") )
3751 else if(
equalTokens(scip, fzninput->token,
"constraint") )
3756 else if(
equalTokens(scip, fzninput->token,
"int") )
3761 else if(
equalTokens(scip, fzninput->token,
"float") )
3766 else if(
equalTokens(scip, fzninput->token,
"bool") )
3771 else if(
equalTokens(scip, fzninput->token,
"set") )
3775 fzninput->valid =
FALSE;
3778 else if(
equalTokens(scip, fzninput->token,
"solve") )
3783 else if(
equalTokens(scip, fzninput->token,
"var") )
3788 else if(
equalTokens(scip, fzninput->token,
"output") )
3826 if( fzninput->comment )
3831 syntaxError(scip, fzninput,
"expected semicolon");
3840 syntaxError(scip, fzninput,
"expected more tokens");
3846 syntaxError(scip, fzninput,
"expected semicolon");
3888 assert( scip !=
NULL );
3889 assert( scalars !=
NULL );
3890 assert( nvars !=
NULL );
3891 assert( vars !=
NULL || *nvars == 0 );
3892 assert( constant !=
NULL );
3899 if( requiredsize > *nvars )
3905 assert( requiredsize <= *nvars );
3909 for( v = 0; v < *nvars; ++v )
3911 assert(vars !=
NULL);
3927 assert( scip !=
NULL );
3928 assert( buffer !=
NULL );
3932 buffer[bufferpos] =
'\0';
3945 const char* extension
3950 assert( scip !=
NULL );
3951 assert( buffer !=
NULL );
3952 assert( bufferlen !=
NULL );
3953 assert( bufferpos !=
NULL );
3954 assert( extension !=
NULL );
3957 newpos = (*bufferpos) + (int)strlen(extension);
3958 if( newpos >= (*bufferlen) )
3960 *bufferlen =
MAX( newpos, 2*(*bufferlen) );
3966 (void)strncpy((*buffer)+(*bufferpos), extension, (size_t)strlen(extension));
3967 *bufferpos = newpos;
4005 assert( scip !=
NULL );
4006 assert( strcmp(type,
"eq") == 0 || strcmp(type,
"le") == 0 || strcmp(type,
"ge") == 0 );
4009 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),
"constraint ") );
4014 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),buffer) );
4017 for( v = 0; v < nvars-1; ++v )
4026 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos), buffer) );
4040 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos), buffer) );
4043 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),
"], [") );
4046 for( v = 0; v < nvars-1; ++v )
4049 assert( var !=
NULL );
4055 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos), buffer) );
4067 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),buffer) );
4070 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),
"], ") );
4083 SCIP_CALL(
appendBuffer(scip, &(fznoutput->consbuffer), &(fznoutput->consbufferlen), &(fznoutput->consbufferpos),buffer) );
4112 assert( scip !=
NULL );
4113 assert( vars !=
NULL || nvars == 0 );
4114 assert( fznoutput !=
NULL );
4115 assert( lhs <= rhs );
4121 nactivevars = nvars;
4124 activeconstant = 0.0;
4137 for( v = 0; v < nactivevars; ++v )
4138 activevals[v] = 1.0;
4149 hasfloats = hasfloats || !
SCIPisIntegral(scip, lhs-activeconstant);
4151 hasfloats = hasfloats || !
SCIPisIntegral(scip, rhs-activeconstant);
4154 for( v = 0; v < nactivevars && !hasfloats; v++ )
4158 assert(activevars != 0);
4159 var = activevars[v];
4168 for( v = 0; v < nactivevars; v++ )
4173 assert(activevars != 0);
4174 var = activevars[v];
4179 if( idx < fznoutput->ndiscretevars && !fznoutput->varhasfloat[idx] )
4184 SCIP_CALL(
appendBuffer(scip, &(fznoutput->varbuffer), &(fznoutput->varbufferlen), &(fznoutput->varbufferpos),buffer) );
4187 SCIP_CALL(
appendBuffer(scip, &(fznoutput->castbuffer), &(fznoutput->castbufferlen), &(fznoutput->castbufferpos),buffer) );
4189 fznoutput->varhasfloat[idx] =
TRUE;
4201 SCIP_CALL(
printRow(scip, fznoutput,
"eq", activevars, activevals, nactivevars, rhs - activeconstant, hasfloats) );
4208 SCIP_CALL(
printRow(scip, fznoutput,
"ge", activevars, activevals, nactivevars, lhs - activeconstant, hasfloats) );
4214 SCIP_CALL(
printRow(scip, fznoutput,
"le", activevars, activevals, nactivevars, rhs - activeconstant, hasfloats) );
4219 if( activevars !=
NULL )
4252 const char* conshdlrname;
4271 const int ndiscretevars = nbinvars+nintvars;
4277 assert( scip !=
NULL );
4282 SCIPinfoMessage(scip, file,
"%% Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
4283 nvars, nbinvars, nintvars, nimplvars, ncontvars);
4291 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Problem variables %%%%%%%%%%%%\n");
4294 for( v = 0; v < nvars; v++ )
4297 assert( var !=
NULL );
4323 if( v < ndiscretevars )
4346 SCIPinfoMessage(scip, file,
"var %s..%s: %s;\n", buffy, buffy2, varname);
4353 assert( v >= nbinvars );
4356 if( v < ndiscretevars )
4364 boundedvars[nboundedvars] = v;
4370 boundedvars[nboundedvars] = v;
4378 fznoutput.ndiscretevars = ndiscretevars;
4379 fznoutput.varbufferpos = 0;
4380 fznoutput.consbufferpos = 0;
4381 fznoutput.castbufferpos = 0;
4391 for( v = 0; v < ndiscretevars; v++ )
4392 fznoutput.varhasfloat[v] =
FALSE;
4393 fznoutput.varbuffer[0] =
'\0';
4394 fznoutput.consbuffer[0] =
'\0';
4395 fznoutput.castbuffer[0] =
'\0';
4398 for( c = 0; c < nconss; c++ )
4401 assert( cons !=
NULL);
4407 assert( conshdlr !=
NULL );
4415 if( strcmp(conshdlrname,
"linear") == 0 )
4421 else if( strcmp(conshdlrname,
"setppc") == 0 )
4431 consvars,
NULL, nconsvars, 1.0, 1.0, transformed,
FALSE) );
4443 else if( strcmp(conshdlrname,
"logicor") == 0 )
4449 else if( strcmp(conshdlrname,
"knapsack") == 0 )
4459 for( v = 0; v < nconsvars; ++v )
4467 else if( strcmp(conshdlrname,
"varbound") == 0 )
4480 consvars, consvals, 2,
4486 else if( strcmp(conshdlrname,
"cumulative") == 0 )
4493 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos),
"cumulative([") );
4495 for( v = 0; v < nconsvars; ++v )
4497 if( v < nconsvars - 1)
4502 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos), varname) );
4505 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos),
"], [") );
4509 for( v = 0; v < nconsvars; ++v )
4511 if( v < nconsvars - 1)
4516 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos), buffy) );
4519 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos),
"], [") );
4523 for( v = 0; v < nconsvars; ++v )
4525 if( v < nconsvars - 1)
4530 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos), buffy) );
4534 SCIP_CALL(
appendBuffer(scip, &(fznoutput.consbuffer), &(fznoutput.consbufferlen), &(fznoutput.consbufferpos), buffy) );
4538 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print flatzinc format\n", conshdlrname );
4548 for( v = 0; v < nvars; v++ )
4560 intobjvars[nintobjvars] = v;
4561 SCIPdebugMsg(scip,
"variable <%s> at pos <%d,%d> has an integral obj: %f=%f*%f\n",
4568 if( v < ndiscretevars && !fznoutput.varhasfloat[v] )
4573 SCIP_CALL(
appendBuffer(scip, &(fznoutput.varbuffer), &(fznoutput.varbufferlen), &(fznoutput.varbufferpos),buffer) );
4576 SCIP_CALL(
appendBuffer(scip, &(fznoutput.castbuffer), &(fznoutput.castbufferlen), &(fznoutput.castbufferpos),buffer) );
4578 fznoutput.varhasfloat[v] =
TRUE;
4581 floatobjvars[nfloatobjvars] = v;
4588 if( fznoutput.varbufferpos > 0 )
4590 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Auxiliary variables %%%%%%%%%%%%\n");
4591 writeBuffer(scip, file, fznoutput.varbuffer, fznoutput.varbufferpos );
4595 if( fznoutput.castbufferpos > 0 )
4597 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Variable conversions %%%%%%%%%%%%\n");
4598 writeBuffer(scip, file, fznoutput.castbuffer, fznoutput.castbufferpos );
4601 if( nboundedvars > 0 )
4602 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Variable bounds %%%%%%%%%%%%\n");
4605 for( v = 0; v < nboundedvars; v++ )
4607 var = vars[boundedvars[v]];
4640 if( fznoutput.consbufferpos > 0 )
4642 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Problem constraints %%%%%%%%%%%%\n");
4643 writeBuffer(scip, file, fznoutput.consbuffer, fznoutput.consbufferpos );
4646 SCIPinfoMessage(scip, file,
"\n%%%%%%%%%%%% Objective function %%%%%%%%%%%%\n");
4649 if( nintobjvars > 0 || nfloatobjvars > 0 )
4654 for( v = 0; v < nintobjvars; v++ )
4657 var = vars[intobjvars[v]];
4663 SCIPinfoMessage(scip, file,
"%s%s", buffy, v < nintobjvars-1 ?
", " :
"" );
4668 for( v = 0; v < nfloatobjvars; v++ )
4675 SCIPinfoMessage(scip, file,
"%s%s", buffy, v < nfloatobjvars-1 ?
", " :
"" );
4682 SCIPinfoMessage(scip, file,
"%s%s", nfloatobjvars == 0 ?
"" :
", ", buffy );
4687 for( v = 0; v < nintobjvars; v++ )
4692 for( v = 0; v < nfloatobjvars; v++ )
4693 SCIPinfoMessage(scip, file,
"%s%s%s",
SCIPvarGetName(vars[floatobjvars[v]]), floatobjvars[v] < ndiscretevars ?
"_float" :
"", v < nfloatobjvars-1 ?
", " :
"" );
4697 SCIPinfoMessage(scip, file,
"%s%.1f", nfloatobjvars == 0 ?
"" :
", ", 1.0 );
4727 assert(reader !=
NULL);
4745 assert(readerdata !=
NULL);
4748 for( v = 0; v < readerdata->nvararrays; ++v )
4771 fzninput.file =
NULL;
4772 fzninput.linebuf[0] =
'\0';
4774 fzninput.token[0] =
'\0';
4781 fzninput.npushedtokens = 0;
4782 fzninput.linenumber = 1;
4783 fzninput.bufpos = 0;
4784 fzninput.linepos = 0;
4786 fzninput.endline =
FALSE;
4787 fzninput.comment =
FALSE;
4788 fzninput.haserror =
FALSE;
4789 fzninput.valid =
TRUE;
4790 fzninput.vararrays =
NULL;
4791 fzninput.nvararrays = 0;
4792 fzninput.vararrayssize = 0;
4793 fzninput.constarrays =
NULL;
4794 fzninput.nconstarrays = 0;
4795 fzninput.constarrayssize = 0;
4803 hashGetKeyVar, SCIPhashKeyEqString, SCIPhashKeyValString,
NULL) );
4806 hashGetKeyConstant, SCIPhashKeyEqString, SCIPhashKeyValString,
NULL) );
4809 fzninput.nconstants = 0;
4810 fzninput.sconstants = 10;
4823 for( i = 0; i < fzninput.nconstants; ++i )
4833 for( i = 0; i < fzninput.nvararrays; ++i )
4840 for( i = 0; i < fzninput.nconstarrays; ++i )
4847 if( fzninput.haserror )
4863 nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
4873 for( i = 0; i < nvars; i++ )
4875 const char* varname;
4879 length = strlen(varname);
4883 SCIPwarningMessage(
scip,
"The name of variable <%d>: \"%s\" is not conform to the fzn standard.\n", i, varname);
4888 legal = (strncmp(&varname[length-6],
"_float",6) != 0);
4891 SCIPwarningMessage(
scip,
"The name of variable <%d>: \"%s\" ends with \"_float\" which is not supported.\n", i, varname);
4900 nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
4902 else if( transformed )
4967 assert(reader !=
NULL);
4970 assert(readerdata !=
NULL);
4972 vararrays = readerdata->vararrays;
4973 nvararrays = readerdata->nvararrays;
4976 SCIPsortPtr((
void**)vararrays, vararraysComp, nvararrays);
4978 for( i = 0; i < nvararrays; ++i )
4980 vararray = vararrays[i];
4981 info = vararray->info;
4982 vars = vararray->vars;
4983 nvars = vararray->nvars;
4984 type = vararray->type;
4986 if( info->ndims == 0 )
4999 SCIPinfoMessage(scip, file,
"%s = array%dd(", vararray->name, info->ndims);
5001 for( v = 0; v < info->ndims; ++v )
5008 for( v = 0; v < nvars; ++v )
enum SCIP_Result SCIP_RESULT
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
enum SCIP_BoundType SCIP_BOUNDTYPE
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
static SCIP_RETCODE parseAggregation(SCIP *scip, FZNINPUT *fzninput, const char *name, const char *type)
SCIP_RETCODE SCIPprintSolReaderFzn(SCIP *scip, SCIP_SOL *sol, FILE *file)
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
static SCIP_DECL_READERCOPY(readerCopyFzn)
static SCIP_RETCODE parseVariable(SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput)
static SCIP_RETCODE parseOutputDimensioninfo(SCIP *scip, FZNINPUT *fzninput, DIMENSIONS **info)
static void parseRange(SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
static SCIP_RETCODE parseConstantArrayAssignment(SCIP *scip, FZNINPUT *fzninput, SCIP_Real **vals, int *nvals, int sizevals)
constraint handler for cumulative constraints
Constraint handler for variable bound constraints .
static SCIP_RETCODE writeFzn(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_CONS **conss, int nconss, SCIP_RESULT *result)
static void writeBuffer(SCIP *scip, FILE *file, char *buffer, int bufferpos)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
static SCIP_RETCODE readerdataAddOutputvararray(SCIP *scip, SCIP_READERDATA *readerdata, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, FZNEXPTYPE *exptype)
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE parseArrayAssignment(SCIP *scip, FZNINPUT *fzninput, char ***elements, int *nelements, int selements)
static CONSTARRAY * findConstarray(SCIP *scip, FZNINPUT *fzninput, const char *name)
enum FznExpType FZNEXPTYPE
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
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)
static SCIP_Bool hasError(FZNINPUT *fzninput)
static SCIP_RETCODE ensureVararrySizeFznInput(SCIP *scip, FZNINPUT *fzninput)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_VAR ** SCIPgetVarsCumulative(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPprintTransProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_RETCODE SCIPincludeReaderFzn(SCIP *scip)
static SCIP_Bool equalTokens(SCIP *scip, const char *token1, const char *token2)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
static void computeLinearConsSides(SCIP *scip, FZNINPUT *fzninput, const char *name, SCIP_Real sidevalue, SCIP_Real *lhs, SCIP_Real *rhs)
static SCIP_RETCODE parseLinking(SCIP *scip, FZNINPUT *fzninput, const char *name, const char *type, SCIP_Real sidevalue)
static SCIP_RETCODE parseConstantArray(SCIP *scip, FZNINPUT *fzninput, const char *name, int nconstants, FZNNUMBERTYPE type)
void SCIPswapPointers(void **pointer1, void **pointer2)
static SCIP_RETCODE fzninputAddVararray(SCIP *scip, FZNINPUT *fzninput, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
static SCIP_Bool isIdentifier(const char *name)
static SCIP_RETCODE appendBuffer(SCIP *scip, char **buffer, int *bufferlen, int *bufferpos, const char *extension)
SCIP_RETCODE SCIPcreateConsXor(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, 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)
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
static SCIP_RETCODE readerdataAddOutputvar(SCIP *scip, SCIP_READERDATA *readerdata, SCIP_VAR *var, FZNNUMBERTYPE type)
static SCIP_Bool isTokenChar(char c)
static SCIP_RETCODE parseArray(SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBlockMemory(scip, ptr)
SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
struct FznConstant FZNCONSTANT
Constraint handler for AND constraints, .
#define SCIPduplicateBufferArray(scip, ptr, source, num)
static void parseValue(SCIP *scip, FZNINPUT *fzninput, SCIP_Real *value, const char *assignment)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPfreeBufferArray(scip, ptr)
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
#define SCIPdebugPrintCons(x, y, z)
static SCIP_RETCODE copyDimensions(SCIP *scip, DIMENSIONS **target, DIMENSIONS *source)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
int SCIPfseek(SCIP_FILE *stream, long offset, int whence)
#define SCIPdebugMsgPrint
static void printValue(SCIP *scip, FILE *file, SCIP_Real value, FZNNUMBERTYPE type)
SCIP_RETCODE SCIPcreateConsOr(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)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
enum FznNumberType FZNNUMBERTYPE
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
struct ConstArray CONSTARRAY
static SCIP_RETCODE readerdataCreate(SCIP *scip, SCIP_READERDATA **readerdata)
static SCIP_RETCODE createConstarray(SCIP *scip, CONSTARRAY **constarray, const char *name, FZNCONSTANT **constants, int nconstants, FZNNUMBERTYPE type)
static void flattenAssignment(SCIP *scip, FZNINPUT *fzninput, char *assignment)
SCIP_RETCODE SCIPcreateConsQuadratic(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, 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)
static SCIP_RETCODE createVararray(SCIP *scip, VARARRAY **vararray, const char *name, SCIP_VAR **vars, int nvars, FZNNUMBERTYPE type, DIMENSIONS *info)
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)
static SCIP_RETCODE parseQuadratic(SCIP *scip, FZNINPUT *fzninput, const char *name)
int SCIPgetNVarsCumulative(SCIP *scip, SCIP_CONS *cons)
Constraint handler for "or" constraints, .
static void parseArrayType(SCIP *scip, FZNINPUT *fzninput, SCIP_Bool *isvararray, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Constraint handler for knapsack constraints of the form , x binary and .
#define CREATE_CONSTRAINT(x)
static SCIP_Bool isBoolExp(const char *name, SCIP_Bool *value)
static void parseArrayIndex(SCIP *scip, FZNINPUT *fzninput, int *idx)
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE parsePredicate(SCIP *scip, FZNINPUT *fzninput)
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)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
#define SCIPallocBuffer(scip, ptr)
static SCIP_RETCODE applyVariableAssignment(SCIP *scip, FZNINPUT *fzninput, SCIP_VAR *var, FZNNUMBERTYPE type, const char *assignment)
struct Dimensions DIMENSIONS
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
static const char delimchars[]
#define SCIPfreeBufferArrayNull(scip, ptr)
int SCIPfeof(SCIP_FILE *stream)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
struct SCIP_File SCIP_FILE
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
static SCIP_RETCODE readFZNFile(SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput, const char *filename)
static SCIP_RETCODE parseName(SCIP *scip, FZNINPUT *fzninput, char *name, SCIP_Bool *output, DIMENSIONS **info)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
const char * SCIPvarGetName(SCIP_VAR *var)
constraint handler for quadratic constraints
static SCIP_DECL_SORTPTRCOMP(vararraysComp)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool isEndStatement(FZNINPUT *fzninput)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
static void parseArrayDimension(SCIP *scip, FZNINPUT *fzninput, int *nelements)
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
static SCIP_RETCODE createQuadraticCons(SCIP *scip, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows)
static SCIP_Bool isDelimChar(char c)
static SCIP_RETCODE createVariable(SCIP *scip, FZNINPUT *fzninput, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, FZNNUMBERTYPE type)
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
SCIP_Longint SCIPgetCapacityKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE fzninputAddConstarray(SCIP *scip, FZNINPUT *fzninput, const char *name, FZNCONSTANT **constants, int nconstants, FZNNUMBERTYPE type)
static void syntaxError(SCIP *scip, FZNINPUT *fzninput, const char *msg)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
struct FznOutput FZNOUTPUT
#define SCIPallocBufferArray(scip, ptr, num)
struct SCIP_ReaderData SCIP_READERDATA
public data structures and miscellaneous methods
static SCIP_Bool isChar(const char *token, char c)
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
void SCIPprintSysError(const char *message)
static const char commentchars[]
enum SCIP_Objsense SCIP_OBJSENSE
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
static void flattenFloat(SCIP *scip, SCIP_Real val, char *buffer)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
static SCIP_Bool getNextLine(SCIP *scip, FZNINPUT *fzninput)
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_DECL_HASHGETKEY(hashGetKeyVar)
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
static SCIP_RETCODE ensureConstarrySizeFznInput(SCIP *scip, FZNINPUT *fzninput)
static void pushToken(FZNINPUT *fzninput)
static SCIP_RETCODE parseConstant(SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE type)
int * SCIPgetDurationsCumulative(SCIP *scip, SCIP_CONS *cons)
Constraint handler for linear constraints in their most general form, .
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
SCIP_Longint SCIPconvertRealToLongint(SCIP *scip, SCIP_Real real)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
static void freeVararray(SCIP *scip, VARARRAY **vararray)
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
#define SCIP_HASHSIZE_NAMES
static VARARRAY * findVararray(SCIP *scip, FZNINPUT *fzninput, const char *name)
static SCIP_RETCODE printLinearCons(SCIP *scip, FZNOUTPUT *fznoutput, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed, SCIP_Bool mayhavefloats)
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)
Constraint handler for XOR constraints, .
#define SCIPfreeBuffer(scip, ptr)
int SCIPgetCapacityCumulative(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
static const SCIP_Real scalars[]
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE parseVariableArrayAssignment(SCIP *scip, FZNINPUT *fzninput, SCIP_VAR ***vars, int *nvars, int sizevars)
static SCIP_RETCODE createLinking(SCIP *scip, FZNINPUT *fzninput, const char *consname, const char *name1, const char *name2, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
static SCIP_RETCODE parseVariableArray(SCIP *scip, SCIP_READERDATA *readerdata, FZNINPUT *fzninput, const char *name, int nvars, FZNNUMBERTYPE type, SCIP_Real lb, SCIP_Real ub, DIMENSIONS *info)
static SCIP_DECL_READERWRITE(readerWriteFzn)
static SCIP_DECL_READERREAD(readerReadFzn)
static void parseType(SCIP *scip, FZNINPUT *fzninput, FZNNUMBERTYPE *type, SCIP_Real *lb, SCIP_Real *ub)
static SCIP_RETCODE parseConstraint(SCIP *scip, FZNINPUT *fzninput)
int * SCIPgetDemandsCumulative(SCIP *scip, SCIP_CONS *cons)
static const char tokenchars[]
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE parseSolveItem(SCIP *scip, FZNINPUT *fzninput)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
static SCIP_RETCODE parseList(SCIP *scip, FZNINPUT *fzninput, char ***elements, int *nelements, int selements)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool getNextToken(SCIP *scip, FZNINPUT *fzninput)
enum SCIP_Vartype SCIP_VARTYPE
SCIP_RETCODE SCIPcreateConsCumulative(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, int *durations, int *demands, int capacity, 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_Real SCIPvarGetUbLocal(SCIP_VAR *var)
static SCIP_DECL_READERFREE(readerFreeFzn)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
static void freeStringBufferArray(SCIP *scip, char **array, int nelements)
static SCIP_RETCODE createConstantAssignment(SCIP *scip, FZNCONSTANT **constant, FZNINPUT *fzninput, const char *name, FZNNUMBERTYPE type, const char *assignment)
static void freeConstarray(SCIP *scip, CONSTARRAY **constarray)
#define BMSclearMemoryArray(ptr, num)
int SCIPfclose(SCIP_FILE *fp)
static SCIP_RETCODE createLinearCons(SCIP *scip, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE ensureVararrySize(SCIP *scip, SCIP_READERDATA *readerdata)
char * SCIPstrtok(char *s, const char *delim, char **ptrptr)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
#define FZN_MAX_PUSHEDTOKENS
static void freeDimensions(SCIP *scip, DIMENSIONS **dim)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE printRow(SCIP *scip, FZNOUTPUT *fznoutput, const char *type, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real rhs, SCIP_Bool hasfloats)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
#define SCIPreallocBufferArray(scip, ptr, num)
static SCIP_Bool isValue(const char *token, SCIP_Real *value)