Reference

This page lists the public API of ParametericOptInterface.

Load the module with:

import ParametericOptInterface as POI

and then prefix all calls with POI. to create POI.<NAME>.

Optimizer

ParametricOptInterface.OptimizerType
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: If true, evaluates the dual of parameters. Set it to false to increase performance when the duals of parameters are not necessary. Defaults to true.

  • save_original_objective_and_constraints: If true saves the orginal function and set of the constraints as well as the original objective function inside Optimizer. This is useful for printing the model but greatly increases the memory footprint. Users might want to set it to false to 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 as MOI.get(model, MOI.ConstraintFunction(), c). Defaults to true.

  • with_bridge_type: the type passed to MOI.Bridges.full_bridge_optimizer

  • with_cache_type: the type passed to MOI.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: 0
source

ConstraintsInterpretation

ParametricOptInterface.ConstraintsInterpretationType
ConstraintsInterpretation <: MOI.AbstractOptimizerAttribute

Attribute to define how Optimizer should interpret constraints.

  • POI.ONLY_CONSTRAINTS: always interpret ScalarAffineFunction constraints as linear constraints. If an expression such as x >= p1 + p2 appears, it will be treated like an affine constraint. This is the default behaviour of Optimizer

  • POI.ONLY_BOUNDS: always interpret ScalarAffineFunction constraints as a variable bound. This is valid for constraints such as x >= p or x >= p1 + p2. If a constraint x1 + x2 >= p appears which is not a valid variable bound, an error will be thrown.

  • POI.BOUNDS_AND_CONSTRAINTS: interpret ScalarAffineFunction constraints as a variable bound if they are a valid variable bound, for example, x >= p or x >= 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
source