Reference
This page lists the public API of ParametericOptInterface.
Load the module with:
import ParametericOptInterface as POIand then prefix all calls with POI. to create POI.<NAME>.
Optimizer
ParametricOptInterface.Optimizer — Type
Optimizer{T}(
optimizer::Union{MOI.ModelLike,Any};
evaluate_duals::Bool = true,
save_original_objective_and_constraints::Bool = true,
with_bridge_type = nothing,
with_cache_type = nothing,
)Create an Optimizer, which allows the handling of parameters in an optimization model.
If optimizer is not a MOI.ModelLike, the inner optimizer is constructed using MOI.instantiate(optimizer; with_cache_type).
If with_bridge_type !== nothing, a MOI.Bridges.full_bridge_optimizer is applied as an outer layer.
The {T} type parameter is optional; it defaults to Float64.
Keyword arguments
evaluate_duals::Bool: Iftrue, evaluates the dual of parameters. Set it tofalseto increase performance when the duals of parameters are not necessary. Defaults totrue.save_original_objective_and_constraints: Iftruesaves the orginal function and set of the constraints as well as the original objective function insideOptimizer. This is useful for printing the model but greatly increases the memory footprint. Users might want to set it tofalseto increase performance in applications where you don't need to query the original expressions provided to the model in constraints or in the objective. Note that this might break printing or queries such asMOI.get(model, MOI.ConstraintFunction(), c). Defaults totrue.with_bridge_type: the type passed toMOI.Bridges.full_bridge_optimizerwith_cache_type: the type passed toMOI.instantiate
Example
julia> import ParametricOptInterface as POI
julia> import HiGHS
julia> POI.Optimizer(HiGHS.Optimizer(); evaluate_duals = true)
ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer}
├ ObjectiveSense: FEASIBILITY_SENSE
├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 0
└ NumberOfConstraints: 0
julia> POI.Optimizer(
HiGHS.Optimizer;
with_bridge_type = Float64,
evaluate_duals = false,
)
ParametricOptInterface.Optimizer{Float64, MOIB.LazyBridgeOptimizer{HiGHS.Optimizer}}
├ ObjectiveSense: FEASIBILITY_SENSE
├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 0
└ NumberOfConstraints: 0ConstraintsInterpretation
ParametricOptInterface.ConstraintsInterpretation — Type
ConstraintsInterpretation <: MOI.AbstractOptimizerAttributeAttribute to define how Optimizer should interpret constraints.
POI.ONLY_CONSTRAINTS: always interpretScalarAffineFunctionconstraints as linear constraints. If an expression such asx >= p1 + p2appears, it will be treated like an affine constraint. This is the default behaviour ofOptimizerPOI.ONLY_BOUNDS: always interpretScalarAffineFunctionconstraints as a variable bound. This is valid for constraints such asx >= porx >= p1 + p2. If a constraintx1 + x2 >= pappears which is not a valid variable bound, an error will be thrown.POI.BOUNDS_AND_CONSTRAINTS: interpretScalarAffineFunctionconstraints as a variable bound if they are a valid variable bound, for example,x >= porx >= p1 + p2, and interpret them as linear constraints otherwise.
Example
julia> import MathOptInterface as MOI
julia> import ParametricOptInterface as POI
julia> model = POI.Optimizer(MOI.Utilities.Model{Float64}())
ParametricOptInterface.Optimizer{Float64, MOIU.Model{Float64}}
├ ObjectiveSense: FEASIBILITY_SENSE
├ ObjectiveFunctionType: MOI.ScalarAffineFunction{Float64}
├ NumberOfVariables: 0
└ NumberOfConstraints: 0
julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS)
julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS)
julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.BOUNDS_AND_CONSTRAINTS)SolveWithoutVariables
ParametricOptInterface.SolveWithoutVariables — Type
SolveWithoutVariables <: MOI.AbstractOptimizerAttributeAn attribute that controls whether Optimizer solves a model that contains parameters but no decision variables, instead of passing it to the inner optimizer.
Such a model has no degrees of freedom, so its solution can be written down directly: the primal solution is the vector of parameter values, every constraint dual is zero, and therefore the dual of each parameter is the derivative of the objective function with respect to it.
Most solvers reject a model with no variables, so set this attribute to false only if the inner optimizer handles such a model itself. Defaults to true.
See also NoVariablesFeasibilityTolerance.
NoVariablesFeasibilityTolerance
ParametricOptInterface.NoVariablesFeasibilityTolerance — Type
NoVariablesFeasibilityTolerance <: MOI.AbstractOptimizerAttributeAn attribute for the tolerance used to decide whether the parameter values satisfy the constraints of a model that contains parameters but no decision variables. Such a constraint is a statement about the parameter values alone, so it is checked by evaluating it and measuring the distance to its set; a distance greater than this tolerance makes the model MOI.INFEASIBLE.
Only used when SolveWithoutVariables is true. Defaults to 1e-6 if T is a floating point type and to zero(T) otherwise, because exact arithmetic needs no slack.
Example
julia> import MathOptInterface as MOI
julia> import ParametricOptInterface as POI
julia> model = POI.Optimizer(MOI.Utilities.Model{Float64}());
julia> MOI.set(model, POI.NoVariablesFeasibilityTolerance(), 1e-5)
julia> MOI.get(model, POI.NoVariablesFeasibilityTolerance())
1.0e-5