File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,14 @@ function MOI.add_constrained_variable(
165165 return p, ci
166166end
167167
168+ function MOI. is_valid (
169+ model:: Optimizer ,
170+ ci:: MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{Float64}} ,
171+ )
172+ p = MOI. VariableIndex (ci. value)
173+ return haskey (model. parameters, p)
174+ end
175+
168176function MOI. set (
169177 model:: Optimizer ,
170178 :: MOI.ConstraintSet ,
Original file line number Diff line number Diff line change @@ -336,6 +336,16 @@ function test_parameter_number_of_variables()
336336 return
337337end
338338
339+ function test_parameter_is_valid ()
340+ model = Ipopt. Optimizer ()
341+ p, ci = MOI. add_constrained_variable (model, MOI. Parameter (2.0 ))
342+ @test MOI. is_valid (model, p)
343+ @test MOI. is_valid (model, ci)
344+ @test ! MOI. is_valid (model, typeof (p)(p. value + 1 ))
345+ @test ! MOI. is_valid (model, typeof (ci)(ci. value + 1 ))
346+ return
347+ end
348+
339349function test_parameter_list_of_variable_indices ()
340350 model = Ipopt. Optimizer ()
341351 x = MOI. add_variable (model)
You can’t perform that action at this time.
0 commit comments