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 ==
'<' )
1656 int linepos = lpinput->linepos-1;
1662 if ( *lpinput->token ==
'-' )
1668 if ( *lpinput->token ==
'>' )
1670 lpinput->linepos = linepos;
1671 strcpy(lpinput->token,
"<");
1673 "SCIP does not support equivalence (<->) indicator constraints; consider using the \"->\" form.");
1681 lpinput->linepos = linepos;
1682 strcpy(lpinput->token,
"<");
1689 if ( *lpinput->token ==
'-' )
1698 if ( *lpinput->token ==
'>' )
1699 isIndicatorCons =
TRUE;
1714 if( !isIndicatorCons )
1717 initial = lpinput->initialconss && !lpinput->inlazyconstraints && !lpinput->inusercuts;
1719 enforce = !lpinput->inusercuts;
1720 check = !lpinput->inusercuts;
1724 dynamic = lpinput->dynamicconss;
1725 removable = lpinput->dynamicrows || lpinput->inusercuts;
1726 if( nquadcoefs == 0 )
1729 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable,
FALSE);
1734 nquadcoefs, quadvars1, quadvars2, quadcoefs, lhs, rhs,
1735 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable);
1742 SCIPdebugMsg(scip,
"(line %d) created constraint%s: ", lpinput->linenumber,
1743 lpinput->inlazyconstraints ?
" (lazy)" : (lpinput->inusercuts ?
" (user cut)" :
""));
1750 if( ncoefs != 1 || nquadcoefs > 0 )
1752 syntaxError(scip, lpinput,
"Indicator part can only consist of one binary variable.");
1755 if( !
SCIPisEQ(scip, coefs[0], 1.0) )
1757 syntaxError(scip, lpinput,
"There cannot be a coefficient before the binary indicator variable.");
1762 syntaxError(scip, lpinput,
"Indicator part cannot handle equations.");
1789 assert(lpinput !=
NULL);
1812 hassign =
isSign(lpinput, &sign);
1820 if(
isValue(scip, lpinput, &value) )
1825 syntaxError(scip, lpinput,
"expected bound sense '<=', '=', or '>='.");
1859 syntaxError(scip, lpinput,
"expected variable name.");
1869 if(
isSense(lpinput, &rightsense) )
1878 syntaxError(scip, lpinput,
"expected value or sign.");
1884 hassign =
isSign(lpinput, &sign);
1892 if( !
isValue(scip, lpinput, &value) )
1899 switch( rightsense )
1919 syntaxError(scip, lpinput,
"the two bound senses do not fit.");
1923 else if( strcasecmp(lpinput->token,
"FREE") == 0 )
1927 syntaxError(scip, lpinput,
"variable with bound is marked as 'free'.");
1960 assert(lpinput !=
NULL);
1978 syntaxError(scip, lpinput,
"unknown variable in generals section.");
1987 SCIPwarningMessage(scip,
"variable <%s> declared as integer has non-integral bounds[%.14g, %.14g] -> if feasible, bounds will be adjusted\n",
SCIPvarGetName(var), lb, ub);
2005 assert(lpinput !=
NULL);
2023 syntaxError(scip, lpinput,
"unknown variable in binaries section.");
2033 SCIPwarningMessage(scip,
"variable <%s> declared as binary has non-binary bounds[%.14g, %.14g] -> if feasible, bounds will be adjusted\n",
SCIPvarGetName(var), lb, ub);
2069 assert(lpinput !=
NULL);
2072 if( strcasecmp(lpinput->token,
"SEMI") == 0 )
2080 if( strcasecmp(lpinput->token,
"-") == 0 )
2082 if( !
getNextToken(scip, lpinput) || strcasecmp(lpinput->token,
"CONTINUOUS") != 0 )
2084 syntaxError(scip, lpinput,
"expected 'CONTINUOUS' after 'SEMI-'.");
2104 syntaxError(scip, lpinput,
"unknown variable in semi-continuous section.");
2157 SCIP_Bool initial, separate, enforce, check, propagate;
2158 SCIP_Bool local, modifiable, dynamic, removable;
2162 assert(lpinput !=
NULL);
2165 initial = lpinput->initialconss;
2172 dynamic = lpinput->dynamicconss;
2173 removable = lpinput->dynamicrows;
2193 if( strcmp(lpinput->token,
":") == 0 )
2216 syntaxError(scip, lpinput,
"expected SOS type: 'S1::' or 'S2::'.");
2220 if( strcmp(lpinput->token,
":") == 0 )
2224 lpinput->token[0] =
':';
2225 lpinput->token[1] =
'\0';
2234 if( strcmp(lpinput->token,
"S1") == 0 )
2237 SCIP_CALL(
SCIPcreateConsSOS1(scip, &cons, name, 0,
NULL,
NULL, initial, separate, enforce, check, propagate,
2238 local, modifiable, dynamic, removable) );
2240 else if( strcmp(lpinput->token,
"S2") == 0 )
2243 SCIP_CALL(
SCIPcreateConsSOS2(scip, &cons, name, 0,
NULL,
NULL, initial, separate, enforce, check, propagate,
2244 local, modifiable, dynamic, removable) );
2248 syntaxError(scip, lpinput,
"SOS constraint type other than 1 or 2 appeared.");
2251 assert( type == 1 || type == 2 );
2253 SCIPdebugMsg(scip,
"created SOS%d constraint <%s>\n", type, name);
2256 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2258 syntaxError(scip, lpinput,
"SOS constraint type has to be followed by two colons.");
2263 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2265 syntaxError(scip, lpinput,
"SOS constraint type has to be followed by two colons.");
2294 if( !
getNextToken(scip, lpinput) || strcmp(lpinput->token,
":") != 0 )
2296 syntaxError(scip, lpinput,
"expected colon and weight.");
2312 if(
isSign(lpinput, &sign) )
2318 if( !
isValue(scip, lpinput, &weight) )
2366 const char* filename
2369 assert(lpinput !=
NULL);
2372 lpinput->file =
SCIPfopen(filename,
"r");
2373 if( lpinput->file ==
NULL )
2387 switch( lpinput->section )
2480 assert( scip !=
NULL );
2481 assert( var !=
NULL );
2484 assert( name !=
NULL );
2486 if( genericnames || name[0] ==
'\0' )
2490 if( isdigit((
unsigned char)name[0]) || name[0] ==
'e' || name[0] ==
'E' )
2512 assert(scip !=
NULL);
2513 assert(vars !=
NULL);
2514 assert(scalars !=
NULL);
2515 assert(*vars !=
NULL);
2516 assert(*scalars !=
NULL);
2517 assert(nvars !=
NULL);
2518 assert(constant !=
NULL);
2524 if( requiredsize > *nvars )
2530 assert( requiredsize <= *nvars );
2535 for( v = 0; v < *nvars; ++v )
2545 (*scalars)[v] *= -1.0;
2560 assert( linebuffer !=
NULL );
2561 assert( linecnt !=
NULL );
2564 linebuffer[0] =
'\0';
2576 assert( scip !=
NULL );
2577 assert( linebuffer !=
NULL );
2578 assert( linecnt !=
NULL );
2580 if( (*linecnt) > 0 )
2582 linebuffer[(*linecnt)] =
'\0';
2596 const char* extension
2599 assert( scip !=
NULL );
2600 assert( linebuffer !=
NULL );
2601 assert( linecnt !=
NULL );
2602 assert( extension !=
NULL );
2611 (*linecnt) += (int) strlen(extension);
2613 SCIPdebugMsg(scip,
"linebuffer <%s>, length = %lu\n", linebuffer, (
unsigned long)strlen(linebuffer));
2616 endLine(scip, file, linebuffer, linecnt);
2625 const char* rowname,
2626 const char* rownameextension,
2648 assert( scip !=
NULL );
2649 assert( strcmp(type,
"=") == 0 || strcmp(type,
"<=") == 0 || strcmp(type,
">=") == 0 );
2650 assert( nlinvars == 0 || (linvars !=
NULL && linvals !=
NULL) );
2651 assert( nquadvarterms == 0 || quadvarterms !=
NULL );
2654 assert( nbilinterms == 0 || (bilinterms !=
NULL && nquadvarterms >= 2) );
2659 appendLine(scip, file, linebuffer, &linecnt,
" ");
2662 if( strlen(rowname) > 0 || strlen(rownameextension) > 0 )
2665 appendLine(scip, file, linebuffer, &linecnt, consname);
2669 for( v = 0; v < nlinvars; ++v )
2672 assert( var !=
NULL );
2676 appendLine(scip, file, linebuffer, &linecnt,
" ");
2681 appendLine(scip, file, linebuffer, &linecnt, buffer);
2685 if( nquadvarterms > 0 )
2688 for( v = 0; v < nquadvarterms; ++v )
2690 if( quadvarterms[v].lincoef == 0.0 )
2695 appendLine(scip, file, linebuffer, &linecnt,
" ");
2700 appendLine(scip, file, linebuffer, &linecnt, buffer);
2704 appendLine(scip, file, linebuffer, &linecnt,
" + [");
2707 for( v = 0; v < nquadvarterms; ++v )
2709 if( quadvarterms[v].sqrcoef == 0.0 )
2714 appendLine(scip, file, linebuffer, &linecnt,
" ");
2719 appendLine(scip, file, linebuffer, &linecnt, buffer);
2723 for( v = 0; v < nbilinterms; ++v )
2727 appendLine(scip, file, linebuffer, &linecnt,
" ");
2733 appendLine(scip, file, linebuffer, &linecnt, buffer);
2737 appendLine(scip, file, linebuffer, &linecnt,
" ]");
2748 appendLine(scip, file, linebuffer, &linecnt,
" ");
2749 appendLine(scip, file, linebuffer, &linecnt, buffer);
2751 endLine(scip, file, linebuffer, &linecnt);
2760 const char* rowname,
2779 assert( scip !=
NULL );
2780 assert( rowname !=
NULL );
2783 assert( nlinvars == 0 || linvars !=
NULL );
2784 assert( nquadvarterms == 0 || quadvarterms !=
NULL );
2785 assert( nbilinterms == 0 || bilinterms !=
NULL );
2787 assert( lhs <= rhs );
2792 nactivevars = nlinvars;
2797 if( linvals !=
NULL )
2805 for( v = 0; v < nactivevars; ++v )
2806 activevals[v] = 1.0;
2819 printRow(scip, file, rowname,
"",
"=", activevars, activevals, nactivevars,
2820 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2821 rhs - activeconstant);
2829 activevars, activevals, nactivevars,
2830 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2831 lhs - activeconstant);
2837 activevars, activevals, nactivevars,
2838 quadvarterms, nquadvarterms, bilinterms, nbilinterms,
2839 rhs - activeconstant);
2859 const char* rowname,
2873 assert( scip !=
NULL );
2874 assert( file !=
NULL );
2875 assert( type == 1 || type == 2 );
2880 appendLine(scip, file, linebuffer, &linecnt,
" ");
2883 if( strlen(rowname) > 0 )
2886 appendLine(scip, file, linebuffer, &linecnt, buffer);
2891 appendLine(scip, file, linebuffer, &linecnt, buffer);
2893 for( v = 0; v < nvars; ++v )
2897 if( weights !=
NULL )
2905 appendLine(scip, file, linebuffer, &linecnt,
" ");
2907 appendLine(scip, file, linebuffer, &linecnt, buffer);
2910 endLine(scip, file, linebuffer, &linecnt);
2918 const char* rowname,
2934 assert( scip !=
NULL );
2935 assert( rowname !=
NULL );
2936 assert( cons !=
NULL );
2951 appendLine(scip, file, linebuffer, &linecnt,
" ");
2954 if( strlen(rowname) > 0 )
2957 appendLine(scip, file, linebuffer, &linecnt, consname);
2966 assert( var !=
NULL );
2970 rhs -= coef * coef * offset * offset;
2972 if( offset == 0.0 || coef == 0.0 )
2977 appendLine(scip, file, linebuffer, &linecnt,
" ");
2982 appendLine(scip, file, linebuffer, &linecnt, buffer);
2988 if( offset != 0.0 && coef != 0.0 )
2991 assert( var !=
NULL );
2993 rhs += coef * coef * offset * offset;
2996 appendLine(scip, file, linebuffer, &linecnt,
" ");
3001 appendLine(scip, file, linebuffer, &linecnt, buffer);
3005 appendLine(scip, file, linebuffer, &linecnt,
" + [");
3011 assert( var !=
NULL );
3019 appendLine(scip, file, linebuffer, &linecnt,
" ");
3024 appendLine(scip, file, linebuffer, &linecnt, buffer);
3032 assert( var !=
NULL );
3036 appendLine(scip, file, linebuffer, &linecnt,
" ");
3041 appendLine(scip, file, linebuffer, &linecnt, buffer);
3045 appendLine(scip, file, linebuffer, &linecnt,
" ]");
3055 appendLine(scip, file, linebuffer, &linecnt,
" ");
3056 appendLine(scip, file, linebuffer, &linecnt, buffer);
3058 endLine(scip, file, linebuffer, &linecnt);
3068 const char* consname,
3082 assert(scip !=
NULL);
3083 assert(consname !=
NULL);
3084 assert(cons !=
NULL);
3095 if( !aggrlinearizationands )
3097 vars[0] = resultant;
3102 for( v = 0; v < nvars; ++v )
3105 vars[1] = operands[v];
3114 for( v = nvars - 1; v >= 0; --v )
3116 vars[v] = operands[v];
3120 vars[nvars] = resultant;
3123 if( aggrlinearizationands )
3164 assert( scip !=
NULL );
3165 assert( aggvars !=
NULL );
3166 assert( naggvars !=
NULL );
3167 assert( saggvars !=
NULL );
3170 for( v = 0; v < nvars; ++v )
3182 assert( varAggregated !=
NULL );
3187 if ( *saggvars <= *naggvars )
3191 assert( newsize > *saggvars );
3193 *saggvars = newsize;
3196 (*aggvars)[*naggvars] = var;
3199 assert( *naggvars <= *saggvars );
3213 int nAggregatedVars,
3225 assert( scip !=
NULL );
3231 for( j = 0; j < nAggregatedVars; ++j )
3236 activevars[0] = aggregatedVars[j];
3237 activevals[0] = 1.0;
3238 activeconstant = 0.0;
3243 activevals[nactivevars] = -1.0;
3244 activevars[nactivevars] = aggregatedVars[j];
3249 printRow(scip, file, consname,
"",
"=", activevars, activevals, nactivevars,
NULL, 0,
NULL, 0, - activeconstant);
3270 assert(scip !=
NULL);
3271 assert(vars !=
NULL || nvars == 0);
3273 printwarning =
TRUE;
3276 for( v = 0; v < nvars; ++v )
3280 SCIPwarningMessage(scip,
"there is a variable name which has to be cut down to %d characters; LP might be corrupted\n",
3286 if( printwarning && isdigit((
unsigned char)
SCIPvarGetName(vars[v])[0]) )
3288 SCIPwarningMessage(scip,
"violation of LP format - a variable name starts with a digit; " \
3289 "it is not possible to read the generated LP file with SCIP; " \
3290 "use write/genproblem or write/gentransproblem for generic variable names\n");
3291 printwarning =
FALSE;
3308 const char* conshdlrname;
3311 assert( scip !=
NULL );
3312 assert( conss !=
NULL || nconss == 0 );
3314 printwarning =
TRUE;
3316 for( c = 0; c < nconss; ++c )
3320 assert(conss !=
NULL);
3322 assert(cons !=
NULL );
3328 assert( conshdlr !=
NULL );
3335 if( strcmp(conshdlrname,
"linear") == 0 )
3353 if( printwarning && isdigit((
unsigned char)
SCIPconsGetName(cons)[0]) )
3355 SCIPwarningMessage(scip,
"violation of LP format - a constraint name starts with a digit; " \
3356 "it is not possible to read the generated LP file with SCIP; " \
3357 "use write/genproblem or write/gentransproblem for generic variable names\n");
3358 printwarning =
FALSE;
3371 assert(scip !=
NULL);
3372 assert(reader !=
NULL);
3389 assert(readerdata !=
NULL);
3410 assert(reader !=
NULL);
3414 nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
3446 "reading/" READER_NAME "/linearize-and-constraints",
3447 "should possible \"and\" constraint be linearized when writing the lp file?",
3451 "should an aggregated linearization for and constraints be used?",
3462 const char* filename,
3471 lpinput.file =
NULL;
3472 lpinput.linebuf[0] =
'\0';
3473 lpinput.probname[0] =
'\0';
3474 lpinput.objname[0] =
'\0';
3476 lpinput.token[0] =
'\0';
3478 lpinput.tokenbuf[0] =
'\0';
3484 lpinput.npushedtokens = 0;
3485 lpinput.linenumber = 0;
3486 lpinput.linepos = 0;
3489 lpinput.inlazyconstraints =
FALSE;
3490 lpinput.inusercuts =
FALSE;
3491 lpinput.haserror =
FALSE;
3492 lpinput.comment =
FALSE;
3493 lpinput.endline =
FALSE;
3501 retcode =
readLPFile(scip, &lpinput, filename);
3518 if( lpinput.haserror )
3567 const char* conshdlrname;
3576 int nConsQuadratic = 0;
3578 int nConsIndicator = 0;
3595 assert(scip !=
NULL);
3602 if( conshdlrInd !=
NULL )
3615 SCIPdebugMsg(scip,
"Number of indicator constraints: %d\n", nConsInd);
3617 for( c = 0; c < nConsInd; ++c )
3619 assert( consInd[c] !=
NULL );
3630 for( c = 0; c < nconss; ++c )
3633 assert( cons !=
NULL);
3636 assert( conshdlr !=
NULL );
3639 if( strcmp(conshdlrname,
"indicator") == 0 )
3644 assert( lincons !=
NULL );
3662 SCIPinfoMessage(scip, file,
"\\ Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
3663 nvars, nbinvars, nintvars, nimplvars, ncontvars);
3672 appendLine(scip, file, linebuffer, &linecnt,
" Obj:");
3674 for( v = 0; v < nvars; ++v )
3689 appendLine(scip, file, linebuffer, &linecnt,
" ");
3694 appendLine(scip, file, linebuffer, &linecnt, buffer);
3697 endLine(scip, file, linebuffer, &linecnt);
3703 if( reader !=
NULL )
3706 assert(readerdata !=
NULL);
3708 linearizeands = readerdata->linearizeands;
3709 aggrlinearizationands = readerdata->aggrlinearizationands;
3724 for( c = 0; c < nconss; ++c )
3727 assert( cons !=
NULL);
3740 assert( conshdlr !=
NULL );
3746 if( strcmp(conshdlrname,
"linear") == 0 )
3752 else if( strcmp(conshdlrname,
"setppc") == 0 )
3761 consvars,
NULL, nconsvars,
NULL, 0,
NULL, 0, 1.0, 1.0, transformed) );
3773 else if( strcmp(conshdlrname,
"logicor") == 0 )
3779 else if( strcmp(conshdlrname,
"knapsack") == 0 )
3789 for( v = 0; v < nconsvars; ++v )
3797 else if( strcmp(conshdlrname,
"varbound") == 0 )
3808 SCIP_CALL(
printQuadraticCons(scip, file, consname, consvars, consvals, 2,
NULL, 0,
NULL, 0,
3814 else if( strcmp(conshdlrname,
"SOS1") == 0 )
3817 consSOS1[nConsSOS1++] = cons;
3819 else if( strcmp(conshdlrname,
"SOS2") == 0 )
3822 consSOS2[nConsSOS2++] = cons;
3824 else if( strcmp(conshdlrname,
"indicator") == 0 )
3835 assert( conshdlrInd !=
NULL );
3841 assert( lincons !=
NULL );
3842 assert( binvar !=
NULL );
3843 assert( slackvar !=
NULL );
3856 assert( linvars !=
NULL );
3857 assert( linvals !=
NULL );
3863 if( strlen(consname) > 0 )
3864 SCIPinfoMessage(scip, file,
" %s: %s = %d ->", consname, varname, rhs);
3872 for( v = 0; v < nlinvars; ++v )
3875 if( var != slackvar )
3877 consvars[cnt] = var;
3878 consvals[cnt++] = linvals[v];
3884 SCIP_CALL(
printQuadraticCons(scip, file,
"", consvars, consvals, cnt,
NULL, 0,
NULL, 0,
3892 consIndicator[nConsIndicator++] = cons;
3894 else if( strcmp(conshdlrname,
"quadratic") == 0 )
3903 consQuadratic[nConsQuadratic++] = cons;
3905 else if( strcmp(conshdlrname,
"soc") == 0 )
3909 consSOC[nConsSOC++] = cons;
3911 else if( strcmp(conshdlrname,
"and") == 0 )
3927 SCIPwarningMessage(scip,
"constraint handler <%s> cannot print requested format\n", conshdlrname );
3935 saggvars =
MAX(10, nvars);
3942 for( c = 0; c < nConsSOS1; ++c )
3952 for( c = 0; c < nConsSOS2; ++c )
3962 for( c = 0; c < nConsQuadratic; ++c )
3964 cons = consQuadratic[c];
3972 for( c = 0; c < nConsSOC; ++c )
3982 for( c = 0; c < nConsIndicator; ++c )
3986 cons = consIndicator[c];
4000 for( v = 0; v < nvars; ++v )
4003 assert( var !=
NULL );
4049 for( v = 0; v < naggvars; ++v )
4052 assert( var !=
NULL );
4066 for( v = 0; v < nvars; ++v )
4069 assert( var !=
NULL );
4075 appendLine(scip, file, linebuffer, &linecnt, buffer);
4080 for( v = 0; v < naggvars; ++v )
4083 assert( var !=
NULL );
4089 appendLine(scip, file, linebuffer, &linecnt, buffer);
4093 endLine(scip, file, linebuffer, &linecnt);
4102 for( v = 0; v < nvars; ++v )
4105 assert( var !=
NULL );
4111 appendLine(scip, file, linebuffer, &linecnt, buffer);
4116 for( v = 0; v < naggvars; ++v )
4119 assert( var !=
NULL );
4125 appendLine(scip, file, linebuffer, &linecnt, buffer);
4129 endLine(scip, file, linebuffer, &linecnt);
4135 if( conshdlrInd !=
NULL )
4139 if( nConsSOS1 > 0 || nConsSOS2 > 0 )
4145 for( c = 0; c < nConsSOS1; ++c )
4153 printSosCons(scip, file, consname, consvars, weights, nconsvars, 1);
4157 for( c = 0; c < nConsSOS2; ++c )
4165 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)