Skip to content

Commit

Permalink
Add Support for JuMP v0.21 (#674)
Browse files Browse the repository at this point in the history
* updates for jump v0.21
* prep for release v0.5.1
  • Loading branch information
ccoffrin committed Feb 17, 2020
1 parent 6780080 commit fd8ebf1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ PowerModels.jl Change Log
### Staged
- nothing

### v0.15.1
- Add support for JuMP v0.21

### v0.15.0
- Standardized use of bounded parameter in variable creation (#651)
- Simplified branch series current variable indexing (breaking)
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerModels"
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
authors = ["Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/PowerModels.jl"
version = "0.15.0"
version = "0.15.1"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
Expand All @@ -18,7 +18,7 @@ Cbc = ">= 0.4"
InfrastructureModels = "~0.4"
Ipopt = ">= 0.4"
JSON = "~0.18, ~0.19, ~0.20, ~0.21"
JuMP = "~0.19.1, ~0.20"
JuMP = "~0.19.1, ~0.20, ~0.21"
Juniper = ">= 0.4"
MathOptInterface = "~0.8, ~0.9"
Memento = "~0.10, ~0.11, ~0.12"
Expand Down
21 changes: 10 additions & 11 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,23 @@ end


""
function optimize_model!(pm::AbstractPowerModel; optimizer::Union{JuMP.OptimizerFactory,Nothing}=nothing, solution_processors=[])
function optimize_model!(pm::AbstractPowerModel; optimizer=nothing, solution_processors=[])
start_time = time()

if optimizer == nothing
if optimizer != nothing
if pm.model.moi_backend.state == _MOI.Utilities.NO_OPTIMIZER
Memento.error(_LOGGER, "no optimizer specified in `optimize_model!` or the given JuMP model.")
JuMP.set_optimizer(pm.model, optimizer)
else
_, solve_time, solve_bytes_alloc, sec_in_gc = @timed JuMP.optimize!(pm.model)
end
else
if pm.model.moi_backend.state == _MOI.Utilities.NO_OPTIMIZER
_, solve_time, solve_bytes_alloc, sec_in_gc = @timed JuMP.optimize!(pm.model, optimizer)
else
Memento.warn(_LOGGER, "Model already contains optimizer factory, cannot use optimizer specified in `solve_generic_model`")
_, solve_time, solve_bytes_alloc, sec_in_gc = @timed JuMP.optimize!(pm.model)
Memento.warn(_LOGGER, "Model already contains optimizer, cannot use optimizer specified in `optimize_model!`")
end
end

if pm.model.moi_backend.state == _MOI.Utilities.NO_OPTIMIZER
Memento.error(_LOGGER, "no optimizer specified in `optimize_model!` or the given JuMP model.")
end

_, solve_time, solve_bytes_alloc, sec_in_gc = @timed JuMP.optimize!(pm.model)

try
solve_time = _MOI.get(pm.model, _MOI.SolveTime())
catch
Expand Down
2 changes: 1 addition & 1 deletion test/opf-var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ end
@test isapprox(result["objective"], 17915.2; atol = 1e0)

switch_status_total = sum(switch["status"] for (i,switch) in result["solution"]["switch"])
@test isapprox(switch_status_total, 14.00, atol=1e-4) # two swtiches off
@test isapprox(switch_status_total, 14.00, atol=1e-4) # zero swtiches off
end
end

Expand Down

0 comments on commit fd8ebf1

Please sign in to comment.