24 #define _USE_MATH_DEFINES 41 #define READER_NAME "osilreader" 42 #define READER_DESC "file reader for OS instance language (OSiL) format" 43 #define READER_EXTENSION "osil" 82 assert(datanode != NULL);
84 assert(nvars != NULL);
85 assert(doingfine != NULL);
92 if( variables == NULL )
100 if( attrval == NULL )
102 SCIPerrorMessage(
"Attribute \"numberOfVariables\" not found in <variables> node.\n");
107 varssize = (int)strtol(attrval, (
char**)&attrval, 10);
108 if( *attrval !=
'\0' || varssize < 0 )
114 assert(varssize >= 0);
129 if( varssize == *nvars )
131 SCIPerrorMessage(
"Expected %d variables, got at least %d many.\n", varssize, *nvars+1);
141 if( attrval != NULL && strcmp(attrval,
"1") != 0 )
143 SCIPerrorMessage(
"Variable attribute 'mult' not supported (while parsing variable <%s>)\n", varname);
150 if( attrval == NULL )
152 else if( strcmp(attrval,
"-INF") == 0 )
154 else if( strcmp(attrval,
"INF") == 0 )
158 varlb = strtod(attrval, (
char**)&attrval);
159 if( *attrval !=
'\0' )
161 SCIPerrorMessage(
"Error parsing variable lower bound '%s' for variable <%s>\n", attrval, varname);
169 if( attrval == NULL )
171 else if( strcmp(attrval,
"-INF") == 0 )
173 else if( strcmp(attrval,
"INF") == 0 )
177 varub = strtod(attrval, (
char**)&attrval);
178 if( *attrval !=
'\0' )
180 SCIPerrorMessage(
"Error parsing variable upper bound '%s' for variable <%s>\n", attrval, varname);
192 if( attrval == NULL )
194 else switch( *attrval )
220 SCIPerrorMessage(
"Unsupported variable type '%s' for variable <%s>\n", attrval, varname);
232 SCIP_CALL(
SCIPcreateVar(scip, &(*vars)[*nvars], varname, varlb, varub, 0.0, vartype, !dynamiccols, dynamiccols, NULL, NULL, NULL, NULL, NULL) );
233 assert((*vars)[*nvars] != NULL);
247 consvars[0] = (*vars)[*nvars];
248 consvars[1] = (*vars)[*nvars];
254 bounds[1] = semibound;
266 if( *nvars < varssize )
268 SCIPerrorMessage(
"Expected %d variables, but got only %d many.\n", varssize, *nvars);
291 assert(scip != NULL);
292 assert(datanode != NULL);
293 assert(vars != NULL || nvars == 0);
294 assert(doingfine != NULL);
300 if( objective == NULL )
305 if( attrval != NULL && strcmp(attrval,
"1") != 0 )
314 if( attrval == NULL )
320 else if( strcmp(attrval,
"min") == 0 )
324 else if( strcmp(attrval,
"max") == 0 )
343 if( attrval == NULL )
349 idx = (int)strtol(attrval, (
char**)&attrval, 10);
350 if( *attrval !=
'\0' )
357 if( idx < 0 || idx >= nvars )
359 SCIPerrorMessage(
"Invalid variable index '%d' of objective coefficient.\n", idx);
373 val = strtod(attrval, (
char**)&attrval);
374 if( *attrval !=
'\0' )
387 if( attrval != NULL )
391 objconst = strtod(attrval, (
char**)&attrval);
392 if( *attrval !=
'\0' )
399 if( objconst != 0.0 )
403 SCIP_CALL(
SCIPcreateVar(scip, &objconstvar,
"objconstvar", objconst, objconst, 1.0,
SCIP_VARTYPE_CONTINUOUS, !dynamiccols, dynamiccols, NULL, NULL, NULL, NULL, NULL) );
442 assert(scip != NULL);
443 assert(datanode != NULL);
444 assert(conss != NULL);
445 assert(constypes != NULL);
446 assert(nconss != NULL);
447 assert(doingfine != NULL);
456 if( constraints == NULL )
461 if( attrval == NULL )
463 SCIPerrorMessage(
"Attribute \"numberOfConstraints\" not found in <constraints> node.\n");
468 consssize = (int)strtol(attrval, (
char**)&attrval, 10);
469 if( *attrval !=
'\0' || consssize < 0 )
475 assert(consssize >= 0);
483 const char* consname;
487 if( consssize == *nconss )
489 SCIPerrorMessage(
"Expected %d constraints, but got at least %d many.\n", consssize, *nconss+1);
496 if( consname == NULL )
504 if( attrval != NULL && strcmp(attrval,
"1") != 0 )
506 SCIPerrorMessage(
"Constraint attribute 'mult' not supported (while parsing constraint <%s>).\n", consname);
513 if( attrval == NULL )
515 else if( strcmp(attrval,
"-INF") == 0 )
517 else if( strcmp(attrval,
"INF") == 0 )
521 conslhs = strtod(attrval, (
char**)&attrval);
522 if( *attrval !=
'\0' )
524 SCIPerrorMessage(
"Error parsing constraint lower bound '%s' for constraint <%s>.\n", attrval, consname);
532 if( attrval == NULL )
534 else if( strcmp(attrval,
"-INF") == 0 )
536 else if( strcmp(attrval,
"INF") == 0 )
540 consrhs = strtod(attrval, (
char**)&attrval);
541 if( *attrval !=
'\0' )
543 SCIPerrorMessage(
"Error parsing constraint upper bound '%s' for constraint <%s>.\n", attrval, consname);
551 if( attrval != NULL )
555 consconstant = strtod(attrval, (
char**)&attrval);
556 if( *attrval !=
'\0' )
558 SCIPerrorMessage(
"Error parsing constraint constant '%s' for constraint <%s>.\n", attrval, consname);
563 conslhs -= consconstant;
565 consrhs -= consconstant;
571 assert((*conss)[*nconss] != NULL);
573 (*constypes)[*nconss] =
LINEAR;
578 if( *nconss < consssize )
580 SCIPerrorMessage(
"Got %d constraints, but expected %d many.\n", *nconss, consssize);
604 assert(node != NULL);
605 assert(mult != NULL);
606 assert(doingfine != NULL);
609 if( incrint != NULL )
611 if( incrreal != NULL )
615 if( attrval == NULL )
619 *mult = (int)strtol(attrval, (
char**)&attrval, 10);
620 if( *attrval !=
'\0' || *mult < 1 )
632 if( attrval == NULL )
635 if( incrint != NULL )
637 *incrint = (int)strtol(attrval, (
char**)&attrval, 10);
638 if( *attrval !=
'\0' )
646 if( incrreal != NULL )
648 *incrreal = strtod(attrval, (
char**)&attrval);
687 assert(scip != NULL);
688 assert(datanode != NULL);
689 assert(vars != NULL || nvars == 0);
690 assert(conss != NULL || nconss == 0);
691 assert(constypes != NULL || nconss == 0);
692 assert(doingfine != NULL);
696 if( lincoef == NULL )
701 if( attrval == NULL )
703 SCIPerrorMessage(
"Attribute \"numberOfValues\" not found for <linearConstraintCoefficients> node.\n");
708 nnz = (int)strtol(attrval, (
char**)&attrval, 10);
709 if( *attrval !=
'\0' || nnz < 0 )
711 SCIPerrorMessage(
"Invalid value '%s' for \"numberOfValues\" attribute in <linearConstraintCoefficients> node.\n",
xmlGetAttrval(lincoef,
"numberOfValues"));
719 if( startnode == NULL )
721 SCIPerrorMessage(
"Node <start> not found inside <linearConstraintCoefficients> node.\n");
727 if( idxnode != NULL )
731 SCIPerrorMessage(
"Both <rowIdx> and <colIdx> found under <linearConstraintCoefficients> node.\n");
740 if( idxnode == NULL )
742 SCIPerrorMessage(
"Both <rowIdx> and <colIdx> not found under <linearConstraintCoefficients> node.\n");
750 if( valnode == NULL )
752 SCIPerrorMessage(
"<value> node not found under <linearConstraintCoefficients> node.\n");
770 SCIPerrorMessage(
"Expected <el> node under <start> node in <linearConstraintCoefficients>, but got '%s'.\n",
xmlGetName(elnode));
774 if( count >= (rowmajor ? nconss : nvars) + 1 )
776 SCIPerrorMessage(
"Too many elements under <start> node in <linearConstraintCoefficients>, expected %d many, got at least %d.\n", (rowmajor ? nconss : nvars) + 1, count + 1);
782 SCIPerrorMessage(
"No data in <el> node in <linearConstraintCoefficients>.\n");
789 if( *attrval !=
'\0' || start[count] < 0 || (start[count] > nnz) )
791 SCIPerrorMessage(
"Invalid value '%s' in <el> node under <start> node in <linearConstraintCoefficients>.\n",
xmlGetData(elnode));
801 for( --mult; mult > 0; --mult )
804 if( count >= (rowmajor ? nconss : nvars) + 1 )
806 SCIPerrorMessage(
"Too many elements under <start> node in <linearConstraintCoefficients>, expected %d many, got at least %d.\n", (rowmajor ? nconss : nvars) + 1, count + 1);
810 start[count] = start[count-1] + incrint;
813 if( count != (rowmajor ? nconss : nvars) + 1 )
815 SCIPerrorMessage(
"Got only %d <start> entries in <linearConstraintCoefficients>, but expected %d many.\n", count, (rowmajor ? nconss : nvars) + 1);
829 SCIPerrorMessage(
"Expected <el> node under <%s> node in <linearConstraintCoefficients>, but got '%s'.\n", rowmajor ?
"colIdx" :
"rowIdx",
xmlGetName(elnode));
835 SCIPerrorMessage(
"Too many elements under <%s> node in <linearConstraintCoefficients>, expected %d many, but got at least %d.\n", rowmajor ?
"colIdx" :
"rowIdx", nnz, count + 1);
841 SCIPerrorMessage(
"No data in <el> node under <%s> node in <linearConstraintCoefficients>.\n", rowmajor ?
"colIdx" :
"rowIdx");
848 if( *attrval !=
'\0' || idx[count] < 0 || (idx[count] >= (rowmajor ? nvars : nconss)) )
850 SCIPerrorMessage(
"Invalid value '%s' in <el> node under <%s> node in <linearConstraintCoefficients>.\n",
xmlGetData(elnode), rowmajor ?
"colIdx" :
"rowIdx");
860 for( --mult; mult > 0; --mult )
865 SCIPerrorMessage(
"Too many elements under <%s> node in <linearConstraintCoefficients>, expected %d many, got at least %d.\n", rowmajor ?
"colIdx" :
"rowIdx", nnz, count + 1);
869 idx[count] = idx[count-1] + incrint;
874 SCIPerrorMessage(
"Got only %d entries in <%s> node in <linearConstraintCoefficients>, expected %d many.\n", count, rowmajor ?
"colIdx" :
"rowIdx", nnz);
888 SCIPerrorMessage(
"Expected <el> node under <value> node in <linearConstraintCoefficients>, but got '%s'.\n",
xmlGetName(elnode));
894 SCIPerrorMessage(
"Too many elements under <value> node in <linearConstraintCoefficients>, expected %d many, got at least %d.\n", nnz, count + 1);
900 SCIPerrorMessage(
"No data in <el> node under <value> node in <linearConstraintCoefficients>.\n");
909 SCIPerrorMessage(
"Invalid value '%s' in <el> node under <value> node in <linearConstraintCoefficients>.\n",
xmlGetData(elnode));
915 readMultIncr(elnode, &mult, NULL, &incrreal, doingfine);
919 for( --mult; mult > 0; --mult )
924 SCIPerrorMessage(
"Too many elements under <value> node in <linearConstraintCoefficients>, expected %d many, got at least %d.\n", nnz, count + 1);
928 val[count] = val[count-1] + incrreal;
933 SCIPerrorMessage(
"Got only %d entries under <value> node in <linearConstraintCoefficients>, expected %d many.\n", count, nnz);
943 for( row = 0; row < nconss; ++row )
946 assert(start[row] >= 0);
947 assert(start[row+1] >= 0);
948 assert(start[row] <= nnz);
949 assert(start[row+1] <= nnz);
950 for( pos = start[row]; pos < start[row+1]; ++pos )
955 assert(idx[pos] >= 0);
956 assert(idx[pos] < nvars);
958 assert(constypes[row] ==
LINEAR);
968 for( col = 0; col < nvars; ++col )
971 assert(start[col] >= 0);
972 assert(start[col+1] >= 0);
973 assert(start[col] <= nnz);
974 assert(start[col+1] <= nnz);
975 for( pos = start[col]; pos < start[col+1]; ++pos )
980 assert(idx[pos] >= 0);
981 assert(idx[pos] < nconss);
983 assert(constypes[idx[pos]] ==
LINEAR);
1015 const char* attrval;
1024 assert(scip != NULL);
1025 assert(datanode != NULL);
1026 assert(vars != NULL || nvars == 0);
1027 assert(conss != NULL || nconss == 0);
1028 assert(constypes != NULL || nconss == 0);
1029 assert(objcons != NULL);
1030 assert(doingfine != NULL);
1034 if( quadcoef == NULL )
1038 attrval =
xmlGetAttrval(quadcoef,
"numberOfQuadraticTerms");
1039 if( attrval == NULL )
1041 SCIPerrorMessage(
"Attribute \"numberOfQuadraticTerms\" not found for <quadraticCoefficients> node.\n");
1046 nqterms = (int)strtol(attrval, (
char**)&attrval, 10);
1047 if( *attrval !=
'\0' || nqterms < 0 )
1049 SCIPerrorMessage(
"Invalid value '%s' for \"numberOfQuadraticTerms\" attribute of <quadraticCoefficients> node.\n",
xmlGetAttrval(quadcoef,
"numberOfQuadraticTerms"));
1053 assert(nqterms >= 0);
1059 if( strcmp(
xmlGetName(qterm),
"qTerm") != 0 )
1065 if( count >= nqterms )
1067 SCIPerrorMessage(
"Too many quadratic terms under <quadraticCoefficients> node, expected %d many, but got at least %d.\n", nqterms, count + 1);
1074 if( attrval == NULL )
1076 SCIPerrorMessage(
"Missing \"idx\" attribute in %d'th <qTerm> node under <quadraticCoefficients> node.\n", count);
1081 considx = (int)strtol(attrval, (
char**)&attrval, 10);
1082 if( *attrval !=
'\0' || considx < -1 || considx >= nconss )
1084 SCIPerrorMessage(
"Invalid value '%s' in \"idx\" attribute of %d'th <qTerm> node under <quadraticCoefficients> node.\n",
xmlGetAttrval(qterm,
"idx"), count);
1091 if( attrval == NULL )
1093 SCIPerrorMessage(
"Missing \"idxOne\" attribute in %d'th <qTerm> node under <quadraticCoefficients> node.\n", count);
1098 varidx1 = (int)strtol(attrval, (
char**)&attrval, 10);
1099 if( *attrval !=
'\0' || varidx1 < 0 || varidx1 >= nvars )
1101 SCIPerrorMessage(
"Invalid value '%s' in \"idxOne\" attribute of %d'th <qTerm> node under <quadraticCoefficients> node.\n",
xmlGetAttrval(qterm,
"idxOne"), count);
1108 if( attrval == NULL )
1110 SCIPerrorMessage(
"Missing \"idxTwo\" attribute in %d'th <qTerm> node under <quadraticCoefficients> node.\n", count);
1115 varidx2 = (int)strtol(attrval, (
char**)&attrval, 10);
1116 if( *attrval !=
'\0' || varidx2 < 0 || varidx2 >= nvars )
1118 SCIPerrorMessage(
"Invalid value '%s' in \"idxTwo\" attribute of %d'th <qTerm> node under <quadraticCoefficients> node.\n",
xmlGetAttrval(qterm,
"idxTwo"), count);
1125 if( attrval != NULL )
1127 coef = strtod(attrval, (
char**)&attrval);
1128 if( *attrval !=
'\0' || (coef != coef) )
1130 SCIPerrorMessage(
"Invalid value '%s' in \"coef\" attribute of %d'th <qTerm> node under <quadraticCoefficients> node.\n",
xmlGetAttrval(qterm,
"coef"), count);
1147 if( *objcons == NULL )
1164 SCIP_CALL(
SCIPcreateConsQuadratic(scip, objcons,
"objcons", 1, &objvar, &minusone, 0, NULL, NULL, NULL,
1175 else if( constypes[considx] ==
LINEAR )
1178 cons = conss[considx];
1182 0, NULL, NULL, NULL,
1190 conss[considx] = cons;
1195 cons = conss[considx];
1196 assert(constypes[considx] ==
QUADRATIC);
1202 if( count != nqterms )
1204 SCIPerrorMessage(
"Got only %d quadratic terms under <quadraticCoefficients> node, but expected %d many.\n", count, nqterms);
1224 const char* exprname;
1226 assert(scip != NULL);
1227 assert(expr != NULL);
1228 assert(node != NULL);
1229 assert(exprvaridx != NULL || nvars == 0);
1230 assert(nexprvars != NULL);
1231 assert(doingfine != NULL);
1234 assert(exprname != NULL);
1239 if( strcmp(exprname,
"variable") == 0 )
1241 const char* attrval;
1247 if( attrval == NULL )
1249 SCIPerrorMessage(
"Attribute \"idx\" required for <variable> node in nonlinear expression\n");
1254 idx = (int)strtol(attrval, (
char**)&attrval, 10);
1255 if( *attrval !=
'\0' || idx < 0 || idx >= nvars )
1264 if( attrval != NULL )
1266 coef = strtod(attrval, (
char**)&attrval);
1280 if( exprvaridx[idx] == -1 )
1282 exprvaridx[idx] = *nexprvars;
1296 if( strcmp(exprname,
"number") == 0 )
1298 const char* attrval;
1302 if( attrval != NULL && (strcmp(attrval,
"real") != 0) )
1304 SCIPerrorMessage(
"Type '%s' for <number> node in nonlinear expression not supported.\n", attrval);
1310 if( attrval != NULL )
1312 val = strtod(attrval, (
char**)&attrval);
1334 if( strcmp(exprname,
"PI") == 0 )
1342 if( strcmp(exprname,
"E") == 0 )
1352 if( strcmp(exprname,
"negate") == 0 ||
1353 strcmp(exprname,
"abs") == 0 ||
1354 strcmp(exprname,
"squareRoot") == 0 ||
1355 strcmp(exprname,
"sqrt") == 0 ||
1356 strcmp(exprname,
"square") == 0 ||
1357 strcmp(exprname,
"exp") == 0 ||
1358 strcmp(exprname,
"ln") == 0 ||
1359 strcmp(exprname,
"log10") == 0
1367 SCIPerrorMessage(
"Expected exactly one child in <%s> node in nonlinear expression\n", exprname);
1378 if( strcmp(exprname,
"negate") == 0 )
1385 else if( strcmp(exprname,
"abs") == 0 )
1389 else if( strcmp(exprname,
"squareRoot") == 0 || strcmp(exprname,
"sqrt") == 0 )
1393 else if( strcmp(exprname,
"square") == 0 )
1397 else if( strcmp(exprname,
"exp") == 0 )
1401 else if( strcmp(exprname,
"ln") == 0 )
1410 assert(strcmp(exprname,
"log10") == 0);
1421 if( strcmp(exprname,
"plus") == 0 ||
1422 strcmp(exprname,
"minus") == 0 ||
1423 strcmp(exprname,
"times") == 0 ||
1424 strcmp(exprname,
"divide") == 0 ||
1425 strcmp(exprname,
"power") == 0 ||
1426 strcmp(exprname,
"log") == 0
1437 SCIPerrorMessage(
"Expected exactly two children in <%s> node in nonlinear expression.\n", exprname);
1455 if( strcmp(exprname,
"plus") == 0 )
1460 else if( strcmp(exprname,
"minus") == 0 )
1465 else if( strcmp(exprname,
"times") == 0 )
1482 else if( strcmp(exprname,
"divide") == 0 )
1495 else if( strcmp(exprname,
"power") == 0 )
1515 SCIPerrorMessage(
"Negative base in <power> node with nonconstant exponent not allowed in nonlinear expression.\n");
1539 else if( strcmp(exprname,
"log") == 0 )
1546 else if( strcmp(exprname,
"min") == 0 )
1552 assert(strcmp(exprname,
"max") == 0);
1561 if( strcmp(exprname,
"sum") == 0 || strcmp(exprname,
"product") == 0 )
1583 if( nargs >= argssize )
1588 assert(nargs < argssize);
1593 assert(args[nargs] == NULL);
1614 if( strcmp(exprname,
"sum") == 0 )
1635 for( ; nargs > 0; --nargs )
1644 if( strcmp(exprname,
"min") == 0 || strcmp(exprname,
"max") == 0 )
1653 SCIPerrorMessage(
"Expected at least one child in <%s> node of nonlinear expression.\n", exprname);
1663 assert(*expr == NULL);
1673 assert(arg2 == NULL);
1677 assert(arg2 == NULL);
1681 assert(*expr != NULL);
1691 assert(arg2 == NULL);
1696 if( strcmp(exprname,
"quadratic") == 0 )
1698 const char* attrval;
1712 for( i = 0; i < nvars; ++i )
1713 quadvarsidxs[i] = -1;
1720 if( strcmp(
xmlGetName(qterm),
"qpTerm") != 0 )
1722 SCIPerrorMessage(
"Unexpected <%s> node under <quadratic> node in nonlinear expression, expected <qpTerm>.\n",
xmlGetName(qterm));
1727 if( nquadelems >= quadelemssize )
1732 assert(quadelemssize > nquadelems);
1736 if( attrval == NULL )
1738 SCIPerrorMessage(
"Missing \"idxOne\" attribute in %d'th <qpTerm> node under <quadratic> node in nonlinear expression.\n", nquadelems);
1743 quadelems[nquadelems].
idx1 = (int)strtol(attrval, (
char**)&attrval, 10);
1744 if( *attrval !=
'\0' || quadelems[nquadelems].idx1 < 0 || quadelems[nquadelems].idx1 >= nvars )
1746 SCIPerrorMessage(
"Invalid value '%s' for \"idxOne\" attribute of %d'th <qpTerm> node under <quadratic> node in nonlinear expression.\n",
xmlGetAttrval(qterm,
"idxOne"), nquadelems);
1753 if( attrval == NULL )
1755 SCIPerrorMessage(
"Missing \"idxTwo\" attribute in %d'th <qpTerm> node under <quadratic> node in nonlinear expression.\n", nquadelems);
1760 quadelems[nquadelems].
idx2 = (int)strtol(attrval, (
char**)&attrval, 10);
1761 if( *attrval !=
'\0' || quadelems[nquadelems].idx2 < 0 || quadelems[nquadelems].idx2 >= nvars )
1763 SCIPerrorMessage(
"Invalid value '%s' for \"idxTwo\" attribute of %d'th <qpTerm> node under <quadratic> node in nonlinear expression.\n",
xmlGetAttrval(qterm,
"idxTwo"), nquadelems);
1770 if( attrval != NULL )
1772 quadelems[nquadelems].
coef = strtod(attrval, (
char**)&attrval);
1773 if( *attrval !=
'\0' || (quadelems[nquadelems].coef != quadelems[nquadelems].coef) )
1775 SCIPerrorMessage(
"Invalid value '%s' for \"coef\" attribute of %d'th <qpTerm> node under <quadratic> node in nonlinear expression.\n",
xmlGetAttrval(qterm,
"coef"), nquadelems);
1782 quadelems[nquadelems].
coef = 1.0;
1786 if( quadvarsidxs[quadelems[nquadelems].idx1] < 0 )
1788 quadvarsidxs[quadelems[nquadelems].
idx1] = nquadvars;
1789 quadelems[nquadelems].idx1 = nquadvars;
1795 quadelems[nquadelems].
idx1 = quadvarsidxs[quadelems[nquadelems].
idx1];
1799 if( quadvarsidxs[quadelems[nquadelems].idx2] < 0 )
1801 quadvarsidxs[quadelems[nquadelems].
idx2] = nquadvars;
1802 quadelems[nquadelems].idx2 = nquadvars;
1808 quadelems[nquadelems].
idx2 = quadvarsidxs[quadelems[nquadelems].
idx2];
1812 if( quadelems[nquadelems].idx1 > quadelems[nquadelems].idx2 )
1816 tmp = quadelems[nquadelems].
idx1;
1817 quadelems[nquadelems].
idx1 = quadelems[nquadelems].
idx2;
1818 quadelems[nquadelems].
idx2 = tmp;
1828 for( i = 0; i < nvars; ++i )
1830 if( quadvarsidxs[i] == -1 )
1834 if( exprvaridx[i] == -1 )
1836 exprvaridx[i] = *nexprvars;
1854 SCIPerrorMessage(
"Expression operand <%s> in nonlinear expression not supported by SCIP so far.\n", exprname);
1878 const char* attrval;
1890 assert(scip != NULL);
1891 assert(datanode != NULL);
1892 assert(vars != NULL || nvars == 0);
1893 assert(conss != NULL || nconss == 0);
1894 assert(constypes != NULL || nconss == 0);
1895 assert(objcons != NULL);
1896 assert(doingfine != NULL);
1902 if( nlexprs == NULL )
1906 attrval =
xmlGetAttrval(nlexprs,
"numberOfNonlinearExpressions");
1907 if( attrval == NULL )
1909 SCIPerrorMessage(
"Attribute \"numberOfNonlinearExpressions\" in <nonlinearExpressions> node not found.\n");
1914 nnlexprs = (int)strtol(attrval, (
char**)&attrval, 10);
1915 if( *attrval !=
'\0' || nnlexprs < 0 )
1917 SCIPerrorMessage(
"Invalid value '%s' for \"numberOfNonlinearExpressions\" attribute in <nonlinearExpressions>.\n",
xmlGetAttrval(nlexprs,
"numberOfNonlinearExpressions"));
1921 assert(nnlexprs >= 0);
1937 if( count >= nnlexprs )
1939 SCIPerrorMessage(
"Too many nonlinear expressions under <nonlinearExpressions> node, expected %d many, but got at least %d.\n", nnlexprs, count + 1);
1950 if( attrval == NULL )
1952 SCIPerrorMessage(
"Missing \"idx\" attribute in %d'th <nl> node under <nonlinearExpressions> node.\n", count);
1957 considx = (int)strtol(attrval, (
char**)&attrval, 10);
1958 if( *attrval !=
'\0' || considx < -1 || considx >= nconss )
1960 SCIPerrorMessage(
"Invalid value '%s' in \"idx\" attribute of %d'th <nl> node under <nonlinearExpressions> node.\n",
xmlGetAttrval(nlexpr,
"idx"), count);
1967 for( i = 0; i < nvars; ++i )
1974 assert(expr == NULL);
1979 for( i = 0; i < nvars; ++i )
1981 assert(exprvaridx[i] < nexprvars );
1983 if( exprvaridx[i] >= 0 )
1984 exprvars[exprvaridx[i]] = vars[i];
1992 if( considx == -1 && *objcons == NULL )
2011 SCIP_CALL_TERMINATE( retcode,
SCIPcreateConsNonlinear(scip, objcons,
"objcons", 1, &objvar, &minusone, 1, &exprtree, &one,
2014 TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
FALSE,
FALSE), TERMINATE );
2028 constype = objconstype;
2032 cons = &conss[considx];
2033 constype = &constypes[considx];
2075 exprtrees[0] = exprtree;
2091 for( i = 0; i < nquadvars; ++i )
2093 lincoefs[i] = quadvarterms[i].
lincoef;
2094 exprvars[i] = quadvarterms[i].
var;
2096 if( quadvarterms[i].sqrcoef != 0.0 )
2098 quadelems[nquadelems].
idx1 = i;
2099 quadelems[nquadelems].
idx2 = i;
2100 quadelems[nquadelems].
coef = quadvarterms[i].
sqrcoef;
2106 for( j = 0; j < quadvarterms[i].
nadjbilin; ++j )
2108 if( bilinterms[quadvarterms[i].adjbilin[j]].var1 == quadvarterms[i].var )
2112 assert(bilinterms[quadvarterms[i].adjbilin[j]].var2 != quadvarterms[i].var);
2115 assert(otheridx >= 0);
2116 assert(otheridx < nquadvars);
2118 quadelems[nquadelems].
idx1 = MIN(i, otheridx);
2119 quadelems[nquadelems].
idx2 =
MAX(i, otheridx);
2206 const char* attrval;
2225 initial = initialconss;
2231 dynamic = dynamicconss;
2232 removable = dynamicrows;
2236 if( soscons== NULL )
2241 if( attrval == NULL )
2243 SCIPerrorMessage(
"Attribute \"numberOfSOS in <specialOrderedSets> node not found.\n");
2248 nsoscons = (int)strtol(attrval, (
char**)&attrval, 10);
2249 if( *attrval !=
'\0' || nsoscons < 0 )
2255 assert(nsoscons >= 0);
2264 if( strcmp(
xmlGetName(soscons),
"sos") != 0 )
2271 if( count >= nsoscons)
2273 SCIPerrorMessage(
"Too many sos under <specialOrderedSets> node, expected %d many, but got at least %d.\n", nsoscons, count + 1);
2280 if( attrval == NULL )
2287 nsosvars = (int)strtol(attrval, (
char**)&attrval, 10);
2288 if( *attrval !=
'\0' || nsosvars < 0 )
2294 assert(nsosvars >= 0);
2298 if( attrval == NULL )
2305 sosorder = (int)strtol(attrval, (
char**)&attrval, 10);
2306 if( *attrval !=
'\0' || sosorder < 0 || sosorder > 2 )
2312 assert(sosorder == 1 || sosorder == 2);
2322 SCIP_CALL(
SCIPcreateConsSOS1(scip, &cons, name, 0, NULL, NULL, initial, separate, enforce, check, propagate,
2323 local, dynamic, removable,
FALSE) );
2326 SCIP_CALL(
SCIPcreateConsSOS2(scip, &cons, name, 0, NULL, NULL, initial, separate, enforce, check, propagate,
2327 local, dynamic, removable,
FALSE) );
2340 if( attrval == NULL )
2342 SCIPerrorMessage(
"Attribute \"idx\" in <var> node below <specialOrderedSets> node not found.\n");
2347 idx = (int)strtol(attrval, (
char**)&attrval, 10);
2348 if( *attrval !=
'\0' || idx < 0 || idx > nvars - 1 )
2389 assert(
scip != NULL);
2419 assert(
scip != NULL);
2420 assert(reader != NULL);
2421 assert(result != NULL);
2422 assert(filename != NULL);
2439 SCIPerrorMessage(
"Some error occurred when parsing the OSiL XML file '%s'.\n", filename);
2448 if( header != NULL )
2482 SCIP_CALL_TERMINATE( retcode,
readVariables(
scip, data, &vars, &nvars, initialconss, dynamicconss, dynamiccols, dynamicrows, &doingfine), CLEANUP );
2485 assert(vars != NULL || nvars == 0);
2493 SCIP_CALL_TERMINATE( retcode,
readConstraints(
scip, data, &conss, &constypes, &nconss, initialconss, dynamicconss, dynamicrows, &doingfine), CLEANUP );
2496 assert(conss != NULL || nconss == 0);
2504 SCIP_CALL_TERMINATE( retcode,
readQuadraticCoefs(
scip, data, vars, nvars, conss, constypes, nconss, &objcons, &objconstype, &doingfine), CLEANUP );
2509 SCIP_CALL_TERMINATE( retcode,
readNonlinearExprs(
scip, data, vars, nvars, conss, constypes, nconss, &objcons, &objconstype, &doingfine), CLEANUP );
2514 for( i = 0; i < nconss; ++i )
2516 assert(conss[i] != NULL);
2519 if( objcons != NULL )
2539 for( i = 0; i < nvars; ++i )
2546 for( i = 0; i < nconss; ++i )
2553 if( objcons != NULL )
enum SCIP_BoundType SCIP_BOUNDTYPE
void SCIPexprFreeDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
static SCIP_RETCODE readNonlinearExprs(SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_CONS **objcons, CONSTYPE *objconstype, SCIP_Bool *doingfine)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
static SCIP_DECL_READERCOPY(readerCopyOsil)
SCIP_EXPROP SCIPexprGetOperator(SCIP_EXPR *expr)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Real * SCIPgetLinearCoefsNonlinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
SCIP_Real SCIPgetRhsNonlinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPexprtreeSetVars(SCIP_EXPRTREE *tree, int nvars, SCIP_VAR **vars)
XML_NODE * xmlProcess(const char *filename)
OS instance language (OSiL) format file reader.
const XML_NODE * xmlFirstChild(const XML_NODE *node)
const char * xmlGetData(const XML_NODE *node)
SCIP_RETCODE SCIPexprtreeCreate(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **tree, SCIP_EXPR *root, int nvars, int nparams, SCIP_Real *params)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPaddExprtreesNonlinear(SCIP *scip, SCIP_CONS *cons, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *coefs)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
static SCIP_RETCODE readSOScons(SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
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)
int SCIPgetNQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
void xmlShowNode(const XML_NODE *root)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
static SCIP_DECL_READERREAD(readerReadOsil)
SCIP_RETCODE SCIPexprCreateQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real constant, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems)
SCIP_RETCODE SCIPfindQuadVarTermQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, int *pos)
enum SCIP_ExprOp SCIP_EXPROP
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE readExpression(SCIP *scip, SCIP_EXPR **expr, const XML_NODE *node, int *exprvaridx, int *nexprvars, int nvars, SCIP_Bool *doingfine)
struct XML_NODE_struct XML_NODE
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
#define SCIPfreeBufferArrayNull(scip, ptr)
const XML_NODE * xmlFindNodeMaxdepth(const XML_NODE *node, const char *name, int depth, int maxdepth)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
const char * SCIPvarGetName(SCIP_VAR *var)
constraint handler for quadratic constraints
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
SCIP_BILINTERM * SCIPgetBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPexprMulConstant(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPR *term, SCIP_Real factor)
SCIP_RETCODE SCIPincludeReaderOsil(SCIP *scip)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_RETCODE SCIPexprAdd(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_Real coef1, SCIP_EXPR *term1, SCIP_Real coef2, SCIP_EXPR *term2, SCIP_Real constant)
SCIP_RETCODE SCIPaddBilinTermQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_Real coef)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
SCIP_Real SCIPgetLhsNonlinear(SCIP *scip, SCIP_CONS *cons)
constraint handler for nonlinear constraints
static SCIP_RETCODE readLinearCoefs(SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_Bool *doingfine)
SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op,...)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
SCIP_RETCODE SCIPexprtreeFree(SCIP_EXPRTREE **tree)
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)
SCIPInterval log(const SCIPInterval &x)
Constraint handler for linear constraints in their most general form, .
const char * xmlGetName(const XML_NODE *node)
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
static SCIP_RETCODE readConstraints(SCIP *scip, const XML_NODE *datanode, SCIP_CONS ***conss, CONSTYPE **constypes, int *nconss, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
static SCIP_RETCODE readObjective(SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_Bool dynamiccols, SCIP_Bool *doingfine)
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)
static void readMultIncr(const XML_NODE *node, int *mult, int *incrint, SCIP_Real *incrreal, SCIP_Bool *doingfine)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
int SCIPgetNLinearVarsNonlinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPexprGetOpReal(SCIP_EXPR *expr)
const char * xmlGetAttrval(const XML_NODE *node, const char *name)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPsortQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE readQuadraticCoefs(SCIP *scip, const XML_NODE *datanode, SCIP_VAR **vars, int nvars, SCIP_CONS **conss, CONSTYPE *constypes, int nconss, SCIP_CONS **objcons, CONSTYPE *objconstype, SCIP_Bool *doingfine)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetLinearVarsNonlinear(SCIP *scip, SCIP_CONS *cons)
#define SCIP_CALL_TERMINATE(retcode, x, TERM)
static SCIP_RETCODE readVariables(SCIP *scip, const XML_NODE *datanode, SCIP_VAR ***vars, int *nvars, SCIP_Bool initialconss, SCIP_Bool dynamicconss, SCIP_Bool dynamiccols, SCIP_Bool dynamicrows, SCIP_Bool *doingfine)
constraint handler for SOS type 1 constraints
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *nonlincoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
declarations for XML parsing
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
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_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)
enum SCIP_Vartype SCIP_VARTYPE
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)
void xmlFreeNode(XML_NODE *node)
SCIP_QUADVARTERM * SCIPgetQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPexprCreateLinear(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefs, SCIP_Real constant)
constraint handler for bound disjunction constraints
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
const XML_NODE * xmlNextSibl(const XML_NODE *node)
#define SCIPreallocBufferArray(scip, ptr, num)