Skip to content

Commit

Permalink
Add support for relax_integrality in run methods (#755)
Browse files Browse the repository at this point in the history
* add relax_integrality support
* add note to changelog
  • Loading branch information
ccoffrin committed Jan 20, 2021
1 parent 80106e0 commit ef19e15
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PowerModels.jl Change Log
=========================

### Staged
- Added support for `relax_integrality` in `run_model`
- Added `export_pti` to write a PSSE file (#752)
- Added `parse_files` to create a PM-multinetwork from multiples files
- Add support for convering matpower ramp rates into per-unit (#561)
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Cbc = ">= 0.4"
InfrastructureModels = "~0.5.3"
InfrastructureModels = "~0.5.4"
Ipopt = ">= 0.4"
JSON = "~0.18, ~0.19, ~0.20, ~0.21"
JuMP = "~0.19.1, ~0.20, ~0.21"
Expand Down
7 changes: 5 additions & 2 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ function run_model(file::String, model_type::Type, optimizer, build_method; kwar
end

""
function run_model(data::Dict{String,<:Any}, model_type::Type, optimizer, build_method; ref_extensions=[], solution_processors=[], multinetwork=false, multiconductor=false, kwargs...)
function run_model(data::Dict{String,<:Any}, model_type::Type, optimizer, build_method;
ref_extensions=[], solution_processors=[], relax_integrality=false,
multinetwork=false, multiconductor=false, kwargs...)

if multinetwork != _IM.ismultinetwork(data)
model_requirement = multinetwork ? "multi-network" : "single-network"
data_type = _IM.ismultinetwork(data) ? "multi-network" : "single-network"
Expand All @@ -46,7 +49,7 @@ function run_model(data::Dict{String,<:Any}, model_type::Type, optimizer, build_
Memento.debug(_LOGGER, "pm model build time: $(time() - start_time)")

start_time = time()
result = optimize_model!(pm, optimizer=optimizer, solution_processors=solution_processors)
result = optimize_model!(pm, relax_integrality=relax_integrality, optimizer=optimizer, solution_processors=solution_processors)
Memento.debug(_LOGGER, "pm model solve and solution time: $(time() - start_time)")

return result
Expand Down
24 changes: 23 additions & 1 deletion test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ end
@test result["dual_status"] == NO_SOLUTION
@test isapprox(result["objective"], 17613.2; atol = 1e0)
end
end
end



@testset "relax integrality" begin
@testset "relax OTS model" begin
result = run_ots("../test/data/matpower/case5.m", DCPPowerModel, ipopt_solver, relax_integrality=true)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 14810.0; atol = 1e0)

br_status_total = sum(branch["br_status"] for (i,branch) in result["solution"]["branch"])
@test isapprox(br_status_total, 5.100; atol = 1e-2)
end

@testset "relax TNEP model" begin
result = run_tnep("../test/data/matpower/case5_tnep.m", SOCWRPowerModel, ipopt_solver, relax_integrality=true)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 0.1236; atol = 1e-2)
end
end

0 comments on commit ef19e15

Please sign in to comment.