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)
ONLY_BOUNDS::ConstraintsInterpretationCode = 1
julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS)
ONLY_CONSTRAINTS::ConstraintsInterpretationCode = 0
julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.BOUNDS_AND_CONSTRAINTS)
BOUNDS_AND_CONSTRAINTS::ConstraintsInterpretationCode = 2