Is ParametricOptInterface needed to define and use parameters in JuMP?

I feel puzzled when it comes to the role of ParametricOptInterface.jl (POI). I think I understand its general mission (in fact the motivating tutorial example Rolling horizon problems · JuMP directed me to it). But it appears that I can get along with just JuMP, can’t I? The Parameter type (of a variable) is defined in JuMP.

The code snippet below is from the POI readme, I have just commented out the second and the third lines, and provided the fourth line instead. And it works fine.

using JuMP, HiGHS
#import ParametricOptInterface as POI
#model = direct_model(POI.Optimizer(HiGHS.Optimizer()))
model = Model(HiGHS.Optimizer)
@variable(model, x)
@variable(model, p in Parameter(1.0))
@constraint(model, cons, x + p >= 3)
@objective(model, Min, 2x)
optimize!(model)
@show value(x)
set_parameter_value(p, 2.0)
optimize!(model)
@show value(x)

Hi @zdenek_hurak, I am not totally sure but I think that the main difference is that the native Parameters of JuMP can only be used when they appear solely in the rhs of problems.

POI is needed when you need parameters in other places, such as the coefficient matrix.

2 Likes

Yes, if the parameters multiplies a variable then without ParametricOptInterface it will appear as a quadratic constraint to the solver and with ParametricOptInterface it will appear as affine to the solver.
Also, ParametricOptInterface is much more efficient

1 Like

Just curious but is this in any way the same as CVXPY’s DPP?

Hi @zdenek_hurak,

  • You can use Parameter regardless of the solver.
  • If the solver doesn’t natively support Parameter, we will bridge it to x in EqualTo(value). With HiGHS, writing p in Parameter(1.0) is the same as p == 1.0.
  • POI is a layer above the solver. Instead of adding fixed variables, it substitutes out the parameters with their value.
  • For additive parameters, there won’t be much difference between POI and HiGHS
  • For multiplicative parameters, you must use POI because HiGHS will see a quadratic bilinear term between parameter * variable.
  • Other solvers like Ipopt have native support for parameters; you don’t (and shouldn’t) need to use POI with them.

I hope that clarifies things.

1 Like