Detailed Description
implementation of AMPL/MPs NLHandler that constructs a SCIP problem while a .nl file is read
Definition at line 102 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 | LinearExprHandler |
class | LinearPartHandler |
class | NumericArgHandler |
class | SuffixHandler |
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 () | |
void | OnHeader (const mp::NLHeader &h) |
SCIP_EXPR * | OnNumber (double value) |
receive notification of a number in a nonlinear expression More... | |
SCIP_EXPR * | OnVariableRef (int variableIndex) |
receive notification of a variable reference in a nonlinear expression More... | |
SCIP_EXPR * | OnUnary (mp::expr::Kind kind, SCIP_EXPR *child) |
receive notification of a unary expression More... | |
SCIP_EXPR * | OnBinary (mp::expr::Kind kind, SCIP_EXPR *firstChild, SCIP_EXPR *secondChild) |
receive notification of a binary expression More... | |
NumericArgHandler | BeginSum (int num_args) |
receive notification of the beginning of a summation More... | |
SCIP_EXPR * | EndSum (NumericArgHandler handler) |
receive notification of the end of a summation More... | |
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 More... | |
void | OnAlgebraicCon (int constraintIndex, SCIP_EXPR *expr) |
receive notification of an algebraic constraint expression More... | |
LinearExprHandler | BeginCommonExpr (int index, int num_linear_terms) |
receive notification of the beginning of a common expression (defined variable) More... | |
void | EndCommonExpr (int index, SCIP_EXPR *expr, int) |
receive notification of the end of a common expression More... | |
SCIP_EXPR * | OnCommonExprRef (int expr_index) |
receive notification of a common expression (defined variable) reference More... | |
void | OnVarBounds (int variableIndex, double variableLB, double variableUB) |
receive notification of variable bounds More... | |
void | OnConBounds (int index, double lb, double ub) |
receive notification of constraint sides More... | |
void | OnInitialValue (int var_index, double value) |
receive notification of the initial value for a variable More... | |
void | OnInitialDualValue (int, double) |
receives notification of the initial value for a dual variable More... | |
ColumnSizeHandler | OnColumnSizes () |
receives notification of Jacobian column sizes More... | |
IntSuffixHandler | OnIntSuffix (fmt::StringRef name, mp::suf::Kind kind, int) |
receive notification of an integer suffix More... | |
DblSuffixHandler | OnDblSuffix (fmt::StringRef name, mp::suf::Kind kind, int) |
receive notification of a double suffix More... | |
LinearPartHandler | OnLinearObjExpr (int objectiveIndex, int) |
receive notification of the linear part of an objective More... | |
LinearConHandler | OnLinearConExpr (int constraintIndex, int) |
receive notification of the linear part of a constraint More... | |
void | EndInput () |
SCIP_RETCODE | cleanup () |
Member Typedef Documentation
◆ IntSuffixHandler
typedef SuffixHandler<int> AMPLProblemHandler::IntSuffixHandler |
Definition at line 1022 of file reader_nl.cpp.
◆ DblSuffixHandler
Definition at line 1033 of file reader_nl.cpp.
◆ LinearObjHandler
Definition at line 1103 of file reader_nl.cpp.
◆ LinearConHandler
Definition at line 1117 of file reader_nl.cpp.
Constructor & Destructor Documentation
◆ AMPLProblemHandler()
|
inline |
constructor
initializes SCIP problem and problem data
- Parameters
-
scip_ SCIP data structure filename name of .nl file that is read
Definition at line 188 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPallocBlockMemoryArray, SCIPallocClearMemory, and SCIPcreateProb().
◆ ~AMPLProblemHandler()
|
inline |
destructor
only asserts that cleanup() has been called, as we cannot throw an exception or return a SCIP_RETCODE here
Definition at line 251 of file reader_nl.cpp.
Member Function Documentation
◆ OnHeader()
|
inline |
process header of .nl files
create and add variables, allocate constraints
- Parameters
-
h header data
Definition at line 264 of file reader_nl.cpp.
References BMScopyMemoryArray, 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().
◆ OnNumber()
|
inline |
receive notification of a number in a nonlinear expression
- Parameters
-
value value
Definition at line 393 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPcreateExprValue().
◆ OnVariableRef()
|
inline |
receive notification of a variable reference in a nonlinear expression
- Parameters
-
variableIndex AMPL index of variable
Definition at line 408 of file reader_nl.cpp.
References NULL.
◆ OnUnary()
receive notification of a unary expression
- Parameters
-
kind expression operator child argument
Definition at line 420 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIP_Real, SCIPcreateExprAbs(), SCIPcreateExprCos(), SCIPcreateExprExp(), SCIPcreateExprLog(), SCIPcreateExprPow(), SCIPcreateExprSin(), SCIPcreateExprSum(), and SCIPreleaseExpr().
◆ OnBinary()
|
inline |
receive notification of a binary expression
- Parameters
-
kind expression operand firstChild first argument secondChild second argument
Definition at line 488 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIP_Real, SCIPcreateExprExp(), SCIPcreateExprLog(), SCIPcreateExprPow(), SCIPcreateExprProduct(), SCIPcreateExprSum(), SCIPgetValueExprValue(), SCIPisExprValue(), and SCIPreleaseExpr().
◆ BeginSum()
|
inline |
receive notification of the beginning of a summation
- Parameters
-
num_args number of terms to expect
Definition at line 601 of file reader_nl.cpp.
References h.
◆ EndSum()
|
inline |
receive notification of the end of a summation
- Parameters
-
handler handler that handled the sum
Definition at line 610 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPcreateExprSum(), and AMPLProblemHandler::NumericArgHandler::v.
◆ OnObj()
|
inline |
receive notification of an objective type and the nonlinear part of an objective expression
- Parameters
-
objectiveIndex index of objective type objective sense nonlinearExpression nonlinear part of objective function
Definition at line 622 of file reader_nl.cpp.
References MAX, NULL, SCIP_CALL_THROW, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddVar(), SCIPcreateVarBasic(), SCIPgetValueExprValue(), SCIPisExprValue(), SCIPreleaseVar(), and SCIPsetObjsense().
◆ OnAlgebraicCon()
|
inline |
receive notification of an algebraic constraint expression
- Parameters
-
constraintIndex index of constraint expr nonlinear part of constraint
Definition at line 652 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPchgExprNonlinear().
◆ BeginCommonExpr()
|
inline |
receive notification of the beginning of a common expression (defined variable)
- Parameters
-
index index of common expression num_linear_terms number of terms to expect
Definition at line 717 of file reader_nl.cpp.
◆ EndCommonExpr()
|
inline |
receive notification of the end of a common expression
- Parameters
-
index index of common expression expr nonlinear part of common expression
Definition at line 729 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, and SCIPappendExprSumExpr().
◆ OnCommonExprRef()
|
inline |
receive notification of a common expression (defined variable) reference
- Parameters
-
expr_index index of common expression
Definition at line 750 of file reader_nl.cpp.
References NULL.
◆ OnVarBounds()
|
inline |
receive notification of variable bounds
- Parameters
-
variableIndex AMPL index of variable variableLB variable lower bound variableUB variable upper bound
Definition at line 761 of file reader_nl.cpp.
References SCIP_CALL_THROW, SCIP_VARTYPE_BINARY, SCIPchgVarLbGlobal(), SCIPchgVarUbGlobal(), SCIPinfinity(), and SCIPvarGetType().
◆ OnConBounds()
|
inline |
receive notification of constraint sides
- Parameters
-
index AMPL index of constraint lb constraint left-hand-side ub constraint right-hand-side
Definition at line 784 of file reader_nl.cpp.
References SCIP_CALL_THROW, SCIPchgLhsLinear(), SCIPchgLhsNonlinear(), SCIPchgRhsLinear(), SCIPchgRhsNonlinear(), and SCIPisInfinity().
◆ OnInitialValue()
|
inline |
receive notification of the initial value for a variable
- Parameters
-
var_index AMPL index of variable value initial primal value of variable
Definition at line 819 of file reader_nl.cpp.
References NULL, SCIP_CALL_THROW, SCIPcreateSol(), and SCIPsetSolVal().
◆ OnInitialDualValue()
|
inline |
receives notification of the initial value for a dual variable
Definition at line 833 of file reader_nl.cpp.
◆ OnColumnSizes()
|
inline |
receives notification of Jacobian column sizes
use ColumnSizeHandler from upper class, which does nothing
Definition at line 842 of file reader_nl.cpp.
◆ OnIntSuffix()
|
inline |
receive notification of an integer suffix
- Parameters
-
name suffix name, not null-terminated kind suffix kind
Definition at line 1024 of file reader_nl.cpp.
◆ OnDblSuffix()
|
inline |
receive notification of a double suffix
- Parameters
-
name suffix name, not null-terminated kind suffix kind
Definition at line 1035 of file reader_nl.cpp.
◆ OnLinearObjExpr()
|
inline |
receive notification of the linear part of an objective
- Parameters
-
objectiveIndex index of objective
Definition at line 1106 of file reader_nl.cpp.
◆ OnLinearConExpr()
|
inline |
receive notification of the linear part of a constraint
- Parameters
-
constraintIndex index of constraint
Definition at line 1120 of file reader_nl.cpp.
◆ EndInput()
|
inline |
receive notification of the end of the input
- setup all nonlinear constraints and add them to SCIP
- add linear constraints to SCIP (should be after nonlinear ones to respect order in .nl file)
- add initial solution, if initial values were given
Definition at line 1133 of file reader_nl.cpp.
References NULL, SCIP_Bool, SCIP_CALL_THROW, SCIP_OBJSENSE_MAXIMIZE, SCIP_OBJSENSE_MINIMIZE, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPaddCons(), SCIPaddLinearVarNonlinear(), SCIPaddSolFree(), SCIPaddVar(), SCIPcreateConsBasicNonlinear(), SCIPcreateConsBasicSOS1(), SCIPcreateConsBasicSOS2(), SCIPcreateVarBasic(), SCIPgetObjsense(), SCIPinfinity(), SCIPreleaseCons(), and SCIPreleaseVar().
◆ cleanup()
|
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 1240 of file reader_nl.cpp.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeSol(), and SCIPreleaseExpr().
Referenced by SCIP_DECL_READERREAD().