33 #if defined(_WIN32) || defined(_WIN64) 54 #define READER_NAME "lpreader" 55 #define READER_DESC "file reader for MIPs in IBM CPLEX's LP file format" 56 #define READER_EXTENSION "lp" 58 #define DEFAULT_LINEARIZE_ANDS TRUE 59 #define DEFAULT_AGGRLINEARIZATION_ANDS TRUE 65 #define LP_MAX_LINELEN 65536 66 #define LP_MAX_PUSHEDTOKENS 2 67 #define LP_INIT_COEFSSIZE 8192 68 #define LP_INIT_QUADCOEFSSIZE 16 69 #define LP_MAX_PRINTLEN 561 70 #define LP_MAX_NAMELEN 256 71 #define LP_PRINTLEN 100 75 struct SCIP_ReaderData
145 assert(lpinput !=
NULL);
147 SCIPerrorMessage(
"Syntax error in line %d ('%s'): %s \n", lpinput->linenumber, lpinput->token, msg);
148 if( lpinput->linebuf[strlen(lpinput->linebuf)-1] ==
'\n' )
156 (void)
SCIPsnprintf(formatstr, 256,
" %%%ds\n", lpinput->linepos);
158 lpinput->section =
LP_END;
159 lpinput->haserror =
TRUE;
168 assert(lpinput !=
NULL);
170 return lpinput->haserror;
228 assert(hasdot !=
NULL);
229 assert(exptype !=
NULL);
231 if( isdigit((
unsigned char)c) )
233 else if( (*exptype ==
LP_EXP_NONE) && !(*hasdot) && (c ==
'.') && ( isdigit((
unsigned char)nextc) || isspace((
unsigned char)nextc) || nextc ==
'e' || nextc ==
'E') )
238 else if( !firstchar && (*exptype ==
LP_EXP_NONE) && (c ==
'e' || c ==
'E') )
240 if( nextc ==
'+' || nextc ==
'-' )
245 else if( isdigit((
unsigned char)nextc) )
251 else if( (*exptype ==
LP_EXP_SIGNED) && (c ==
'+' || c ==
'-') )
271 assert(lpinput !=
NULL);
274 if( !lpinput->endline && lpinput->comment )
281 (void)
SCIPfgets(lpinput->linebuf, (
int)
sizeof(lpinput->linebuf), lpinput->file);
285 lpinput->comment =
FALSE;
286 lpinput->endline =
TRUE;
290 lpinput->linepos = 0;
293 if(
SCIPfgets(lpinput->linebuf, (
int)
sizeof(lpinput->linebuf), lpinput->file) ==
NULL )
301 lpinput->linenumber++;
309 lpinput->endline =
FALSE;
310 last = strrchr(lpinput->linebuf,
' ');
314 SCIPwarningMessage(scip,
"we read %d characters from the file; this might indicate a corrupted input file!",
321 SCIPfseek(lpinput->file, -(
long) strlen(last), SEEK_CUR);
322 SCIPdebugMsg(scip,
"correct buffer, reread the last %ld characters\n", (
long) strlen(last));
329 lpinput->endline =
TRUE;
332 lpinput->comment =
FALSE;
339 commentstart = strchr(lpinput->linebuf,
commentchars[i]);
340 if( commentstart !=
NULL )
342 *commentstart =
'\0';
343 *(commentstart+1) =
'\0';
345 lpinput->comment =
TRUE;
363 *pointer1 = *pointer2;
379 assert(lpinput !=
NULL);
383 if( lpinput->npushedtokens > 0 )
385 swapPointers(&lpinput->token, &lpinput->pushedtokens[lpinput->npushedtokens-1]);
386 lpinput->npushedtokens--;
388 SCIPdebugMsg(scip,
"(line %d) read token again: '%s'\n", lpinput->linenumber, lpinput->token);
393 buf = lpinput->linebuf;
396 if( buf[lpinput->linepos] ==
'\0' )
400 lpinput->section =
LP_END;
401 SCIPdebugMsg(scip,
"(line %d) end of file\n", lpinput->linenumber);
404 assert(lpinput->linepos == 0);
415 if(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
TRUE, &hasdot, &exptype) )
423 lpinput->token[tokenlen] = buf[lpinput->linepos];
427 while(
isValueChar(buf[lpinput->linepos], buf[lpinput->linepos+1],
FALSE, &hasdot, &exptype) );
436 lpinput->token[tokenlen] = buf[lpinput->linepos];
439 if( tokenlen == 1 &&
isTokenChar(lpinput->token[0]) )
448 if( tokenlen >= 1 && lpinput->token[tokenlen-1] ==
'^' && buf[lpinput->linepos] ==
'2' )
453 && (lpinput->token[tokenlen-1] ==
'<' || lpinput->token[tokenlen-1] ==
'>' || lpinput->token[tokenlen-1] ==
'=')
454 && buf[lpinput->linepos] ==
'=' )
458 else if( lpinput->token[tokenlen-1] ==
'=' && (buf[lpinput->linepos] ==
'<' || buf[lpinput->linepos] ==
'>') )
460 lpinput->token[tokenlen-1] = buf[lpinput->linepos];
465 lpinput->token[tokenlen] =
'\0';
467 SCIPdebugMsg(scip,
"(line %d) read token: '%s'\n", lpinput->linenumber, lpinput->token);
478 assert(lpinput !=
NULL);
481 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->token);
482 lpinput->npushedtokens++;
491 assert(lpinput !=
NULL);
494 swapPointers(&lpinput->pushedtokens[lpinput->npushedtokens], &lpinput->tokenbuf);
495 lpinput->npushedtokens++;
504 assert(lpinput !=
NULL);
519 assert(lpinput !=
NULL);
528 iscolon = (*lpinput->token ==
':');
539 len = strlen(lpinput->token);
543 if( len > 1 && (len < 9 || len == 15) )
548 while( lpinput->token[c] !=
'\0' )
550 token[c] = toupper(lpinput->token[c]);
556 if( (len == 3 && strcmp(token,
"MIN") == 0)
557 || (len == 7 && strcmp(token,
"MINIMUM") == 0)
558 || (len == 8 && strcmp(token,
"MINIMIZE") == 0) )
560 SCIPdebugMsg(scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
566 if( (len == 3 && strcmp(token,
"MAX") == 0)
567 || (len == 7 && strcmp(token,
"MAXIMUM") == 0)
568 || (len == 8 && strcmp(token,
"MAXIMIZE") == 0) )
570 SCIPdebugMsg(scip,
"(line %d) new section: OBJECTIVE\n", lpinput->linenumber);
576 if( len == 7 && strcmp(token,
"SUBJECT") == 0 )
582 if( strcasecmp(lpinput->token,
"TO") == 0 )
584 SCIPdebugMsg(scip,
"(line %d) new section: CONSTRAINTS\n", lpinput->linenumber);
586 lpinput->inlazyconstraints =
FALSE;
587 lpinput->inusercuts =
FALSE;
596 if( len == 4 && strcmp(token,
"SUCH") == 0 )
602 if( strcasecmp(lpinput->token,
"THAT") == 0 )
604 SCIPdebugMsg(scip,
"(line %d) new section: CONSTRAINTS\n", lpinput->linenumber);
606 lpinput->inlazyconstraints =
FALSE;
607 lpinput->inusercuts =
FALSE;
616 if( (len == 2 && strcmp(token,
"ST") == 0)
617 || (len == 3 && strcmp(token,
"ST.") == 0)
618 || (len == 4 && strcmp(token,
"S.T.") == 0) )
620 SCIPdebugMsg(scip,
"(line %d) new section: CONSTRAINTS\n", lpinput->linenumber);
622 lpinput->inlazyconstraints =
FALSE;
623 lpinput->inusercuts =
FALSE;
627 if( len == 4 && strcmp(token,
"LAZY") == 0 )
633 if( strcasecmp(lpinput->token,
"CONSTRAINTS") == 0 )
635 SCIPdebugMsg(scip,
"(line %d) new section: CONSTRAINTS (lazy)\n", lpinput->linenumber);
637 lpinput->inlazyconstraints =
TRUE;
638 lpinput->inusercuts =
FALSE;
647 if( len == 4 && strcmp(token,
"USER") == 0 )
653 if( strcasecmp(lpinput->token,
"CUTS") == 0 )
655 SCIPdebugMsg(scip,
"(line %d) new section: CONSTRAINTS (user cuts)\n", lpinput->linenumber);
657 lpinput->inlazyconstraints =
FALSE;
658 lpinput->inusercuts =
TRUE;
667 if( (len == 5 && strcmp(token,
"BOUND") == 0)
668 || (len == 6 && strcmp(token,
"BOUNDS") == 0) )
670 SCIPdebugMsg(scip,
"(line %d) new section: BOUNDS\n", lpinput->linenumber);
675 if( (len == 3 && (strcmp(token,
"GEN") == 0 || strcmp(token,
"INT") == 0))
676 || (len == 7 && (strcmp(token,
"GENERAL") == 0 || strcmp(token,
"INTEGER") == 0))
677 || (len == 8 && (strcmp(token,
"GENERALS") == 0 || strcmp(token,
"INTEGERS") == 0)) )
679 SCIPdebugMsg(scip,
"(line %d) new section: GENERALS\n", lpinput->linenumber);
684 if( (len == 3 && strcmp(token,
"BIN") == 0)
685 || (len == 6 && strcmp(token,
"BINARY") == 0)
686 || (len == 8 && strcmp(token,
"BINARIES") == 0) )
688 SCIPdebugMsg(scip,
"(line %d) new section: BINARIES\n", lpinput->linenumber);
693 if( (len == 4 && strcmp(token,
"SEMI") == 0)
694 || (len == 5 && strcmp(token,
"SEMIS") == 0)
695 || (len == 15 && strcmp(token,
"SEMI-CONTINUOUS") == 0) )
697 SCIPdebugMsg(scip,
"(line %d) new section: SEMICONTINUOUS\n", lpinput->linenumber);
702 if( len == 3 && strcmp(token,
"SOS") == 0 )
704 SCIPdebugMsg(scip,
"(line %d) new section: SOS\n", lpinput->linenumber);
705 lpinput->section =
LP_SOS;
709 if( len == 3 && strcmp(token,
"END") == 0 )
711 SCIPdebugMsg(scip,
"(line %d) new section: END\n", lpinput->linenumber);
712 lpinput->section =
LP_END;
727 assert(lpinput !=
NULL);
728 assert(sign !=
NULL);
729 assert(*sign == +1 || *sign == -1);
731 if( lpinput->token[1] ==
'\0' )
733 if( *lpinput->token ==
'+' )
735 else if( *lpinput->token ==
'-' )
753 assert(lpinput !=
NULL);
754 assert(value !=
NULL);
756 if( strcasecmp(lpinput->token,
"INFINITY") == 0 || strcasecmp(lpinput->token,
"INF") == 0 )
766 val = strtod(lpinput->token, &endptr);
767 if( endptr != lpinput->token && *endptr ==
'\0' )
784 assert(lpinput !=
NULL);
786 if( strcmp(lpinput->token,
"<") == 0 )
792 else if( strcmp(lpinput->token,
">") == 0 )
798 else if( strcmp(lpinput->token,
"=") == 0 )
817 assert(name !=
NULL);
829 initial = !dynamiccols;
830 removable = dynamiccols;
833 SCIPdebugMsg(scip,
"creating new variable: <%s>\n", name);
844 if( created !=
NULL )
847 else if( created !=
NULL )
860 assert(lpinput !=
NULL);
901 assert(lpinput !=
NULL);
902 assert(name !=
NULL);
903 assert(coefssize !=
NULL);
904 assert(vars !=
NULL);
905 assert(coefs !=
NULL);
906 assert(ncoefs !=
NULL);
907 assert(quadcoefssize !=
NULL);
908 assert(quadvars1 !=
NULL);
909 assert(quadvars2 !=
NULL);
910 assert(quadcoefs !=
NULL);
911 assert(nquadcoefs !=
NULL);
912 assert(newsection !=
NULL);
943 if( strcmp(lpinput->token,
":") == 0 )
949 SCIPdebugMsg(scip,
"(line %d) read constraint name: '%s'\n", lpinput->linenumber, name);
988 if(
isSign(lpinput, &coefsign) )
990 SCIPdebugMsg(scip,
"(line %d) read coefficient sign: %+d\n", lpinput->linenumber, coefsign);
996 if(
isValue(scip, lpinput, &coef) )
998 SCIPdebugMsg(scip,
"(line %d) read coefficient value: %g with sign %+d\n", lpinput->linenumber, coef, coefsign);
1001 syntaxError(scip, lpinput,
"two consecutive values.");
1013 syntaxError(scip, lpinput,
"no sense allowed in objective");
1025 if( (isobjective || (!havevalue && !havesign)) && !inquadpart &&
isNewSection(scip, lpinput) )
1027 if( havesign && !havevalue )
1029 SCIPwarningMessage(scip,
"skipped single sign %c without value or variable in objective\n", coefsign == 1 ?
'+' :
'-');
1031 else if( isobjective && havevalue && !
SCIPisZero(scip, coef) )
1033 SCIPwarningMessage(scip,
"constant term %+g in objective is skipped\n", coef * coefsign);
1041 if( *lpinput->token ==
'[' )
1045 syntaxError(scip, lpinput,
"cannot start quadratic part while already in quadratic part.");
1048 if( havesign && coefsign != +1 )
1050 syntaxError(scip, lpinput,
"cannot have '-' in front of quadratic part.");
1055 syntaxError(scip, lpinput,
"cannot have value in front of quadratic part.");
1059 SCIPdebugMsg(scip,
"(line %d) start quadratic part\n", lpinput->linenumber);
1065 if( *lpinput->token ==
']' )
1069 syntaxError(scip, lpinput,
"cannot end quadratic part before starting one.");
1072 if( havesign || havevalue || firstquadvar !=
NULL )
1074 if( firstquadvar ==
NULL )
1076 syntaxError(scip, lpinput,
"expected value or first quadratic variable.");
1080 syntaxError(scip, lpinput,
"expected second quadratic variable.");
1085 SCIPdebugMsg(scip,
"(line %d) end quadratic part\n", lpinput->linenumber);
1093 syntaxError(scip, lpinput,
"expected '/2' or '/ 2' after end of quadratic part in objective.");
1096 if( strcmp(lpinput->token,
"/2") == 0 )
1098 SCIPdebugMsg(scip,
"(line %d) saw '/2' or '/ 2' after quadratic part in objective\n", lpinput->linenumber);
1100 else if( *lpinput->token ==
'/' )
1103 if( !
getNextToken(scip, lpinput) || *lpinput->token !=
'2' )
1105 syntaxError(scip, lpinput,
"expected '/2' or '/ 2' after end of quadratic part in objective.");
1108 SCIPdebugMsg(scip,
"(line %d) saw '/ 2' after quadratic part in objective\n", lpinput->linenumber);
1112 syntaxError(scip, lpinput,
"expected '/2' or '/ 2' after end of quadratic part in objective.");
1121 if( *lpinput->token ==
'*' )
1125 syntaxError(scip, lpinput,
"cannot have '*' outside of quadratic part.");
1128 if( firstquadvar ==
NULL )
1130 syntaxError(scip, lpinput,
"cannot have '*' before first variable in quadratic term.");
1138 if( !inquadpart && *ncoefs > 0 && !havesign )
1140 syntaxError(scip, lpinput,
"expected sign ('+' or '-') or sense ('<' or '>').");
1143 if( inquadpart && *nquadcoefs > 0 && !havesign )
1145 syntaxError(scip, lpinput,
"expected sign ('+' or '-').");
1150 if( *lpinput->token ==
'^' )
1154 syntaxError(scip, lpinput,
"cannot have squares ('^2') outside of quadratic part.");
1157 if( firstquadvar ==
NULL )
1159 syntaxError(scip, lpinput,
"cannot have square '^2' before variable.");
1174 SCIPdebugMsg(scip,
"(line %d) read linear coefficient: %+g<%s>\n", lpinput->linenumber, coefsign * coef,
SCIPvarGetName(var));
1178 if( *ncoefs >= *coefssize )
1181 oldcoefssize = *coefssize;
1183 *coefssize =
MAX(*coefssize, (*ncoefs)+1);
1187 assert(*ncoefs < *coefssize);
1190 (*vars)[*ncoefs] = var;
1191 (*coefs)[*ncoefs] = coefsign * coef;
1197 if( firstquadvar ==
NULL )
1209 if( *nquadcoefs >= *quadcoefssize )
1211 int oldquadcoefssize;
1212 oldquadcoefssize = *quadcoefssize;
1213 *quadcoefssize *= 2;
1214 *quadcoefssize =
MAX(*quadcoefssize, (*nquadcoefs)+1);
1219 assert(*nquadcoefs < *quadcoefssize);
1222 (*quadvars1)[*nquadcoefs] = firstquadvar;
1223 (*quadvars2)[*nquadcoefs] = var;
1224 (*quadcoefs)[*nquadcoefs] = coefsign * coef;
1226 (*quadcoefs)[*nquadcoefs] /= 2.0;
1236 firstquadvar =
NULL;
1261 assert(lpinput !=
NULL);
1265 &quadcoefssize, &quadvars1, &quadvars2, &quadcoefs, &nquadcoefs, &newsection) );
1272 for( i = 0; i < ncoefs; ++i )
1283 if( nquadcoefs > 0 )
1307 SCIP_CALL(
SCIPcreateConsQuadratic(scip, &quadobjcons,
"quadobj", 1, &quadobjvar, &minusone, nquadcoefs, quadvars1, quadvars2, quadcoefs, lhs, rhs,
1311 SCIPdebugMsg(scip,
"(line %d) added constraint <%s> to represent quadratic objective: ", lpinput->linenumber,
SCIPconsGetName(quadobjcons));
1367 assert( lpinput !=
NULL );
1368 assert( binvar !=
NULL );
1375 syntaxError(scip, lpinput,
"value for binary variable must be '0' or '1'.");
1397 assert( binvar !=
NULL );
1402 &quadcoefssize, &quadvars1, &quadvars2, &quadcoefs, &nquadcoefs, &newsection) );
1408 syntaxError(scip, lpinput,
"expected constraint.");
1411 if( nquadcoefs > 0 )
1414 syntaxError(scip, lpinput,
"quadratic indicator constraints not supported.");
1417 if( name2[0] !=
'\0' )
1419 syntaxError(scip, lpinput,
"did not expect name for linear constraint.");
1426 syntaxError(scip, lpinput,
"expected constraint sense '<=', '=', or '>='.");
1435 syntaxError(scip, lpinput,
"missing right hand side.");
1438 if(
isSign(lpinput, &linsidesign) )
1442 syntaxError(scip, lpinput,
"missing value of right hand side.");
1446 if( !
isValue(scip, lpinput, &linsidevalue) )
1448 syntaxError(scip, lpinput,
"expected value for right hand side.");
1451 linsidevalue *= linsidesign;
1458 linrhs = -linsidevalue;
1459 for( j = 0; j < nlincoefs; ++j )
1463 linrhs = linsidevalue;
1467 linrhs = linsidevalue;
1477 initial = lpinput->initialconss && !lpinput->inlazyconstraints && !lpinput->inusercuts;
1479 enforce = !lpinput->inusercuts;
1480 check = !lpinput->inusercuts;
1483 dynamic = lpinput->dynamicconss;
1484 removable = lpinput->dynamicrows || lpinput->inusercuts;
1487 initial, separate, enforce, check, propagate, local, dynamic, removable,
FALSE);
1493 SCIPdebugMsg(scip,
"(line %d) created constraint%s: ", lpinput->linenumber,
1494 lpinput->inlazyconstraints ?
" (lazy)" : (lpinput->inusercuts ?
" (user cut)" :
""));
1505 for( j = 0; j < nlincoefs; ++j )
1509 initial, separate, enforce, check, propagate, local, dynamic, removable,
FALSE);
1515 SCIPdebugMsg(scip,
"(line %d) created constraint%s: ", lpinput->linenumber,
1516 lpinput->inlazyconstraints ?
" (lazy)" : (lpinput->inusercuts ?
" (user cut)" :
""));
1579 assert(lpinput !=
NULL);
1585 &quadcoefssize, &quadvars1, &quadvars2, &quadcoefs, &nquadcoefs, &newsection) );
1591 if( ncoefs > 0 || nquadcoefs > 0 )
1592 syntaxError(scip, lpinput,
"expected constraint sense '<=', '=', or '>='.");
1599 syntaxError(scip, lpinput,
"expected constraint sense '<=', '=', or '>='.");
1608 syntaxError(scip, lpinput,
"missing right hand side.");
1611 if(
isSign(lpinput, &sidesign) )
1615 syntaxError(scip, lpinput,
"missing value of right hand side.");
1619 if( !
isValue(scip, lpinput, &sidevalue) )
1621 syntaxError(scip, lpinput,
"expected value as right hand side.");
1624 sidevalue *= sidesign;
1649 isIndicatorCons =
FALSE;
1653 if ( *lpinput->token ==
'<' )
1655 int linepos = lpinput->linepos-1;
1661 if ( *lpinput->token ==
'-' )
1667 if ( *lpinput->token ==
'>' )
1669 lpinput->linepos = linepos;
1670 strcpy(lpinput->token,
"<");
1672 "SCIP does not support equivalence (<->) indicator constraints; consider using the \"->\" form.");
1679 lpinput->linepos = linepos;
1680 strcpy(lpinput->token,
"<");
1684 if ( *lpinput->token ==
'-' )
1693 if ( *lpinput->token ==
'>' )
1694 isIndicatorCons =
TRUE;
1709 if( !isIndicatorCons )
1712 initial = lpinput->initialconss && !lpinput->inlazyconstraints && !lpinput->inusercuts;
1714 enforce = !lpinput->inusercuts;
1715 check = !lpinput->inusercuts;
1719 dynamic = lpinput->dynamicconss;
1720 removable = lpinput->dynamicrows || lpinput->inusercuts;
1721 if( nquadcoefs == 0 )
1724 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable,
FALSE);
1729 nquadcoefs, quadvars1, quadvars2, quadcoefs, lhs, rhs,
1730 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable);
1737 SCIPdebugMsg(scip,
"(line %d) created constraint%s: ", lpinput->linenumber,
1738 lpinput->inlazyconstraints ?
" (lazy)" : (lpinput->inusercuts ?
" (user cut)" :
""));
1745 if( ncoefs != 1 || nquadcoefs > 0 )
1747 syntaxError(scip, lpinput,
"Indicator part can only consist of one binary variable.");
1750 if( !
SCIPisEQ(scip, coefs[0], 1.0) )
1752 syntaxError(scip, lpinput,
"There cannot be a coefficient before the binary indicator variable.");
1757 syntaxError(scip, lpinput,
"Indicator part cannot handle equations.");
1784 assert(lpinput !=
NULL);
1807 hassign =
isSign(lpinput, &sign);
1815 if(
isValue(scip, lpinput, &value) )
1820 syntaxError(scip, lpinput,
"expected bound sense '<=', '=', or '>='.");
1854 syntaxError(scip, lpinput,
"expected variable name.");
1864 if(
isSense(lpinput, &rightsense) )
1873 syntaxError(scip, lpinput,
"expected value or sign.");
1879 hassign =
isSign(lpinput, &sign);
1887 if( !
isValue(scip, lpinput, &value) )
1894 switch( rightsense )
1914 syntaxError(scip, lpinput,
"the two bound senses do not fit.");
1918 else if( strcasecmp(lpinput->token,
"FREE") == 0 )
1922 syntaxError(scip, lpinput,
"variable with bound is marked as 'free'.");
1955 assert(lpinput !=
NULL);
1973 syntaxError(scip, lpinput,
"unknown variable in generals section.");
1982 SCIPwarningMessage(scip,
"variable <%s> declared as integer has non-integral bounds[%.14g, %.14g] -> if feasible, bounds will be adjusted\n",
SCIPvarGetName(var), lb, ub);
2000 assert(lpinput !=
NULL);
2018 syntaxError(scip, lpinput,
"unknown variable in binaries section.");
2028 SCIPwarningMessage(scip,
"variable <%s> declared as binary has non-binary bounds[%.14g, %.14g] -> if feasible, bounds will be adjusted\n",
SCIPvarGetName(var), lb, ub);
2064 assert(lpinput !=
NULL);
2067 if( strcasecmp(lpinput->token,
"SEMI") == 0 )
2075 if( strcasecmp(lpinput->token,
"-") == 0 )
2077 if( !
getNextToken(scip, lpinput) || strcasecmp(lpinput->token,
"CONTINUOUS") != 0 )
2079 syntaxError(scip, lpinput,
"expected 'CONTINUOUS' after 'SEMI-'.");
2099 syntaxError(scip, lpinput,
"unknown variable in semi-continuous section.");
2152 SCIP_Bool initial, separate, enforce, check, propagate;
2153 SCIP_Bool local, modifiable, dynamic, removable;
2157 assert(lpinput !=
NULL);
2160 initial = lpinput->initialconss;
2167 dynamic = lpinput->dynamicconss;
2168 removable = lpinput->dynamicrows;
2188 if( strcmp(lpinput->token,
":") == 0 )
2211 syntaxError(scip, lpinput,
"expected SOS type: 'S1::' or 'S2::'.");
2215 if( strcmp(lpinput->token,
":") == 0 )
2219 lpinput->token[0] =
':';
2220 lpinput->token[1] =
'\0';
2229 if( strcmp(lpinput->token,
"S1") == 0 )
2232 SCIP_CALL(
SCIPcreateConsSOS1(scip, &cons, name, 0,
NULL,
NULL, initial, separate, enforce, check, propagate,
2233 local, modifiable, dynamic, removable) );
2235 else if( strcmp(lpinput->token,
"S2") == 0 )
2238 SCIP_CALL(
SCIPcreateConsSOS2(scip, &cons, name, 0,
NULL,
NULL, initial, separate, enforce, check, propagate,
2239 local, modifiable, dynamic, removable) );
2243 syntaxError(scip, lpinput,
"SOS constraint type other than 1 or 2 appeared.");
2246 assert( type == 1 || type == 2 );
2248 SCIPdebugMsg(scip,
"created SOS%d constraint <%s>\n", type, name);
2251 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2253 syntaxError(scip, lpinput,
"SOS constraint type has to be followed by two colons.");
2258 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2260 syntaxError(scip, lpinput,
"SOS constraint type has to be followed by two colons.");
2289 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2291 syntaxError(scip, lpinput,
"expected colon and weight.");
2307 if(
isSign(lpinput, &sign) )
2313 if( !
isValue(scip, lpinput, &weight) )
2361 const char* filename
2364 assert(lpinput !=
NULL);
2367 lpinput->file =
SCIPfopen(filename,
"r");
2368 if( lpinput->file ==
NULL )
2382 switch( lpinput->section )
2475 assert( scip !=
NULL );
2476 assert( var !=
NULL );
2479 assert( name !=
NULL );
2481 if( genericnames || name[0] ==
'\0' )
2485 if( isdigit((
unsigned char)name[0]) || name[0] ==
'e' || name[0] ==
'E' )
2507 assert(scip !=
NULL);
2508 assert(vars !=
NULL);
2509 assert(scalars !=
NULL);
2510 assert(*vars !=
NULL);
2511 assert(*scalars !=
NULL);
2512 assert(nvars !=
NULL);
2513 assert(constant !=
NULL);
2519 if( requiredsize > *nvars )
2525 assert( requiredsize <= *nvars );
2530 for( v = 0; v < *nvars; ++v )
2540 (*scalars)[v] *= -1.0;
2555 assert( linebuffer !=
NULL );
2556 assert( linecnt !=
NULL );
2559 linebuffer[0] =
'\0';
2571 assert( scip !=
NULL );
2572 assert( linebuffer !=
NULL );
2573 assert( linecnt !=
NULL );
2575 if( (*linecnt) > 0 )
2577 linebuffer[(*linecnt)] =
'\0';
2591 const char* extension
2594 assert( scip !=
NULL );
2595 assert( linebuffer !=
NULL );
2596 assert( linecnt !=
NULL );
2597 assert( extension !=
NULL );
2606 (*linecnt) += (int) strlen(extension);
2608 SCIPdebugMsg(scip,
"linebuffer <%s>, length = %lu\n", linebuffer, (
unsigned long)strlen(linebuffer));
2611 endLine(scip, file, linebuffer, linecnt);
2620 const char* rowname,
2621 const char* rownameextension,
2643 assert( scip !=
NULL );
2644 assert( strcmp(type,
"=") == 0 || strcmp(type,
"<=") == 0 || strcmp(type,
">=") == 0 );
2645 assert( nlinvars == 0 || (linvars !=
NULL && linvals !=
NULL) );
2646 assert( nquadvarterms == 0 || quadvarterms !=
NULL );
2649 assert( nbilinterms == 0 || (bilinterms !=
NULL && nquadvarterms >= 2) );
2654 appendLine(scip, file, linebuffer, &linecnt,
" ");
2657 if( strlen(rowname) > 0 || strlen(rownameextension) > 0 )
2660 appendLine(scip, file, linebuffer, &linecnt, consname);
2664 for( v = 0; v < nlinvars; ++v )
2667 assert( var !=
NULL );
2671 appendLine(scip, file, linebuffer, &linecnt,
" ");
2676 appendLine(scip, file, linebuffer, &linecnt, buffer);
2680 if( nquadvarterms > 0 )
2683 for( v = 0; v < nquadvarterms; ++v )
2685 if( quadvarterms[v].lincoef == 0.0 )
2690 appendLine(scip, file, linebuffer, &linecnt,
" ");
2695 appendLine(scip, file, linebuffer, &linecnt, buffer);
2699 appendLine(scip, file, linebuffer, &linecnt,
" + [");
2702 for( v = 0; v < nquadvarterms; ++v )
2704 if( quadvarterms[v].sqrcoef == 0.0 )
2709 appendLine(scip, file, linebuffer, &linecnt,
" ");
2714 appendLine(scip, file, linebuffer, &linecnt, buffer);
2718 for( v = 0; v < nbilinterms; ++v )
2722 appendLine(scip, file, linebuffer, &linecnt,
" ");
2728 appendLine(scip, file, linebuffer, &linecnt, buffer);
2732 appendLine(scip, file, linebuffer, &linecnt,
" ]");
2743 appendLine(scip, file, linebuffer, &linecnt,
" ");
2744 appendLine(scip, file, linebuffer, &linecnt, buffer);
2746 endLine(scip, file, linebuffer, &linecnt);
2755 const char* rowname,
2774 assert( scip !=
NULL );
2775 assert( rowname !=
NULL );
2778 assert( nlinvars == 0 || linvars !=
NULL );
2779 assert( nquadvarterms == 0 || quadvarterms !=
NULL );
2780 assert( nbilinterms == 0 || bilinterms !=
NULL );
2782 assert( lhs <= rhs );
2787 nactivevars = nlinvars;
2792 if( linvals !=
NULL )
2800 for( v = 0; v < nactivevars; ++v )
2801 activevals[v] = 1.0;
2814 printRow(scip, file, rowname,
"",
"=", activevars, activevals, nactivevars,
2815 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2816 rhs - activeconstant);
2824 activevars, activevals, nactivevars,
2825 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2826 lhs - activeconstant);
2832 activevars, activevals, nactivevars,
2833 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2834 rhs - activeconstant);
2854 const char* rowname,
2868 assert( scip !=
NULL );
2869 assert( file !=
NULL );
2870 assert( type == 1 || type == 2 );
2875 appendLine(scip, file, linebuffer, &linecnt,
" ");
2878 if( strlen(rowname) > 0 )
2881 appendLine(scip, file, linebuffer, &linecnt, buffer);
2886 appendLine(scip, file, linebuffer, &linecnt, buffer);
2888 for( v = 0; v < nvars; ++v )
2892 if( weights !=
NULL )
2900 appendLine(scip, file, linebuffer, &linecnt,
" ");
2902 appendLine(scip, file, linebuffer, &linecnt, buffer);
2905 endLine(scip, file, linebuffer, &linecnt);
2913 const char* rowname,
2929 assert( scip !=
NULL );
2930 assert( rowname !=
NULL );
2931 assert( cons !=
NULL );
2946 appendLine(scip, file, linebuffer, &linecnt,
" ");
2949 if( strlen(rowname) > 0 )
2952 appendLine(scip, file, linebuffer, &linecnt, consname);
2961 assert( var !=
NULL );
2965 rhs -= coef * coef * offset * offset;
2967 if( offset == 0.0 || coef == 0.0 )
2972 appendLine(scip, file, linebuffer, &linecnt,
" ");
2977 appendLine(scip, file, linebuffer, &linecnt, buffer);
2983 if( offset != 0.0 && coef != 0.0 )
2986 assert( var !=
NULL );
2988 rhs += coef * coef * offset * offset;
2991 appendLine(scip, file, linebuffer, &linecnt,
" ");
2996 appendLine(scip, file, linebuffer, &linecnt, buffer);
3000 appendLine(scip, file, linebuffer, &linecnt,
" + [");
3006 assert( var !=
NULL );
3014 appendLine(scip, file, linebuffer, &linecnt,
" ");
3019 appendLine(scip, file, linebuffer, &linecnt, buffer);
3027 assert( var !=
NULL );
3031 appendLine(scip, file, linebuffer, &linecnt,
" ");
3036 appendLine(scip, file, linebuffer, &linecnt, buffer);
3040 appendLine(scip, file, linebuffer, &linecnt,
" ]");
3050 appendLine(scip, file, linebuffer, &linecnt,
" ");
3051 appendLine(scip, file, linebuffer, &linecnt, buffer);
3053 endLine(scip, file, linebuffer, &linecnt);
3063 const char* consname,
3077 assert(scip !=
NULL);
3078 assert(consname !=
NULL);
3079 assert(cons !=
NULL);
3090 if( !aggrlinearizationands )
3092 vars[0] = resultant;
3097 for( v = 0; v < nvars; ++v )
3100 vars[1] = operands[v];
3109 for( v = nvars - 1; v >= 0; --v )
3111 vars[v] = operands[v];
3115 vars[nvars] = resultant;
3118 if( aggrlinearizationands )
3159 assert( scip !=
NULL );
3160 assert( aggvars !=
NULL );
3161 assert( naggvars !=
NULL );
3162 assert( saggvars !=
NULL );
3165 for( v = 0; v < nvars; ++v )
3177 assert( varAggregated !=
NULL );
3182 if ( *saggvars <= *naggvars )
3186 assert( newsize > *saggvars );
3188 *saggvars = newsize;
3191 (*aggvars)[*naggvars] = var;
3194 assert( *naggvars <= *saggvars );
3208 int nAggregatedVars,
3220 assert( scip !=
NULL );
3226 for( j = 0; j < nAggregatedVars; ++j )
3231 activevars[0] = aggregatedVars[j];
3232 activevals[0] = 1.0;
3233 activeconstant = 0.0;
3238 activevals[nactivevars] = -1.0;
3239 activevars[nactivevars] = aggregatedVars[j];
3244 printRow(scip, file, consname,
"",
"=", activevars, activevals, nactivevars,
NULL, 0,
NULL, 0, - activeconstant);
3265 assert(scip !=
NULL);
3266 assert(vars !=
NULL || nvars == 0);
3268 printwarning =
TRUE;
3271 for( v = 0; v < nvars; ++v )
3275 SCIPwarningMessage(scip,
"there is a variable name which has to be cut down to %d characters; LP might be corrupted\n",
3281 if( printwarning && isdigit((
unsigned char)
SCIPvarGetName(vars[v])[0]) )
3283 SCIPwarningMessage(scip,
"violation of LP format - a variable name starts with a digit; " \
3284 "it is not possible to read the generated LP file with SCIP; " \
3285 "use write/genproblem or write/gentransproblem for generic variable names\n");
3286 printwarning =
FALSE;
3303 const char* conshdlrname;
3306 assert( scip !=
NULL );
3307 assert( conss !=
NULL || nconss == 0 );
3309 printwarning =
TRUE;
3311 for( c = 0; c < nconss; ++c )
3315 assert(conss !=
NULL);
3317 assert(cons !=
NULL );
3323 assert( conshdlr !=
NULL );
3330 if( strcmp(conshdlrname,
"linear") == 0 )
3348 if( printwarning && isdigit((
unsigned char)
SCIPconsGetName(cons)[0]) )
3350 SCIPwarningMessage(scip,
"violation of LP format - a constraint name starts with a digit; " \
3351 "it is not possible to read the generated LP file with SCIP; " \
3352 "use write/genproblem or write/gentransproblem for generic variable names\n");
3353 printwarning =
FALSE;
3366 assert(scip !=
NULL);
3367 assert(reader !=
NULL);
3384 assert(readerdata !=
NULL);
3405 assert(reader !=
NULL);
3409 nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
3441 "reading/" READER_NAME "/linearize-and-constraints",
3442 "should possible \"and\" constraint be linearized when writing the lp file?",
3446 "should an aggregated linearization for and constraints be used?",
3457 const char* filename,
3466 lpinput.file =
NULL;
3467 lpinput.linebuf[0] =
'\0';
3468 lpinput.probname[0] =
'\0';
3469 lpinput.objname[0] =
'\0';
3471 lpinput.token[0] =
'\0';
3473 lpinput.tokenbuf[0] =
'\0';
3479 lpinput.npushedtokens = 0;
3480 lpinput.linenumber = 0;
3481 lpinput.linepos = 0;
3484 lpinput.inlazyconstraints =
FALSE;
3485 lpinput.inusercuts =
FALSE;
3486 lpinput.haserror =
FALSE;
3487 lpinput.comment =
FALSE;
3488 lpinput.endline =
FALSE;
3496 retcode =
readLPFile(scip, &lpinput, filename);
3513 if( lpinput.haserror )
3562 const char* conshdlrname;
3571 int nConsQuadratic = 0;
3573 int nConsIndicator = 0;
3590 assert(scip !=
NULL);
3597 if( conshdlrInd !=
NULL )
3610 SCIPdebugMsg(scip,
"Number of indicator constraints: %d\n", nConsInd);
3612 for( c = 0; c < nConsInd; ++c )
3614 assert( consInd[c] !=
NULL );
3625 for( c = 0; c < nconss; ++c )
3628 assert( cons !=
NULL);
3631 assert( conshdlr !=
NULL );
3634 if( strcmp(conshdlrname,
"indicator") == 0 )
3639 assert( lincons !=
NULL );
3657 SCIPinfoMessage(scip, file,
"\\ Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
3658 nvars, nbinvars, nintvars, nimplvars, ncontvars);
3667 appendLine(scip, file, linebuffer, &linecnt,
" Obj:");
3669 for( v = 0; v < nvars; ++v )
3684 appendLine(scip, file, linebuffer, &linecnt,
" ");
3689 appendLine(scip, file, linebuffer, &linecnt, buffer);
3692 endLine(scip, file, linebuffer, &linecnt);
3698 if( reader !=
NULL )
3701 assert(readerdata !=
NULL);
3703 linearizeands = readerdata->linearizeands;
3704 aggrlinearizationands = readerdata->aggrlinearizationands;
3719 for( c = 0; c < nconss; ++c )
3722 assert( cons !=
NULL);
3735 assert( conshdlr !=
NULL );
3741 if( strcmp(conshdlrname,
"linear") == 0 )
3747 else if( strcmp(conshdlrname,
"setppc") == 0 )
3756 consvars,
NULL, nconsvars,
NULL, 0,
NULL, 0, 1.0, 1.0, transformed) );
3768 else if( strcmp(conshdlrname,
"logicor") == 0 )
3774 else if( strcmp(conshdlrname,
"knapsack") == 0 )
3784 for( v = 0; v < nconsvars; ++v )
3792 else if( strcmp(conshdlrname,
"varbound") == 0 )
3803 SCIP_CALL(
printQuadraticCons(scip, file, consname, consvars, consvals, 2,
NULL, 0,
NULL, 0,
3809 else if( strcmp(conshdlrname,
"SOS1") == 0 )
3812 consSOS1[nConsSOS1++] = cons;
3814 else if( strcmp(conshdlrname,
"SOS2") == 0 )
3817 consSOS2[nConsSOS2++] = cons;
3819 else if( strcmp(conshdlrname,
"indicator") == 0 )
3830 assert( conshdlrInd !=
NULL );
3836 assert( lincons !=
NULL );
3837 assert( binvar !=
NULL );
3838 assert( slackvar !=
NULL );
3851 assert( linvars !=
NULL );
3852 assert( linvals !=
NULL );
3858 if( strlen(consname) > 0 )
3859 SCIPinfoMessage(scip, file,
" %s: %s = %d ->", consname, varname, rhs);
3867 for( v = 0; v < nlinvars; ++v )
3870 if( var != slackvar )
3872 consvars[cnt] = var;
3873 consvals[cnt++] = linvals[v];
3879 SCIP_CALL(
printQuadraticCons(scip, file,
"", consvars, consvals, cnt,
NULL, 0,
NULL, 0,
3887 consIndicator[nConsIndicator++] = cons;
3889 else if( strcmp(conshdlrname,
"quadratic") == 0 )
3898 consQuadratic[nConsQuadratic++] = cons;
3900 else if( strcmp(conshdlrname,
"soc") == 0 )
3904 consSOC[nConsSOC++] = cons;
3906 else if( strcmp(conshdlrname,
"and") == 0 )
3922 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
3930 saggvars =
MAX(10, nvars);
3937 for( c = 0; c < nConsSOS1; ++c )
3947 for( c = 0; c < nConsSOS2; ++c )
3957 for( c = 0; c < nConsQuadratic; ++c )
3959 cons = consQuadratic[c];
3967 for( c = 0; c < nConsSOC; ++c )
3977 for( c = 0; c < nConsIndicator; ++c )
3981 cons = consIndicator[c];
3995 for( v = 0; v < nvars; ++v )
3998 assert( var !=
NULL );
4044 for( v = 0; v < naggvars; ++v )
4047 assert( var !=
NULL );
4061 for( v = 0; v < nvars; ++v )
4064 assert( var !=
NULL );
4070 appendLine(scip, file, linebuffer, &linecnt, buffer);
4075 for( v = 0; v < naggvars; ++v )
4078 assert( var !=
NULL );
4084 appendLine(scip, file, linebuffer, &linecnt, buffer);
4088 endLine(scip, file, linebuffer, &linecnt);
4097 for( v = 0; v < nvars; ++v )
4100 assert( var !=
NULL );
4106 appendLine(scip, file, linebuffer, &linecnt, buffer);
4111 for( v = 0; v < naggvars; ++v )
4114 assert( var !=
NULL );
4120 appendLine(scip, file, linebuffer, &linecnt, buffer);
4124 endLine(scip, file, linebuffer, &linecnt);
4130 if( conshdlrInd !=
NULL )
4134 if( nConsSOS1 > 0 || nConsSOS2 > 0 )
4140 for( c = 0; c < nConsSOS1; ++c )
4148 printSosCons(scip, file, consname, consvars, weights, nconsvars, 1);
4152 for( c = 0; c < nConsSOS2; ++c )
4160 printSosCons(scip, file, consname, consvars, weights, nconsvars, 2);
enum SCIP_Result SCIP_RESULT
static void syntaxError(SCIP *scip, LPINPUT *lpinput, const char *msg)
SCIP_VAR ** SCIPgetLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
enum SCIP_BoundType SCIP_BOUNDTYPE
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
SCIP_VAR ** SCIPgetLhsVarsSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
int SCIPmemccpy(char *dest, const char *src, char stop, unsigned int cnt)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
static void checkConsnames(SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_Bool transformed)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static const char commentchars[]
static SCIP_DECL_HASHKEYEQ(hashKeyEqVar)
static SCIP_RETCODE printAndCons(SCIP *scip, FILE *file, const char *consname, SCIP_CONS *cons, SCIP_Bool aggrlinearizationands, SCIP_Bool transformed)
Constraint handler for variable bound constraints .
static void swapPointers(char **pointer1, char **pointer2)
SCIP_VAR ** SCIPgetVarsSOS1(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPgetLhsOffsetsSOC(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)
#define DEFAULT_LINEARIZE_ANDS
static SCIP_DECL_HASHKEYVAL(hashKeyValVar)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
static SCIP_DECL_READERCOPY(readerCopyLp)
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Real * SCIPgetWeightsSOS1(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_HASHGETKEY(hashGetKeyVar)
static SCIP_Bool isSense(LPINPUT *lpinput, LPSENSE *sense)
const char * SCIPreaderGetName(SCIP_READER *reader)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
static SCIP_RETCODE readSemicontinuous(SCIP *scip, LPINPUT *lpinput)
#define LP_MAX_PUSHEDTOKENS
constraint handler for indicator constraints
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
enum SCIP_Varstatus SCIP_VARSTATUS
static SCIP_RETCODE collectAggregatedVars(SCIP *scip, SCIP_VAR **vars, int nvars, SCIP_VAR ***aggvars, int *naggvars, int *saggvars, SCIP_HASHTABLE *varAggregated)
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBlockMemory(scip, ptr)
static SCIP_RETCODE readObjective(SCIP *scip, LPINPUT *lpinput)
SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
Constraint handler for AND constraints, .
#define SCIPduplicateBufferArray(scip, ptr, source, num)
int SCIPgetNVarsSOS2(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
#define LP_INIT_QUADCOEFSSIZE
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
constraint handler for second order cone constraints
#define SCIPfreeBufferArray(scip, ptr)
static SCIP_Bool isDelimChar(char c)
Constraint handler for the set partitioning / packing / covering constraints .
#define SCIPallocBlockMemory(scip, ptr)
#define SCIPdebugPrintCons(x, y, z)
static SCIP_Bool isNewSection(SCIP *scip, LPINPUT *lpinput)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
int SCIPfseek(SCIP_FILE *stream, long offset, int whence)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsQuadratic(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE getVariable(SCIP *scip, char *name, SCIP_VAR **var, SCIP_Bool *created)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
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)
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)
int SCIPgetNQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_READERFREE(readerFreeLp)
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
static SCIP_Bool isValueChar(char c, char nextc, SCIP_Bool firstchar, SCIP_Bool *hasdot, LPEXPTYPE *exptype)
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
int SCIPgetNBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetSlackVarIndicator(SCIP_CONS *cons)
static void pushToken(LPINPUT *lpinput)
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Constraint handler for knapsack constraints of the form , x binary and .
static SCIP_RETCODE readSos(SCIP *scip, LPINPUT *lpinput)
static SCIP_RETCODE readGenerals(SCIP *scip, LPINPUT *lpinput)
SCIP_VAR ** SCIPgetVarsAnd(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
static SCIP_Bool getNextLine(SCIP *scip, LPINPUT *lpinput)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
SCIP_VAR * SCIPgetResultantAnd(SCIP *scip, SCIP_CONS *cons)
static void printSosCons(SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **vars, SCIP_Real *weights, int nvars, int type)
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsSOS2(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
SCIP_Real * SCIPgetCoefsLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
static void appendLine(SCIP *scip, FILE *file, char *linebuffer, int *linecnt, const char *extension)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
struct SCIP_File SCIP_FILE
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPInterval sign(const SCIPInterval &x)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
const char * SCIPvarGetName(SCIP_VAR *var)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
constraint handler for quadratic constraints
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE readStart(SCIP *scip, LPINPUT *lpinput)
#define LP_INIT_COEFSSIZE
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 getActiveVariables(SCIP *scip, SCIP_VAR ***vars, SCIP_Real **scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
SCIP_RETCODE SCIPincludeReaderLp(SCIP *scip)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
static SCIP_Bool getNextToken(SCIP *scip, LPINPUT *lpinput)
SCIP_BILINTERM * SCIPgetBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
SCIP_Real SCIPgetRhsOffsetSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_Longint SCIPgetCapacityKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE printQuadraticCons(SCIP *scip, FILE *file, const char *rowname, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_QUADVARTERM *quadvarterms, int nquadvarterms, SCIP_BILINTERM *bilinterms, int nbilinterms, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool transformed)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_Real SCIPgetRhsQuadratic(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE readConstraints(SCIP *scip, LPINPUT *lpinput)
#define SCIPallocBufferArray(scip, ptr, num)
struct SCIP_ReaderData SCIP_READERDATA
public data structures and miscellaneous methods
static SCIP_DECL_READERWRITE(readerWriteLp)
int SCIPgetNLhsVarsSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
static SCIP_RETCODE readBounds(SCIP *scip, LPINPUT *lpinput)
void SCIPprintSysError(const char *message)
enum SCIP_Objsense SCIP_OBJSENSE
SCIP_VAR * SCIPgetRhsVarSOC(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool isTokenChar(char c)
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
static void checkVarnames(SCIP *scip, SCIP_VAR **vars, int nvars)
SCIP_Real * SCIPgetWeightsSOS2(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
static void printRow(SCIP *scip, FILE *file, const char *rowname, const char *rownameextension, const char *type, SCIP_VAR **linvars, SCIP_Real *linvals, int nlinvars, SCIP_QUADVARTERM *quadvarterms, int nquadvarterms, SCIP_BILINTERM *bilinterms, int nbilinterms, SCIP_Real rhs)
static SCIP_DECL_READERREAD(readerReadLp)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
int SCIPgetNVarsSOS1(SCIP *scip, SCIP_CONS *cons)
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)
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
static SCIP_RETCODE readBinaries(SCIP *scip, LPINPUT *lpinput)
static SCIP_Bool isSign(LPINPUT *lpinput, int *sign)
Constraint handler for linear constraints in their most general form, .
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)
static void pushBufferToken(LPINPUT *lpinput)
SCIP_RETCODE SCIPcreateConsIndicator(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *binvar, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
static SCIP_RETCODE createIndicatorConstraint(SCIP *scip, LPINPUT *lpinput, const char *name, SCIP_VAR *binvar, SCIP_Real binvalue)
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)
#define DEFAULT_AGGRLINEARIZATION_ANDS
int SCIPgetNLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE readCoefficients(SCIP *scip, LPINPUT *lpinput, SCIP_Bool isobjective, char *name, int *coefssize, SCIP_VAR ***vars, SCIP_Real **coefs, int *ncoefs, int *quadcoefssize, SCIP_VAR ***quadvars1, SCIP_VAR ***quadvars2, SCIP_Real **quadcoefs, int *nquadcoefs, SCIP_Bool *newsection)
static const SCIP_Real scalars[]
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
static SCIP_RETCODE printAggregatedCons(SCIP *scip, FILE *file, SCIP_Bool transformed, int nvars, int nAggregatedVars, SCIP_VAR **aggregatedVars)
static SCIP_RETCODE readLPFile(SCIP *scip, LPINPUT *lpinput, const char *filename)
SCIP_Real SCIPgetLhsConstantSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsCoefSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPhashmapSetImage(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
int SCIPgetNVarsAnd(SCIP *scip, SCIP_CONS *cons)
constraint handler for SOS type 1 constraints
static void swapTokenBuffer(LPINPUT *lpinput)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
static void endLine(SCIP *scip, FILE *file, char *linebuffer, int *linecnt)
static SCIP_RETCODE printSOCCons(SCIP *scip, FILE *file, const char *rowname, SCIP_CONS *cons)
SCIP_RETCODE SCIPreadLp(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
int SCIPvarGetIndex(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
SCIP_RETCODE SCIPcreateConsBounddisjunction(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_BOUNDTYPE *boundtypes, SCIP_Real *bounds, 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 SCIPisZero(SCIP *scip, SCIP_Real val)
static SCIP_Bool isValue(SCIP *scip, LPINPUT *lpinput, SCIP_Real *value)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
constraint handler for SOS type 2 constraints
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
#define BMSclearMemoryArray(ptr, num)
SCIP_QUADVARTERM * SCIPgetQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPwriteLp(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)
int SCIPfclose(SCIP_FILE *fp)
constraint handler for bound disjunction constraints
SCIP_CONS * SCIPgetLinearConsIndicator(SCIP_CONS *cons)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool hasError(LPINPUT *lpinput)
static void clearLine(char *linebuffer, int *linecnt)
SCIP_Real * SCIPgetLhsCoefsSOC(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderFree(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERFREE((*readerfree)))
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 SCIPvarIsNegated(SCIP_VAR *var)
#define SCIPreallocBufferArray(scip, ptr, num)