diff --git a/src/QCQP/MOI_wrapper.jl b/src/QCQP/MOI_wrapper.jl index 2b14c7d..c305b7e 100644 --- a/src/QCQP/MOI_wrapper.jl +++ b/src/QCQP/MOI_wrapper.jl @@ -56,6 +56,14 @@ end MOI.add_variable(model::Optimizer) = MOI.add_variable(model.model) +function MOI.set(model::Optimizer, attr::MOI.AbstractVariableAttribute, vi::MOI.VariableIndex, value) + return MOI.set(model.model, attr, vi, value) +end + +function MOI.get(model::Optimizer, attr::MOI.AbstractVariableAttribute, vi::MOI.VariableIndex) + return MOI.get(model.model, attr, vi) +end + function MOI.supports_add_constrained_variable( model::Optimizer, ::Type{S}, diff --git a/test/qcqp.jl b/test/qcqp.jl index 6f48007..e0c0c2d 100644 --- a/test/qcqp.jl +++ b/test/qcqp.jl @@ -215,6 +215,20 @@ function test_scalar_nonlinear_function(x, y, T) return end +function test_variable_primal(x, y, T) + inner = Model{T}() + optimizer = MOI.Utilities.MockOptimizer(inner) + model = PolyJuMP.JuMP.direct_generic_model( + T, + PolyJuMP.QCQP.Optimizer{T}(optimizer), + ) + PolyJuMP.@variable(model, 1 <= a <= 3) + MOI.set(model, MOI.VariablePrimal(), a, T(2)) + MOI.set(model, MOI.TerminationStatus(), MOI.OPTIMAL) + @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL + @test PolyJuMP.value(a) == 2 +end + function runtests(x, y) for name in names(@__MODULE__; all = true) if startswith("$name", "test_")