implementation of AMPL/MPs NLHandler that constructs a SCIP problem while a .nl file is read
Definition at line 141 of file reader_nl.cpp.
implementation of AMPL/MPs NLHandler that constructs a SCIP problem while a .nl file is read More...
Data Structures | |
| class | NumericArgHandler |
| class | LinearExprHandler |
| class | SuffixHandler |
| class | LinearPartHandler |
Public Types | |
| typedef SuffixHandler< int > | IntSuffixHandler |
| typedef SuffixHandler< SCIP_Real > | DblSuffixHandler |
| typedef LinearPartHandler | LinearObjHandler |
| typedef LinearPartHandler | LinearConHandler |
Public Member Functions | |
| AMPLProblemHandler (SCIP *scip_, const char *filename) | |
| AMPLProblemHandler (const AMPLProblemHandler &)=delete | |
| AMPLProblemHandler & | operator= (const AMPLProblemHandler &)=delete |
| ~AMPLProblemHandler () override | |
| void | OnHeader (const mp::NLHeader &h) |
| SCIP_EXPR * | OnNumber (double value) |
| receive notification of a number in a nonlinear expression | |
| SCIP_EXPR * | OnVariableRef (int variableIndex) |
| receive notification of a variable reference in a nonlinear expression | |
| SCIP_EXPR * | OnUnary (mp::expr::Kind kind, SCIP_EXPR *child) |
| receive notification of a unary expression | |
| SCIP_EXPR * | OnBinary (mp::expr::Kind kind, SCIP_EXPR *firstChild, SCIP_EXPR *secondChild) |
| receive notification of a binary expression | |
| NumericArgHandler | BeginSum (int num_args) |
| receive notification of the beginning of a summation | |
| SCIP_EXPR * | EndSum (NumericArgHandler handler) |
| receive notification of the end of a summation | |
| void | OnObj (int objectiveIndex, mp::obj::Type type, SCIP_EXPR *nonlinearExpression) |
| receive notification of an objective type and the nonlinear part of an objective expression | |
| void | OnAlgebraicCon (int constraintIndex, SCIP_EXPR *expr) |
| receive notification of an algebraic constraint expression | |
| void | OnLogicalCon (int index, LogicalExpr expr) |
| receives notification of a logical constraint expression | |
| LinearExprHandler | BeginCommonExpr (int index, int num_linear_terms) |
| receive notification of the beginning of a common expression (defined variable) | |
| void | EndCommonExpr (int index, SCIP_EXPR *expr, int) |
| receive notification of the end of a common expression | |
| SCIP_EXPR * | OnCommonExprRef (int expr_index) |
| receive notification of a common expression (defined variable) reference | |
| void | OnVarBounds (int variableIndex, double variableLB, double variableUB) |
| receive notification of variable bounds | |
| void | OnConBounds (int index, double lb, double ub) |
| receive notification of constraint sides | |
| void | OnInitialValue (int var_index, double value) |
| receive notification of the initial value for a variable | |
| void | OnInitialDualValue (int, double) |
| receives notification of the initial value for a dual variable | |
| ColumnSizeHandler | OnColumnSizes () |
| receives notification of Jacobian column sizes | |
| IntSuffixHandler | OnIntSuffix (fmt::StringRef name, mp::suf::Kind kind, int) |
| receive notification of an integer suffix | |
| DblSuffixHandler | OnDblSuffix (fmt::StringRef name, mp::suf::Kind kind, int) |
| receive notification of a double suffix | |
| LinearPartHandler | OnLinearObjExpr (int objectiveIndex, int) |
| receive notification of the linear part of an objective | |
| LinearConHandler | OnLinearConExpr (int constraintIndex, int) |
| receive notification of the linear part of a constraint | |
| LogicalExpr | OnBool (bool value) |
| receives notification of a Boolean value <mp::expr::BOOL> | |
| LogicalExpr | OnNot (LogicalExpr arg) |
| receives notification of a logical not <mp::expr::NOT> | |
| LogicalExpr | OnBinaryLogical (mp::expr::Kind kind, LogicalExpr lhs, LogicalExpr rhs) |
| receives notification of a binary logical expression <mp::expr::FIRST_BINARY_LOGICAL> | |
| LogicalExpr | OnRelational (mp::expr::Kind kind, NumericExpr lhs, NumericExpr rhs) |
| void | EndInput () |
| SCIP_RETCODE | cleanup () |
| typedef SuffixHandler<int> AMPLProblemHandler::IntSuffixHandler |
Definition at line 1154 of file reader_nl.cpp.
Definition at line 1165 of file reader_nl.cpp.
Definition at line 1235 of file reader_nl.cpp.
Definition at line 1249 of file reader_nl.cpp.
|
inline |
constructor
initializes SCIP problem and problem data
| scip_ | SCIP data structure |
| filename | name of .nl file that is read |
Definition at line 272 of file reader_nl.cpp.
References assert(), NULL, SCIP_CALL_THROW, SCIPallocBlockMemoryArray, SCIPallocClearMemory, and SCIPcreateProb().
Referenced by AMPLProblemHandler(), AMPLProblemHandler::LinearExprHandler::LinearExprHandler(), AMPLProblemHandler::LinearPartHandler::LinearPartHandler(), AMPLProblemHandler::LinearPartHandler::LinearPartHandler(), operator=(), and AMPLProblemHandler::SuffixHandler< int >::SuffixHandler().
|
delete |
References AMPLProblemHandler().
|
inlineoverride |
destructor
only asserts that cleanup() has been called, as we cannot throw an exception or return a SCIP_RETCODE here
Definition at line 339 of file reader_nl.cpp.
References assert().
|
delete |
References AMPLProblemHandler().
|
inline |
process header of .nl files
create and add variables, allocate constraints
| h | header data |
Definition at line 352 of file reader_nl.cpp.
References assert(), BMScopyMemoryArray, h, i, MAX, NULL, SCIP_CALL_THROW, SCIP_MAXSTRLEN, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_CONTINUOUS, SCIP_VARTYPE_INTEGER, SCIPABORT, SCIPaddVar(), SCIPallocBlockMemoryArray, SCIPcreateConsBasicLinear(), SCIPcreateConsBasicNonlinear(), SCIPcreateExprValue(), SCIPcreateExprVar(), SCIPcreateVarBasic(), SCIPinfinity(), SCIPreleaseExpr(), and SCIPsnprintf().
|
inline |
receive notification of a number in a nonlinear expression
| value | value |
Definition at line 482 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPcreateExprValue().
|
inline |
receive notification of a variable reference in a nonlinear expression
| variableIndex | AMPL index of variable |
Definition at line 497 of file reader_nl.cpp.
receive notification of a unary expression
| kind | expression operator |
| child | argument |
Definition at line 509 of file reader_nl.cpp.
References assert(), NULL, SCIP_CALL_THROW, SCIP_Real, SCIPcreateExprAbs(), SCIPcreateExprCos(), SCIPcreateExprExp(), SCIPcreateExprLog(), SCIPcreateExprPow(), SCIPcreateExprSin(), SCIPcreateExprSum(), and SCIPreleaseExpr().
|
inline |
receive notification of a binary expression
| kind | expression operand |
| firstChild | first argument |
| secondChild | second argument |
Definition at line 577 of file reader_nl.cpp.
References assert(), NULL, SCIP_CALL_THROW, SCIP_Real, SCIPcreateExprExp(), SCIPcreateExprLog(), SCIPcreateExprPow(), SCIPcreateExprProduct(), SCIPcreateExprSum(), SCIPgetValueExprValue(), SCIPisExprValue(), and SCIPreleaseExpr().
|
inline |
receive notification of the beginning of a summation
| num_args | number of terms to expect |
Definition at line 690 of file reader_nl.cpp.
References h.
|
inline |
receive notification of the end of a summation
| handler | handler that handled the sum |
Definition at line 699 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPcreateExprSum(), and AMPLProblemHandler::NumericArgHandler::v.
|
inline |
receive notification of an objective type and the nonlinear part of an objective expression
| objectiveIndex | index of objective |
| type | objective sense |
| nonlinearExpression | nonlinear part of objective function |
Definition at line 711 of file reader_nl.cpp.
References assert(), NULL, SCIP_CALL_THROW, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPcreateVarBasic(), SCIPgetValueExprValue(), SCIPisExprValue(), SCIPreleaseVar(), and SCIPsetObjsense().
|
inline |
receive notification of an algebraic constraint expression
| constraintIndex | index of constraint |
| expr | nonlinear part of constraint |
Definition at line 741 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPchgExprNonlinear().
|
inline |
receives notification of a logical constraint expression
Definition at line 753 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPaddCons(), SCIPcreateConsBasicNonlinear(), and SCIPreleaseCons().
|
inline |
receive notification of the beginning of a common expression (defined variable)
| index | index of common expression |
| num_linear_terms | number of terms to expect |
Definition at line 821 of file reader_nl.cpp.
References assert().
|
inline |
receive notification of the end of a common expression
| index | index of common expression |
| expr | nonlinear part of common expression |
Definition at line 833 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPappendExprSumExpr().
|
inline |
receive notification of a common expression (defined variable) reference
| expr_index | index of common expression |
Definition at line 854 of file reader_nl.cpp.
|
inline |
receive notification of variable bounds
| variableIndex | AMPL index of variable |
| variableLB | variable lower bound |
| variableUB | variable upper bound |
Definition at line 865 of file reader_nl.cpp.
References assert(), nvars, SCIP_Bool, SCIP_CALL_THROW, SCIP_VARTYPE_BINARY, SCIPchgVarLbGlobal(), SCIPchgVarUbGlobal(), SCIPinfinity(), and SCIPvarGetType().
|
inline |
receive notification of constraint sides
| index | AMPL index of constraint |
| lb | constraint left-hand-side |
| ub | constraint right-hand-side |
Definition at line 889 of file reader_nl.cpp.
References assert(), SCIP_CALL_THROW, SCIPchgLhsLinear(), SCIPchgLhsNonlinear(), SCIPchgRhsLinear(), SCIPchgRhsNonlinear(), and SCIPisInfinity().
|
inline |
receive notification of the initial value for a variable
| var_index | AMPL index of variable |
| value | initial primal value of variable |
Definition at line 935 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPcreateSol(), and SCIPsetSolVal().
|
inline |
receives notification of the initial value for a dual variable
Definition at line 949 of file reader_nl.cpp.
|
inline |
receives notification of Jacobian column sizes
use ColumnSizeHandler from upper class, which does nothing
Definition at line 958 of file reader_nl.cpp.
|
inline |
receive notification of an integer suffix
| name | suffix name, not null-terminated |
| kind | suffix kind |
Definition at line 1156 of file reader_nl.cpp.
|
inline |
receive notification of a double suffix
| name | suffix name, not null-terminated |
| kind | suffix kind |
Definition at line 1167 of file reader_nl.cpp.
|
inline |
receive notification of the linear part of an objective
| objectiveIndex | index of objective |
Definition at line 1238 of file reader_nl.cpp.
|
inline |
receive notification of the linear part of a constraint
| constraintIndex | index of constraint |
Definition at line 1252 of file reader_nl.cpp.
|
inline |
receives notification of a Boolean value <mp::expr::BOOL>
Definition at line 1261 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPcreateExprValue().
|
inline |
receives notification of a logical not <mp::expr::NOT>
Definition at line 1276 of file reader_nl.cpp.
References NULL, SCIP_Bool, SCIP_CALL_THROW, SCIPcreateExprValue(), SCIPcreateExprVar(), SCIPgetNegatedVar(), and var.
|
inline |
receives notification of a binary logical expression <mp::expr::FIRST_BINARY_LOGICAL>
Definition at line 1302 of file reader_nl.cpp.
References assert(), NULL, SCIP_Bool, SCIP_CALL_THROW, SCIP_VARTYPE_BINARY, SCIPaddCons(), SCIPaddVar(), SCIPcreateConsBasicAnd(), SCIPcreateConsBasicOr(), SCIPcreateConsBasicXor(), SCIPcreateExprValue(), SCIPcreateExprVar(), SCIPcreateVarBasic(), SCIPgetNegatedVar(), SCIPreleaseCons(), SCIPreleaseVar(), TRUE, and vars.
|
inline |
receives notification of a relational expression <mp::expr::FIRST_RELATIONAL> we only handle equality or inequality between binary variables and boolean values here
Definition at line 1503 of file reader_nl.cpp.
References assert(), FALSE, NULL, SCIP_Bool, SCIP_CALL_THROW, SCIP_VARTYPE_BINARY, SCIPaddCons(), SCIPaddVar(), SCIPcreateConsBasicXor(), SCIPcreateExprValue(), SCIPcreateExprVar(), SCIPcreateVarBasic(), SCIPgetNegatedVar(), SCIPreleaseCons(), SCIPreleaseVar(), TRUE, and vars.
|
inline |
receive notification of the end of the input
Definition at line 1596 of file reader_nl.cpp.
References assert(), cleanup(), i, NULL, SCIP_Bool, SCIP_CALL_THROW, SCIP_INVALID, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddCons(), SCIPaddLinearVarNonlinear(), SCIPaddSolFree(), SCIPaddVar(), SCIPcreateConsBasicNonlinear(), SCIPcreateConsBasicSOS1(), SCIPcreateConsBasicSOS2(), SCIPcreateVarBasic(), SCIPevalExpr(), SCIPexprGetEvalValue(), SCIPgetObjsense(), SCIPinfinity(), SCIPreleaseCons(), SCIPreleaseVar(), SCIPsetSolVal(), SCIPsnprintf(), SCIPwarningMessage(), and varidx.
|
inline |
releases expressions and linear constraints from data
should be called if there was an error while reading the .nl file this is not in the destructor, because we want to return SCIP_RETCODE
Definition at line 1717 of file reader_nl.cpp.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeSol(), and SCIPreleaseExpr().
Referenced by EndInput(), and SCIP_DECL_READERREAD().