Skip to content

Commit

Permalink
Adding Direct Model option
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemarkson committed Feb 18, 2023
1 parent c8ee79d commit baa128b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MunozDelgado2014"
uuid = "13da4ae5-6830-5b45-8fa1-3a1d57a72793"
authors = ["Felipe M. dos S. Monteiro <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[deps]
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Expand Down
9 changes: 7 additions & 2 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ using Crayons
# end
# println("]")
# end
function build_model(path2main)
function build_model(path2main, optimizer; is_direct=false)


include(path2main * "/main.jl")
model = JuMP.Model()
if is_direct
model = JuMP.direct_model(optimizer())
else
model = JuMP.Model(optimizer)
end

JuMP.set_string_names_on_creation(model, false)

Sᴿᵂ = [1, 2]
Expand Down
20 changes: 18 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@ using JuMP

function test_primal(path; run=false)

model = MD14.build_model(path)
JuMP.set_optimizer(model, HiGHS.Optimizer; add_bridges=false)
model = MD14.build_model(path, HiGHS.Optimizer)
# JuMP.set_optimizer(model, ; add_bridges=false)
set_optimizer_attribute(model, "mip_rel_gap", 1e-1)
if run
set_silent(model)
optimize!(model)
@test primal_status(model) == MOI.FEASIBLE_POINT
end
@test true
return model
end

function test_primal_direct(path; run=false)

model = MD14.build_model(path, HiGHS.Optimizer, is_direct=true)
# JuMP.set_optimizer(model, ; add_bridges=false)
set_optimizer_attribute(model, "mip_rel_gap", 1e-1)
if run
set_silent(model)
Expand Down Expand Up @@ -37,8 +51,10 @@ function runtest()
@testset "$sys" begin
run = sys in to_solve
model = test_primal(systems[sys]; run=run)
model2 = test_primal_direct(systems[sys]; run=run)
if run
test_save_results(model, sys)
test_save_results(model2, sys)
end
end
end
Expand Down

0 comments on commit baa128b

Please sign in to comment.