Skip to content

Commit

Permalink
Fix NLPBlockDualStart and tidy MOI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 3, 2023
1 parent 149c8b6 commit d0d1695
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 44 deletions.
9 changes: 6 additions & 3 deletions src/MOI_wrapper/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ end

MOI.supports(::Optimizer, ::MOI.NLPBlockDualStart) = true

# TODO: FIXME
function MOI.set(model::Optimizer, ::MOI.NLPBlockDualStart, values)
# @assert length(values) == length(model.nlp_index_cons)
KN_set_con_dual_init_values(model.inner, Cint[0], values)
KN_set_con_dual_init_values(
model.inner,
length(model.nlp_index_cons),
model.nlp_index_cons,
values,
)
return
end
49 changes: 8 additions & 41 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
module TestMOIWrapper

using Test
using KNITRO

const MOI = KNITRO.MOI
import KNITRO
import MathOptInterface as MOI

function runtests()
for name in names(@__MODULE__; all=true)
Expand All @@ -22,38 +22,22 @@ function runtests()
end

function test_MOI_Test_cached()
second_order_exclude = String[
"test_conic_GeometricMeanCone_VectorAffineFunction",
"test_conic_GeometricMeanCone_VectorAffineFunction_2",
"test_conic_GeometricMeanCone_VectorOfVariables",
"test_conic_GeometricMeanCone_VectorOfVariables_2",
"test_conic_RotatedSecondOrderCone_INFEASIBLE_2",
"test_conic_RotatedSecondOrderCone_VectorAffineFunction",
"test_conic_RotatedSecondOrderCone_VectorOfVariables",
"test_conic_RotatedSecondOrderCone_out_of_order",
"test_conic_SecondOrderCone_Nonpositives",
"test_conic_SecondOrderCone_Nonnegatives",
"test_conic_SecondOrderCone_VectorAffineFunction",
"test_conic_SecondOrderCone_VectorOfVariables",
"test_conic_SecondOrderCone_out_of_order",
"test_constraint_PrimalStart_DualStart_SecondOrderCone",
]
model = MOI.Utilities.CachingOptimizer(
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),
MOI.instantiate(KNITRO.Optimizer; with_bridge_type=Float64),
model = MOI.instantiate(
KNITRO.Optimizer;
with_bridge_type=Float64,
with_cache_type=Float64,
)
MOI.set(model, MOI.Silent(), true)
MOI.Test.runtests(
model,
MOI.Test.Config(
atol=1e-4,
rtol=1e-4,
atol=1e-3,
rtol=1e-3,
optimal_status=MOI.LOCALLY_SOLVED,
infeasible_status=MOI.LOCALLY_INFEASIBLE,
exclude=Any[
MOI.ConstraintBasisStatus,
MOI.VariableBasisStatus,
MOI.DualObjectiveValue,
],
);
exclude=String[
Expand All @@ -67,25 +51,8 @@ function test_MOI_Test_cached()
"test_solve_ObjectiveBound_MAX_SENSE_LP",
# KNITRO doesn't support INFEASIBILITY_CERTIFICATE results.
"test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_",
second_order_exclude...,
],
)
MOI.Test.runtests(
model,
MOI.Test.Config(
atol=1e-3,
rtol=1e-3,
optimal_status=MOI.LOCALLY_SOLVED,
infeasible_status=MOI.LOCALLY_INFEASIBLE,
exclude=Any[
MOI.ConstraintBasisStatus,
MOI.VariableBasisStatus,
MOI.DualObjectiveValue,
MOI.ConstraintDual,
],
);
include=second_order_exclude,
)
return
end

Expand Down

0 comments on commit d0d1695

Please sign in to comment.