diff --git a/Project.toml b/Project.toml index 43e23dc1..4388fa0c 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,7 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" GLPK = "1" Ipopt = "1" JuMP = "1" -MathOptInterface = "1.3" +MathOptInterface = "1.13.2" SCS = "1" julia = "1.6" diff --git a/README.md b/README.md index b45da9b0..9c51660d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ using JuMP, HiGHS import ParametricOptInterface as POI model = Model(() -> POI.Optimizer(HiGHS.Optimizer())) @variable(model, x) -@variable(model, p in POI.Parameter(1.0)) +@variable(model, p in MOI.Parameter(1.0)) @constraint(model, cons, x + p >= 3) @objective(model, Min, 2x) optimize!(model) diff --git a/benchmark/MOI_benchmarks.jl b/benchmark/MOI_benchmarks.jl index 60386540..c9a1e8a6 100644 --- a/benchmark/MOI_benchmarks.jl +++ b/benchmark/MOI_benchmarks.jl @@ -117,7 +117,7 @@ function generate_poi_problem(model, data::PMedianData, add_parameters::Bool) if add_parameters d, cd = MOI.add_constrained_variable( model, - POI.Parameter(data.num_facilities), + MOI.Parameter(data.num_facilities), ) end diff --git a/benchmark/run_benchmarks.jl b/benchmark/run_benchmarks.jl index 3ca572a2..fd4b2943 100644 --- a/benchmark/run_benchmarks.jl +++ b/benchmark/run_benchmarks.jl @@ -24,14 +24,14 @@ end function poi_add_parameters(N::Int) model = POI.Optimizer(MOI.Utilities.Model{Float64}()) - MOI.add_constrained_variable.(model, POI.Parameter.(ones(N))) + MOI.add_constrained_variable.(model, MOI.Parameter.(ones(N))) return nothing end function poi_add_parameters_and_variables(N::Int) model = POI.Optimizer(MOI.Utilities.Model{Float64}()) MOI.add_variables(model, N / 2) - MOI.add_constrained_variable.(model, POI.Parameter.(ones(Int(N / 2)))) + MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))) return nothing end @@ -39,7 +39,7 @@ function poi_add_parameters_and_variables_alternating(N::Int) model = POI.Optimizer(MOI.Utilities.Model{Float64}()) for i in 1:Int(N / 2) MOI.add_variable(model) - MOI.add_constrained_variable(model, POI.Parameter(1)) + MOI.add_constrained_variable(model, MOI.Parameter(1.0)) end return nothing end @@ -77,7 +77,7 @@ function poi_add_saf_variables_and_parameters_ctr(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -103,7 +103,7 @@ function poi_add_saf_variables_and_parameters_ctr_parameter_update( first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -162,7 +162,7 @@ function poi_add_sqf_variables_parameters_ctr(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -186,7 +186,7 @@ function poi_add_sqf_variables_parameters_ctr_parameter_update(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -212,7 +212,7 @@ function poi_add_sqf_parameters_parameters_ctr(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -236,7 +236,7 @@ function poi_add_sqf_parameters_parameters_ctr_parameter_update(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -288,7 +288,7 @@ function poi_add_saf_variables_and_parameters_obj(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -314,7 +314,7 @@ function poi_add_saf_variables_and_parameters_obj_parameter_update( first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -375,7 +375,7 @@ function poi_add_sqf_variables_parameters_obj(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -399,7 +399,7 @@ function poi_add_sqf_variables_parameters_obj_parameter_update(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -427,7 +427,7 @@ function poi_add_sqf_parameters_parameters_obj(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M @@ -451,7 +451,7 @@ function poi_add_sqf_parameters_parameters_obj_parameter_update(N::Int, M::Int) first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ) ) for _ in 1:M diff --git a/benchmark/run_benchmarks_jump.jl b/benchmark/run_benchmarks_jump.jl index 9ddc49e9..fe95b743 100644 --- a/benchmark/run_benchmarks_jump.jl +++ b/benchmark/run_benchmarks_jump.jl @@ -43,7 +43,7 @@ function poi_add_parameters(N::Int) ), ), ) - @variable(model, x[i = 1:N] in POI.Parameter(1)) + @variable(model, x[i = 1:N] in MOI.Parameter(1.0)) return nothing end @@ -56,7 +56,7 @@ function poi_add_parameters_and_variables(N::Int) ), ), ) - @variable(model, x[i = 1:N] in POI.Parameter(1)) + @variable(model, x[i = 1:N] in MOI.Parameter(1.0)) return nothing end @@ -71,7 +71,7 @@ function poi_add_parameters_and_variables_alternating(N::Int) ) for i in 1:Int(N / 2) @variable(model) - @variable(model, set = POI.Parameter(1)) + @variable(model, set = MOI.Parameter(1.0)) end return nothing end @@ -112,7 +112,7 @@ function poi_add_saf_variables_and_parameters_ctr(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(0)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(0)) @constraint(model, con[i = 1:M], sum(x) + sum(p) >= 1) return nothing end @@ -130,7 +130,7 @@ function poi_add_saf_variables_and_parameters_ctr_parameter_update( ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(0)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(0)) @constraint(model, con[i = 1:M], sum(x) + sum(p) >= 1) MOI.set.(model, POI.ParameterValue(), p, 0.5) POI.update_parameters!(backend(model)) @@ -173,7 +173,7 @@ function poi_add_sqf_variables_parameters_ctr(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) @constraint(model, con[i = 1:M], dot(x, p) >= 1) return nothing end @@ -188,7 +188,7 @@ function poi_add_sqf_variables_parameters_ctr_parameter_update(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) @constraint(model, con[i = 1:M], dot(x, p) >= 1) MOI.set.(model, POI.ParameterValue(), p, 0.5) POI.update_parameters!(backend(model)) @@ -205,7 +205,7 @@ function poi_add_sqf_parameters_parameters_ctr(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) @constraint(model, con[i = 1:M], dot(p, p) >= 1) return nothing end @@ -220,7 +220,7 @@ function poi_add_sqf_parameters_parameters_ctr_parameter_update(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) @constraint(model, con[i = 1:M], dot(p, p) >= 1) MOI.set.(model, POI.ParameterValue(), p, 0.5) POI.update_parameters!(backend(model)) @@ -265,7 +265,7 @@ function poi_add_saf_variables_and_parameters_obj(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, sum(x) + sum(p)) end @@ -285,7 +285,7 @@ function poi_add_saf_variables_and_parameters_obj_parameter_update( ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, sum(x) + sum(p)) end @@ -336,7 +336,7 @@ function poi_add_sqf_variables_parameters_obj(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, dot(x, p)) end @@ -353,7 +353,7 @@ function poi_add_sqf_variables_parameters_obj_parameter_update(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, dot(x, p)) end @@ -374,7 +374,7 @@ function poi_add_sqf_parameters_parameters_obj(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, dot(p, p)) end @@ -391,7 +391,7 @@ function poi_add_sqf_parameters_parameters_obj_parameter_update(N::Int, M::Int) ), ) @variable(model, x[i = 1:Int(N / 2)]) - @variable(model, p[i = 1:Int(N / 2)] in POI.Parameter.(1)) + @variable(model, p[i = 1:Int(N / 2)] in MOI.Parameter.(1)) for _ in 1:M @objective(model, Min, dot(p, p)) end diff --git a/benchmark/run_benders_quantile_regression_benchmark.jl b/benchmark/run_benders_quantile_regression_benchmark.jl index fcebb0c5..7765efec 100644 --- a/benchmark/run_benders_quantile_regression_benchmark.jl +++ b/benchmark/run_benders_quantile_regression_benchmark.jl @@ -142,7 +142,7 @@ function slave_model(PARAM, K) @variable(slave, β[i = 1:N_Candidates] == 0, Param()) elseif PARAM == 1 # Create parameters - @variable(slave, β[i = 1:N_Candidates] in POI.Parameter.(0)) + @variable(slave, β[i = 1:N_Candidates] in MOI.Parameter.(0.0)) else # Create fixed variables @variables(slave, begin diff --git a/docs/src/Examples/benders.md b/docs/src/Examples/benders.md index 5b707214..2fb10ace 100644 --- a/docs/src/Examples/benders.md +++ b/docs/src/Examples/benders.md @@ -153,7 +153,7 @@ function inner_model(K) # create the regression coefficient representation # Create parameters - β = [@variable(inner, set = POI.Parameter(0)) for i in 1:N_Candidates] + β = [@variable(inner, set = MOI.Parameter(0.0)) for i in 1:N_Candidates] for (i, βi) in enumerate(β) set_name(βi, "β[$i]") end diff --git a/docs/src/Examples/example.md b/docs/src/Examples/example.md index 0d9fc4df..cdad6370 100644 --- a/docs/src/Examples/example.md +++ b/docs/src/Examples/example.md @@ -26,12 +26,12 @@ for x_i in x end ``` -Now, let's consider 3 [`ParametricOptInterface.Parameter`](@ref). Two of them, `y`, `z`, will be placed in the constraints and one, `w`, in the objective function. We'll start all three of them with a value equal to `0`: +Now, let's consider 3 `MOI.Parameter`. Two of them, `y`, `z`, will be placed in the constraints and one, `w`, in the objective function. We'll start all three of them with a value equal to `0`: ```@example moi1 -w, cw = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) -y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) -z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) +w, cw = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) +y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) +z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) ``` Let's add the constraints. Notice that we treat parameters and variables in the same way when building the functions that will be placed in some set to create a constraint (`Function-in-Set`): @@ -146,12 +146,12 @@ We declare the variable `x` as in a typical `JuMP` model: @variable(model, x[i = 1:2] >= 0) ``` -Now, let's consider 3 [`ParametricOptInterface.Parameter`](@ref). Two of them, `y`, `z`, will be placed in the constraints and one, `w`, in the objective function. We'll start all three of them with a value equal to `0`: +Now, let's consider 3 `MOI.Parameter`. Two of them, `y`, `z`, will be placed in the constraints and one, `w`, in the objective function. We'll start all three of them with a value equal to `0`: ```@example jump1 -@variable(model, y in ParametricOptInterface.Parameter(0)) -@variable(model, z in ParametricOptInterface.Parameter(0)) -@variable(model, w in ParametricOptInterface.Parameter(0)) +@variable(model, y in MOI.Parameter(0.0)) +@variable(model, z in MOI.Parameter(0.0)) +@variable(model, w in MOI.Parameter(0.0)) ``` Let's add the constraints. Notice that we treat parameters the same way we treat variables when writing the model: @@ -246,9 +246,9 @@ const POI = ParametricOptInterface model = Model(() -> ParametricOptInterface.Optimizer(HiGHS.Optimizer())) @variable(model, x[i = 1:3] >= 0) -@variable(model, p1[i = 1:3] in ParametricOptInterface.Parameter(0)) -@variable(model, p2[i = 1:3] in ParametricOptInterface.Parameter.([1, 10, 45])) -@variable(model, p3[i = 1:3] in ParametricOptInterface.Parameter.(ones(3))) +@variable(model, p1[i = 1:3] in MOI.Parameter(0.0)) +@variable(model, p2[i = 1:3] in MOI.Parameter.([1, 10, 45])) +@variable(model, p3[i = 1:3] in MOI.Parameter.(ones(3))) ``` ## JuMP Example - Dealing with parametric expressions as variable bounds @@ -263,11 +263,11 @@ const POI = ParametricOptInterface model = direct_model(POI.Optimizer(HiGHS.Optimizer())) @variable(model, x) -@variable(model, p in POI.Parameter(0.0)) +@variable(model, p in MOI.Parameter(0.0)) @constraint(model, x >= p) ``` -Since parameters are treated like variables JuMP lowers this to MathOptInterface as `x - p >= 0` which is not a variable bound but a linear constraint.This means that the current representation of this problem at the solver level is: +Since parameters are treated like variables JuMP lowers this to MOI as `x - p >= 0` which is not a variable bound but a linear constraint.This means that the current representation of this problem at the solver level is: ```math \begin{align} @@ -288,7 +288,7 @@ const POI = ParametricOptInterface model = direct_model(POI.Optimizer(HiGHS.Optimizer())) @variable(model, x) -@variable(model, p in POI.Parameter(0.0)) +@variable(model, p in MOI.Parameter(0.0)) # Indicate that all the new constraints will be valid variable bounds MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @@ -343,7 +343,7 @@ MOI.set(optimizer, MOI.ObjectiveSense(), MOI.MAX_SENSE) obj_func = MOI.ScalarQuadraticFunction( [MOI.ScalarQuadraticTerm(1.0, x, x) MOI.ScalarQuadraticTerm(1.0, y, y)], - MathOptInterface.ScalarAffineTerm{Float64}[], + MOI.ScalarAffineTerm{Float64}[], 0.0, ) MOI.set( @@ -357,7 +357,7 @@ To multiply a parameter in a quadratic term, the user will need to use the `POI.QuadraticObjectiveCoef` model attribute. ```@example moi2 -p = first(MOI.add_constrained_variable.(optimizer, POI.Parameter(1.0))) +p = first(MOI.add_constrained_variable.(optimizer, MOI.Parameter(1.0))) MOI.set(optimizer, POI.QuadraticObjectiveCoef(), (x,y), p) ``` @@ -403,7 +403,7 @@ model = direct_model(optimizer) @variable(model, x >= 0) @variable(model, y >= 0) -@variable(model, p in POI.Parameter(1.0)) +@variable(model, p in MOI.Parameter(1.0)) @constraint(model, 2x + y <= 4) @constraint(model, x + 2y <= 4) @objective(model, Max, (x^2 + y^2)/2) @@ -447,7 +447,7 @@ POI currently works with NLPs when users wish to add the parameters to the non-N ```julia @variable(model, x) @variable(model, y) -@variable(model, z in POI.Parameter(10)) +@variable(model, z in MOI.Parameter(10)) @constraint(model, x + y >= z) @NLobjective(model, Min, x^2 + y^2) ``` @@ -457,7 +457,7 @@ but does not work with models that have parameters on the NL expressions like th ```julia @variable(model, x) @variable(model, y) -@variable(model, z in POI.Parameter(10)) +@variable(model, z in MOI.Parameter(10)) @constraint(model, x + y >= z) @NLobjective(model, Min, x^2 + y^2 + z) # There is a parameter here ``` @@ -481,7 +481,7 @@ POI_cached_optimizer() = POI.Optimizer(cached()) model = Model(() -> POI_cached_optimizer()) @variable(model, x) @variable(model, y) -@variable(model, z in POI.Parameter(10)) +@variable(model, z in MOI.Parameter(10)) @constraint(model, x + y >= z) @NLobjective(model, Min, x^2 + y^2) ``` @@ -493,7 +493,7 @@ If users wish to make modifications on variable bounds the POI interface will he ```julia model = Model(() -> POI.Optimizer(Ipopt.Optimizer())) @variable(model, x) -@variable(model, z in POI.Parameter(10)) +@variable(model, z in MOI.Parameter(10)) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @constraint(model, x >= z) @NLobjective(model, Min, x^2) diff --git a/docs/src/Examples/markowitz.md b/docs/src/Examples/markowitz.md index 73d4fcd0..800fd595 100644 --- a/docs/src/Examples/markowitz.md +++ b/docs/src/Examples/markowitz.md @@ -47,7 +47,7 @@ function first_model(μ,Σ) N = length(μ) @variable(portfolio, x[1:N] >= 0) - @variable(portfolio, γ in POI.Parameter(0.0)) + @variable(portfolio, γ in MOI.Parameter(0.0)) @objective(portfolio, Max, γ*dot(μ,x) - x' * Σ * x) @constraint(portfolio, sum(x) == 1) diff --git a/docs/src/manual.md b/docs/src/manual.md index 696aff6d..d8ff2e1e 100644 --- a/docs/src/manual.md +++ b/docs/src/manual.md @@ -56,22 +56,26 @@ optimizer = POI.Optimizer(HiGHS.Optimizer()) ### Parameters -A [`ParametricOptInterface.Parameter`](@ref) is a variable with a fixed value that can be changed by the user. +A `MOI.Parameter` is a set used to define a variable with a fixed value that +can be changed by the user. It is analogous to `MOI.EqualTo`, but can be used +by special methods like the ones in this package to remove the fixed variable from the +optimization problem. This permits the usage of multiplicative parameters in lienar models +and might speedup solves since the number of variables is reduced. ### Adding a new parameter to a model -To add a parameter to a model, we must use the `MOI.add_constrained_variable()` function, passing as its arguments the model and a [`ParametricOptInterface.Parameter`](@ref) with its given value: +To add a parameter to a model, we must use the `MOI.add_constrained_variable()` function, passing as its arguments the model and a `MOI.Parameter` with its given value: ```julia -y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) +y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) ``` ### Changing the parameter value -To change a given parameter's value, access its `VariableIndex` and set it to the new value using the [`ParametricOptInterface.Parameter`](@ref) structure. +To change a given parameter's value, access its `VariableIndex` and set it to the new value using the `MOI.Parameter` structure. ```julia -MOI.set(optimizer, POI.ParameterValue(), y, POI.Parameter(2.0)) +MOI.set(optimizer, POI.ParameterValue(), y, MOI.Parameter(2.0)) ``` ### Retrieving the dual of a parameter diff --git a/docs/src/reference.md b/docs/src/reference.md index a978374a..acb5eba3 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -3,7 +3,6 @@ ```@docs ParametricOptInterface.ConstraintsInterpretation ParametricOptInterface.Optimizer -ParametricOptInterface.Parameter ParametricOptInterface.ParameterDual ParametricOptInterface.ParameterValue ``` \ No newline at end of file diff --git a/src/ParametricOptInterface.jl b/src/ParametricOptInterface.jl index e0ab8fc1..cf0aacf5 100644 --- a/src/ParametricOptInterface.jl +++ b/src/ParametricOptInterface.jl @@ -16,23 +16,6 @@ const PARAMETER_INDEX_THRESHOLD = Int64(4_611_686_018_427_387_904) # div(typemax const SIMPLE_SCALAR_SETS{T} = Union{MOI.LessThan{T},MOI.GreaterThan{T},MOI.EqualTo{T}} -""" - Parameter(val::Float64) - -The `Parameter` structure stores the numerical value associated to a given -parameter. - -## Example - -```julia-repl -julia> ParametricOptInterface.Parameter(5) -ParametricOptInterface.Parameter(5) -``` -""" -struct Parameter <: MOI.AbstractScalarSet - val::Float64 -end - # Utilities for using a CleverDict in Parameters struct ParameterIndex index::Int64 @@ -161,6 +144,9 @@ mutable struct Optimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer last_variable_index_added::Int64 last_parameter_index_added::Int64 + # mapping of all constraints: necessary for getters + constraint_outer_to_inner::DoubleDict{MOI.ConstraintIndex} + # affine constraint data last_affine_added::Int64 # Store the map for SAFs (some might be transformed into VI) @@ -234,6 +220,7 @@ mutable struct Optimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer ), 0, PARAMETER_INDEX_THRESHOLD, + DoubleDict{MOI.ConstraintIndex}(), # affine constraint 0, DoubleDict{MOI.ConstraintIndex}(), @@ -280,6 +267,7 @@ function MOI.is_empty(model::Optimizer) isempty(model.variables) && model.last_variable_index_added == 0 && model.last_parameter_index_added == PARAMETER_INDEX_THRESHOLD && + isempty(model.constraint_outer_to_inner) && # affine ctr model.last_affine_added == 0 && isempty(model.affine_outer_to_inner) && @@ -311,6 +299,7 @@ function MOI.empty!(model::Optimizer{T}) where {T} empty!(model.variables) model.last_variable_index_added = 0 model.last_parameter_index_added = PARAMETER_INDEX_THRESHOLD + empty!(model.constraint_outer_to_inner) # affine ctr model.last_affine_added = 0 empty!(model.affine_outer_to_inner) @@ -636,6 +625,17 @@ function MOI.get( return MOI.get(model.optimizer, attr, ci) end end +function MOI.get( + model::Optimizer{T}, + ::MOI.ConstraintFunction, + cp::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}, +) where {T} + p = MOI.VariableIndex(cp.value) + if !is_parameter_in_model(model, p) + error("Parameter not in the model") + end + return p +end function MOI.get( model::Optimizer, @@ -702,10 +702,6 @@ function MOI.set(model::Optimizer, attr::MOI.AbstractOptimizerAttribute, value) return end -function MOI.get(model::Optimizer, ::MOI.NumberOfConstraints{F,S}) where {F,S} - return length(MOI.get(model, MOI.ListOfConstraintIndices{F,S}())) -end - function MOI.get( model::Optimizer, attr::MOI.ConstraintSet, @@ -739,83 +735,30 @@ function MOI.get(model::Optimizer, attr::MOI.ResultCount) return MOI.get(model.optimizer, attr) end -# TODO: cleanup -# In the AbstractBridgeOptimizer, we collect all the possible constraint types and them filter with NumberOfConstraints. -# If NumberOfConstraints is zero then we remove it from the list. -# Here, you can look over keys(quadratic_outer_to_inner) and add the F-S types of all the keys in constraints. -# To implement NumberOfConstraints, you call NumberOfConstraints to the inner optimizer. -# Then you remove the number of constraints of that that in values(quadratic_outer_to_inner) function MOI.get(model::Optimizer, ::MOI.ListOfConstraintTypesPresent) - inner_ctrs = MOI.get(model.optimizer, MOI.ListOfConstraintTypesPresent()) - if !has_quadratic_constraint_caches(model) - return inner_ctrs - end - - cache_keys = collect(keys(model.quadratic_outer_to_inner)) - constraints = Set{Tuple{DataType,DataType}}() - - for (F, S) in inner_ctrs - inner_index = - MOI.get(model.optimizer, MOI.ListOfConstraintIndices{F,S}()) - cache_map_check = - quadratic_constraint_cache_map_check.(model, inner_index) - for type in typeof.(cache_keys[cache_map_check]) - push!(constraints, (type.parameters[1], type.parameters[2])) - end - # If not all the constraints are cached then also push the original type - # since there was a function with no parameters of that type - if !all(cache_map_check) - push!(constraints, (F, S)) - end - end - - return collect(constraints) -end - -function MOI.get( - model::Optimizer, - attr::MOI.ListOfConstraintIndices{F,S}, -) where {S,F<:Union{MOI.VectorOfVariables,MOI.VariableIndex}} - return MOI.get(model.optimizer, attr) + constraint_types = MOI.Utilities.DoubleDicts.nonempty_outer_keys( + model.constraint_outer_to_inner, + ) + return collect(constraint_types) end function MOI.get( model::Optimizer, ::MOI.ListOfConstraintIndices{F,S}, -) where { - S<:MOI.AbstractSet, - F<:Union{MOI.ScalarAffineFunction{T},MOI.VectorAffineFunction{T}}, -} where {T} - inner_index = MOI.get(model.optimizer, MOI.ListOfConstraintIndices{F,S}()) - if !has_quadratic_constraint_caches(model) - return inner_index - end - - cache_map_check = quadratic_constraint_cache_map_check(mode, inner_index) - return inner_index[cache_map_check] +) where {S,F} + list = collect(values(model.constraint_outer_to_inner[F, S])) + sort!(list, lt = (x, y) -> (x.value < y.value)) + return list end -function MOI.get( - model::Optimizer, - ::MOI.ListOfConstraintIndices{F,S}, -) where {S<:MOI.AbstractSet,F<:MOI.ScalarQuadraticFunction{T}} where {T} - inner_index = MOI.ConstraintIndex{F,S}[] - if MOI.supports_constraint(model.optimizer, F, S) - inner_index = - MOI.get(model.optimizer, MOI.ListOfConstraintIndices{F,S}()) - end - if !has_quadratic_constraint_caches(model) - return inner_index - end - - for key in keys(model.quadratic_outer_to_inner) - push!(inner_index, key) - end - - return inner_index +function MOI.get(model::Optimizer, ::MOI.NumberOfConstraints{F,S}) where {S,F} + return length(model.constraint_outer_to_inner[F, S]) end -function MOI.supports_add_constrained_variable(::Optimizer, ::Type{Parameter}) +function MOI.supports_add_constrained_variable( + ::Optimizer{T}, + ::Type{MOI.Parameter{T}}, +) where {T} return true end @@ -834,18 +777,36 @@ function MOI.add_variable(model::Optimizer) ) end -function MOI.add_constrained_variable(model::Optimizer, set::Parameter) +function MOI.add_constrained_variable( + model::Optimizer{T}, + set::MOI.Parameter{T}, +) where {T} next_parameter_index!(model) p = MOI.VariableIndex(model.last_parameter_index_added) - MOI.Utilities.CleverDicts.add_item(model.parameters, set.val) - cp = MOI.ConstraintIndex{MOI.VariableIndex,Parameter}( + MOI.Utilities.CleverDicts.add_item(model.parameters, set.value) + cp = MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}( model.last_parameter_index_added, ) + _add_to_constraint_map!(model, cp) MOI.Utilities.CleverDicts.add_item(model.updated_parameters, NaN) update_number_of_parameters!(model) return p, cp end +function _add_to_constraint_map!(model::Optimizer, ci) + model.constraint_outer_to_inner[ci] = ci + return +end +function _add_to_constraint_map!(model::Optimizer, ci_in, ci_out) + model.constraint_outer_to_inner[ci_out] = ci_in + return +end +function _add_constraint_direct_and_cache_map!(model::Optimizer, f, set) + ci = MOI.add_constraint(model.optimizer, f, set) + _add_to_constraint_map!(model, ci) + return ci +end + function MOI.add_constraint( model::Optimizer, f::MOI.VariableIndex, @@ -856,7 +817,7 @@ function MOI.add_constraint( elseif !is_variable_in_model(model, f) error("Variable not in the model") end - return MOI.add_constraint(model.optimizer, f, set) + return _add_constraint_direct_and_cache_map!(model, f, set) end function add_constraint_with_parameters_on_function( @@ -902,7 +863,7 @@ function add_saf_constraint( model.last_affine_added, ) model.affine_outer_to_inner[outer_ci] = inner_ci - # model.outer_to_inner_map[outer_ci] = inner_ci + model.constraint_outer_to_inner[outer_ci] = inner_ci model.affine_constraint_cache[inner_ci] = pf model.affine_constraint_cache_set[inner_ci] = set return outer_ci @@ -924,7 +885,7 @@ function add_vi_constraint( model.last_affine_added, ) model.affine_outer_to_inner[outer_ci] = inner_ci - # model.outer_to_inner_map[outer_ci] = inner_ci + model.constraint_outer_to_inner[outer_ci] = inner_ci model.affine_constraint_cache[inner_ci] = pf model.affine_constraint_cache_set[inner_ci] = set return outer_ci @@ -936,7 +897,7 @@ function MOI.add_constraint( set::MOI.AbstractScalarSet, ) where {T} if !function_has_parameters(f) - return MOI.add_constraint(model.optimizer, f, set) + return _add_constraint_direct_and_cache_map!(model, f, set) else return add_constraint_with_parameters_on_function(model, f, set) end @@ -990,16 +951,32 @@ function MOI.get( end function MOI.set( - model::Optimizer, + model::Optimizer{T}, ::MOI.ConstraintSet, - cp::MOI.ConstraintIndex{MOI.VariableIndex,Parameter}, - set::Parameter, -) + cp::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}, + set::MOI.Parameter{T}, +) where {T} p = MOI.VariableIndex(cp.value) if !is_parameter_in_model(model, p) error("Parameter not in the model") end - return model.updated_parameters[p_idx(p)] = set.val + return model.updated_parameters[p_idx(p)] = set.value +end + +function MOI.get( + model::Optimizer{T}, + ::MOI.ConstraintSet, + cp::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}, +) where {T} + p = MOI.VariableIndex(cp.value) + if !is_parameter_in_model(model, p) + error("Parameter not in the model") + end + val = model.updated_parameters[p_idx(p)] + if isnan(val) + return MOI.Parameter{T}(model.parameters[p_idx(p)]) + end + return MOI.Parameter{T}(val) end """ @@ -1026,8 +1003,9 @@ function MOI.set( var::MOI.VariableIndex, val::Float64, ) - ci = MOI.ConstraintIndex{MOI.VariableIndex,Parameter}(var.value) - set = MOI.set(opt, MOI.ConstraintSet(), ci, Parameter(val)) + ci = + MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{Float64}}(var.value) + set = MOI.set(opt, MOI.ConstraintSet(), ci, MOI.Parameter(val)) return nothing end @@ -1037,8 +1015,9 @@ function MOI.set( var::MOI.VariableIndex, val::Float64, ) - ci = MOI.ConstraintIndex{MOI.VariableIndex,Parameter}(var.value) - set = MOI.set(model, MOI.ConstraintSet(), ci, Parameter(val)) + ci = + MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{Float64}}(var.value) + set = MOI.set(model, MOI.ConstraintSet(), ci, MOI.Parameter(val)) return nothing end @@ -1065,9 +1044,10 @@ function MOI.get( ::ParameterValue, var::MOI.VariableIndex, ) - ci = MOI.ConstraintIndex{MOI.VariableIndex,Parameter}(var.value) + ci = + MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{Float64}}(var.value) set = MOI.get(opt, MOI.ConstraintSet(), ci) - return set.val + return set.value end function MOI.get(model::Optimizer, ::ParameterValue, var::MOI.VariableIndex) @@ -1256,7 +1236,7 @@ function MOI.add_constraint( if function_has_parameters(f) error("VectorOfVariables does not allow parameters") end - return MOI.add_constraint(model.optimizer, f, set) + return _add_constraint_direct_and_cache_map!(model, f, set) end function MOI.add_constraint( @@ -1265,7 +1245,7 @@ function MOI.add_constraint( set::MOI.AbstractVectorSet, ) where {T} if !function_has_parameters(f) - return MOI.add_constraint(model.optimizer, f, set) + return _add_constraint_direct_and_cache_map!(model, f, set) else return add_constraint_with_parameters_on_function(model, f, set) end @@ -1281,6 +1261,7 @@ function add_constraint_with_parameters_on_function( update_cache!(pf, model) inner_ci = MOI.add_constraint(model.optimizer, current_function(pf), set) model.vector_affine_constraint_cache[inner_ci] = pf + _add_to_constraint_map!(model, inner_ci) return inner_ci end @@ -1307,7 +1288,7 @@ function add_constraint_with_parameters_on_function( model.last_quad_add_added, ) model.quadratic_outer_to_inner[outer_ci] = inner_ci - # model.outer_to_inner_map[outer_ci] = inner_ci + model.constraint_outer_to_inner[outer_ci] = inner_ci else fa = MOI.ScalarAffineFunction(func.affine_terms, func.constant) inner_ci = MOI.Utilities.normalize_and_add_constraint( @@ -1322,7 +1303,7 @@ function add_constraint_with_parameters_on_function( # This part is used to remember that ci came from a quadratic function # It is particularly useful because sometimes the constraint mutates model.quadratic_outer_to_inner[outer_ci] = inner_ci - # model.outer_to_inner_map[outer_ci] = inner_ci + model.constraint_outer_to_inner[outer_ci] = inner_ci end model.quadratic_constraint_cache[inner_ci] = pf model.quadratic_constraint_cache_set[inner_ci] = s @@ -1335,7 +1316,7 @@ function MOI.add_constraint( set::MOI.AbstractScalarSet, ) where {T} if !function_has_parameters(f) - return MOI.add_constraint(model.optimizer, f, set) + return _add_constraint_direct_and_cache_map!(model, f, set) else return add_constraint_with_parameters_on_function(model, f, set) end @@ -1345,6 +1326,54 @@ function MOI.delete(model::Optimizer, v::MOI.VariableIndex) delete!(model.variables, v) MOI.delete(model.optimizer, v) MOI.delete(model.original_objective_cache, v) + # TODO - what happens if the variable was in a SAF that was converted to bounds? + # solution: do not allow if that is the case (requires going trhought the scalar affine cache) + # TODO - deleting a variable also deletes constraints + for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys( + model.constraint_outer_to_inner, + ) + _delete_variable_index_constraint( + model.constraint_outer_to_inner, + F, + S, + v.value, + ) + end + return +end + +function _delete_variable_index_constraint(d, F, S, v) + return +end +function _delete_variable_index_constraint( + d, + F::Type{MOI.VariableIndex}, + S, + value, +) + inner = d[F, S] + for k in keys(inner) + if k.value == value + delete!(inner, k) + end + end + return +end + +function MOI.delete( + model::Optimizer, + c::MOI.ConstraintIndex{F,S}, +) where {F<:MOI.ScalarQuadraticFunction,S<:MOI.AbstractSet} + if haskey(model.quadratic_outer_to_inner, c) + ci_inner = model.quadratic_outer_to_inner[c] + deleteat!(model.quadratic_outer_to_inner, c) + deleteat!(model.quadratic_constraint_cache, c) + deleteat!(model.quadratic_constraint_cache_set, c) + MOI.delete(model.optimizer, ci_inner) + else + MOI.delete(model.optimizer, c) + end + deleteat!(model.constraint_outer_to_inner, c) return end @@ -1352,10 +1381,16 @@ function MOI.delete( model::Optimizer, c::MOI.ConstraintIndex{F,S}, ) where {F<:MOI.ScalarAffineFunction,S<:MOI.AbstractSet} - if haskey(model.affine_constraint_cache, c) + if haskey(model.affine_outer_to_inner, c) + ci_inner = model.affine_outer_to_inner[c] + delete!(model.affine_outer_to_inner, c) delete!(model.affine_constraint_cache, c) + delete!(model.affine_constraint_cache_set, c) + MOI.delete(model.optimizer, ci_inner) + else + MOI.delete(model.optimizer, c) end - MOI.delete(model.optimizer, c) + delete!(model.constraint_outer_to_inner, c) return end @@ -1364,6 +1399,7 @@ function MOI.delete( c::MOI.ConstraintIndex{F,S}, ) where {F<:Union{MOI.VariableIndex,MOI.VectorOfVariables},S<:MOI.AbstractSet} MOI.delete(model.optimizer, c) + delete!(model.constraint_outer_to_inner, c) return end @@ -1372,6 +1408,7 @@ function MOI.delete( c::MOI.ConstraintIndex{F,S}, ) where {F<:MOI.VectorAffineFunction,S<:MOI.AbstractSet} MOI.delete(model.optimizer, c) + delete!(model.constraint_outer_to_inner, c) deleteat!(model.vector_affine_constraint_cache, c) return end @@ -1533,13 +1570,14 @@ function _poi_default_copy_to(dest::T, src::MOI.ModelLike) where {T} Any[ MOI.get(src, MOI.ListOfConstraintIndices{F,S}()) for (F, S) in MOI.get(src, MOI.ListOfConstraintTypesPresent()) if - MOI.Utilities._is_variable_function(F) && S != Parameter + MOI.Utilities._is_variable_function(F) && + S != MOI.Parameter{Float64} ], Any[MOI.Utilities._try_constrain_variables_on_creation( dest, src, index_map, - Parameter, + MOI.Parameter{Float64}, )], ) else diff --git a/src/duals.jl b/src/duals.jl index 7c2140b1..0a74646f 100644 --- a/src/duals.jl +++ b/src/duals.jl @@ -107,10 +107,14 @@ struct ParameterDual <: MOI.AbstractVariableAttribute end MOI.is_set_by_optimize(::ParametricOptInterface.ParameterDual) = true -function MOI.get(model::Optimizer, ::ParameterDual, v::MOI.VariableIndex) +function MOI.get( + model::Optimizer{T}, + ::ParameterDual, + v::MOI.VariableIndex, +) where {T} if !is_additive( model, - MOI.ConstraintIndex{MOI.VariableIndex,Parameter}(v.value), + MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}(v.value), ) error("Cannot compute the dual of a multiplicative parameter") end @@ -118,10 +122,10 @@ function MOI.get(model::Optimizer, ::ParameterDual, v::MOI.VariableIndex) end function MOI.get( - model::Optimizer, + model::Optimizer{T}, ::MOI.ConstraintDual, - cp::MOI.ConstraintIndex{MOI.VariableIndex,Parameter}, -) + cp::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}, +) where {T} if !is_additive(model, cp) error("Cannot compute the dual of a multiplicative parameter") end diff --git a/test/jump_tests.jl b/test/jump_tests.jl index b99a1696..2dd27999 100644 --- a/test/jump_tests.jl +++ b/test/jump_tests.jl @@ -7,9 +7,9 @@ function test_jump_direct_affine_parameters() optimizer = POI.Optimizer(GLPK.Optimizer()) model = direct_model(optimizer) @variable(model, x[i = 1:2] >= 0) - @variable(model, y in POI.Parameter(0)) - @variable(model, w in POI.Parameter(0)) - @variable(model, z in POI.Parameter(0)) + @variable(model, y in MOI.Parameter(0.0)) + @variable(model, w in MOI.Parameter(0.0)) + @variable(model, z in MOI.Parameter(0.0)) @constraint(model, 2 * x[1] + x[2] + y <= 4) @constraint(model, 1 * x[1] + 2 * x[2] + z <= 4) @objective(model, Max, 4 * x[1] + 3 * x[2] + w) @@ -30,9 +30,9 @@ function test_jump_direct_parameter_times_variable() optimizer = POI.Optimizer(GLPK.Optimizer()) model = direct_model(optimizer) @variable(model, x[i = 1:2] >= 0) - @variable(model, y in POI.Parameter(0)) - @variable(model, w in POI.Parameter(0)) - @variable(model, z in POI.Parameter(0)) + @variable(model, y in MOI.Parameter(0.0)) + @variable(model, w in MOI.Parameter(0.0)) + @variable(model, z in MOI.Parameter(0.0)) @constraint(model, 2 * x[1] + x[2] + y <= 4) @constraint(model, (1 + y) * x[1] + 2 * x[2] + z <= 4) @objective(model, Max, 4 * x[1] + 3 * x[2] + w) @@ -52,9 +52,9 @@ end function test_jump_affine_parameters() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) @variable(model, x[i = 1:2] >= 0) - @variable(model, y in POI.Parameter(0)) - @variable(model, w in POI.Parameter(0)) - @variable(model, z in POI.Parameter(0)) + @variable(model, y in MOI.Parameter(0.0)) + @variable(model, w in MOI.Parameter(0.0)) + @variable(model, z in MOI.Parameter(0.0)) @constraint(model, 2 * x[1] + x[2] + y <= 4) @constraint(model, 1 * x[1] + 2 * x[2] + z <= 4) @objective(model, Max, 4 * x[1] + 3 * x[2] + w) @@ -74,9 +74,9 @@ end function test_jump_parameter_times_variable() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) @variable(model, x[i = 1:2] >= 0) - @variable(model, y in POI.Parameter(0)) - @variable(model, w in POI.Parameter(0)) - @variable(model, z in POI.Parameter(0)) + @variable(model, y in MOI.Parameter(0.0)) + @variable(model, w in MOI.Parameter(0.0)) + @variable(model, z in MOI.Parameter(0.0)) @test MOI.get(model, POI.ParameterValue(), y) == 0 @constraint(model, 2 * x[1] + x[2] + y <= 4) @constraint(model, (1 + y) * x[1] + 2 * x[2] + z <= 4) @@ -104,7 +104,7 @@ function test_jump_constraintfunction_getter() ), ) vx = @variable(model, x[i = 1:2]) - vp = @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + vp = @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) c1 = @constraint(model, con, sum(x) + sum(p) >= 1) c2 = @constraint(model, conq, sum(x .* p) >= 1) c3 = @constraint(model, conqa, sum(x .* p) + x[1]^2 + x[1] + p[1] >= 1) @@ -255,19 +255,24 @@ function test_jump_interpret_parameteric_bounds() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i]) @objective(model, Min, sum(x)) optimize!(model) - @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - Tuple{Type,Type}[ + expected = Tuple{Type,Type}[ (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}), - (MOI.VariableIndex, POI.Parameter), + (MOI.VariableIndex, MOI.Parameter{Float64}), ] - @test MOI.get( + result = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) + expected = Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + result = MOI.get( backend(model).optimizer.model.optimizer, MOI.ListOfConstraintTypesPresent(), - ) == Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + ) + @test Set(result) == Set(expected) + @test length(result) == length(expected) @test objective_value(model) == -2 MOI.set(model, POI.ParameterValue(), p[1], 4.0) optimize!(model) @@ -279,19 +284,24 @@ function test_jump_interpret_parameteric_bounds_expression() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i] + p[1]) @objective(model, Min, sum(x)) optimize!(model) - @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - Tuple{Type,Type}[ + expected = Tuple{Type,Type}[ (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}), - (MOI.VariableIndex, POI.Parameter), + (MOI.VariableIndex, MOI.Parameter{Float64}), ] - @test MOI.get( + result = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) + expected = Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + result = MOI.get( backend(model).optimizer.model.optimizer, MOI.ListOfConstraintTypesPresent(), - ) == Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + ) + @test Set(result) == Set(expected) + @test length(result) == length(expected) @test objective_value(model) == -4 MOI.set(model, POI.ParameterValue(), p[1], 4.0) optimize!(model) @@ -303,16 +313,22 @@ function test_jump_direct_interpret_parameteric_bounds() model = direct_model(POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i]) @objective(model, Min, sum(x)) optimize!(model) - @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] - @test MOI.get( - backend(model).optimizer, - MOI.ListOfConstraintTypesPresent(), - ) == Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + expected = Tuple{Type,Type}[ + (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}), + (MOI.VariableIndex, MOI.Parameter{Float64}), + ] + result = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) + expected = Tuple{Type,Type}[(MOI.VariableIndex, MOI.GreaterThan{Float64})] + result = + MOI.get(backend(model).optimizer, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) @test objective_value(model) == -2 MOI.set(model, POI.ParameterValue(), p[1], 4.0) optimize!(model) @@ -324,22 +340,25 @@ function test_jump_direct_interpret_parameteric_bounds_no_interpretation() model = direct_model(POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i]) @objective(model, Min, sum(x)) optimize!(model) - @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == - Tuple{Type,Type}[( - MOI.ScalarAffineFunction{Float64}, - MOI.GreaterThan{Float64}, - )] - @test MOI.get( - backend(model).optimizer, - MOI.ListOfConstraintTypesPresent(), - ) == Tuple{Type,Type}[( + expected = Tuple{Type,Type}[ + (MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}), + (MOI.VariableIndex, MOI.Parameter{Float64}), + ] + result = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) + expected = Tuple{Type,Type}[( MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}, - )] + ),] + result = + MOI.get(backend(model).optimizer, MOI.ListOfConstraintTypesPresent()) + @test Set(result) == Set(expected) + @test length(result) == length(expected) @test objective_value(model) == -2 MOI.set(model, POI.ParameterValue(), p[1], 4.0) optimize!(model) @@ -351,7 +370,7 @@ function test_jump_direct_interpret_parameteric_bounds_change() model = direct_model(POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i]) @test_throws ErrorException @constraint(model, [i in 1:2], 2x[i] >= p[i]) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_CONSTRAINTS) @@ -369,7 +388,7 @@ function test_jump_direct_interpret_parameteric_bounds_both() model = direct_model(POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.BOUNDS_AND_CONSTRAINTS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @constraint(model, [i in 1:2], x[i] >= p[i]) @constraint(model, [i in 1:2], 2x[i] >= p[i]) @objective(model, Min, sum(x)) @@ -385,7 +404,7 @@ function test_jump_direct_interpret_parameteric_bounds_invalid() model = direct_model(POI.Optimizer(GLPK.Optimizer())) MOI.set(model, POI.ConstraintsInterpretation(), POI.ONLY_BOUNDS) @variable(model, x[i = 1:2]) - @variable(model, p[i = 1:2] in POI.Parameter.(-1)) + @variable(model, p[i = 1:2] in MOI.Parameter.(-1.0)) @test_throws ErrorException @constraint( model, [i in 1:2], @@ -405,7 +424,7 @@ function test_jump_set_variable_start_value() optimizer = POI.Optimizer(cached) model = direct_model(optimizer) @variable(model, x >= 0) - @variable(model, p in POI.Parameter(0)) + @variable(model, p in MOI.Parameter(0.0)) set_start_value(x, 1.0) @test start_value(x) == 1 err = ErrorException( @@ -420,7 +439,7 @@ function test_jump_direct_get_parameter_value() model = direct_model(POI.Optimizer(GLPK.Optimizer())) @variable(model, x, lower_bound = 0.0, upper_bound = 10.0) @variable(model, y, binary = true) - @variable(model, z, set = POI.Parameter(10)) + @variable(model, z, set = MOI.Parameter(10.0)) c = @constraint(model, 19.0 * x - z + 22.0 * y <= 1.0) @objective(model, Min, x + y) @test MOI.get(model, POI.ParameterValue(), z) == 10 @@ -431,7 +450,7 @@ function test_jump_get_parameter_value() model = Model(() -> ParametricOptInterface.Optimizer(GLPK.Optimizer())) @variable(model, x, lower_bound = 0.0, upper_bound = 10.0) @variable(model, y, binary = true) - @variable(model, z, set = POI.Parameter(10)) + @variable(model, z, set = MOI.Parameter(10)) c = @constraint(model, 19.0 * x - z + 22.0 * y <= 1.0) @objective(model, Min, x + y) @test MOI.get(model, POI.ParameterValue(), z) == 10 @@ -449,7 +468,7 @@ function test_jump_sdp_scalar_parameter() optimizer = POI.Optimizer(cached) m = direct_model(optimizer) set_silent(m) - @variable(m, p in POI.Parameter(0)) + @variable(m, p in MOI.Parameter(0.0)) @variable(m, x[1:2, 1:2], Symmetric) @objective(m, Min, x[1, 1] + x[2, 2]) @constraint(m, LinearAlgebra.Symmetric(x .- [1+p 0; 0 1+p]) in PSDCone()) @@ -473,7 +492,7 @@ function test_jump_sdp_matrix_parameter() m = direct_model(optimizer) set_silent(m) P1 = [1 2; 2 3] - @variable(m, p[1:2, 1:2] in POI.Parameter.(P1)) + @variable(m, p[1:2, 1:2] in MOI.Parameter.(P1)) @variable(m, x[1:2, 1:2], Symmetric) @objective(m, Min, x[1, 1] + x[2, 2]) @constraint(m, LinearAlgebra.Symmetric(x - p) in PSDCone()) @@ -488,7 +507,7 @@ end function test_jump_dual_basic() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, x[1:2] in POI.Parameter.(ones(2) .* 4.0)) + @variable(model, x[1:2] in MOI.Parameter.(ones(2) .* 4.0)) @variable(model, y[1:6]) @constraint(model, ctr1, 3 * y[1] >= 2 - 7 * x[1]) @objective(model, Min, 5 * y[1]) @@ -503,7 +522,7 @@ end function test_jump_dual_multiplicative_fail() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) @variable(model, x) - @variable(model, p in POI.Parameter(1.0)) + @variable(model, p in MOI.Parameter(1.0)) @constraint(model, cons, x * p >= 3) @objective(model, Min, 2x) optimize!(model) @@ -516,7 +535,7 @@ end function test_jump_dual_objective_min() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) @variable(model, x) - @variable(model, p in POI.Parameter(1.0)) + @variable(model, p in MOI.Parameter(1.0)) @constraint(model, cons, x >= 3 * p) @objective(model, Min, 2x + p) optimize!(model) @@ -527,7 +546,7 @@ end function test_jump_dual_objective_max() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) @variable(model, x) - @variable(model, p in POI.Parameter(1.0)) + @variable(model, p in MOI.Parameter(1.0)) @constraint(model, cons, x >= 3 * p) @objective(model, Max, -2x + p) optimize!(model) @@ -537,7 +556,7 @@ end function test_jump_dual_multiple_parameters_1() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, x[1:6] in POI.Parameter.(ones(6) .* 4.0)) + @variable(model, x[1:6] in MOI.Parameter.(ones(6) .* 4.0)) @variable(model, y[1:6]) @constraint(model, ctr1, 3 * y[1] >= 2 - 7 * x[3]) @constraint(model, ctr2, 3 * y[1] >= 2 - 7 * x[3]) @@ -571,7 +590,7 @@ end function test_jump_duals_LessThan() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(-1.0)) + @variable(model, α in MOI.Parameter(-1.0)) @variable(model, x) cref = @constraint(model, x ≤ α) @objective(model, Max, x) @@ -590,7 +609,7 @@ end function test_jump_duals_EqualTo() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(-1.0)) + @variable(model, α in MOI.Parameter(-1.0)) @variable(model, x) cref = @constraint(model, x == α) @objective(model, Max, x) @@ -608,7 +627,7 @@ end function test_jump_duals_GreaterThan() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(1.0)) + @variable(model, α in MOI.Parameter(1.0)) MOI.set(model, POI.ParameterValue(), α, -1.0) @variable(model, x) cref = @constraint(model, x >= α) @@ -627,7 +646,7 @@ end function test_jump_dual_multiple_parameters_2() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α[1:10] in POI.Parameter.(ones(10))) + @variable(model, α[1:10] in MOI.Parameter.(ones(10))) @variable(model, x) cref = @constraint(model, x == sum(2 * α[i] for i in 1:10)) @objective(model, Min, x) @@ -640,7 +659,7 @@ end function test_jump_dual_mixing_params_and_vars_1() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α[1:5] in POI.Parameter.(ones(5))) + @variable(model, α[1:5] in MOI.Parameter.(ones(5))) @variable(model, x) cref = @constraint(model, sum(x for i in 1:5) == sum(2 * α[i] for i in 1:5)) @objective(model, Min, x) @@ -653,7 +672,7 @@ end function test_jump_dual_mixing_params_and_vars_2() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α[1:5] in POI.Parameter.(ones(5))) + @variable(model, α[1:5] in MOI.Parameter.(ones(5))) @variable(model, x) cref = @constraint(model, 0.0 == sum(-x + 2 * α[i] for i in 1:5)) @objective(model, Min, x) @@ -666,7 +685,7 @@ end function test_jump_dual_mixing_params_and_vars_3() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α[1:5] in POI.Parameter.(ones(5))) + @variable(model, α[1:5] in MOI.Parameter.(ones(5))) @variable(model, x) cref = @constraint(model, 0.0 == sum(-x + 2.0 + 2 * α[i] for i in 1:5)) @objective(model, Min, x) @@ -679,7 +698,7 @@ end function test_jump_dual_add_after_solve() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(1.0)) + @variable(model, α in MOI.Parameter(1.0)) MOI.set(model, POI.ParameterValue(), α, -1.0) @variable(model, x) cref = @constraint(model, x <= α) @@ -688,7 +707,7 @@ function test_jump_dual_add_after_solve() @test JuMP.value(x) == -1.0 @test JuMP.dual(cref) == -1.0 @test MOI.get(model, POI.ParameterDual(), α) == -1.0 - @variable(model, b in POI.Parameter(-2.0)) + @variable(model, b in MOI.Parameter(-2.0)) cref = @constraint(model, x <= b) JuMP.optimize!(model) @test JuMP.value(x) == -2.0 @@ -700,7 +719,7 @@ end function test_jump_dual_add_ctr_alaternative() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(-1.0)) + @variable(model, α in MOI.Parameter(-1.0)) @variable(model, x) exp = x - α cref = @constraint(model, exp ≤ 0) @@ -714,7 +733,7 @@ end function test_jump_dual_delete_constraint() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, α in POI.Parameter(-1.0)) + @variable(model, α in MOI.Parameter(-1.0)) @variable(model, x) cref1 = @constraint(model, x ≤ α / 2) cref2 = @constraint(model, x ≤ α) @@ -749,7 +768,7 @@ function test_jump_nlp() model = Model(() -> POI_cached_optimizer()) @variable(model, x) @variable(model, y) - @variable(model, z in ParametricOptInterface.Parameter(10)) + @variable(model, z in MOI.Parameter(10.0)) @constraint(model, x + y >= z) @NLobjective(model, Min, x^2 + y^2) optimize!(model) @@ -764,7 +783,7 @@ function test_jump_nlp() MOI.set(ipopt, MOI.RawOptimizerAttribute("print_level"), 0) model = Model(() -> ParametricOptInterface.Optimizer(ipopt)) @variable(model, x) - @variable(model, z in ParametricOptInterface.Parameter(10)) + @variable(model, z in MOI.Parameter(10.0)) MOI.set( model, ParametricOptInterface.ConstraintsInterpretation(), @@ -803,7 +822,7 @@ function test_jump_direct_vector_parameter_affine_nonnegatives() set_silent(model) @variable(model, x) @variable(model, y) - @variable(model, t in POI.Parameter(5)) + @variable(model, t in MOI.Parameter(5.0)) @constraint(model, [(x - t + 1), (y - t + 2)...] in MOI.Nonnegatives(2)) @objective(model, Min, x + y) optimize!(model) @@ -839,7 +858,7 @@ function test_jump_direct_vector_parameter_affine_nonpositives() set_silent(model) @variable(model, x) @variable(model, y) - @variable(model, t in POI.Parameter(5)) + @variable(model, t in MOI.Parameter(5.0)) @constraint(model, [(-x + t - 1), (-y + t - 2)...] in MOI.Nonpositives(2)) @objective(model, Min, x + y) optimize!(model) @@ -881,7 +900,7 @@ function test_jump_direct_soc_parameters() @variable(model, x) @variable(model, y) @variable(model, t) - @variable(model, p in POI.Parameter(0)) + @variable(model, p in MOI.Parameter(0.0)) @constraint(model, [y - 1 / √2] in MOI.Nonnegatives(1)) @constraint(model, [t - 1] in MOI.Zeros(1)) @constraint(model, [t, (x - p), y...] in SecondOrderCone()) @@ -904,7 +923,7 @@ function test_jump_direct_qp_objective() MOI.set(model, MOI.Silent(), true) @variable(model, x >= 0) @variable(model, y >= 0) - @variable(model, p in POI.Parameter(1.0)) + @variable(model, p in MOI.Parameter(1.0)) @constraint(model, 2x + y <= 4) @constraint(model, x + 2y <= 4) @objective(model, Max, (x^2 + y^2) / 2) @@ -1003,7 +1022,7 @@ function test_jump_direct_rsoc_constraints() @variable(model, x) @variable(model, y) @variable(model, t) - @variable(model, p in POI.Parameter(0)) + @variable(model, p in MOI.Parameter(0.0)) @constraint(model, [y - 1 / √2] in MOI.Nonnegatives(1)) @constraint(model, [t - 1] in MOI.Zeros(1)) @constraint(model, [t, x, y - p] in RotatedSecondOrderCone()) @@ -1028,8 +1047,8 @@ function test_jump_quadratic_interval() MOI.set(model, MOI.Silent(), true) @variable(model, x >= 0) @variable(model, y >= 0) - @variable(model, p in POI.Parameter(10.0)) - @variable(model, q in POI.Parameter(4.0)) + @variable(model, p in MOI.Parameter(10.0)) + @variable(model, q in MOI.Parameter(4.0)) @constraint(model, 0 <= x - p * y + q <= 0) @objective(model, Min, x + y) optimize!(model) @@ -1062,8 +1081,8 @@ function test_jump_quadratic_interval_cached() # MOI.set(model, MOI.Silent(), true) @variable(model, x >= 0) @variable(model, y >= 0) - @variable(model, p in POI.Parameter(10.0)) - @variable(model, q in POI.Parameter(4.0)) + @variable(model, p in MOI.Parameter(10.0)) + @variable(model, q in MOI.Parameter(4.0)) @constraint(model, 0 <= x - p * y + q <= 0) @objective(model, Min, x + y) optimize!(model) @@ -1082,7 +1101,7 @@ end function test_affine_parametric_objective() model = Model(() -> POI.Optimizer(GLPK.Optimizer())) - @variable(model, p in POI.Parameter(1.0)) + @variable(model, p in MOI.Parameter(1.0)) @variable(model, 0 <= x <= 1) @objective(model, Max, (p + 0.5) * x) optimize!(model) diff --git a/test/moi_tests.jl b/test/moi_tests.jl index 8c9057ef..ef2cba31 100644 --- a/test/moi_tests.jl +++ b/test/moi_tests.jl @@ -16,9 +16,9 @@ function test_basic_tests() optimizer = POI.Optimizer(GLPK.Optimizer()) MOI.set(optimizer, MOI.Silent(), true) x = MOI.add_variables(optimizer, 2) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) z = MOI.VariableIndex(4) - cz = MOI.ConstraintIndex{MOI.VariableIndex,POI.Parameter}(4) + cz = MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{Float64}}(4) for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end @@ -59,12 +59,12 @@ function test_basic_tests() MOI.VariableIndex[MOI.VariableIndex(1), MOI.VariableIndex(2)] @test MOI.get(optimizer, POI.ListOfParameterIndices()) == POI.ParameterIndex[POI.ParameterIndex(1)] - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) @test_throws ErrorException("Parameter not in the model") MOI.set( optimizer, MOI.ConstraintSet(), cz, - POI.Parameter(1.0), + MOI.Parameter(1.0), ) MOI.optimize!(optimizer) @test MOI.get(optimizer, MOI.ObjectiveValue()) == 2 @@ -112,7 +112,7 @@ function test_basic_special_cases_of_getters() for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], x[1], y)) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], x[1], y)) @@ -286,7 +286,7 @@ function test_moi_ListOfConstraintTypesPresent() first.( MOI.add_constrained_variable.( model, - POI.Parameter.(ones(Int(N / 2))), + MOI.Parameter.(ones(Int(N / 2))), ), ) @@ -299,9 +299,13 @@ function test_moi_ListOfConstraintTypesPresent() ), MOI.GreaterThan(1.0), ) - list_ctrs_types = MOI.get(model, MOI.ListOfConstraintTypesPresent()) - @test list_ctrs_types == - [(MOI.ScalarQuadraticFunction{Float64}, MOI.GreaterThan{Float64})] + result = MOI.get(model, MOI.ListOfConstraintTypesPresent()) + expected = [ + (MOI.ScalarQuadraticFunction{Float64}, MOI.GreaterThan{Float64}), + (MOI.VariableIndex, MOI.Parameter{Float64}), + ] + @test Set(result) == Set(expected) + @test length(result) == length(expected) return end @@ -314,9 +318,9 @@ function test_production_problem_example() b2 = 4.0 x = MOI.add_variables(optimizer, length(c)) @test typeof(x[1]) == MOI.VariableIndex - w, cw = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + w, cw = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) @test MOI.get(optimizer, MOI.VariablePrimal(), w) == 0 for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) @@ -355,9 +359,9 @@ function test_production_problem_example() MOI.get(optimizer, MOI.VariablePrimal(), w) MOI.get(optimizer, MOI.VariablePrimal(), y) MOI.get(optimizer, MOI.VariablePrimal(), z) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(2.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(1.0)) MOI.optimize!(optimizer) @test MOI.get(optimizer, MOI.VariablePrimal(), w) == 2.0 @test MOI.get(optimizer, MOI.VariablePrimal(), y) == 1.0 @@ -367,14 +371,14 @@ function test_production_problem_example() @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cy), 5 / 3, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cz), 2 / 3, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cw), -3.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(0.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(0.0)) MOI.optimize!(optimizer) @test MOI.get(optimizer, MOI.VariablePrimal(), w) == 0.0 @test MOI.get(optimizer, MOI.VariablePrimal(), y) == 1.0 @test MOI.get(optimizer, MOI.VariablePrimal(), z) == 1.0 @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 7, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [1.0, 1.0] - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(-5.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(-5.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 12.0, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [3.0, 0.0] @@ -392,9 +396,9 @@ function test_production_problem_example_duals() b2 = 4.0 x = MOI.add_variables(optimizer, length(c)) @test typeof(x[1]) == MOI.VariableIndex - w, cw = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + w, cw = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) @test MOI.get(optimizer, MOI.VariablePrimal(), w) == 0 for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) @@ -440,23 +444,23 @@ function test_production_problem_example_duals() -0.5 * MOI.get(optimizer, MOI.ConstraintDual(), ci2), atol = 1e-4, ) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(2.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(1.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 7.0, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [0.0, 1.0] @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cy), 9.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cz), 0.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cw), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(0.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(0.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 3.0, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [0.0, 1.0] @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cy), 9.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cz), 0.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cw), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(-5.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(-5.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 14.0, atol = ATOL) @test ≈( @@ -485,9 +489,9 @@ function test_production_problem_example_parameters_for_duals_and_intervals() b2 = 4.0 x = MOI.add_variables(optimizer, length(c)) @test typeof(x[1]) == MOI.VariableIndex - w, cw = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + w, cw = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) @test MOI.get(optimizer, MOI.VariablePrimal(), w) == 0 for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) @@ -533,23 +537,23 @@ function test_production_problem_example_parameters_for_duals_and_intervals() -0.5 * MOI.get(optimizer, MOI.ConstraintDual(), ci2), atol = 1e-4, ) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(2.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(1.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 7.0, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [0.0, 1.0] @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cy), 9.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cz), 0.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cw), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(0.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(0.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 3.0, atol = ATOL) @test MOI.get.(optimizer, MOI.VariablePrimal(), x) == [0.0, 1.0] @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cy), 9.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cz), 0.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.ConstraintDual(), cw), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(-5.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(-5.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 14.0, atol = ATOL) @test ≈( @@ -581,7 +585,7 @@ function test_vector_parameter_affine_nonnegatives() MOI.set(model, MOI.Silent(), true) x = MOI.add_variable(model) y = MOI.add_variable(model) - t, ct = MOI.add_constrained_variable(model, POI.Parameter(5)) + t, ct = MOI.add_constrained_variable(model, MOI.Parameter(5.0)) A = [1.0 0 -1; 0 1 -1] b = [1.0; 2] terms = @@ -640,7 +644,7 @@ function test_vector_parameter_affine_nonpositives() MOI.set(model, MOI.Silent(), true) x = MOI.add_variable(model) y = MOI.add_variable(model) - t, ct = MOI.add_constrained_variable(model, POI.Parameter(5)) + t, ct = MOI.add_constrained_variable(model, MOI.Parameter(5.0)) A = [-1.0 0 1; 0 -1 1] b = [-1.0; -2] terms = @@ -703,7 +707,7 @@ function test_vector_soc_parameters() model = POI.Optimizer(cached) MOI.set(model, MOI.Silent(), true) x, y, t = MOI.add_variables(model, 3) - p, cp = MOI.add_constrained_variable(model, POI.Parameter(0)) + p, cp = MOI.add_constrained_variable(model, MOI.Parameter(0.0)) MOI.set( model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), @@ -911,7 +915,7 @@ function test_qp_parameter_in_affine_constraint() G = [2.0 3.0 1.0; 1.0 1.0 1.0] h = [4.0; 3.0] x = MOI.add_variables(optimizer, 2) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] for i in 1:2 for j in i:2 # indexes (i,j), (j,i) will be mirrored. specify only one kind @@ -943,7 +947,7 @@ function test_qp_parameter_in_affine_constraint() @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 12.5, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 5.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[2]), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 5.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 3.0, atol = ATOL) @@ -962,8 +966,8 @@ function test_qp_parameter_in_quadratic_constraint() G = [2.0 3.0 1.0 0.0; 1.0 1.0 0.0 1.0] h = [4.0; 3.0] x = MOI.add_variables(optimizer, 2) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - w, cw = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + w, cw = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] for i in 1:2 for j in i:2 # indexes (i,j), (j,i) will be mirrored. specify only one kind @@ -1001,8 +1005,8 @@ function test_qp_parameter_in_quadratic_constraint() @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 12.5, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 5.0, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[2]), -2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cw, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cw, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 5.7142, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 2.1428, atol = ATOL) @@ -1027,7 +1031,7 @@ function test_qp_variable_times_variable_plus_parameter() for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], x[1], x[1])) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], x[1], x[2])) @@ -1056,7 +1060,7 @@ function test_qp_variable_times_variable_plus_parameter() -MOI.get(optimizer, MOI.ConstraintDual(), cons_index), atol = ATOL, ) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 8.6609, atol = ATOL) return @@ -1075,7 +1079,7 @@ function test_qp_variable_times_variable_plus_parameter_duals() for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], x[1], x[1])) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], x[1], x[2])) @@ -1106,7 +1110,7 @@ function test_qp_variable_times_variable_plus_parameter_duals() -2 * MOI.get(optimizer, MOI.ConstraintDual(), cons_index), atol = ATOL, ) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 8.2376, atol = ATOL) return @@ -1126,7 +1130,7 @@ function test_qp_parameter_times_variable() MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end MOI.add_constraint(optimizer, x[1], MOI.LessThan(20.0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], x[1], x[1])) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], x[1], y)) @@ -1149,7 +1153,7 @@ function test_qp_parameter_times_variable() @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 30.25, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 0.5, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[2]), 29.25, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 22.0, atol = ATOL) return @@ -1169,7 +1173,7 @@ function test_qp_variable_times_parameter() MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end MOI.add_constraint(optimizer, x[1], MOI.LessThan(20.0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[2, 2], y, y)) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], y, x[1])) @@ -1192,7 +1196,7 @@ function test_qp_variable_times_parameter() @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 30.25, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 0.5, atol = ATOL) @test ≈(MOI.get(optimizer, MOI.VariablePrimal(), x[2]), 29.25, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test ≈(MOI.get(optimizer, MOI.ObjectiveValue()), 22.0, atol = ATOL) return @@ -1212,8 +1216,8 @@ function test_qp_parameter_times_parameter() MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end MOI.add_constraint(optimizer, x[1], MOI.LessThan(20.0)) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], y, y)) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], y, z)) @@ -1244,14 +1248,14 @@ function test_qp_parameter_times_parameter() 10.0, atol = ATOL, ) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 42.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(1.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 36.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(-1.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(-1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(-1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(-1.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 45.0, atol = ATOL) return @@ -1268,7 +1272,7 @@ function test_qp_quadratic_constant() G = [2.0 3.0; 1.0 1.0] h = [4.0; 3.0] x = MOI.add_variables(optimizer, 2) - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(0)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] for i in 1:2 for j in i:2 # indexes (i,j), (j,i) will be mirrored. specify only one kind @@ -1311,7 +1315,7 @@ function test_qp_quadratic_constant() -2.0, atol = ATOL, ) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(1.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(1.0)) MOI.optimize!(optimizer) # @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 5.7142, atol = ATOL) # @test isapprox.(MOI.get(optimizer, MOI.VariablePrimal(), x[1]), 2.1428, atol = ATOL) @@ -1330,8 +1334,8 @@ function test_qp_objective_parameter_times_parameter() for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(1)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(1)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(1.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(1.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(1.0, y, z)) objective_function = MOI.ScalarQuadraticFunction( @@ -1356,10 +1360,10 @@ function test_qp_objective_parameter_times_parameter() ErrorException("Cannot compute the dual of a multiplicative parameter") @test_throws err MOI.get(optimizer, MOI.ConstraintDual(), cy) @test_throws err MOI.get(optimizer, MOI.ConstraintDual(), cz) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 2.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(3.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(3.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 6.0, atol = ATOL) MOI.set(optimizer, POI.ParameterValue(), y, 5) @@ -1386,8 +1390,8 @@ function test_qp_objective_affine_parameter() for x_i in x MOI.add_constraint(optimizer, x_i, MOI.GreaterThan(0.0)) end - y, cy = MOI.add_constrained_variable(optimizer, POI.Parameter(1)) - z, cz = MOI.add_constrained_variable(optimizer, POI.Parameter(1)) + y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(1.0)) + z, cz = MOI.add_constrained_variable(optimizer, MOI.Parameter(1.0)) quad_terms = MOI.ScalarQuadraticTerm{Float64}[] push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 1], x[1], x[1])) push!(quad_terms, MOI.ScalarQuadraticTerm(A[1, 2], x[1], x[2])) @@ -1410,14 +1414,14 @@ function test_qp_objective_affine_parameter() 0, atol = ATOL, ) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(2.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(2.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 5.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(3.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(3.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 7.0, atol = ATOL) - MOI.set(optimizer, MOI.ConstraintSet(), cy, POI.Parameter(5.0)) - MOI.set(optimizer, MOI.ConstraintSet(), cz, POI.Parameter(5.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cy, MOI.Parameter(5.0)) + MOI.set(optimizer, MOI.ConstraintSet(), cz, MOI.Parameter(5.0)) MOI.optimize!(optimizer) @test isapprox(MOI.get(optimizer, MOI.ObjectiveValue()), 15.0, atol = ATOL) return @@ -1429,7 +1433,7 @@ function test_qp_objective_parameter_in_quadratic_part() x = MOI.add_variable(model) y = MOI.add_variable(model) z = MOI.add_variable(model) - p = first(MOI.add_constrained_variable.(model, POI.Parameter(1.0))) + p = first(MOI.add_constrained_variable.(model, MOI.Parameter(1.0))) MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) MOI.add_constraint(model, y, MOI.GreaterThan(0.0)) cons1 = @@ -1479,7 +1483,7 @@ function test_qp_objective_parameter_in_quadratic_part() MOI.set(model, MOI.Silent(), true) x = MOI.add_variable(model) y = MOI.add_variable(model) - p = first(MOI.add_constrained_variable.(model, POI.Parameter(1.0))) + p = first(MOI.add_constrained_variable.(model, MOI.Parameter(1.0))) MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) MOI.add_constraint(model, y, MOI.GreaterThan(0.0)) cons1 = @@ -1517,7 +1521,7 @@ function test_qp_objective_parameter_in_quadratic_part() MOI.set(model, MOI.Silent(), true) x = MOI.add_variable(model) y = MOI.add_variable(model) - p = first(MOI.add_constrained_variable.(model, POI.Parameter(1.0))) + p = first(MOI.add_constrained_variable.(model, MOI.Parameter(1.0))) MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) MOI.add_constraint(model, y, MOI.GreaterThan(0.0)) cons1 = @@ -1543,7 +1547,7 @@ function test_qp_objective_parameter_in_quadratic_part() MOI.set(model, MOI.Silent(), true) x = MOI.add_variable(model) y = MOI.add_variable(model) - p = first(MOI.add_constrained_variable.(model, POI.Parameter(1.0))) + p = first(MOI.add_constrained_variable.(model, MOI.Parameter(1.0))) MOI.add_constraint(model, x, MOI.GreaterThan(0.0)) MOI.add_constraint(model, y, MOI.GreaterThan(0.0)) cons1 =