From 40518504c1c1b8ddf23d578411197b7257df1493 Mon Sep 17 00:00:00 2001 From: Byron Tasseff Date: Mon, 21 Sep 2020 15:38:34 -0600 Subject: [PATCH] Updates for GasModels v0.8. --- .travis.yml | 4 ++-- CHANGELOG.md | 12 +++++++----- LICENSE.md | 11 ++++++++--- Project.toml | 4 ++-- README.md | 6 +++--- docs/src/index.md | 2 +- docs/src/quickguide.md | 4 ++-- src/GasPowerModels.jl | 4 ++-- src/form/{nlp.jl => exact.jl} | 0 src/form/{qp.jl => relaxed.jl} | 2 +- test/base.jl | 2 +- test/gpf.jl | 4 ++-- test/ne.jl | 4 ++-- test/ne_opf.jl | 4 ++-- test/neopf_long.jl | 8 ++++---- test/opf.jl | 4 ++-- 16 files changed, 41 insertions(+), 34 deletions(-) rename src/form/{nlp.jl => exact.jl} (100%) rename src/form/{qp.jl => relaxed.jl} (93%) diff --git a/.travis.yml b/.travis.yml index ed6b408..8d242f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: - osx julia: - 1.0 - - 1.5 + - 1 - nightly codecov: true jobs: @@ -12,7 +12,7 @@ jobs: - julia: nightly include: - stage: "Documentation" - julia: 1.5 + julia: 1 os: linux script: - julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))' diff --git a/CHANGELOG.md b/CHANGELOG.md index 65b8687..f69d480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,15 @@ GasPowerModels.jl Change Log ======================= -### Pending +### v0.3.0 +- Update to GasModels v0.8. -### Staged -- none +### v0.2.0 +- Update to GasModels v0.7 and PowerModels v0.17. +- Change input conventions for gas and power model linking. ### v0.1.1 -- Update to PowerModels v0.12 +- Update to PowerModels v0.12. ### v0.1.0 -- Initial implementation +- Initial implementation. diff --git a/LICENSE.md b/LICENSE.md index 4316a20..a07f41b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,7 @@ Multi Infrastructure Control and Optimization Toolkit (MICOT), LA-CC-13-108 Copyright (c) 2016, Triad National Security, LLC + All rights reserved. This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. @@ -10,7 +11,11 @@ All rights in the program are reserved by Triad National Security, LLC, and the The U.S. Government has rights to use, reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR TRIAD NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL. Additionally, redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3. Neither the name of Triad National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of Triad National Security, LLC, Los Alamos National Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY TRIAD NATIONAL SECURITY, LLC AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TRIAD NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Project.toml b/Project.toml index d1400ab..49c77b2 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "GasPowerModels" uuid = "1fcaf345-95e3-5b8b-91d6-2145eb844b9d" authors = ["Russell Bent"] repo = "https://github.com/lanl-ansi/GasPowerModels.jl" -version = "0.2.0" +version = "0.3.0" [deps] GasModels = "5e113713-6c35-5477-b766-e1109486666f" @@ -12,7 +12,7 @@ Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] -GasModels = "~0.7" +GasModels = "~0.8" JSON = "~0.18, ~0.19, ~0.20, ~0.21" JuMP = "~0.21" Memento = "~1.0, ~1.1" diff --git a/README.md b/README.md index cf3e888..2782654 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ This decoupling enables the definition of a variety of optimization formulations * Optimal Power Flow with Network Expansion Planning (`opf_ne`) **Core Network Formulations** -* Mixed-integer nonconvex nonlinear program (`MINLP`) -* Mixed-integer second-order cone program (`MISOCP`) +* Directed flow, mixed-integer nonconvex formulation (`D`) +* Convexly relaxed, directed flow mixed-integer formulation (`CRD`) ## Documentation The package [documentation](https://lanl-ansi.github.io/GasPowerModels.jl/stable/) includes a [quick start guide](https://lanl-ansi.github.io/GasPowerModels.jl/stable/quickguide). @@ -65,7 +65,7 @@ g_file = "examples/data/matgas/belgian.m" # Gas network. p_file = "examples/data/matpower/case14.m" # Power network. # Specify the gas and power formulation types separately. -g_type, p_type = MISOCPGasModel, SOCWRPowerModel +g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the gas-power flow feasibility problem. result = run_gpf(g_file, p_file, g_type, p_type, juniper; diff --git a/docs/src/index.md b/docs/src/index.md index 1e470c2..5beb3e2 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -53,7 +53,7 @@ g_file = "examples/data/matgas/belgian.m" # Gas network. p_file = "examples/data/matpower/case14.m" # Power network. # Specify the gas and power formulation types separately. -g_type, p_type = MISOCPGasModel, SOCWRPowerModel +g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the gas-power flow feasibility problem. result = run_gpf(g_file, p_file, g_type, p_type, juniper; diff --git a/docs/src/quickguide.md b/docs/src/quickguide.md index 6e4dc92..667ab71 100644 --- a/docs/src/quickguide.md +++ b/docs/src/quickguide.md @@ -46,7 +46,7 @@ g_file = "examples/data/matgas/belgian-ne_opf.m" # Gas network. p_file = "examples/data/matpower/case14-ne.m" # Power network. # Specify the gas and power formulation types separately. -g_type, p_type = MISOCPGasModel, SOCWRPowerModel +g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the optimal power flow with network expansion problem. result = run_ne_opf(g_file, p_file, g_type, p_type, juniper; @@ -89,7 +89,7 @@ For more information about GasPowerModels result data, see the [GasPowerModels R To solve the preceding problem using the mixed-integer nonconvex model for natural gas flow, the following can be executed: ```julia # Specify the gas and power formulation types separately. -g_type, p_type = MINLPGasModel, SOCWRPowerModel +g_type, p_type = DWPGasModel, SOCWRPowerModel # Solve the optimal power flow with network expansion problem. result = run_ne_opf(g_file, p_file, g_type, p_type, juniper; diff --git a/src/GasPowerModels.jl b/src/GasPowerModels.jl index f74b4da..facb414 100644 --- a/src/GasPowerModels.jl +++ b/src/GasPowerModels.jl @@ -41,8 +41,8 @@ module GasPowerModels include("core/data.jl") include("core/ref.jl") - include("form/qp.jl") - include("form/nlp.jl") + include("form/relaxed.jl") + include("form/exact.jl") include("prob/gpf.jl") include("prob/opf.jl") diff --git a/src/form/nlp.jl b/src/form/exact.jl similarity index 100% rename from src/form/nlp.jl rename to src/form/exact.jl diff --git a/src/form/qp.jl b/src/form/relaxed.jl similarity index 93% rename from src/form/qp.jl rename to src/form/relaxed.jl index 692e4ef..5101c4f 100644 --- a/src/form/qp.jl +++ b/src/form/relaxed.jl @@ -1,5 +1,5 @@ function constraint_heat_rate_curve( - pm::_PM.AbstractPowerModel, gm::_GM.AbstractMISOCPModel, n::Int, j::Int, + pm::_PM.AbstractPowerModel, gm::_GM.AbstractCRDWPModel, n::Int, j::Int, generators::Array, heat_rates::Dict{Int,Any}, constant::Float64, dispatchable::Int) # If flow is not dispatchable, gas will not be consumed by the generator. fl = dispatchable == 1 ? _GM.var(gm, n, :fl, j) : 0.0 diff --git a/test/base.jl b/test/base.jl index 4212659..03f5d5d 100644 --- a/test/base.jl +++ b/test/base.jl @@ -1,7 +1,7 @@ @testset "src/core/base.jl" begin g_file = "../test/data/matgas/GasLib-11-GPF.m" p_file = "../test/data/matpower/case5-GPF.m" - g_type, p_type = MISOCPGasModel, SOCWRPowerModel + g_type, p_type = CRDWPGasModel, SOCWRPowerModel @testset "instantiate_model (with file inputs)" begin gm, pm = instantiate_model(g_file, p_file, g_type, p_type, build_gpf) diff --git a/test/gpf.jl b/test/gpf.jl index 546973a..2c41dfe 100644 --- a/test/gpf.jl +++ b/test/gpf.jl @@ -3,7 +3,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-GPF.m" p_file = "../test/data/matpower/case5-GPF.m" - g_type, p_type = MISOCPGasModel, SOCWRPowerModel + g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the gas-power flow feasibility problem. result = run_gpf(g_file, p_file, g_type, p_type, juniper; @@ -21,7 +21,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-GPF.m" p_file = "../test/data/matpower/case5-GPF.m" - g_type, p_type = MINLPGasModel, SOCWRPowerModel + g_type, p_type = DWPGasModel, SOCWRPowerModel # Solve the gas-power flow feasibility problem. result = run_gpf(g_file, p_file, g_type, p_type, juniper; diff --git a/test/ne.jl b/test/ne.jl index 70b8b13..2023eb4 100644 --- a/test/ne.jl +++ b/test/ne.jl @@ -3,7 +3,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-NE.m" p_file = "../test/data/matpower/case5-NE.m" - g_type, p_type = MISOCPGasModel, SOCWRPowerModel + g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the joint gas-power network expansion planning problem. result = run_ne(g_file, p_file, g_type, p_type, juniper; @@ -21,7 +21,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-NE.m" p_file = "../test/data/matpower/case5-NE.m" - g_type, p_type = MINLPGasModel, SOCWRPowerModel + g_type, p_type = DWPGasModel, SOCWRPowerModel # Solve the joint gas-power network expansion planning problem. result = run_ne(g_file, p_file, g_type, p_type, juniper; diff --git a/test/ne_opf.jl b/test/ne_opf.jl index 5358c8f..eede7ed 100644 --- a/test/ne_opf.jl +++ b/test/ne_opf.jl @@ -3,7 +3,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-NE.m" p_file = "../test/data/matpower/case5-NE.m" - g_type, p_type = MISOCPGasModel, SOCWRPowerModel + g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the joint network expansion, optimal gas-power flow problem. result = run_ne_opf(g_file, p_file, g_type, p_type, juniper; @@ -21,7 +21,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-NE.m" p_file = "../test/data/matpower/case5-NE.m" - g_type, p_type = MINLPGasModel, SOCWRPowerModel + g_type, p_type = DWPGasModel, SOCWRPowerModel # Solve the joint network expansion, optimal gas-power flow problem. result = run_ne_opf(g_file, p_file, g_type, p_type, juniper; diff --git a/test/neopf_long.jl b/test/neopf_long.jl index 0e9081f..911c656 100644 --- a/test/neopf_long.jl +++ b/test/neopf_long.jl @@ -5,14 +5,14 @@ @testset "36 Bus Ilic 1.1 Northeast 1.0" begin data = GasModels.parse_file("../data/TC_PennToNortheast_wValves_expansion_1.0.json") - result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.1.m", "../data/TC_PennToNortheast_wValves_expansion_1.0.json", SOCWRPowerModel, MISOCPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) + result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.1.m", "../data/TC_PennToNortheast_wValves_expansion_1.0.json", SOCWRPowerModel, CRDWPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) @test result["status"] == :LocalOptimal || result["status"] == :Optimal @test isapprox(result["objective"], 4.926397139595786e9; atol = 1e6) end @testset "36 Bus Ilic 1.1 Northeast 2.25" begin data = GasModels.parse_file("../data/TC_PennToNortheast_wValves_expansion_2.25.json") - result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.1.m", "../data/TC_PennToNortheast_wValves_expansion_2.25.json", SOCWRPowerModel, MISOCPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) + result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.1.m", "../data/TC_PennToNortheast_wValves_expansion_2.25.json", SOCWRPowerModel, CRDWPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) @test result["status"] == :LocalOptimal || result["status"] == :Optimal @test isapprox(result["objective"], 5.127290418071447e9; atol = 1e6) @@ -20,7 +20,7 @@ @testset "36 Bus Ilic 1.0 Northeast 1.0" begin data = GasModels.parse_file("../data/TC_PennToNortheast_wValves_expansion_1.0.json") - result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.0.m", "../data/TC_PennToNortheast_wValves_expansion_1.0.json", SOCWRPowerModel, MISOCPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) + result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.0.m", "../data/TC_PennToNortheast_wValves_expansion_1.0.json", SOCWRPowerModel, CRDWPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) @test result["status"] == :LocalOptimal || result["status"] == :Optimal @test isapprox(result["objective"], 4.0269404390948544e9; atol = 1e6) @@ -28,7 +28,7 @@ @testset "36 Bus Ilic 1.0 Northeast 2.25" begin data = GasModels.parse_file("../data/TC_PennToNortheast_wValves_expansion_2.25.json") - result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.0.m", "../data/TC_PennToNortheast_wValves_expansion_2.25.json", SOCWRPowerModel, MISOCPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) + result = GasPowerModels.run_ne_opf("../data/36bus_ilic_expansion_1.0.m", "../data/TC_PennToNortheast_wValves_expansion_2.25.json", SOCWRPowerModel, CRDWPGasModel, misocp_solver; power_opf_weight=365, gas_price_weight=365) @test result["status"] == :LocalOptimal || result["status"] == :Optimal @test isapprox(result["objective"], 4.1859768708376384e9; atol = 1e6) diff --git a/test/opf.jl b/test/opf.jl index 5849eb8..90e5509 100644 --- a/test/opf.jl +++ b/test/opf.jl @@ -3,7 +3,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-GPF.m" p_file = "../test/data/matpower/case5-GPF.m" - g_type, p_type = MISOCPGasModel, SOCWRPowerModel + g_type, p_type = CRDWPGasModel, SOCWRPowerModel # Solve the optimal gas-power flow problem. result = run_opf(g_file, p_file, g_type, p_type, juniper; @@ -20,7 +20,7 @@ # Set up problem metadata. g_file = "../test/data/matgas/GasLib-11-GPF.m" p_file = "../test/data/matpower/case5-GPF.m" - g_type, p_type = MINLPGasModel, SOCWRPowerModel + g_type, p_type = DWPGasModel, SOCWRPowerModel # Solve the optimal gas-power flow problem. result = run_opf(g_file, p_file, g_type, p_type, juniper;