Reference¶
Index¶
See the alphabetic index.
Alternatively, use the Search Page or look below.
Namespace mp¶
-
namespace mp¶
Backend with a Model Manager.
Implementation of value presolver.
Value presolver: namespace mp::pre.
Wrappers implementing a HashStreamer interface.
File utils.
Support for .nl/.sol/console I/O requiring a (Basic)Solver.
Generate ModelManagerWithPB<mp::Problem>
Generate ModelManagerWithPB<mp::Problem>, header file.
This is an abstract interface to a Model Manager which provides model IO, solution handling and suffixes, etc.
Redefinition of PL flat constraint into SOS2 + linear.
Redefinition of smooth nonlinear functions via piecewise-linear approximation.
Convert quadratic indicators for MIP.
Redefinition for MIP of <cond> ==> <constr1> [ else <constr2> ].
Converter-independent linear approximation routines.
Implementation of flat model info.
Public interface for flat model info.
Basic definitions for a FlatModelAPI.
Bounds and type computation for various expressions.
A template algebraic expression: Body (variable_terms) + constant_term.
Propagate flat constraints from result (result bounds & context) “down”, i.e., to the arguments.
Preprocess flat constraints before adding.
Static general constraints.
Functional flat constraints.
Static algebraic constraints.
The mp namespace.
Backends using ValuePresolver should derive from here.
Separates compiling NLHandler from Converter
Separate compiling NLHandler from Converter to improve compilation speed
Include this in a separate .cc
Copyright (C) 2021 AMPL Optimization Inc
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation.
The author and AMPL Optimization Inc disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use , data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.
Author: Gleb Belov
HashStreamer can
Compute hash for a given array in 1 go;
”Accumulate” new values / arrays to an intermediate “hash state”.
Various implementations are possible, one is typedef’d as HashStreamer.
Typedefs
-
using Env = BasicSolver¶
Typedef Env to access solver options, output handler, etc.
-
typedef BasicExpr<expr::FIRST_NUMERIC, expr::LAST_NUMERIC> NumericExpr¶
A numeric expression.
-
typedef BasicExpr<expr::FIRST_LOGICAL, expr::LAST_LOGICAL> LogicalExpr¶
A logical expression.
-
typedef BasicUnaryExpr<NumericExpr, expr::FIRST_UNARY, expr::LAST_UNARY> UnaryExpr¶
A unary numeric expression.
Examples: -x, sin(x), where x is a variable.
-
typedef BasicBinaryExpr<NumericExpr, expr::FIRST_BINARY, expr::LAST_BINARY> BinaryExpr¶
A binary numeric expression.
Examples: x / y, atan2(x, y), where x and y are variables.
-
typedef BasicIfExpr<NumericExpr, expr::IF> IfExpr¶
An if-then-else expression.
Example: if x != 0 then y else z, where x, y and z are variables.
-
typedef BasicIteratedExpr<NumericExpr, expr::FIRST_ITERATED, expr::LAST_ITERATED> IteratedExpr¶
A numeric iterated expression such as min, max, sum or numberof.
Examples: min{i in I} x[i], sum{i in I} x[i], numberof 42 in ({i in I} x[i]), where I is a set and x is a variable.
-
typedef BasicIteratedExpr<Expr, expr::NUMBEROF_SYM> SymbolicNumberOfExpr¶
A symbolic numberof expression.
Example: numberof (if x then ‘a’ else ‘b’) in (‘a’, ‘b’, ‘c’), where x is a variable.
-
typedef BasicIteratedExpr<LogicalExpr, expr::COUNT> CountExpr¶
A count expression.
Example: count{i in I} (x[i] >= 0), where I is a set and x is a variable.
-
typedef BasicUnaryExpr<LogicalExpr, expr::NOT> NotExpr¶
A logical NOT expression.
Example: not a, where a is a logical expression.
-
typedef BasicBinaryExpr<LogicalExpr, expr::FIRST_BINARY_LOGICAL, expr::LAST_BINARY_LOGICAL> BinaryLogicalExpr¶
A binary logical expression.
Examples: a || b, a && b, where a and b are logical expressions.
-
typedef BasicBinaryExpr<NumericExpr, expr::FIRST_RELATIONAL, expr::LAST_RELATIONAL> RelationalExpr¶
A relational expression.
Examples: x < y, x != y, where x and y are variables.
-
typedef BasicIfExpr<LogicalExpr, expr::IMPLICATION> ImplicationExpr¶
An implication expression.
Example: a ==> b else c, where a, b and c are logical expressions.
-
typedef BasicIteratedExpr<LogicalExpr, expr::FIRST_ITERATED_LOGICAL, expr::LAST_ITERATED_LOGICAL> IteratedLogicalExpr¶
An iterated logical expression.
Example: exists{i in I} x[i] >= 0, where I is a set and x is a variable.
-
typedef BasicIteratedExpr<NumericExpr, expr::FIRST_PAIRWISE, expr::LAST_PAIRWISE> PairwiseExpr¶
A pairwise expression (alldiff or !alldiff).
Example: alldiff{i in I} x[i], where I is a set and x is a variable.
-
typedef BasicIfExpr<Expr, expr::IFSYM> SymbolicIfExpr¶
A symbolic if-then-else expression.
Example: if x != 0 then ‘a’ else 0, where x is a variable.
-
typedef BasicExprFactory<std::allocator<char>> ExprFactory¶
-
using LinConRange = AlgebraicConstraint<LinTerms, AlgConRange>¶
Linear range constraint.
-
using LinConRhs = AlgebraicConstraint<LinTerms, AlgConRhs<sens>>¶
Convenience typedef.
-
using QuadConRange = AlgebraicConstraint<QuadAndLinTerms, AlgConRange>¶
Quadratic range constraint.
-
using QuadConRhs = AlgebraicConstraint<QuadAndLinTerms, AlgConRhs<sens>>¶
Convenience typedef.
-
using QuadConLT = QuadConRhs<-2>¶
Quadratic constraint c’x+x’Qx < d.
-
using QuadConLE = QuadConRhs<-1>¶
Quadratic constraint c’x+x’Qx <= d.
-
using QuadConEQ = QuadConRhs<0>¶
Quadratic constraint c’x+x`Qx == d.
-
using QuadConGE = QuadConRhs<1>¶
Quadratic constraint c’x+x`Qx >= d.
-
using QuadConGT = QuadConRhs<2>¶
Quadratic constraint c’x+x`Qx > d.
-
using VarArray1 = std::array<int, 1>¶
Possible argument arrays for CustomFunctionalConstraint.
Fixed argument array of 1 element
-
using VarArray2 = std::array<int, 2>¶
Fixed argument array of 2 elements.
-
using VarArrayN = std::array<int, N>¶
Fixed argument array of N elements.
-
using VarArray = std::vector<int>¶
Variable-size argument array.
-
using ParamArrayN = std::array<Num, N>¶
Possible parameter arrays.
Fixed parameter array of N elements
-
using ParamArray0 = ParamArrayN<int, 0>¶
Empty parameter array.
-
using DblParamArray1 = ParamArrayN<double, 1>¶
Fixed parameter array of 1 double.
-
using DblParamArray = std::vector<double>¶
Variable-length parameter array.
-
using IndicatorConstraintLinLE = IndicatorConstraint<LinConLE>¶
Typedef indicator<LinConLE>
-
using IndicatorConstraintLinEQ = IndicatorConstraint<LinConEQ>¶
Typedef indicator<LinConEQ>
-
using IndicatorConstraintLinGE = IndicatorConstraint<LinConGE>¶
Typedef indicator<LinConGE>
-
using IndicatorConstraintQuadLE = IndicatorConstraint<QuadConLE>¶
Typedef indicator<QuadConLE>
-
using IndicatorConstraintQuadEQ = IndicatorConstraint<QuadConEQ>¶
Typedef indicator<QuadConEQ>
-
using IndicatorConstraintQuadGE = IndicatorConstraint<QuadConGE>¶
Typedef indicator<QuadConGE>
-
using SOS1Constraint = SOS_1or2_Constraint<1>¶
Typedef SOS1Constraint.
-
using SOS2Constraint = SOS_1or2_Constraint<2>¶
Typedef SOS2Constraint.
-
using ComplementarityLinear = ComplementarityConstraint<AffineExpr>¶
Typedef ComplementarityLinRange.
-
using ComplementarityQuadratic = ComplementarityConstraint<QuadraticExpr>¶
Typedef ComplementarityQuadRange.
-
using AbstractConstraintLocation = ConstraintLocationHelper<BasicConstraintKeeper>¶
Without constraint type.
-
using ConstraintMap = std::unordered_map<std::reference_wrapper<const Constraint>, int>¶
Subexpression map.
Indexes constraint location
-
using AffineExpr = AlgebraicExpression<LinTerms>¶
Typedef AffineExpr.
-
using QuadraticExpr = AlgebraicExpression<QuadAndLinTerms>¶
Typedef QuadraticExpr.
-
using PreprocessInfoStd = PreprocessInfo<int>¶
Typical preprocess info.
-
using P_ZZI_Encoding = std::shared_ptr<ZZI_Encoding>¶
Obtain an object of ZII_Encoding.
-
using ComplCvtLin_MIP = ComplementarityConverter_MIP<MC, ComplementarityLinear>¶
Typedef linear compl cvt.
-
using ComplCvtQuad_MIP = ComplementarityConverter_MIP<MC, ComplementarityQuadratic>¶
Typedef quadratic compl cvt.
-
using CondLinEQConverter_MIP = CondEQConverter_MIP<MC, LinTerms>¶
Specialize for linear constraint.
-
using CondQuadEQConverter_MIP = CondEQConverter_MIP<MC, QuadAndLinTerms>¶
Specialize for quadratic constraint.
-
using CondLinLEConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, LinConLE>¶
Specialize for linear constraint.
-
using CondQuadLEConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, QuadConLE>¶
Specialize for quadratic constraint.
-
using CondLinGEConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, LinConGE>¶
Specialize for linear constraint.
-
using CondQuadGEConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, QuadConGE>¶
Specialize for quadratic constraint.
-
using CondLinLTConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, LinConLT>¶
Specialize for linear constraint.
-
using CondQuadLTConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, QuadConLT>¶
Specialize for quadratic constraint.
-
using CondLinGTConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, LinConGT>¶
Specialize for linear constraint.
-
using CondQuadGTConverter_MIP = Cond_LE_LT_GT_GE_Converter_MIP<MC, QuadConGT>¶
Specialize for quadratic constraint.
-
using IndicatorQuadLEConverter_MIP = IndicatorQuadConverter_MIP<MC, -1>¶
Typedef IndicatorQuadLEConverter_MIP.
-
using IndicatorQuadEQConverter_MIP = IndicatorQuadConverter_MIP<MC, 0>¶
Typedef IndicatorQuadEQConverter_MIP.
-
using IndicatorQuadGEConverter_MIP = IndicatorQuadConverter_MIP<MC, 1>¶
Typedef IndicatorQuadGEConverter_MIP.
-
using FuncConConverter_MIP_Exp = FuncConConverter_MIP<MC, ExpConstraint>¶
Typedef FuncConConverter_MIP_Exp.
-
using FuncConConverter_MIP_Log = FuncConConverter_MIP<MC, LogConstraint>¶
Typedef FuncConConverter_MIP_Log.
-
using FuncConConverter_MIP_LogA = FuncConConverter_MIP<MC, LogAConstraint>¶
Typedef FuncConConverter_MIP_LogA.
-
using FuncConConverter_MIP_ExpA = FuncConConverter_MIP<MC, ExpAConstraint>¶
Typedef FuncConConverter_MIP_ExpA.
-
using FuncConConverter_MIP_Sin = FuncConConverter_MIP<MC, SinConstraint>¶
Typedef FuncConConverter_MIP_Sin.
-
using FuncConConverter_MIP_Cos = FuncConConverter_MIP<MC, CosConstraint>¶
Typedef FuncConConverter_MIP_Cos.
-
using FuncConConverter_MIP_Tan = FuncConConverter_MIP<MC, TanConstraint>¶
Typedef FuncConConverter_MIP_Tan.
-
using FuncConConverter_MIP_Asin = FuncConConverter_MIP<MC, AsinConstraint>¶
Typedef FuncConConverter_MIP_ASin.
-
using FuncConConverter_MIP_Acos = FuncConConverter_MIP<MC, AcosConstraint>¶
Typedef FuncConConverter_MIP_ACos.
-
using FuncConConverter_MIP_Atan = FuncConConverter_MIP<MC, AtanConstraint>¶
Typedef FuncConConverter_MIP_ATan.
-
using FuncConConverter_MIP_Sinh = FuncConConverter_MIP<MC, SinhConstraint>¶
Typedef FuncConConverter_MIP_Sinh.
-
using FuncConConverter_MIP_Cosh = FuncConConverter_MIP<MC, CoshConstraint>¶
Typedef FuncConConverter_MIP_Cosh.
-
using FuncConConverter_MIP_Tanh = FuncConConverter_MIP<MC, TanhConstraint>¶
Typedef FuncConConverter_MIP_Tanh.
-
using FuncConConverter_MIP_Asinh = FuncConConverter_MIP<MC, AsinhConstraint>¶
Typedef FuncConConverter_MIP_ASinh.
-
using FuncConConverter_MIP_Acosh = FuncConConverter_MIP<MC, AcoshConstraint>¶
Typedef FuncConConverter_MIP_ACosh.
-
using FuncConConverter_MIP_Atanh = FuncConConverter_MIP<MC, AtanhConstraint>¶
Typedef FuncConConverter_MIP_ATanh.
-
using MinConverter_MIP = MinOrMaxConverter_MIP<ModelConverter, -1>¶
Typedef of MinConverter.
-
using MaxConverter_MIP = MinOrMaxConverter_MIP<ModelConverter, 1>¶
Typedef of MaxConverter.
-
using MulCvtLE_MIP = QCConverter_MIP<MC, -1>¶
Typedef MulCvt<QuadConLE>
-
using MulCvtEQ_MIP = QCConverter_MIP<MC, 0>¶
Typedef MulCvt<QuadConEQ>
-
using MulCvtGE_MIP = QCConverter_MIP<MC, 1>¶
Typedef MulCvt<QuadConGE>
-
using RangeLinearConstraintConverter = RangeConstraintConverter<MC, LinTerms>¶
Typedef RangeLinearConstraintConverter.
-
using RangeQuadraticConstraintConverter = RangeConstraintConverter<MC, QuadAndLinTerms>¶
Typedef RangeQuadraticConstraintConverter.
-
using ModelMgrWithStdPB = ModelManagerWithProblemBuilder<BasicConverter<mp::Problem>>¶
-
typedef BasicProblem<> Problem¶
A BasicProblem<> with default parameters.
-
typedef bool (*InterruptHandler)(void*)¶
Interrupt handler.
Returns true if the solver was interrupted, false if it is not running.
-
using SolutionWriter = SolutionWriterImpl<Solver, typename Solver::ProblemBuilder, Writer>¶
Convenience typedef for APIs using SolverImpl<> or similar.
-
typedef BasicSuffix<int> IntSuffix¶
-
typedef BasicSuffix<double> DoubleSuffix¶
-
typedef BasicMutSuffix<int> MutIntSuffix¶
-
typedef BasicMutSuffix<double> MutDoubleSuffix¶
-
typedef BasicSuffixSet<std::allocator<char>> SuffixSet¶
Typedef SuffixSet.
-
using ModelSuffixDef = SuffixDef<T>¶
Description of a suffix that can exist for several itme types (vars, cons, objs, problem).
The kind parameter should be a bitwise OR of suf::Kind::…_BIT’s.
-
using HashStreamer = HashStreamerCombine¶
Selecting one particular implementation as HashStreamer.
Enums
-
enum IISStatus¶
.iis suffix values
Values:
-
enumerator non¶
-
enumerator low¶
-
enumerator fix¶
-
enumerator upp¶
-
enumerator mem¶
-
enumerator pmem¶
-
enumerator plow¶
-
enumerator pupp¶
-
enumerator bug¶
-
enumerator non¶
-
enum BasicStatus¶
Basic status values (suffix .sstatus)
Values:
-
enumerator none¶
-
enumerator bas¶
-
enumerator sup¶
-
enumerator low¶
-
enumerator upp¶
-
enumerator equ¶
-
enumerator btw¶
-
enumerator none¶
-
enum ConstraintAcceptanceLevel¶
Level of acceptance of a constraint by a backend.
Values:
-
enumerator NotAccepted¶
-
enumerator AcceptedButNotRecommended¶
-
enumerator Recommended¶
-
enumerator NotAccepted¶
-
enum ConstraintGroup¶
Constraint groups.
This is used to access constraint attributes (basis status, duals, …) Convenient when the solver accesses constraint attributes in groups For example, Gurobi 9.5 has linear, quadratic, SOS, and general
Values:
-
enumerator CG_Default¶
-
enumerator CG_Linear¶
-
enumerator CG_Quadratic¶
-
enumerator CG_General¶
-
enumerator CG_Piecewiselinear¶
-
enumerator CG_SOS¶
-
enumerator CG_SOS1¶
-
enumerator CG_SOS2¶
-
enumerator CG_Logical¶
-
enumerator CG_Default¶
Functions
-
template<class Vec>
inline auto data_or_null(const Vec &v) -> decltype(v.data())¶ std::vector::data() might not return nullptr when empty
-
inline int RunBackendApp(char **argv, std::function<std::unique_ptr<mp::BasicBackend>()> be_creator, BasicBackend::Callbacks callbacks = {})¶
Create and run a backend.
- Parameters
argv – command-line arguments, null-terminated vector
be_creator – backend factory
callbacks – special callbacks
- Returns
application exit value
-
template<typename DurationTo, typename Rep, typename Period>
DurationTo duration_cast(const duration<Rep, Period> &d)¶
-
double GetTimeAndReset(steady_clock::time_point &t)¶
-
template<class ProblemBuilder>
EasyModeler<ProblemBuilder> MakeEasyModeler(ProblemBuilder &bld)¶
-
inline UnsupportedError MakeUnsupportedError(fmt::CStringRef format_str, fmt::ArgList args)¶
Makes UnsupportedError with prefix “unsupported: “.
Use via macro MP_UNSUPPORTED
-
template<typename ExprType>
inline ExprType Cast(Expr e)¶ Casts an expression to type ExprType which must be a valid expression type.
Returns a null expression if e is not convertible to ExprType.
-
inline void format(fmt::BasicFormatter<char> &f, const char*&, NumericExpr e)¶
-
inline bool IsZero(NumericExpr e)¶
Returns true iff e is a zero constant.
-
bool Equal(Expr e1, Expr e2)¶
Recursively compares two expressions and returns true if they are equal.
- DEF_NUMERIC_FUNC_CONSTR (MaxConstraint, VarArray, "r = max(v1, v2, ..., vn)")
- DEF_NUMERIC_FUNC_CONSTR (MinConstraint, VarArray, "r = min(v1, v2, ..., vn)")
- DEF_NUMERIC_FUNC_CONSTR (AbsConstraint, VarArray1, "r = abs(v)")
- DEF_LOGICAL_FUNC_CONSTR (AndConstraint, VarArray, "r = forall({vi})")
- DEF_LOGICAL_FUNC_CONSTR (OrConstraint, VarArray, "r = exists({vi})")
- DEF_LOGICAL_FUNC_CONSTR (NotConstraint, VarArray1, "r = !v")
- DEF_NUMERIC_FUNC_CONSTR (DivConstraint, VarArray2, "r = v1 / v2 and v2!=0")
DivConstraint.
- DEF_NUMERIC_FUNC_CONSTR (IfThenConstraint, VarArrayN< 3 >, "Expr-valued: if (cond) then (expr1) else (expr2)")
- DEF_LOGICAL_FUNC_CONSTR (ImplicationConstraint, VarArrayN< 3 >, "Logic-valued: if (cond) then (con1) else (con2)")
- DEF_LOGICAL_FUNC_CONSTR (AllDiffConstraint, VarArray, "alldiff({})")
- DEF_NUMERIC_FUNC_CONSTR_WITH_PRM (NumberofConstConstraint, VarArray, DblParamArray1, "numberof_const(k (=x0), {x1...xn})")
- DEF_NUMERIC_FUNC_CONSTR (NumberofVarConstraint, VarArray, "numberof_var(x0, {x1...xn})")
- DEF_NUMERIC_FUNC_CONSTR (CountConstraint, VarArray, "count({x0...xn})")
- DEF_NUMERIC_FUNC_CONSTR (ExpConstraint, VarArray1, "r = exp(v)")
- DEF_NUMERIC_FUNC_CONSTR_WITH_PRM (ExpAConstraint, VarArray1, DblParamArray1, "r = a**v")
- DEF_NUMERIC_FUNC_CONSTR (LogConstraint, VarArray1, "r = log(v)")
- DEF_NUMERIC_FUNC_CONSTR_WITH_PRM (LogAConstraint, VarArray1, DblParamArray1, "r = log(v)/log(a)")
- DEF_NUMERIC_FUNC_CONSTR_WITH_PRM (PowConstraint, VarArray1, DblParamArray1, "r = v ** a")
- DEF_NUMERIC_FUNC_CONSTR (SinConstraint, VarArray1, "r = sin(v)")
- DEF_NUMERIC_FUNC_CONSTR (CosConstraint, VarArray1, "r = cos(v)")
- DEF_NUMERIC_FUNC_CONSTR (TanConstraint, VarArray1, "r = tan(v)")
- DEF_NUMERIC_FUNC_CONSTR (AsinConstraint, VarArray1, "r = asin(v)")
- DEF_NUMERIC_FUNC_CONSTR (AcosConstraint, VarArray1, "r = acos(v)")
- DEF_NUMERIC_FUNC_CONSTR (AtanConstraint, VarArray1, "r = atan(v)")
- DEF_NUMERIC_FUNC_CONSTR (SinhConstraint, VarArray1, "r = sinh(v)")
- DEF_NUMERIC_FUNC_CONSTR (CoshConstraint, VarArray1, "r = cosh(v)")
- DEF_NUMERIC_FUNC_CONSTR (TanhConstraint, VarArray1, "r = tanh(v)")
- DEF_NUMERIC_FUNC_CONSTR (AsinhConstraint, VarArray1, "r = asinh(v)")
- DEF_NUMERIC_FUNC_CONSTR (AcoshConstraint, VarArray1, "r = acosh(v)")
- DEF_NUMERIC_FUNC_CONSTR (AtanhConstraint, VarArray1, "r = atanh(v)")
-
DEF_CONDITIONAL_CONSTRAINT_WRAPPER(CondLinConLT, LinConLT)¶
Not using: var1 != var2.
Represented by Not { Eq0Constraint… }
- DEF_NUMERIC_FUNC_CONSTR_WITH_PRM (PLConstraint, VarArray1, PLConParams, "r = piecewise_linear(x)")
Define PLConstraint.
- DEF_STATIC_CONSTR_WITH_PRM (QuadraticConeConstraint, VarArray, DblParamArray, "Quadratic cone x1 >= sqrt(x2^2 + ...)) with factors " "applied to the squared arguments, aka MOSEK 10 affine cones")
Quadratic cone.
- DEF_STATIC_CONSTR_WITH_PRM (RotatedQuadraticConeConstraint, VarArray, DblParamArray, "Rotated quadratic cone x1*x2 >= sqrt(x3^2 + ...)) with factors " "applied to the squared arguments, aka MOSEK 10 affine cones")
Rotated quadratic cone.
-
template<class Args, class Params, class NumOrLogic, class Id>
inline bool operator==(std::reference_wrapper<const CustomFunctionalConstraint<Args, Params, NumOrLogic, Id>> c1, std::reference_wrapper<const CustomFunctionalConstraint<Args, Params, NumOrLogic, Id>> c2)¶ Subexpression maps for an expression require operator==(refwrap<expr>, refwrap<expr>).
The below one is for CustomFunctionalConstraint<>
-
template<class Con>
inline bool operator==(std::reference_wrapper<const ConditionalConstraint<Con>> c1, std::reference_wrapper<const ConditionalConstraint<Con>> c2)¶ operator==(refwrap<ConditionalConstraint<> >)
-
inline bool operator==(std::reference_wrapper<const LinearFunctionalConstraint> c1, std::reference_wrapper<const LinearFunctionalConstraint> c2)¶
operator==(LFC)
-
inline bool operator==(std::reference_wrapper<const QuadraticFunctionalConstraint> c1, std::reference_wrapper<const QuadraticFunctionalConstraint> c2)¶
operator==(QFC)
-
template<class Converter, class Constraint, class Converter2>
FCC<Converter, Constraint> MakeFuncConstrConverter(Converter2 &cvt, Constraint &&fc)¶
-
inline AffineExpr MoveOutAffineExpr(QuadraticExpr &&qe)¶
Extract (move out) affine expr.
-
template<class ModelAPI, template<typename, typename, typename> class FlatConverter, class Backend>
std::unique_ptr<BasicModelManager> CreateModelMgrWithFlatConverter(Backend &gc, Env &e, pre::BasicValuePresolver *&pPre)¶ A template to create a ModelManager with a FlatConverter for a specific solver.
Currently is uses mp::Problem as intermediate storage of the NL model.
- Parameters
Backend – the Backend class
ModelAPI – the ModelAPI class to be created and used by the ModelManager
FlatConverter – the FlatConverter to be used
gc – Backend object
e – the MP environment
pPre – return ValuePresolver for Backends that use it
-
std::unique_ptr<FlatModelInfo> CreateFlatModelInfo()¶
FlatModelInfo factory.
-
inline LinTerms ToLinTerms(const LinearExpr &e)¶
Convert mp::LinearExpr to LinTerms.
-
P_ZZI_Encoding MakeZZIEncoding()¶
-
std::vector<double> GetExtendedColumn(ZZI_Encoding&, int r, int k, int v0, int v1)¶
Obtain column k of the encoding matrix C^r prepended by 0 and postpended by line v1-1 if v1-1 == 2^r.
-
template<class FuncCon>
void PLApproximate(const FuncCon &con, PLApproxParams &laPrm)¶ Do the approximation by calling the function-specific approximator.
- Parameters
laPrm – in-out parameter
-
std::pair<const char*, const char*> GetWarningKeyAndText(const char *conName, double tol)¶
A function to add warning about PL approximation.
-
std::unique_ptr<BasicModelManager> CreateModelManagerWithStdBuilder(std::unique_ptr<BasicConverter<mp::Problem>> pcvt)¶
Declare a ModelManager factory.
-
template<typename Handler>
void ReadNLString(NLStringRef str, Handler &handler, fmt::CStringRef name ="(input)", int flags = 0)¶ Reads an optimization problem in the NL format from the string str and sends notifications of the problem components to the handler object. See
mp::ReadNLFile()
for description of handler and flags. Both str and name can be C strings orstd::string
objects. The name argument is used as the name of the input when reporting errors.
-
template<typename Handler>
inline void ReadNLFile(fmt::CStringRef filename, Handler &handler, int flags = 0)¶ Reads an optimization problem in the NL format from the file filename and sends notifications of the problem components to the handler object. The handler class can be one of the following
derived from
mp::NLHandler
ormp::NullNLHandler
,provide an interface compatible with one of the above.
The filename argument can be a C string or an
std::string
object. flags can be either 0, which is the default, to read all constructs in the order they appear in the input, ormp::READ_BOUNDS_FIRST
to read variable bounds after the NL header and before other constructs such as nonlinear expressions.Example:
// Count the number of variable references in all nonlinear expressions. struct VarCounter : mp::NullNLHandler<int> { int num_vars; VarCounter() : num_vars(0) {} Reference OnVariableRef(int) { ++num_vars; return Reference(); } }; VarCounter counter; mp::ReadNLFile("test.nl", counter); fmt::print("The number of variable references is {}.", counter.num_vars);
-
char ParseOptions(char **&args, OptionList &options)¶
Parses command-line options until the first argument that doesn’t start with ‘-’.
Returns the option that terminated parsing or 0 if parsing continued till the end.
-
template<typename Solution>
void WriteSolFile(fmt::CStringRef filename, const Solution &sol)¶ Writes a solution to a .sol file.
-
template<typename SuffixType>
inline SuffixType Cast(Suffix s)¶ “inline” is used here instead of the definition to suppress bogus C4396 warnings in MSVC.
Casts a suffix to type SuffixType which must be a valid suffix type.
Returns a null suffix if s is not convertible to SuffixType.
-
template<typename SuffixType>
inline SuffixType Cast(MutSuffix s)¶
-
std::unique_ptr<BasicFileAppender> MakeFileAppender()¶
FileAppender maker.
-
std::vector<std::string> split_string(const char*)¶
Variables
-
static const mp::OptionValueInfo values_item_acceptance[] = {{
"0","Not accepted natively, automatic redefinition will be attempted", 0}, {"1","Accepted but automatic redefinition will be used where possible", 1}, {"2","Accepted natively and preferred", 2}}¶
-
template<class ModelConverter>
class AbsConverter_MIP : public mp::BasicFuncConstrCvt<AbsConverter_MIP<ModelConverter>, ModelConverter>¶ - #include <abs.h>
Converts abs for MIP.
Public Types
-
using Base = BasicFuncConstrCvt<AbsConverter_MIP<ModelConverter>, ModelConverter>¶
Base class.
-
using ItemType = AbsConstraint¶
Converted item type.
Public Functions
-
inline AbsConverter_MIP(ModelConverter &mc)¶
Constructor.
-
inline void Convert(const ItemType &item, int i)¶
Generic Convert(), distinguishes context & result variable.
Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.
Responsible for adding presolve links, if any
The Impl can reimplement this
- Parameters
item – the item to be converted
i – item index, used to create a presolve link
-
inline void ConvertCtxNeg(const ItemType &item, int)
Convert in negative context.
-
inline void ConvertCtxPos(const ItemType &item, int)
Convert in positive context.
-
template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)¶ Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.
Example: PowConstraint(x, …) with lb(x)<0. Default: false.
-
inline const ModelConverter &GetMC() const¶
Access const ModelConverter.
-
inline ModelConverter &GetMC()¶
Access ModelConverter.
-
using Base = BasicFuncConstrCvt<AbsConverter_MIP<ModelConverter>, ModelConverter>¶
-
class AlgConRange¶
- #include <constr_algebraic.h>
Algebraic constraint range (template parameter)
Public Functions
-
inline AlgConRange(double l, double u)¶
Constructor.
-
inline void negate()¶
negate
-
inline bool equals(const AlgConRange &r) const¶
operator==
Public Static Functions
-
static inline constexpr const char *GetTypeName()¶
Class name.
-
inline AlgConRange(double l, double u)¶
-
template<int kind_>
class AlgConRhs¶ - #include <constr_algebraic.h>
Algebraic constraint right-hand side (template parameter).
Kind: -2/-1/0/1 for <= / == / >=
-
template<class Body, class RhsOrRange>
class AlgebraicConstraint : public mp::BasicConstraint, public Body, public RhsOrRange¶ - #include <constr_algebraic.h>
Generic algebraic constraint.
- Parameters
Body – linear or linear and higher-order terms
RhsOrRange – rhs or range
Public Functions
-
inline AlgebraicConstraint(Body le, RhsOrRange rr, bool fSort = true)¶
Constructor.
By default (fSort = true), it sorts terms. Pass fSort = false to skip if you complement the terms list but do sorting later.
- Parameters
le – linear / linear + higher-order terms
rr – rhs or range
-
inline RhsOrRange GetRhsOrRange() const¶
Range or RHS. Used for hash<>
-
inline bool empty() const¶
If no variable terms in the body.
-
inline void sort_terms()¶
Sorting and merging terms, some solvers require.
-
inline void negate()¶
Negate.
-
inline bool operator==(const AlgebraicConstraint &lc) const¶
Testing API.
-
inline const char *GetName() const¶
Constraint name.
-
inline const char *name() const¶
Constraint name.
-
inline void SetName(std::string nm)¶
Set constraint name.
-
inline int GetResultVar() const¶
For functional constraints, result variable index.
-
template<class Body>
class AlgebraicExpression : public Body¶ - #include <expr_algebraic.h>
A template algebraic expression: Body (variable_terms) + constant_term.
Public Types
-
using Constant = ConstructorHelper<double>¶
Helper “constant type”.
-
using Variable = ConstructorHelper<int>¶
Helper “variable type”.
Public Functions
-
AlgebraicExpression() = default¶
Default constructor.
-
inline bool is_constant() const¶
Whether AlgebraicExpression represents a constant.
-
inline bool is_variable() const¶
true when constant=0 and 1 variable with coef 1.0
-
inline bool is_affine() const¶
if affine
-
inline const Body &GetAlgConBody() const¶
Get the body (variable terms) of a corresponding algebraic constraint.
-
inline double constant_term() const¶
The constant term.
-
inline void constant_term(double v)¶
Set constant term.
-
inline void add_to_constant(double a)¶
Add to constant.
-
inline void negate()¶
Negate the ae.
-
inline void add(const AlgebraicExpression &ae)¶
Add another ae.
-
inline void subtract(AlgebraicExpression ae)¶
Subtract another ae.
-
inline void operator*=(double n)¶
Multiply by const.
-
inline bool operator==(const AlgebraicExpression &ae) const¶
operator==
Public Static Functions
-
static inline std::string GetTypeName()¶
Name.
-
template<class Value>
struct ConstructorHelper¶ - #include <expr_algebraic.h>
Helper to construct AlgebraicExpression to represent something special.
- Parameters
Value – stored value type
-
using Constant = ConstructorHelper<double>¶
-
template<class ModelConverter>
class AllDiffConverter_MIP : public mp::BasicFuncConstrCvt<AllDiffConverter_MIP<ModelConverter>, ModelConverter>¶ - #include <alldiff.h>
Converts alldiff for MIP.
Public Types
-
using Base = BasicFuncConstrCvt<AllDiffConverter_MIP<ModelConverter>, ModelConverter>¶
Base class.
-
using ItemType = AllDiffConstraint¶
Converted item type.
Public Functions
-
inline AllDiffConverter_MIP(ModelConverter &mc)¶
Constructor.
-
inline void Convert(const ItemType &item, int i)¶
Generic Convert(), distinguishes context & result variable.
Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.
Responsible for adding presolve links, if any
The Impl can reimplement this
- Parameters
item – the item to be converted
i – item index, used to create a presolve link
-
inline void ConvertCtxPos(const ItemType &item, int)
Convert in positive context.
-
template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)¶ Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.
Example: PowConstraint(x, …) with lb(x)<0. Default: false.
-
inline const ModelConverter &GetMC() const¶
Access const ModelConverter.
-
inline ModelConverter &GetMC()¶
Access ModelConverter.
-
using Base = BasicFuncConstrCvt<AllDiffConverter_MIP<ModelConverter>, ModelConverter>¶
-
template<class ModelConverter>
class AndConverter_MIP : public mp::BasicFuncConstrCvt<AndConverter_MIP<ModelConverter>, ModelConverter>¶ - #include <logical_and.h>
Converts And/Forall for MIP.
Public Types
-
using Base = BasicFuncConstrCvt<AndConverter_MIP<ModelConverter>, ModelConverter>¶
Base class.
-
using ItemType = AndConstraint¶
Converted item type.
Public Functions
-
inline AndConverter_MIP(ModelConverter &mc)¶
Constructor.
-
inline void Convert(const ItemType &item, int i)¶
Generic Convert(), distinguishes context & result variable.
Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.
Responsible for adding presolve links, if any
The Impl can reimplement this
- Parameters
item – the item to be converted
i – item index, used to create a presolve link
-
inline void ConvertCtxNeg(const ItemType &item, int)
Convert in negative context.
-
inline void ConvertCtxPos(const ItemType &item, int)
Convert in positive context.
-
template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)¶ Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.
Example: PowConstraint(x, …) with lb(x)<0. Default: false.
-
inline const ModelConverter &GetMC() const¶
Access const ModelConverter.
-
inline ModelConverter &GetMC()¶
Access ModelConverter.
-
using Base = BasicFuncConstrCvt<AndConverter_MIP<ModelConverter>, ModelConverter>¶
-
template<typename T>
class ArrayRef¶ - #include <arrayref.h>
A reference to an immutable array which can be stored inside if ArrayRef<> is constructed from an rvalue std::vector.
Public Functions
-
template<class CommonInfo>
class Backend2ModelAPIConnector : public CommonInfo¶ - #include <backend-to-model-api.h>
A wrapper for CommonInfo providing some functionality to connect Backend to ModelAPI.
- Parameters
CommonInfo – common information (e.g., env/model handlers) stored in both Backend and ModelAPI
Public Functions
-
inline void set_other(CommonInfo *other)¶
Set the other object.
This is standardly called from CreateModelManagerWithModelAPI()
-
inline void copy_common_info_to_other()¶
Copy into the other object.
Typically after initializing solver env/model
-
class BackendApp¶
- #include <backend-app.h>
Backend app.
Reads command-line parameters like -AMPL and NL filename, installs handlers for screen output and signals, and calls backend class
Public Functions
-
virtual int Run(char **argv)¶
Runs the application.
It processes command-line arguments and, if the file name (stub) is specified, calls NLSolver class.
- Parameters
argv – an array of command-line arguments terminated by a null pointer
- Returns
app exit code
-
inline int GetResultCode() const¶
Get result code.
-
inline const BasicBackend &GetBackend() const¶
Get backend, const.
-
inline BasicBackend &GetBackend()¶
Get backend.
-
virtual int Run(char **argv)¶
-
class BackendWithModelManager : public mp::BasicBackend¶
- #include <backend-with-mm.h>
Backends using a separate Model Manager could derive from this.
Subclassed by mp::StdBackend< Impl >
Public Types
-
using Callbacks = CCallbacks¶
Callbacks typedef.
-
enum [anonymous]¶
Possible values for the wantsol option (can be combined with bitwise OR).
Values:
-
enumerator WRITE_SOL_FILE¶
-
enumerator PRINT_SOLUTION¶
-
enumerator PRINT_DUAL_SOLUTION¶
-
enumerator SUPPRESS_SOLVER_MSG¶
-
enumerator WRITE_SOL_FILE¶
-
enum [anonymous]¶
The default precision used in FormatObjValue if the objective_precision env variable is not specified or 0.
Values:
-
enumerator DEFAULT_PRECISION¶
-
enumerator DEFAULT_PRECISION¶
-
enum [anonymous]¶
Solver flags.
Values:
-
using WarningsMap = std::map<std::string, std::pair<int, std::string>>¶
Map to count warnings by types.
Stores char* to names / descriptions for speed Indexed by pointers to names, not values
-
enum [anonymous]¶
Flags for ParseOptions.
Values:
-
enumerator NO_OPTION_ECHO¶
Don’t echo options during parsing.
-
enumerator FROM_COMMAND_LINE¶
When options are passed from command line (not via environment var) the quotes are automatically removed and the input string split in substrings (accessible via argv)
-
enumerator NO_OPTION_ECHO¶
-
typedef std::unique_ptr<SolverOption> OptionPtr¶
Smart ptr to an option.
-
using set_option_iterator = option_iterator_base<OptionSet::iterator>¶
Alias for writeable option iterator.
-
using option_iterator = option_iterator_base<OptionSet::const_iterator>¶
Alias for const option iterator.
Public Functions
-
inline virtual void Init(char **argv) override¶
Initialize backend, incl.
solver options
- Parameters
argv – the command-line arguments, NULL-terminated
-
inline virtual bool ParseSolverOptions(const char *filename_no_ext, char **argv, unsigned flags = 0)¶
Parse solver options such as “outlev=1” from env and argv.
- Parameters
filename_no_ext – basname of the .nl file (or whatever should be the basename of an output .sol file)
argv – (remaining part of) vector of cmdline strings
flags – 0 or Solver::NO_OPTION_ECHO
-
virtual void RunFromNLFile(const std::string &nl_filename, const std::string &filename_no_ext) = 0¶
Runs Solver given the NL file name.
-
virtual void ReadNL(const std::string &nl_filename, const std::string &filename_no_ext) = 0¶
Detailed steps for AMPLS C API.
Read NL. This is used by the AMPLS C API
-
virtual void InputExtras() = 0¶
Input warm start, suffixes, and all that can modify the model.
This is used by the AMPLS C API
-
virtual void ReportResults() = 0¶
Report results.
This is used by the AMPLS C API
-
inline virtual void InitOptionParsing()¶
Chance for the Backend to init solver environment, etc.
-
inline virtual void FinishOptionParsing()¶
Chance to consider options immediately (open cloud, etc)
-
inline std::string GetOptionFile(const SolverOption&) const¶
Name of the file with option settings, provided by tech:optionfile.
-
void UseOptionFile(const SolverOption&, fmt::StringRef value)¶
Read otpions from option file.
-
inline int GetWantSol(const SolverOption&) const¶
wantsol value
-
inline void SetWantSol(const SolverOption&, int value)¶
set wantsol
-
inline std::string GetSolutionStub(const SolverOption&) const¶
solution output filename stub
-
inline void SetSolutionStub(const SolverOption&, fmt::StringRef value)¶
Set sol stub.
-
inline int GetObjNo(const SolverOption&) const¶
Obj number.
-
inline void SetObjNo(const SolverOption &opt, int value)¶
Set obj number.
-
inline const char *name() const¶
Returns the solver name.
This is used to extract solver options from the env variable (solver_name)_options.
-
inline const char *long_name() const¶
Returns the long solver name.
This name is used in startup “banner”.
-
inline const char *exe_path() const¶
Returns the executable path.
-
inline const char *version() const¶
Returns the solver version.
-
inline long date() const¶
Returns the solver date in YYYYMMDD format.
-
inline int wantsol() const¶
Returns the value of the wantsol option which specifies what solution information to write in a stand-alone invocation (no -AMPL on the command line).
-
inline bool verbose_mode() const¶
True if verbose mode.
Should be set by the implementation, otherwise it’s true
-
inline void set_verbose_mode(bool f)¶
Set verbosity, by the impl.
-
inline bool debug_mode() const¶
True if need to debug.
Outputs test infos etc
-
inline int objno_used() const¶
Returns the index of the objective to optimize starting from 1, 0 to not use objective.
-
inline int objno_specified() const¶
Both multiobj() and objno_specified() are used in NLReader to select the objective(s), solvers should not use these accessors.
-
inline bool is_objno_specified() const¶
Whether user specified the option objno.
-
inline bool multiobj() const¶
Returns true if multiobjective optimization is enabled.
Both multiobj and objno are used in NLReader to select the objective(s), solvers should not use these options.
-
inline bool timing() const¶
Returns true if the timing is enabled.
-
inline ErrorHandler *error_handler()¶
Return error handler.
-
inline void set_error_handler(ErrorHandler *eh)¶
Set the error handler.
-
inline OutputHandler *output_handler()¶
Return output handler.
-
inline OutputHandler &get_output_handler()¶
Return output handler.
-
inline void set_output_handler(OutputHandler *oh)¶
Sets the output handler.
-
inline const Interrupter *interrupter() const¶
Interrupter, const.
-
inline Interrupter *interrupter()¶
-
inline void set_interrupter(Interrupter *interrupter)¶
Set interrupter.
-
inline const char *solution_stub() const¶
Sol stub as char*.
-
inline bool need_multiple_solutions() const¶
Need mutiple solutions.
-
inline virtual void HandleOutput(fmt::CStringRef output) override¶
Override methods from base service classes.
-
inline virtual void HandleError(fmt::CStringRef message) override¶
Handle error.
-
inline virtual bool Stop() const override¶
The default implementation of Interrupter does nothing.
-
inline virtual void SetHandler(InterruptHandler, void*) override¶
Set interrupt handler.
-
inline virtual void HandleUnknownOption(const char *name)¶
Handle unknown option.
-
inline void ReportError(fmt::CStringRef format, const fmt::ArgList &args)¶
Reports an error printing the formatted error message to stderr.
Usage: ReportError(“File not found: {}”) << filename;
-
inline void Print(fmt::CStringRef format, const fmt::ArgList &args)¶
Variadic overload of ReportError()
Formats a string and prints it to stdout or, if an output handler is registered, sends it to the output handler.
-
void AddWarning(std::string key, std::string msg)¶
Variadic overload of Print()
Add a warning.
- Parameters
key – warning category
msg – detailed message
-
void PrintWarnings()¶
Print warnings.
-
bool ShowVersion()¶
Prints version information.
-
DoubleFormatter FormatObjValue(double value)¶
Returns a formatter that writes value using objective precision.
Usage: Print(“objective {}”, FormatObjValue(obj_value));
-
virtual bool ParseOptions(char **argv, unsigned flags = 0, const ASLProblem *p = 0)¶
Parses solver options from the (solver)_options env variable and/or strings in argv.
For example, solver_options=’timelim=300’ solver /tmp/diet.nl -AMPL “basis=0”.
- Returns
true if there were no errors and false otherwise. It accepts a pointer to the problem because some options may depend on problem features.
-
void ParseOptionString(const char *s, unsigned flags)¶
Parses a solver option string.
-
inline WarningsMap &GetWarnings()¶
Get warnings map.
-
inline void SetConstraintListHeader(std::string clh)¶
Set constraint list header (printed at the start of -c)
-
inline void AddConstraintDescr(std::string cn, std::string cdescr)¶
Add constraint type description.
-
bool ShowConstraintDescriptions()¶
Show constraint descriptions.
-
inline int num_options() const¶
Returns the number of options.
-
inline SolverOption *GetOption(const char *name) const¶
Returns the option with specified name.
-
inline void set_option_header(const char *header)¶
Sets a text to be displayed before option descriptions.
-
inline void add_to_option_header(const char *header_more)¶
Add more text to be displayed before option descriptions.
-
template<class Value>
inline void AddOption(const char *name, const char *description, Value &value, Value lb, Value ub)¶ Same: stored option referencing a variable; min, max values.
-
SolverOption *FindOption(const char *name, bool wildcardvalues = false) const¶
Finds an option and returns a pointer to it if found or null otherwise.
If wildcardvalues==true, wildcarded options should have values (i.e., parsing real input)
-
inline const char *option_header() const¶
Returns the option header.
-
inline fmt::LongLong GetIntOption(const char *name) const¶
Returns the value of an integer option.
Throws OptionError if there is no such option or it has a different type.
-
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())¶ Simple stored option referencing a variable.
-
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, Value, Value)¶ Simple stored option referencing a variable; min, max values (currently unused)
-
void AddOptionSynonyms_Inline_Front(const char *names_list, const char *realName)¶
Add “inline” option synonyms The _Front version puts them in the front of the synonyms list and the 1st of them is used in the -a output for sorting.
-
void AddOptionSynonyms_OutOfLine(const char *name, const char *realName)¶
Add an “out-of-line” synonym Creates extra entry under -=.
-
inline option_iterator option_begin() const¶
Get the start const-iterator.
-
inline option_iterator option_end() const¶
Get the end const-iterator.
-
inline set_option_iterator set_option_begin() const¶
Get the start writeable iterator.
-
inline set_option_iterator set_option_end() const¶
Get the end writeable iterator.
Public Static Functions
-
static std::string ToString(const WarningsMap::value_type &wrn)¶
Stringify a WarningsMap entry.
-
using Callbacks = CCallbacks¶
-
class BackendWithValuePresolver : public mp::BasicValuePresolverKeeper¶
Subclassed by mp::FlatBackend< BaseBackend >
-
class BasicBackend : public mp::BasicSolver¶
- #include <backend-base.h>
Abstract backend API.
Subclassed by mp::BackendWithModelManager
Public Types
-
using Callbacks = CCallbacks¶
Callbacks typedef.
-
enum [anonymous]¶
Possible values for the wantsol option (can be combined with bitwise OR).
Values:
-
enumerator WRITE_SOL_FILE¶
-
enumerator PRINT_SOLUTION¶
-
enumerator PRINT_DUAL_SOLUTION¶
-
enumerator SUPPRESS_SOLVER_MSG¶
-
enumerator WRITE_SOL_FILE¶
-
enum [anonymous]¶
The default precision used in FormatObjValue if the objective_precision env variable is not specified or 0.
Values:
-
enumerator DEFAULT_PRECISION¶
-
enumerator DEFAULT_PRECISION¶
-
enum [anonymous]¶
Solver flags.
Values:
-
using WarningsMap = std::map<std::string, std::pair<int, std::string>>¶
Map to count warnings by types.
Stores char* to names / descriptions for speed Indexed by pointers to names, not values
-
enum [anonymous]¶
Flags for ParseOptions.
Values:
-
enumerator NO_OPTION_ECHO¶
Don’t echo options during parsing.
-
enumerator FROM_COMMAND_LINE¶
When options are passed from command line (not via environment var) the quotes are automatically removed and the input string split in substrings (accessible via argv)
-
enumerator NO_OPTION_ECHO¶
-
typedef std::unique_ptr<SolverOption> OptionPtr¶
Smart ptr to an option.
-
using set_option_iterator = option_iterator_base<OptionSet::iterator>¶
Alias for writeable option iterator.
-
using option_iterator = option_iterator_base<OptionSet::const_iterator>¶
Alias for const option iterator.
Public Functions
-
virtual ~BasicBackend() = default¶
Virtual destructor.
-
inline virtual void Init(char **argv)¶
Initialize backend, incl.
solver options. Not parse options yet, as we need to parse cmdline arguments first.
- Parameters
argv – the command-line arguments, 0-terminated
-
inline virtual bool ParseSolverOptions(const char *filename_no_ext, char **argv, unsigned flags = 0)¶
Parse solver options such as “outlev=1” from env and argv.
- Parameters
filename_no_ext – basname of the .nl file (or whatever should be the basename of an output .sol file)
argv – (remaining part of) vector of cmdline strings
flags – 0 or Solver::NO_OPTION_ECHO
-
virtual void RunFromNLFile(const std::string &nl_filename, const std::string &filename_no_ext) = 0¶
Runs Solver given the NL file name.
-
virtual void ReadNL(const std::string &nl_filename, const std::string &filename_no_ext) = 0¶
Detailed steps for AMPLS C API.
Read NL. This is used by the AMPLS C API
-
virtual void InputExtras() = 0¶
Input warm start, suffixes, and all that can modify the model.
This is used by the AMPLS C API
-
virtual void ReportResults() = 0¶
Report results.
This is used by the AMPLS C API
-
inline virtual void SetBasename(const std::string&)¶
Chance for the Backend to note base IO filename.
-
inline virtual void InitOptionParsing()¶
Chance for the Backend to init solver environment, etc.
-
inline virtual void FinishOptionParsing()¶
Chance to consider options immediately (open cloud, etc)
-
inline std::string GetOptionFile(const SolverOption&) const¶
Name of the file with option settings, provided by tech:optionfile.
-
void UseOptionFile(const SolverOption&, fmt::StringRef value)¶
Read otpions from option file.
-
inline int GetWantSol(const SolverOption&) const¶
wantsol value
-
inline void SetWantSol(const SolverOption&, int value)¶
set wantsol
-
inline std::string GetSolutionStub(const SolverOption&) const¶
solution output filename stub
-
inline void SetSolutionStub(const SolverOption&, fmt::StringRef value)¶
Set sol stub.
-
inline int GetObjNo(const SolverOption&) const¶
Obj number.
-
inline void SetObjNo(const SolverOption &opt, int value)¶
Set obj number.
-
inline const char *name() const¶
Returns the solver name.
This is used to extract solver options from the env variable (solver_name)_options.
-
inline const char *long_name() const¶
Returns the long solver name.
This name is used in startup “banner”.
-
inline const char *exe_path() const¶
Returns the executable path.
-
inline const char *version() const¶
Returns the solver version.
-
inline long date() const¶
Returns the solver date in YYYYMMDD format.
-
inline int wantsol() const¶
Returns the value of the wantsol option which specifies what solution information to write in a stand-alone invocation (no -AMPL on the command line).
-
inline bool verbose_mode() const¶
True if verbose mode.
Should be set by the implementation, otherwise it’s true
-
inline void set_verbose_mode(bool f)¶
Set verbosity, by the impl.
-
inline bool debug_mode() const¶
True if need to debug.
Outputs test infos etc
-
inline int objno_used() const¶
Returns the index of the objective to optimize starting from 1, 0 to not use objective.
-
inline int objno_specified() const¶
Both multiobj() and objno_specified() are used in NLReader to select the objective(s), solvers should not use these accessors.
-
inline bool is_objno_specified() const¶
Whether user specified the option objno.
-
inline bool multiobj() const¶
Returns true if multiobjective optimization is enabled.
Both multiobj and objno are used in NLReader to select the objective(s), solvers should not use these options.
-
inline bool timing() const¶
Returns true if the timing is enabled.
-
inline ErrorHandler *error_handler()¶
Return error handler.
-
inline void set_error_handler(ErrorHandler *eh)¶
Set the error handler.
-
inline OutputHandler *output_handler()¶
Return output handler.
-
inline OutputHandler &get_output_handler()¶
Return output handler.
-
inline void set_output_handler(OutputHandler *oh)¶
Sets the output handler.
-
inline const Interrupter *interrupter() const¶
Interrupter, const.
-
inline Interrupter *interrupter()¶
-
inline void set_interrupter(Interrupter *interrupter)¶
Set interrupter.
-
inline const char *solution_stub() const¶
Sol stub as char*.
-
inline bool need_multiple_solutions() const¶
Need mutiple solutions.
-
inline virtual void HandleOutput(fmt::CStringRef output) override¶
Override methods from base service classes.
-
inline virtual void HandleError(fmt::CStringRef message) override¶
Handle error.
-
inline virtual bool Stop() const override¶
The default implementation of Interrupter does nothing.
-
inline virtual void SetHandler(InterruptHandler, void*) override¶
Set interrupt handler.
-
inline virtual void HandleUnknownOption(const char *name)¶
Handle unknown option.
-
inline void ReportError(fmt::CStringRef format, const fmt::ArgList &args)¶
Reports an error printing the formatted error message to stderr.
Usage: ReportError(“File not found: {}”) << filename;
-
inline void Print(fmt::CStringRef format, const fmt::ArgList &args)¶
Variadic overload of ReportError()
Formats a string and prints it to stdout or, if an output handler is registered, sends it to the output handler.
-
void AddWarning(std::string key, std::string msg)¶
Variadic overload of Print()
Add a warning.
- Parameters
key – warning category
msg – detailed message
-
void PrintWarnings()¶
Print warnings.
-
bool ShowVersion()¶
Prints version information.
-
DoubleFormatter FormatObjValue(double value)¶
Returns a formatter that writes value using objective precision.
Usage: Print(“objective {}”, FormatObjValue(obj_value));
-
virtual bool ParseOptions(char **argv, unsigned flags = 0, const ASLProblem *p = 0)¶
Parses solver options from the (solver)_options env variable and/or strings in argv.
For example, solver_options=’timelim=300’ solver /tmp/diet.nl -AMPL “basis=0”.
- Returns
true if there were no errors and false otherwise. It accepts a pointer to the problem because some options may depend on problem features.
-
void ParseOptionString(const char *s, unsigned flags)¶
Parses a solver option string.
-
inline WarningsMap &GetWarnings()¶
Get warnings map.
-
inline void SetConstraintListHeader(std::string clh)¶
Set constraint list header (printed at the start of -c)
-
inline void AddConstraintDescr(std::string cn, std::string cdescr)¶
Add constraint type description.
-
bool ShowConstraintDescriptions()¶
Show constraint descriptions.
-
inline int num_options() const¶
Returns the number of options.
-
inline SolverOption *GetOption(const char *name) const¶
Returns the option with specified name.
-
inline void set_option_header(const char *header)¶
Sets a text to be displayed before option descriptions.
-
inline void add_to_option_header(const char *header_more)¶
Add more text to be displayed before option descriptions.
-
template<class Value>
inline void AddOption(const char *name, const char *description, Value &value, Value lb, Value ub)¶ Same: stored option referencing a variable; min, max values.
-
SolverOption *FindOption(const char *name, bool wildcardvalues = false) const¶
Finds an option and returns a pointer to it if found or null otherwise.
If wildcardvalues==true, wildcarded options should have values (i.e., parsing real input)
-
inline const char *option_header() const¶
Returns the option header.
-
inline fmt::LongLong GetIntOption(const char *name) const¶
Returns the value of an integer option.
Throws OptionError if there is no such option or it has a different type.
-
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())¶ Simple stored option referencing a variable.
-
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, Value, Value)¶ Simple stored option referencing a variable; min, max values (currently unused)
-
void AddOptionSynonyms_Inline_Front(const char *names_list, const char *realName)¶
Add “inline” option synonyms The _Front version puts them in the front of the synonyms list and the 1st of them is used in the -a output for sorting.
-
void AddOptionSynonyms_OutOfLine(const char *name, const char *realName)¶
Add an “out-of-line” synonym Creates extra entry under -=.
-
inline option_iterator option_begin() const¶
Get the start const-iterator.
-
inline option_iterator option_end() const¶
Get the end const-iterator.
-
inline set_option_iterator set_option_begin() const¶
Get the start writeable iterator.
-
inline set_option_iterator set_option_end() const¶
Get the end writeable iterator.
Public Static Functions
-
static std::string ToString(const WarningsMap::value_type &wrn)¶
Stringify a WarningsMap entry.
-
using Callbacks = CCallbacks¶
-
template<typename Arg, expr::Kind FIRST, expr::Kind LAST = FIRST>
class BasicBinaryExpr : public mp::BasicExpr<FIRST, LAST>¶ - #include <expr.h>
A binary expression.
Base: base expression class. Arg: argument expression class.
-
class BasicConstraint¶
- #include <constr_base.h>
Custom constraints to derive from, so that overloaded default settings work.
Subclassed by mp::AlgebraicConstraint< Body, RhsOrRange >, mp::ComplementarityConstraint< Expr >, mp::FunctionalConstraint, mp::IndicatorConstraint< Con >, mp::SOS_1or2_Constraint< type >
-
class BasicConstraintKeeper¶
- #include <constr_keeper.h>
Interface for an array of constraints of certain type.
Subclassed by mp::ConstraintKeeper< Converter, Backend, Constraint >
Public Types
-
using ConstraintType = BasicConstraint¶
Constraint type.
Public Functions
-
inline virtual ~BasicConstraintKeeper()¶
Destructor.
-
inline BasicConstraintKeeper(pre::BasicValuePresolver &pres, const char *nm, const char *optN)¶
Constructor.
-
virtual const std::string &GetDescription() const = 0¶
Constraint keeper description.
-
virtual void PropagateResult(BasicFlatConverter &cvt, int i, double lb, double ub, Context ctx) = 0¶
Propagate expression result of constraint i top-down.
-
virtual int GetResultVar(int i) const = 0¶
Result variable of constraint i. Returns -1 if none.
-
virtual bool ConvertAllNewWith(BasicFlatConverter &cvt) = 0¶
Convert all new items of this constraint.
This normally dispatches conversion (decomposition) to the Converter
- Returns
whether any converted
-
inline virtual ConstraintAcceptanceLevel GetChosenAcceptanceLevel() const¶
Query (user-chosen, if sensible) constraint acceptance level.
-
virtual bool IfConverterConverts(BasicFlatConverter &cvt) const = 0¶
Converter’s ability to convert the constraint type.
-
virtual ConstraintAcceptanceLevel GetModelAPIAcceptance(const BasicFlatModelAPI&) const = 0¶
ModelAPI’s acceptance level for the constraint type.
This should not be used directly, instead: GetChosenAcceptanceLevel()
-
virtual const std::type_info &GetTypeInfo() const = 0¶
Constraint type_info.
-
virtual int GetConstraintGroup(const BasicFlatModelAPI&) const = 0¶
Backend’s group number for the constraint type.
-
virtual int GetNumberOfAddable() const = 0¶
Report how many will be added to Backend.
-
virtual void AddUnbridgedToBackend(BasicFlatModelAPI &be) = 0¶
This adds all unbridged items to the backend (without conversion)
-
inline pre::NodeRange SelectValueNodeRange(int pos, int n = 1)¶
Create ValueNode range pointer: select n elements at certain pos.
-
inline const char *GetConstraintName() const¶
Constraint name.
-
inline virtual const char *GetAcceptanceOptionNames() const¶
Acceptance option names.
-
inline virtual void ConsiderAcceptanceOptions(BasicFlatConverter &cvt, const BasicFlatModelAPI &ma, Env &env)¶
See what options are available for this constraint: whether it is accepted natively by ModelAPI and/or can be converted by the Converter.
If both, add constraint acceptance option. This should be called before using the class.
-
inline virtual void SetChosenAcceptanceLevel(ConstraintAcceptanceLevel acc)¶
Set user preferred acceptance level.
-
using ConstraintType = BasicConstraint¶
-
template<class Model>
class BasicConverter : public mp::EnvKeeper¶ - #include <converter-base.h>
BasicConverter<> is an interface for a class that takes a Model and translates it into the solver API.
Model can be a ProblemBuilder used by NLHandler for NL input, as done by ModelManagerWithProblemBuilder.
Public Types
-
using ModelType = Model¶
The ProblemBuilder a.k.a. Model type.
-
using ModelType = Model¶
-
template<expr::Kind FIRST, expr::Kind LAST = FIRST>
class BasicExpr : private mp::internal::ExprBase¶ - #include <expr.h>
namespace internal
An expression. A BasicExpr object represents a reference to an expression so it is cheap to construct and pass by value. A type safe way to process expressions of different types is by using ExprVisitor. Although this class is not intended for use in the client code, it is not placed in the internal namespace to enable argument- dependent lookup.
Subclassed by mp::BasicBinaryExpr< Arg, FIRST, LAST >, mp::BasicIteratedExpr< ArgType, FIRST, LAST >, mp::BasicUnaryExpr< Arg, FIRST, LAST >
Public Functions
-
inline BasicExpr()¶
Constructs a BasicExpr object representing a null reference to an expression.
The only operation permitted for such object is copying, assignment and check whether it is null using operator SafeBool.
- template<typename Expr> inline BasicExpr (Expr other, typename fmt::internal::EnableIf< static_cast< expr::Kind >(Expr::FIRST_KIND) >=FIRST &&static_cast< expr::Kind >(Expr::LAST_KIND)<=LAST, int >::type=0)
Construct from another expression.
-
inline BasicExpr()¶
-
template<typename Alloc>
class BasicExprFactory : private Alloc¶ - #include <expr.h>
namespace internal
An expression factory. Alloc: a memory allocator. Allocator requirements:
The allocate function should return a pointer suitably aligned to hold an object of any fundamental alignment like operator new(std::size_t) does.
The deallocate function should be able to handle 0 passed as the second argument.
Public Functions
-
inline int num_functions() const¶
Returns the number of functions.
-
inline Function AddFunction(fmt::StringRef name, int num_args, func::Type type = func::NUMERIC)¶
Adds a function.
name: Function name that may not be null-terminated.
-
inline void AddFunctions(int num_funcs)¶
Adds a function that will be defined later.
-
inline Function DefineFunction(int index, fmt::StringRef name, int num_args, func::Type type)¶
Defines a function.
-
inline NumericConstant MakeNumericConstant(double value)¶
Makes a numeric constant.
-
inline UnaryExpr MakeUnary(expr::Kind kind, NumericExpr arg)¶
Makes a unary expression.
-
inline BinaryExpr MakeBinary(expr::Kind kind, NumericExpr lhs, NumericExpr rhs)¶
Makes a binary expression.
-
inline IfExpr MakeIf(LogicalExpr condition, NumericExpr then_expr, NumericExpr else_expr)¶
Makes an if expression.
-
inline PLTermBuilder BeginPLTerm(int num_breakpoints)¶
Begins building a piecewise-linear term.
-
inline PLTerm EndPLTerm(PLTermBuilder builder, Reference arg)¶
Ends building a piecewise-linear term.
arg: argument that should be either a variable or a common expression.
-
inline IteratedExprBuilder BeginIterated(expr::Kind kind, int num_args)¶
Begins building an iterated expression.
-
inline IteratedExpr EndIterated(IteratedExprBuilder builder)¶
Ends building an iterated expression.
-
inline NumberOfExprBuilder BeginNumberOf(int num_args, NumericExpr arg0)¶
Begins building a numberof expression.
-
inline IteratedExpr EndNumberOf(NumberOfExprBuilder builder)¶
Ends building a numberof expression.
-
inline SymbolicNumberOfExprBuilder BeginSymbolicNumberOf(int num_args, Expr arg0)¶
Begins building a numberof expression.
-
inline SymbolicNumberOfExpr EndSymbolicNumberOf(SymbolicNumberOfExprBuilder builder)¶
Ends building a numberof expression.
-
inline CountExprBuilder BeginCount(int num_args)¶
Begins building a count expression.
-
inline LogicalConstant MakeLogicalConstant(bool value)¶
Makes a logical constant.
-
inline NotExpr MakeNot(LogicalExpr arg)¶
Makes a logical NOT expression.
-
inline BinaryLogicalExpr MakeBinaryLogical(expr::Kind kind, LogicalExpr lhs, LogicalExpr rhs)¶
Makes a binary logical expression.
-
inline RelationalExpr MakeRelational(expr::Kind kind, NumericExpr lhs, NumericExpr rhs)¶
Makes a relational expression.
-
inline LogicalCountExpr MakeLogicalCount(expr::Kind kind, NumericExpr lhs, CountExpr rhs)¶
Makes a logical count expression.
-
inline ImplicationExpr MakeImplication(LogicalExpr condition, LogicalExpr then_expr, LogicalExpr else_expr)¶
Makes an implication expression.
-
inline IteratedLogicalExprBuilder BeginIteratedLogical(expr::Kind kind, int num_args)¶
Begins building an iterated logical expression.
-
inline IteratedLogicalExpr EndIteratedLogical(IteratedLogicalExprBuilder builder)¶
Ends building an iterated logical expression.
-
inline PairwiseExprBuilder BeginPairwise(expr::Kind kind, int num_args)¶
Begins building a pairwise expression.
-
inline PairwiseExpr EndPairwise(PairwiseExprBuilder builder)¶
Ends building a pairwise expression.
-
inline StringLiteral MakeStringLiteral(fmt::StringRef value)¶
Makes a string literal.
-
inline SymbolicIfExpr MakeSymbolicIf(LogicalExpr condition, Expr then_expr, Expr else_expr)¶
Makes a symbolic if expression.
-
class PLTermBuilder¶
- #include <expr.h>
A piecewise-linear term builder.
-
template<typename Impl, typename Result, typename ExprTypes>
class BasicExprVisitor¶ - #include <basic-expr-visitor.h>
A basic expression visitor that can be used with different expression hierarchies described by ExprTypes.
BasicExprVisitor uses the curiously recurring template pattern: http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
Public Functions
-
inline Result VisitBinary(BinaryExpr e)¶
Visits a binary expression or a function taking two arguments.
-
inline Result VisitBinary(BinaryExpr e)¶
-
template<class Impl, class Converter, class Constraint>
class BasicFCC¶ - #include <convert_functional.h>
Helper class providing a default framework for assigning result to a functional expression, possibly adding a corresponding constraint on the result variable.
Public Functions
-
inline VarOrConst Convert()¶
Convert array of arguments into a result (var or const), possibly adding extra constraint(s).
- Returns
either a constant or a variable
-
class VarOrConst¶
- #include <convert_functional.h>
Holder for the conversion result of an expression.
-
inline VarOrConst Convert()¶
-
class BasicFileAppender¶
- #include <utils-file.h>
Class appending strings to file with given name.
-
class BasicFlatConverter¶
- #include <constr_keeper.h>
Converters handling custom constraints should derive from.
Subclassed by mp::FlatConverter< Impl, ModelAPI, Model >, mp::FlatConverter< Impl, ModelAPI, FlatModel >
Public Functions
-
inline int MapFind(const BasicConstraint&)¶
For Common Subexpression Elimination, we can use maps This stub returns empty Id.
Public Static Functions
-
static inline constexpr double ConstraintCvtPriority(BasicConstraint*)¶
Default conversion priority.
-
static inline constexpr double Pi()¶
Value of Pi.
-
static inline constexpr double Infty()¶
Infinity.
-
static inline constexpr double MinusInfty()¶
-Infinity
-
static inline constexpr double PracticallyInfty()¶
Pract inf.
-
static inline constexpr double PracticallyMinusInfty()¶
Pract -inf.
-
inline int MapFind(const BasicConstraint&)¶
-
template<class ModelParams = DefaultFlatModelParams>
class BasicFlatModel : public mp::ConstraintManager¶ - #include <converter_model.h>
Class BasicFlatModel stores vars, objs, custom constraints to be used internally in a FlatConverter.
Public Functions
-
inline Var AddVar__basic(double lb = MinusInf(), double ub = Inf(), var::Type type = var::CONTINUOUS)¶
VARIABLES //////////////////////////////// Add variable, return its index.
-
inline void AddVars__basic(const VarBndVec &lbs, const VarBndVec &ubs, const VarTypeVec &types)¶
Add several variables.
-
inline bool is_binary_var(int v) const¶
Returns true also when fixed.
-
template<class Backend>
inline void PushModelTo(Backend &backend) const¶ EXPORT INSTANCE TO A BACKEND ///////////////////////////////.
Pushing the whole instance to a backend or converter. A responsible backend should handle all essential items
-
inline bool check_vars() const¶
Check var arrays.
-
inline void AddConstraintKeeper(BasicConstraintKeeper &ck, double priority)¶
Add a new CKeeper with given conversion priority (smaller = sooner)
-
inline void ConsiderAcceptanceOptions(BasicFlatConverter &cvt, const BasicFlatModelAPI &ma, Env &env)¶
This should be called after adding all constraint keepers.
-
inline void ConvertAllConstraints(BasicFlatConverter &cvt)¶
Convert all constraints (including any new appearing)
-
inline void FillConstraintCounters(const BasicFlatModelAPI &mapi, FlatModelInfo &fmi) const¶
Fill counters of unbridged constraints.
-
inline void AddUnbridgedConstraintsToBackend(BasicFlatModelAPI &be) const¶
Add all unbridged constraints to Backend.
-
inline Var AddVar__basic(double lb = MinusInf(), double ub = Inf(), var::Type type = var::CONTINUOUS)¶
-
class BasicFlatModelAPI¶
- #include <model_api_base.h>
ModelAPIs handling custom flat constraints should derive from.
Public Functions
-
inline void InitCustomOptions()¶
Placeholder for InitCustomOptions()
-
inline void PassFlatModelInfo(std::unique_ptr<FlatModelInfo> &&pfmi)¶
Pass on a FlatModelInfo object.
-
inline const FlatModelInfo *GetFlatModelInfo() const¶
Retrieve FlatModelInfo*.
-
inline void InitProblemModificationPhase(const FlatModelInfo*)¶
Chance to prepare problem update, e.g., allocate storage.
-
inline void FinishProblemModificationPhase()¶
Chance to end problem update.
-
inline void SetLinearObjective(int, const LinearObjective&)¶
Placeholder for SetLinearObjective()
-
inline void SetQuadraticObjective(int, const QuadraticObjective&)¶
Placeholder for SetQuadraticObjective()
-
template<class Constraint>
inline void AddConstraint(const Constraint&)¶ Placeholder for AddConstraint<>()
Public Static Functions
-
static inline const char *GetTypeName()¶
Placeholder for GetTypeName()
-
static inline const char *GetLongName()¶
Placeholder for GetLongName()
-
static inline int AcceptsQuadObj()¶
Whether accepting quadratic objectives: 0 - no, 1 - convex, 2 - nonconvex.
-
static inline constexpr ConstraintGroup GroupNumber(const BasicConstraint*)¶
Default constraint group.
-
static inline constexpr ConstraintAcceptanceLevel AcceptanceLevel(const BasicConstraint*)¶
By default, we say constraint XYZ is not accepted but…
-
static inline constexpr bool AcceptsNonconvexQC()¶
Specifically, ask if the solver accepts non-convex quadratic constraints.
-
inline void InitCustomOptions()¶
-
template<class Impl, class ModelConverter>
class BasicFuncConstrCvt : public mp::BasicItemConverter<ModelConverter>¶ - #include <redef_base.h>
A functional constraint converter.
- Parameters
Impl – the final converter
ModelConverter –
Subclassed by mp::FuncConConverter_MIP_CRTP< Impl, ModelConverter, FuncCon >
Public Types
-
using Base = BasicItemConverter<ModelConverter>¶
Base class.
Public Functions
-
inline BasicFuncConstrCvt(ModelConverter &mc)¶
Constructor.
-
template<class ItemType>
inline void Convert(const ItemType &item, int i)¶ Generic Convert(), distinguishes context & result variable.
Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.
Responsible for adding presolve links, if any
The Impl can reimplement this
- Parameters
item – the item to be converted
i – item index, used to create a presolve link
-
template<class ItemType>
inline void ConvertCtxNeg(const ItemType &item, int)¶ Convert in negative context.
-
template<class ItemType>
inline void ConvertCtxPos(const ItemType &item, int)¶ Convert in positive context.
-
template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)¶ Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.
Example: PowConstraint(x, …) with lb(x)<0. Default: false.
-
inline const ModelConverter &GetMC() const¶
Access const ModelConverter.
-
inline ModelConverter &GetMC()¶
Access ModelConverter.
-
template<class ModelConverter>
class BasicItemConverter¶ - #include <redef_base.h>
A base class for specific Item Converters, such as individual constraint converters.
- Parameters
ModelConverter –
Subclassed by mp::BasicFuncConstrCvt< AbsConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< AllDiffConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< AndConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< ComplementarityConverter_MIP< ModelConverter, ComplCon >, ModelConverter >, mp::BasicFuncConstrCvt< Cond_LE_LT_GT_GE_Converter_MIP< ModelConverter, AlgCon >, ModelConverter >, mp::BasicFuncConstrCvt< CondEQConverter_MIP< ModelConverter, AlgConBody >, ModelConverter >, mp::BasicFuncConstrCvt< CountConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< DivConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< FuncConConverter_MIP< ModelConverter, FuncCon >, ModelConverter >, mp::BasicFuncConstrCvt< IfThenElseConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< ImplicationConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< MinOrMaxConverter_MIP< ModelConverter, sense >, ModelConverter >, mp::BasicFuncConstrCvt< NotConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< NumberofConstConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< NumberofVarConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< OrConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< PLConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< PowConstExponentConverter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< SOS2Converter_MIP< ModelConverter >, ModelConverter >, mp::BasicFuncConstrCvt< Impl, ModelConverter >, mp::IndicatorLinGEConverter_MIP< ModelConverter >, mp::IndicatorLinLEConverter_MIP< ModelConverter >, mp::IndicatorQuadConverter_MIP< ModelConverter, sens >, mp::QCConverter_MIP< ModelConverter, sens >, mp::RangeConstraintConverter< ModelConverter, AlgConBody >
Public Functions
-
inline BasicItemConverter(ModelConverter &mc)¶
Constructor.
-
template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)¶ Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.
Example: PowConstraint(x, …) with lb(x)<0. Default: false.
-
inline const ModelConverter &GetMC() const¶
Access const ModelConverter.
-
inline ModelConverter &GetMC()¶
Access ModelConverter.
-
template<typename ArgType, expr::Kind FIRST, expr::Kind LAST = FIRST>
class BasicIteratedExpr : public mp::BasicExpr<FIRST, LAST>¶ - #include <expr.h>
BasicIteratedExpr<ArgType>
Public Types
-
class BasicModelManager¶
- #include <model-mgr-base.h>
Abstract Model Manager.
Standardizes the following tasks:
Input the model;
Access user-provided solution/suffixes;
Report solutions/suffixes.
Subclassed by mp::ModelManagerWithProblemBuilder< Converter >
Public Functions
-
virtual void InitOptions() = 0¶
Setup Model Manager’s solver options.
-
virtual void SetBasename(const std::string &filename_no_ext) = 0¶
IO file basename, ideal to know this before option parsing.
-
virtual void ReadNLModel(const std::string &nl_filename, const std::string &filename_no_ext, void (*cb_checkmodel)(size_t, size_t, size_t)) = 0¶
Read NL model.
-
virtual void ReportSuffix(const SuffixDef<int> &suf, ArrayRef<int> values) = 0¶
Report integer suffix.
-
virtual void ReportSuffix(const SuffixDef<double> &suf, ArrayRef<double> values) = 0¶
Report double suffix.
-
virtual size_t GetSuffixSize(int kind) = 0¶
Length of a suffix vector of given kind.
-
virtual void HandleSolution(int, fmt::CStringRef, const double*, const double*, double) = 0¶
Report final solution.
-
virtual void HandleFeasibleSolution(fmt::CStringRef, const double*, const double*, double) = 0¶
Report intermediate solution.
-
virtual const std::vector<bool> &IsVarInt() const = 0¶
Integrality flags of the variables in the original instance.
Used for solution rounding
-
template<typename T>
class BasicMutSuffix : public mp::BasicSuffix<T>¶ - #include <suffix.h>
A mutable suffix.
-
template<typename ProblemParams = BasicProblemParams<>>
class BasicProblem : public mp::BasicExprFactory<std::allocator<char>>, public mp::SuffixManager¶ - #include <problem.h>
An optimization problem.
Subclassed by mp::ColProblem
Public Types
-
typedef BasicVariable<ProblemItem> Variable¶
An optimization variable.
-
typedef BasicObjective<ProblemItem> Objective¶
An objective.
-
typedef BasicAlgebraicCon<ProblemItem> AlgebraicCon¶
An algebraic constraint.
-
typedef Range<AlgebraicCon> AlgebraicConRange¶
A range of algebraic constraints.
Public Functions
-
inline const std::vector<bool> &IsVarInt() const¶
Deprecated.
-
inline BasicProblem()¶
Constructs an empty optimization problem.
-
template<class Solver>
inline explicit BasicProblem(const Solver&)¶ Placeholder, some APIs assume a ProblemBuilder to use a Solver.
-
inline int num_vars() const¶
Returns the number of variables.
-
inline int num_objs() const¶
Returns the number of objectives.
-
inline int num_algebraic_cons() const¶
Returns the number of algebraic constraints.
-
inline int num_logical_cons() const¶
Returns the number of logical constraints.
-
inline bool has_nonlinear_cons() const¶
Return true if the problem has nonlinear constraints.
-
inline int num_common_exprs() const¶
Returns the number of common expressions.
-
inline VarRange vars() const¶
Returns a range representing all variables in this optimization problem. It can be used for iterating over variables:
for (auto var: problem.vars()) { ... }
-
inline std::vector<int> AddVars(std::size_t nvars, double lb = -INFINITY, double ub = INFINITY, var::Type type = var::CONTINUOUS)¶
Add vector of variables. Type: var::CONTINUOUS by default.
-
inline ObjRange objs() const¶
Returns a range representing all objectives in this optimization problem. It can be used for iterating over objectives:
for (auto obj: problem.objs()) { ... }
-
inline MutObjective obj(int index)¶
Returns the mutable objective at the specified index.
-
LinearObjBuilder AddObj(obj::Type type, NumericExpr expr, int num_linear_terms = 0)¶
Adds an objective.
Returns a builder for the linear part of an objective expression.
-
inline AlgebraicConRange algebraic_cons() const¶
Returns a range representing all algebraic constraints in this optimization problem. It can be used for iterating over algebraic constraints:
for (auto con: problem.algebraic_cons()) { ... }
-
inline AlgebraicCon algebraic_con(int index) const¶
Returns the algebraic constraint at the specified index.
-
inline MutAlgebraicCon algebraic_con(int index)¶
Returns the mutable algebraic constraint at the specified index.
-
inline MutAlgebraicCon AddCon(double lb, double ub)¶
Adds an algebraic constraint.
Returns a builder for the linear part of a constraint expression.
-
inline LogicalConRange logical_cons() const¶
Returns a range representing all logical constraints in this optimization problem. It can be used for iterating over logical constraints:
for (auto con: problem.logical_cons()) { ... }
-
inline LogicalCon logical_con(int index) const¶
Returns the logical constraint at the specified index.
-
inline MutLogicalCon logical_con(int index)¶
Returns the mutable logical constraint at the specified index.
-
inline void AddCon(LogicalExpr expr)¶
Adds a logical constraint.
-
inline CommonExpr common_expr(int index) const¶
Returns the common expression at the specified index.
-
inline MutCommonExpr AddCommonExpr(NumericExpr expr)¶
Adds a common expression (defined variable).
-
void SetComplementarity(int con_index, int var_index, ComplInfo info)¶
Sets a complementarity condition.
-
inline bool HasComplementarity() const¶
Returns true if the problem has complementarity conditions.
-
inline int GetComplementarityVariable(int i) const¶
Returns complementarity variable for algebraic constraint i.
Result > 0 means constraint i complements variable Result - 1.
-
inline IntSuffixHandler AddIntSuffix(fmt::StringRef name, int kind, int = 0)¶
Adds an integer suffix.
name: Suffix name that may not be null-terminated.
-
inline DblSuffixHandler AddDblSuffix(fmt::StringRef name, suf::Kind kind, int)¶
Adds a double suffix.
name: Suffix name that may not be null-terminated.
-
inline ArrayRef<double> ReadDblSuffix(const SuffixDef<double> &sufdef)¶
Read double suffix.
If absent but an integer suffix with the same name exists, take that
-
void SetInfo(const ProblemInfo &info)¶
Sets problem information and reserves memory for problem elements.
-
template<class Backend>
inline void PushModelTo(Backend &backend) const¶ Pushing the whole instance to a backend or converter.
A responsible backend should handle all essential items
-
inline BasicProblem &problem()¶
Returns the built problem.
This is used for compatibility with the problem builder API.
-
inline UnaryExpr MakeUnary(expr::Kind kind, NumericExpr arg)¶
Makes a unary expression.
-
inline BinaryExpr MakeBinary(expr::Kind kind, NumericExpr lhs, NumericExpr rhs)¶
Makes a binary expression.
-
inline IfExpr MakeIf(LogicalExpr condition, NumericExpr then_expr, NumericExpr else_expr)¶
Makes an if expression.
-
inline IteratedExprBuilder BeginIterated(expr::Kind kind, int num_args)¶
Begins building an iterated expression.
-
inline IteratedExpr EndIterated(IteratedExprBuilder builder)¶
Ends building an iterated expression.
-
inline int num_functions() const¶
Returns the number of functions.
-
inline Function AddFunction(fmt::StringRef name, int num_args, func::Type type = func::NUMERIC)¶
Adds a function.
name: Function name that may not be null-terminated.
-
inline void AddFunctions(int num_funcs)¶
Adds a function that will be defined later.
-
inline Function DefineFunction(int index, fmt::StringRef name, int num_args, func::Type type)¶
Defines a function.
-
inline NumericConstant MakeNumericConstant(double value)¶
Makes a numeric constant.
-
inline PLTermBuilder BeginPLTerm(int num_breakpoints)¶
Begins building a piecewise-linear term.
-
inline PLTerm EndPLTerm(PLTermBuilder builder, Reference arg)¶
Ends building a piecewise-linear term.
arg: argument that should be either a variable or a common expression.
- inline CallExprBuilder BeginCall(Function func, int num_args)
-
typedef BasicVariable<ProblemItem> Variable¶