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.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: 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.ConstraintsInterpretation — Type
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)

julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS)

julia> MOI.set(model, POI.ConstraintsInterpretation(), POI.BOUNDS_AND_CONSTRAINTS)
source

SolveWithoutVariables

ParametricOptInterface.SolveWithoutVariables — Type
SolveWithoutVariables <: MOI.AbstractOptimizerAttribute

An 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.

source

NoVariablesFeasibilityTolerance

ParametricOptInterface.NoVariablesFeasibilityTolerance — Type
NoVariablesFeasibilityTolerance <: MOI.AbstractOptimizerAttribute

An 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
source