Skip to content

Commit 4844cee

Browse files
committed
Update tests.
1 parent c29ab5b commit 4844cee

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

test/runtests.jl

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,22 @@ function construct_model(f, name::String)
2020
set_silent(model)
2121
@variable(model, x[1:m])
2222
@objective(model, Min, c' * x)
23-
@constraint(model, con1, Symmetric(-Matrix(F[1]) + sum(Matrix(F[k + 1]) .* x[k] for k in 1:m)) in JuMP.PSDCone())
24-
return model
23+
@constraint(model, con, Symmetric(-Matrix(F[1]) + sum(Matrix(F[k + 1]) .* x[k] for k in 1:m)) in JuMP.PSDCone())
24+
return model, con
2525
end
2626

27-
model = construct_model("mcp124-1") do
28-
MOCD.Optimizer(Mosek.Optimizer)
29-
end
30-
31-
JuMP.optimize!(model)
32-
@test round(objective_value(model); digits = 2) == 141.99
27+
for name in ("mcp124-1", "mcp124-2", "mcp124-3", "mcp124-4")
28+
old, oldcon = construct_model(Mosek.Optimizer, name)
29+
new, newcon = construct_model(() -> MOCD.Optimizer(Mosek.Optimizer), name)
3330

34-
model = construct_model("mcp124-2") do
35-
MOCD.Optimizer(Mosek.Optimizer)
36-
end
31+
JuMP.optimize!(old)
32+
JuMP.optimize!(new)
3733

38-
JuMP.optimize!(model)
39-
@test round(objective_value(model); digits = 2) == 269.88
34+
# primal
35+
@test -0.005 < objective_value(old) - objective_value(new) < 0.005
36+
@test -0.005 < norm(value(oldcon) - value(newcon)) < 0.005
4037

41-
model = construct_model("mcp124-3") do
42-
MOCD.Optimizer(Mosek.Optimizer)
38+
# dual
39+
@test -0.005 < dual_objective_value(old) - dual_objective_value(new) < 0.005
40+
@test -0.005 < norm(dual(oldcon) - dual(newcon)) < 0.005
4341
end
44-
45-
JuMP.optimize!(model)
46-
@test round(objective_value(model); digits = 2) == 467.75
47-
48-
model = construct_model("mcp124-4") do
49-
MOCD.Optimizer(Mosek.Optimizer)
50-
end
51-
52-
JuMP.optimize!(model)
53-
@test round(objective_value(model); digits = 2) == 864.41

0 commit comments

Comments
 (0)