Skip to content

Commit

Permalink
Merge pull request jump-dev#409 from JuliaOpt/bl/cachingnames
Browse files Browse the repository at this point in the history
Fix names for CachingOptimizer
  • Loading branch information
blegat authored Jul 9, 2018
2 parents 247c4ba + 1012acb commit 851125c
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 207 deletions.
58 changes: 25 additions & 33 deletions src/Test/UnitTests/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ function solve_affine_lessthan(model::MOI.ModelLike, config::TestConfig)
""")
x = MOI.get(model, MOI.VariableIndex, "x")
c = MOI.get(model, MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64}}, "c")
if config.solve
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, -0.5)]
)
end
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, -0.5)]
)
end
unittests["solve_affine_lessthan"] = solve_affine_lessthan

Expand All @@ -68,14 +66,12 @@ function solve_affine_greaterthan(model::MOI.ModelLike, config::TestConfig)
""")
x = MOI.get(model, MOI.VariableIndex, "x")
c = MOI.get(model, MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}}, "c")
if config.solve
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, 0.5)]
)
end
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, 0.5)]
)
end
unittests["solve_affine_greaterthan"] = solve_affine_greaterthan

Expand All @@ -95,14 +91,12 @@ function solve_affine_equalto(model::MOI.ModelLike, config::TestConfig)
""")
x = MOI.get(model, MOI.VariableIndex, "x")
c = MOI.get(model, MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}}, "c")
if config.solve
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, 0.5)]
)
end
test_model_solution(model, config;
objective_value = 0.5,
variable_primal = [(x, 0.5)],
constraint_primal = [(c, 1.0)],
constraint_dual = [(c, 0.5)]
)
end
unittests["solve_affine_equalto"] = solve_affine_equalto

Expand All @@ -122,14 +116,12 @@ function solve_affine_interval(model::MOI.ModelLike, config::TestConfig)
""")
x = MOI.get(model, MOI.VariableIndex, "x")
c = MOI.get(model, MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}, MOI.Interval{Float64}}, "c")
if config.solve
test_model_solution(model, config;
objective_value = 6.0,
variable_primal = [(x, 2.0)],
constraint_primal = [(c, 4.0)],
constraint_dual = [(c, -1.5)]
)
end
test_model_solution(model, config;
objective_value = 6.0,
variable_primal = [(x, 2.0)],
constraint_primal = [(c, 4.0)],
constraint_dual = [(c, -1.5)]
)
end
unittests["solve_affine_interval"] = solve_affine_interval

Expand Down Expand Up @@ -218,7 +210,7 @@ function solve_affine_deletion_edge_cases(model::MOI.ModelLike, config::TestConf
# test adding a VectorAffineFunction -in- LessThan
c1 = MOI.addconstraint!(model, vaf, MOI.Nonpositives(1))
test_model_solution(model, config; objective_value = 0.0,
constraint_primal = [(c1, [0.0])]
constraint_primal = [(c1, [0.0])]
)
# test adding a ScalarAffineFunction -in- LessThan
c2 = MOI.addconstraint!(model, saf, MOI.LessThan(1.0))
Expand Down
Loading

0 comments on commit 851125c

Please sign in to comment.