Skip to content

Commit

Permalink
drop MOI dep (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoffrin authored Nov 18, 2021
1 parent 0bde83d commit 6d78d86
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 44 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ InfrastructureModels.jl Change Log
### Staged
- nothing

### v0.7.0
- Drop support for JuMP v0.21
- Remove dependency on MathOptInterface package

### v0.6.2
- Add support for JuMP v0.22

### v0.6.1
- Use JuMP's `result_count` funciton in `build_result`
- Use JuMP's `solve_time` funciton in `optimize_model!`
- Use JuMP's `result_count` function in `build_result`
- Use JuMP's `solve_time` function in `optimize_model!`
- Add support for Memento v1.2

### v0.6.0
Expand Down
11 changes: 5 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ name = "InfrastructureModels"
uuid = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
authors = ["Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/InfrastructureModels.jl"
version = "0.6.2"
version = "0.7.0"

[deps]
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"

[compat]
ECOS = ">= 0.11"
Ipopt = ">= 0.6"
JuMP = "~0.21.4, ~0.22"
MathOptInterface = "~0.9, ~0.10"
ECOS = ">= 0.12"
Ipopt = ">= 0.8"
JuMP = "~0.22"
Juniper = ">= 0.8"
Memento = "~1.0, ~1.1, ~1.2"
julia = "^1"

Expand Down
3 changes: 0 additions & 3 deletions src/InfrastructureModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ module InfrastructureModels
import JuMP
import Memento

import MathOptInterface
const _MOI = MathOptInterface

# Create our module level logger (this will get precompiled)
const _LOGGER = Memento.getlogger(@__MODULE__)

Expand Down
4 changes: 2 additions & 2 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ function optimize_model!(aim::AbstractInfrastructureModel; relax_integrality=fal
end

if JuMP.mode(aim.model) != JuMP.DIRECT && optimizer !== nothing
if aim.model.moi_backend.state == _MOI.Utilities.NO_OPTIMIZER
if JuMP.backend(aim.model).optimizer === nothing
JuMP.set_optimizer(aim.model, optimizer)
else
Memento.warn(_LOGGER, "Model already contains optimizer, cannot use optimizer specified in `optimize_model!`")
end
end

if JuMP.mode(aim.model) != JuMP.DIRECT && aim.model.moi_backend.state == _MOI.Utilities.NO_OPTIMIZER
if JuMP.mode(aim.model) != JuMP.DIRECT && JuMP.backend(aim.model).optimizer === nothing
Memento.error(_LOGGER, "No optimizer specified in `optimize_model!` or the given JuMP model.")
end

Expand Down
6 changes: 3 additions & 3 deletions test/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ end
@test length(result["solution"]) == 6
@test length(result["solution"]["comp"]) == 2

@test result["termination_status"] == MOI.LOCALLY_SOLVED
@test result["primal_status"] == MOI.FEASIBLE_POINT
@test result["dual_status"] == MOI.FEASIBLE_POINT
@test result["termination_status"] == JuMP.LOCALLY_SOLVED
@test result["primal_status"] == JuMP.FEASIBLE_POINT
@test result["dual_status"] == JuMP.FEASIBLE_POINT
end
52 changes: 26 additions & 26 deletions test/relaxation_scheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -66,8 +66,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -105,8 +105,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -144,8 +144,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -173,8 +173,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -212,8 +212,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -243,8 +243,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -325,8 +325,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance*100)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -457,8 +457,8 @@ seed!(0)
@test(isapprox(JuMP.value(ind), 0, atol=1e-6))
@test(isapprox(JuMP.value(rind), 0, atol=1e-6))

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -552,8 +552,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand All @@ -575,8 +575,8 @@ seed!(0)
# @test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
# @test(rstatus == status)
#
# JuMP.set_objective_sense(m, MOI.MAX_SENSE)
# JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
# JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
# JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)
#
# status = JuMP.optimize!(m)
# rstatus = JuMP.optimize!(rm)
Expand Down Expand Up @@ -606,8 +606,8 @@ seed!(0)
@test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
@test(rstatus == status)

JuMP.set_objective_sense(m, MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)

status = JuMP.optimize!(m)
rstatus = JuMP.optimize!(rm)
Expand All @@ -628,8 +628,8 @@ seed!(0)
# @test(JuMP.objective_value(rm) <= JuMP.objective_value(m) + tolerance)
# @test(rstatus == status)
#
# JuMP.set_objective_sense(m, MOI.MAX_SENSE)
# JuMP.set_objective_sense(rm, MOI.MAX_SENSE)
# JuMP.set_objective_sense(m, JuMP.MOI.MAX_SENSE)
# JuMP.set_objective_sense(rm, JuMP.MOI.MAX_SENSE)
#
# status = JuMP.optimize!(m)
# rstatus = JuMP.optimize!(rm)
Expand Down
2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import Ipopt
import ECOS
import Juniper

const MOI = JuMP.MathOptInterface

ipopt_solver = JuMP.optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0)
ecos_solver = JuMP.optimizer_with_attributes(ECOS.Optimizer, "verbose"=>0)
juniper_solver = JuMP.optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>ipopt_solver, "log_levels"=>[])
Expand Down

0 comments on commit 6d78d86

Please sign in to comment.