From 2ef1642c975ee402c76a42c4cdb6178d6ce780b9 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 10 Jan 2020 15:55:40 +0100 Subject: [PATCH 01/10] tweak syntax for compat entries --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index fa8a174d..721ba0a7 100644 --- a/Project.toml +++ b/Project.toml @@ -13,11 +13,11 @@ PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] Cbc = "≥ 0.4.0" Ipopt = "≥ 0.4.0" -PowerModels = "~ 0.13.0" +PowerModels = "~0.13.0" SCS = "≥ 0.4.0" julia = "1.1" Memento = "0.12.1" -InfrastructureModels = "~ 0.3.2" +InfrastructureModels = "~0.3.2" JuMP = "0.20.1" [extras] From 5b5691d54faf7942955919e76fc8035ed2fb42d8 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 11:35:07 +0200 Subject: [PATCH 02/10] TNEP tests finished ReleaseNotes added. --- README.md | 28 ++++- ReleaseNotes.txt | 8 ++ src/core/variabledcgrid.jl | 48 +++++---- test/data/tnep/case6_test.m | 22 +--- test/data/tnep/case9_test.m | 136 ++++--------------------- test/runtests.jl | 14 +-- test/tnep.jl | 197 ++++++++++++++++++++++++++---------- 7 files changed, 233 insertions(+), 220 deletions(-) create mode 100644 ReleaseNotes.txt diff --git a/README.md b/README.md index f9482100..7e529318 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ The developers thank Carleton Coffrin (LANL) for his support. ## Citing PowerModelsACDC -If you find PowerModelsACDC useful in your work, we kindly request that you cite the following [publication](https://ieeexplore.ieee.org/document/8636236): - +If you find PowerModelsACDC useful in your work, we kindly request that you cite the following publications: +[AC/DC OPF Core](https://ieeexplore.ieee.org/document/8636236): ``` @ARTICLE{8636236, author={H. {Ergun} and J. {Dave} and D. {Van Hertem} and F. {Geth}}, @@ -59,7 +59,29 @@ doi={10.1109/TPWRS.2019.2897835}, ISSN={0885-8950}, month={July},} ``` - +[TNEP Extension 1](https://digital-library.theiet.org/content/journals/10.1049/iet-gtd.2019.0383): +``` +@ARTICLE{ + iet:/content/journals/10.1049/iet-gtd.2019.0383, + author = {Jay Dave}, + author = {Hakan Ergun}, + author = {Ting An}, + author = {Jingjing Lu}, + author = {Dirk Van Hertem}, + keywords = {power systems;meshed HVDC grids;increased utilisation;presented formulations;convex formulations;second-order cone convex relaxation;multiple HVDC links;linear approximation;dc grids;transmission network expansion planning problem;high-voltage direct current;traditional ac grid;TNEP problem;nonlinear formulation;}, + ISSN = {1751-8687}, + title = {TNEP of meshed HVDC grids: ‘AC’, ‘DC’ and convex formulations}, + journal = {IET Generation, Transmission & Distribution}, + issue = {24}, + volume = {13}, + year = {2019}, + month = {December}, + pages = {5523-5532(9)}, + publisher ={Institution of Engineering and Technology}, + copyright = {© The Institution of Engineering and Technology}, + url = {https://digital-library.theiet.org/content/journals/10.1049/iet-gtd.2019.0383} +} +``` ## License This code is provided under a BSD license. diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt new file mode 100644 index 00000000..ac9ffac7 --- /dev/null +++ b/ReleaseNotes.txt @@ -0,0 +1,8 @@ +v0.3.0 Release Notes + +- Added TNEP problems in single and multiperiod +- TNEP formulated in DCP, LPAC, SOCBFM, SOCBIM, SDP, QC and ACP +- TNEP test cases and unit tests integrated +- Update code base for compliance with PowerModels v0.15.3 +-- Variable definitions & reporting +-- Conductors removed diff --git a/src/core/variabledcgrid.jl b/src/core/variabledcgrid.jl index 44797cea..8656e438 100644 --- a/src/core/variabledcgrid.jl +++ b/src/core/variabledcgrid.jl @@ -189,6 +189,8 @@ function variable_dcgrid_voltage_magnitude_sqr_ne(pm::_PM.AbstractPowerModel; nw JuMP.set_upper_bound(wdcr_ne[br], bus_vdcmax[bi_bp[br][1]] * bus_vdcmax[bi_bp[br][2]]) end end + report && _PM.sol_component_value(pm, nw, :busdc_ne, :wdc_ne, _PM.ids(pm, nw, :busdc_ne), wdc_ne) + report && _PM.sol_component_value(pm, nw, :busdc_ne, :wdcr_ne, _PM.ids(pm, nw, :busdc_ne), wdcr_ne) end function variable_dcgrid_voltage_magnitude_sqr_du(pm::_PM.AbstractPowerModel; nw::Int=pm.cnw, bounded::Bool = true, report::Bool=true) # this has to to every branch, different than its counterpart(Wdc_fr) since two candidate branches can be connected to same node and two duplicate variables will be needed @@ -217,43 +219,45 @@ function variable_dcgrid_voltage_magnitude_sqr_du(pm::_PM.AbstractPowerModel; nw JuMP.set_upper_bound(wdcr_frto_ne[i], 1.21) end end - + report && _PM.sol_component_value(pm, nw, :busdc_ne, :wdc_du_fr, _PM.ids(pm, nw, :busdc_ne), wdc_fr_ne) + report && _PM.sol_component_value(pm, nw, :busdc_ne, :wdc_du_to, _PM.ids(pm, nw, :busdc_ne), wdc_to_ne) + report && _PM.sol_component_value(pm, nw, :busdc_ne, :wdcr_du, _PM.ids(pm, nw, :busdc_ne), wdcr_frto_ne) end "variable: `p_dcgrid[l,i,j]` for `(l,i,j)` in `arcs_dcgrid`" function variable_active_dcbranch_flow_ne(pm::_PM.AbstractPowerModel; nw::Int=pm.cnw, bounded::Bool = true, report::Bool=true) - if bounded - _PM.var(pm, nw)[:p_dcgrid_ne]= JuMP.@variable(pm.model, - [(l,i,j) in _PM.ref(pm, nw, :arcs_dcgrid_ne)], base_name="$(nw)_pdcgrid_ne", - lower_bound = -_PM.ref(pm, nw, :branchdc_ne, l, "rateA"), - upper_bound = _PM.ref(pm, nw, :branchdc_ne, l, "rateA"), - start = _PM.comp_start_value(_PM.ref(pm, nw, :branchdc_ne, l), "p_start", 1.0) - ) - else - _PM.var(pm, nw)[:p_dcgrid_ne] = JuMP.@variable(pm.model, + p = _PM.var(pm, nw)[:p_dcgrid_ne]= JuMP.@variable(pm.model, [(l,i,j) in _PM.ref(pm, nw, :arcs_dcgrid_ne)], base_name="$(nw)_pdcgrid_ne", start = _PM.comp_start_value(_PM.ref(pm, nw, :branchdc_ne, l), "p_start", 1.0) ) + + if bounded + for arc in _PM.ref(pm, nw, :arcs_dcgrid_ne) + l,i,j = arc + JuMP.set_lower_bound(p[arc], -_PM.ref(pm, nw, :branchdc_ne, l)["rateA"]) + JuMP.set_upper_bound(p[arc], _PM.ref(pm, nw, :branchdc_ne, l)["rateA"]) + end end + + report && _PM.sol_component_value_edge(pm, nw, :branchdc_ne, :pf, :pt, _PM.ref(pm, nw, :arcs_dcgrid_from_ne), _PM.ref(pm, nw, :arcs_dcgrid_to_ne), p) end "variable: `ccm_dcgrid[l]` for `(l)` in `branchdc`" function variable_dcbranch_current_sqr_ne(pm::_PM.AbstractPowerModel; nw::Int=pm.cnw, bounded::Bool = true, report::Bool=true) vpu = 0.8 + cc= _PM.var(pm, nw)[:ccm_dcgrid_ne] = JuMP.@variable(pm.model, + [l in _PM.ids(pm, nw, :branchdc_ne)], base_name="$(nw)_ccm_dcgrid_ne", + start = (_PM.comp_start_value(_PM.ref(pm, nw, :branchdc_ne, l), "p_start", 0.0) / vpu)^2 + ) + if bounded - _PM.var(pm, nw)[:ccm_dcgrid_ne] = JuMP.@variable(pm.model, - [l in _PM.ids(pm, nw, :branchdc_ne)], base_name="$(nw)_ccm_dcgrid_ne", - lower_bound = 0, - upper_bound = (_PM.ref(pm, nw, :branchdc_ne, l, "rateA")/vpu)^2, - start = (_PM.comp_start_value(_PM.ref(pm, nw, :branchdc_ne, l), "p_start", 0.0) / vpu)^2 - ) - else - _PM.var(pm, nw)[:ccm_dcgrid_ne] = JuMP.@variable(pm.model, - [l in _PM.ids(pm, nw, :branchdc_ne)], base_name="$(nw)_ccm_dcgrid_ne", - start = (_PM.comp_start_value(_PM.ref(pm, nw, :branchdc_ne, l), "p_start", 0.0)/vpu)^2, - lower_bound = 0, - ) + for (l, branchdc) in _PM.ref(pm, nw, :branchdc_ne) + JuMP.set_lower_bound(cc[l], 0) + JuMP.set_upper_bound(cc[l], (branchdc["rateA"] / vpu)^2) + end end + + report && _PM.sol_component_value(pm, nw, :branchdc_ne, :ccm, _PM.ids(pm, nw, :branchdc), cc) end "variable: `0 <= convdc_ne[c] <= 1` for `c` in `candidate converters" diff --git a/test/data/tnep/case6_test.m b/test/data/tnep/case6_test.m index f562ece0..80386eb9 100644 --- a/test/data/tnep/case6_test.m +++ b/test/data/tnep/case6_test.m @@ -1,6 +1,6 @@ -% Case to test two connected components in the network data -% the case is two replicates of the case3 network - +% Garver system - Transmission Network Estimation Using Linear Programming, IEEE trans. on power appratus and sys +% Power system transmission network expansion planning using AC model by Rider, MJ and Garcia, AV and Romero, R +%modification: gen cost is changed. A low value is set to penalize power losses but not dominate the objective. function mpc = case6 mpc.version = '2'; mpc.baseMVA = 100.0; @@ -57,31 +57,15 @@ %% candidate branches %column_names% fbusdc tbusdc r l c rateA rateB rateC status cost mpc.branchdc_ne = [ - 1 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.1; - 1 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.1; - 1 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.1; - 2 3 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.2; - 2 3 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.2; - 2 3 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.2; - 2 5 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.3; 2 5 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.3; - 2 5 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.3; - 2 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.4; 2 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.4; 2 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.4; - 3 4 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.5; - 3 4 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.5; - 3 4 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.5; - 3 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.6; 3 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.6; 3 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.6; - 4 5 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.7; 4 5 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.7; 4 5 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.7; - 4 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.8; 4 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.8; 4 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.8; - 5 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.9; 5 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 2.9; 5 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 3.9; ]; diff --git a/test/data/tnep/case9_test.m b/test/data/tnep/case9_test.m index 781ef83a..277bf13e 100644 --- a/test/data/tnep/case9_test.m +++ b/test/data/tnep/case9_test.m @@ -12,7 +12,7 @@ %%----- Power Flow Data -----%% %% system MVA base mpc.baseMVA = 100; - +%modified case to motivate expansion: L45 deleted and L56s rating reduced. gen cost = 0 to check only expansion cost %% bus data % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin mpc.bus = [ @@ -20,27 +20,27 @@ 2 2 0 0 0 0 1 1 0 345 1 1.1 0.9; 3 2 0 0 0 0 1 1 0 345 1 1.1 0.9; 4 1 0 0 0 0 1 1 0 345 1 1.1 0.9; - 5 1 270 90 0 0 1 1 0 345 1 1.1 0.9; + 5 1 90 30 0 0 1 1 0 345 1 1.1 0.9; 6 1 0 0 0 0 1 1 0 345 1 1.1 0.9; - 7 1 300 105 0 0 1 1 0 345 1 1.1 0.9; + 7 1 100 35 0 0 1 1 0 345 1 1.1 0.9; 8 1 0 0 0 0 1 1 0 345 1 1.1 0.9; - 9 1 375 150 0 0 1 1 0 345 1 1.1 0.9; + 9 1 125 50 0 0 1 1 0 345 1 1.1 0.9; ]; %% generator data % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf mpc.gen = [ - 1 0 0 900 900 1 100 1 750 10 0 0 0 0 0 0 0 0 0 0 0; - 2 163 0 900 900 1 100 1 900 10 0 0 0 0 0 0 0 0 0 0 0; - 3 85 0 900 900 1 100 1 810 10 0 0 0 0 0 0 0 0 0 0 0; + 1 0 0 300 -300 1 100 1 250 10 0 0 0 0 0 0 0 0 0 0 0; + 2 163 0 300 -300 1 100 1 300 10 0 0 0 0 0 0 0 0 0 0 0; + 3 85 0 300 -300 1 100 1 270 10 0 0 0 0 0 0 0 0 0 0 0; ]; %% branch data % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax mpc.branch = [ 1 4 0 0.0576 0 250 250 250 0 0 1 -360 360; - 4 5 0.017 0.092 0.158 250 250 250 0 0 1 -360 360; - 5 6 0.039 0.17 0.358 150 150 150 0 0 1 -360 360; +% 4 5 0.017 0.092 0.158 50 250 250 0 0 1 -360 360; + 5 6 0.039 0.17 0.358 50 150 150 0 0 1 -360 360; 3 6 0 0.0586 0 300 300 300 0 0 1 -360 360; 6 7 0.0119 0.1008 0.209 150 150 150 0 0 1 -360 360; 7 8 0.0085 0.072 0.149 250 250 250 0 0 1 -360 360; @@ -54,124 +54,30 @@ % 1 startup shutdown n x1 y1 ... xn yn % 2 startup shutdown n c(n-1) ... c0 mpc.gencost = [ -2 1500 0 3 0 0.01 0; % modified -2 1500 0 3 0 0.01 0; % modified -2 1500 0 3 0 0.01 0; % modified +2 1500 0 3 0 0.0 0; % modified +2 1500 0 3 0 0.0 0; % modified +2 1500 0 3 0 0.0 0; % modified ]; + %% candidate dc bus data %column_names% busdc_i grid Pdc Vdc basekVdc Vdcmax Vdcmin Cdc mpc.busdc_ne = [ - 1 1 0 1 345 1.1 0.9 0; - 2 1 0 1 345 1.1 0.9 0; - 3 1 0 1 345 1.1 0.9 0; - 4 1 0 1 345 1.1 0.9 0; - 5 1 0 1 345 1.1 0.9 0; - 6 1 0 1 345 1.1 0.9 0; - 7 1 0 1 345 1.1 0.9 0; - 8 1 0 1 345 1.1 0.9 0; - 9 1 0 1 345 1.1 0.9 0; + 1 1 0 1 345 1.1 0.9 0; + 2 1 0 1 345 1.1 0.9 0; ]; %% candidate branches %column_names% fbusdc tbusdc r l c rateA rateB rateC status cost mpc.branchdc_ne = [ - 1 2 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.1; - 1 3 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.2; - 1 5 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.3; - 1 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.4; - 1 7 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.5; - 1 8 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.6; - 1 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.7; - 2 3 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.8; - 2 4 0.01 0.00 0.00 100.0 0.0 0.0 1.0 1.9; - 2 5 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.1; - 2 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.2; - 2 7 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.3; - 2 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.4; - 3 4 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.5; - 3 5 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.6; - 3 7 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.7; - 3 8 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.8; - 3 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 2.9; - 4 6 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3; - 4 7 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.1; - 4 8 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.2; - 5 7 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.3; - 5 8 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.4; - 5 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.5; - 6 8 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.6; - 6 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.7; - 7 9 0.01 0.00 0.00 100.0 0.0 0.0 1.0 3.8; - - 1 2 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.1; - 1 3 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.2; - 1 5 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.3; - 1 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.4; - 1 7 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.5; - 1 8 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.6; - 1 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.7; - 2 3 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.8; - 2 4 0.01 0.00 0.00 200.0 0.0 0.0 1.0 4.9; - 2 5 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.0; - 2 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.1; - 2 7 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.2; - 2 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.3; - 3 4 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.4; - 3 5 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.5; - 3 7 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.6; - 3 8 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.7; - 3 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.8; - 4 6 0.01 0.00 0.00 200.0 0.0 0.0 1.0 5.9; - 4 7 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.0; - 4 8 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.1; - 5 7 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.2; - 5 8 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.3; - 5 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.4; - 6 8 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.5; - 6 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.6; - 7 9 0.01 0.00 0.00 200.0 0.0 0.0 1.0 6.7; - - 1 2 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.1; - 1 3 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.2; - 1 5 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.3; - 1 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.4; - 1 7 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.5; - 1 8 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.6; - 1 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.7; - 2 3 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.8; - 2 4 0.01 0.00 0.00 400.0 0.0 0.0 1.0 7.9; - 2 5 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8; - 2 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.1; - 2 7 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.2; - 2 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.3; - 3 4 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.4; - 3 5 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.5; - 3 7 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.6; - 3 8 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.7; - 3 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.8; - 4 6 0.01 0.00 0.00 400.0 0.0 0.0 1.0 8.9; - 4 7 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9; - 4 8 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.1; - 5 7 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.2; - 5 8 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.3; - 5 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.4; - 6 8 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.5; - 6 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.6; - 7 9 0.01 0.00 0.00 400.0 0.0 0.0 1.0 9.7; - ]; +1 2 0.017 0.00 0.00 250 0.0 0.0 1.0 1.2; +1 2 0.017 0.00 0.00 250 0.0 0.0 1.0 1.3; +]; %% candidate converters %column_names% busdc_i busac_i type_dc type_ac P_g Q_g islcc Vtar rtf xtf transformer tm bf filter rc xc reactor basekVac Vmmax Vmmin Imax status LossA LossB LossCrec LossCinv droop Pdcset Vdcset dVdcset Pacmax Pacmin Qacmax Qacmin cost -mpc.convdc_ne = [ -1 1 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.1; -2 2 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.2; -3 3 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.3; -4 4 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.4; -5 5 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.5; -6 6 2 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.6; -7 7 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.7; -8 8 1 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.8; -9 9 2 1 -360 -1.66 0 1.0 0.001 0.001 1 1 0.001 1 0.001 0.001 1 345 1.1 0.9 10 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 700 -700 700 -700 3.9; + mpc.convdc_ne = [ + 1 4 1 1 -360 -1.66 0 1.0 0.001 0.1 1 1 0.08 1 0.001 0.09 1 345 1.1 0.9 100 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 1000 -1000 500 -500 4.5; + 2 5 1 1 -360 -1.66 0 1.0 0.001 0.1 1 1 0.08 1 0.001 0.09 1 345 1.1 0.9 100 1 1.1033 0.887 2.885 2.885 0.0050 -52.7 1.0079 0 1000 -1000 500 -500 5; ]; diff --git a/test/runtests.jl b/test/runtests.jl index 2218f77f..a42645b8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,23 +10,25 @@ Memento.setlevel!(Memento.getlogger(PowerModelsACDC), "error") Memento.setlevel!(Memento.getlogger(PowerModels), "error") import Ipopt -import Gurobi -#import GLPKMathProgInterface import SCS import Cbc -import Mosek -import MosekTools import Juniper using Test ipopt_solver = JuMP.with_optimizer(Ipopt.Optimizer, tol=1e-6, print_level=0) scs_solver = JuMP.with_optimizer(SCS.Optimizer) -gurobi = JuMP.with_optimizer(Gurobi.Optimizer) -mosek = JuMP.with_optimizer(Mosek.Optimizer) cbc = JuMP.with_optimizer(Cbc.Optimizer, tol=1e-4, print_level=0) juniper = JuMP.with_optimizer(Juniper.Optimizer, nl_solver = ipopt_solver, mip_solver= cbc, time_limit= 7200) +#### ONLY for local testing, not supported intravis due to licensces ############## +# import Gurobi +# import Mosek +# import MosekTools +# gurobi = JuMP.with_optimizer(Gurobi.Optimizer) +# mosek = JuMP.with_optimizer(Mosek.Optimizer) +############################### + @testset "PowerModelsACDC" begin include("pf.jl") diff --git a/test/tnep.jl b/test/tnep.jl index fe29298b..896e1dae 100644 --- a/test/tnep.jl +++ b/test/tnep.jl @@ -2,21 +2,19 @@ s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => false) @testset "test dc tnep" begin @testset "6-bus case" begin resultDC = run_tnepopf("../test/data/tnep/case6_test.m", DCPPowerModel, cbc; setting = s) - - @test isapprox(resultDC["objective"], 24.7; atol = 1e-1) - @test isapprox(resultDC["solution"]["branchdc_ne"]["12"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultDC["solution"]["branchdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultDC["objective"], 25.25; atol = 1e-1) @test isapprox(resultDC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) @test isapprox(resultDC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) @test isapprox(resultDC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultDC["solution"]["branchdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultDC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultDC["solution"]["branchdc_ne"]["2"]["pf"], 1.87; atol = 1e-2) end - # + @testset "9-bus case" begin resultDC = run_tnepopf("../test/data/tnep/case9_test.m", DCPPowerModel, cbc; setting = s) - @test isapprox(resultDC["objective"], 20.9; atol = 1e-1) - @test isapprox(resultDC["solution"]["branchdc_ne"]["34"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultDC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultDC["solution"]["convdc_ne"]["9"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultDC["objective"], 5; atol = 1e-1) + @test isapprox(resultDC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) end # @testset "14-bus case" begin @@ -39,61 +37,150 @@ s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => false) end # @testset "test soc tnep" begin + @testset "test SOC-BFM tnep" begin + @testset "6-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFPowerModel, juniper; setting = s) + @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + + @testset "9-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFPowerModel, juniper; setting = s) + @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 0.998; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.984497; atol = 1e-2) + end + end +# ONLY WITH MOSEK -> Doesn't run on travis, can be used locally +#################################################################### +# @testset "14-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) +# end +# # +# @testset "39-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) +# end + +end + +@testset "test SOC-BIM tnep" begin @testset "6-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 30.7; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["12"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["25"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, juniper; setting = s) + @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) end -# @testset "9-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 36.5; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["61"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["9"]["isbuilt"], 1; atol = 1e-2) + resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, juniper; setting = s) + @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.484749; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.959131; atol = 1e-2) + end -# - @testset "14-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) +end + +@testset "test QC tnep" begin + @testset "6-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, juniper; setting = s) + @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) end -# - @testset "39-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) + @testset "9-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, juniper; setting = s) + @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9092088301606092; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.958239; atol = 1e-2) end +end +@testset "test AC tnep" begin + @testset "6-bus case" begin + resultACP = run_tnepopf("../test/data/tnep/case6_test.m", ACPPowerModel, juniper; setting = s) + @test isapprox(resultACP["objective"], 32.7; atol = 1e-1) + @test isapprox(resultACP["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["branchdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["branchdc_ne"]["6"]["isbuilt"], 0; atol = 1e-2) + @test isapprox(resultACP["solution"]["branchdc_ne"]["10"]["isbuilt"], 0; atol = 1e-2) + @test isapprox(resultACP["solution"]["branchdc_ne"]["2"]["pf"], -1.9834; atol = 1e-2) + @test isapprox(resultACP["solution"]["busdc_ne"]["2"]["vm"], 1.09; atol = 1e-2) + end + @testset "9-bus case" begin + resultACP = run_tnepopf("../test/data/tnep/case9_test.m", ACPPowerModel, juniper; setting = s) + @test isapprox(resultACP["objective"], 10.7; atol = 1e-1) + @test isapprox(resultACP["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultACP["solution"]["branchdc_ne"]["1"]["pf"], 0.838; atol = 1e-2) + @test isapprox(resultACP["solution"]["busdc_ne"]["2"]["vm"], 0.99; atol = 1e-2) + end end -@testset "test ac tnep" begin +@testset "test LPAC tnep" begin @testset "6-bus case" begin - resultAC = run_tnepopf("../test/data/tnep/case6_test.m", ACPPowerModel, juniper; setting = s) - @test isapprox(resultAC["objective"], 31.284; atol = 1e-2) - @test isapprox(resultAC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["branchdc_ne"]["23"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["branchdc_ne"]["25"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultAC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + resultLPAC = run_tnepopf("../test/data/tnep/case6_test.m", LPACCPowerModel, juniper; setting = s) + @test isapprox(resultLPAC["objective"], 30.5; atol = 1e-1) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["branchdc_ne"]["1"]["pf"], 1.63; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["busdc_ne"]["2"]["phivdcm_ne"], -0.00668065; atol = 1e-2) + + end + @testset "9-bus case" begin + resultLPAC = run_tnepopf("../test/data/tnep/case9_test.m", LPACCPowerModel, juniper; setting = s) + @test isapprox(resultLPAC["objective"], 10.7; atol = 1e-1) + @test isapprox(resultLPAC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["branchdc_ne"]["1"]["pf"], 0.814; atol = 1e-2) + @test isapprox(resultLPAC["solution"]["busdc_ne"]["2"]["phivdcm_ne"], -0.00345834; atol = 1e-2) end end From b0c8061df082d590671636a95c4487c332550341 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 11:39:59 +0200 Subject: [PATCH 03/10] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 03a83068..22d6d04e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,8 @@ before_install: - julia -e 'using Pkg; Pkg.add("Ipopt")' - julia -e 'using Pkg; Pkg.add("SCS")' - julia -e 'using Pkg; Pkg.add("Documenter")' +- julia -e 'using Pkg; Pkg.add("Juniper")' +- julia -e 'using Pkg; Pkg.add("Cbc")' script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi From 3852c31df99ea3dffdb3fdacdf0159ee51a215f0 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 12:50:44 +0200 Subject: [PATCH 04/10] Fis tnep test - Make tests using gurobi & mosek optional --- test/runtests.jl | 19 ++++-- test/tnep.jl | 170 +++++++++++++++++++++++------------------------ 2 files changed, 96 insertions(+), 93 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index a42645b8..1a3fc2e0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,18 +16,23 @@ import Juniper using Test +local_test = true + ipopt_solver = JuMP.with_optimizer(Ipopt.Optimizer, tol=1e-6, print_level=0) scs_solver = JuMP.with_optimizer(SCS.Optimizer) cbc = JuMP.with_optimizer(Cbc.Optimizer, tol=1e-4, print_level=0) juniper = JuMP.with_optimizer(Juniper.Optimizer, nl_solver = ipopt_solver, mip_solver= cbc, time_limit= 7200) -#### ONLY for local testing, not supported intravis due to licensces ############## -# import Gurobi -# import Mosek -# import MosekTools -# gurobi = JuMP.with_optimizer(Gurobi.Optimizer) -# mosek = JuMP.with_optimizer(Mosek.Optimizer) -############################### + +if local_test == false + ### ONLY for local testing, not supported intravis due to licensces ############## + import Gurobi + import Mosek + import MosekTools + gurobi = JuMP.with_optimizer(Gurobi.Optimizer) + mosek = JuMP.with_optimizer(Mosek.Optimizer) + ############################## +end @testset "PowerModelsACDC" begin diff --git a/test/tnep.jl b/test/tnep.jl index 896e1dae..c100ecfc 100644 --- a/test/tnep.jl +++ b/test/tnep.jl @@ -36,105 +36,103 @@ s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => false) end end # -@testset "test soc tnep" begin - @testset "test SOC-BFM tnep" begin - @testset "6-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFPowerModel, juniper; setting = s) - @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) +if local_test == true + @testset "test soc tnep" begin + @testset "test SOC-BFM tnep" begin + @testset "6-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 1.029695717391926; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.9607722492758961; atol = 1e-2) + end + end + @testset "14-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) + end + # + @testset "39-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) end - @testset "9-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFPowerModel, juniper; setting = s) - @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 0.998; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.984497; atol = 1e-2) - end end -# ONLY WITH MOSEK -> Doesn't run on travis, can be used locally -#################################################################### -# @testset "14-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) -# end -# # -# @testset "39-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) -# end - -end -@testset "test SOC-BIM tnep" begin - @testset "6-bus case" begin - resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, juniper; setting = s) - @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) - end - @testset "9-bus case" begin - resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, juniper; setting = s) - @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.484749; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.959131; atol = 1e-2) + @testset "test SOC-BIM tnep" begin + @testset "6-bus case" begin + resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, gurobi; setting = s) + @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, gurobi; setting = s) + @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.9468396226925635; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8653240759694054; atol = 1e-2) + end end -end -@testset "test QC tnep" begin - @testset "6-bus case" begin - resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, juniper; setting = s) - @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) - @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) - @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) - end - @testset "9-bus case" begin - resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, juniper; setting = s) - @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) - @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9092088301606092; atol = 1e-2) - @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.958239; atol = 1e-2) + @testset "test QC tnep" begin + @testset "6-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, gurobi; setting = s) + @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, gurobi; setting = s) + @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9517040201768898; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8510801499908695; atol = 1e-2) + end end end - @testset "test AC tnep" begin @testset "6-bus case" begin resultACP = run_tnepopf("../test/data/tnep/case6_test.m", ACPPowerModel, juniper; setting = s) From eb54869f039f2bf0d95ab0e32a684f847aa65115 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 13:04:19 +0200 Subject: [PATCH 05/10] Update tnep.jl --- test/tnep.jl | 194 +++++++++++++++++++++++++-------------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/test/tnep.jl b/test/tnep.jl index c100ecfc..402e2342 100644 --- a/test/tnep.jl +++ b/test/tnep.jl @@ -36,103 +36,103 @@ s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => false) end end # -if local_test == true - @testset "test soc tnep" begin - @testset "test SOC-BFM tnep" begin - @testset "6-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) - end - @testset "9-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 1.029695717391926; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.9607722492758961; atol = 1e-2) - end - end - @testset "14-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) - end - # - @testset "39-bus case" begin - resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) - @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) - end - - end - - @testset "test SOC-BIM tnep" begin - @testset "6-bus case" begin - resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, gurobi; setting = s) - @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) - end - @testset "9-bus case" begin - resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, gurobi; setting = s) - @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.9468396226925635; atol = 1e-2) - @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8653240759694054; atol = 1e-2) - - end - end - - @testset "test QC tnep" begin - @testset "6-bus case" begin - resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, gurobi; setting = s) - @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) - @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) - @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) - end - @testset "9-bus case" begin - resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, gurobi; setting = s) - @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) - @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) - @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9517040201768898; atol = 1e-2) - @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8510801499908695; atol = 1e-2) - end - end -end +# if local_test == true +# @testset "test soc tnep" begin +# @testset "test SOC-BFM tnep" begin +# @testset "6-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) +# end +# @testset "9-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 1.029695717391926; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.9607722492758961; atol = 1e-2) +# end +# end +# @testset "14-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) +# end +# # +# @testset "39-bus case" begin +# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) +# @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) +# end +# +# end +# +# @testset "test SOC-BIM tnep" begin +# @testset "6-bus case" begin +# resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, gurobi; setting = s) +# @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) +# end +# @testset "9-bus case" begin +# resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, gurobi; setting = s) +# @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) +# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.9468396226925635; atol = 1e-2) +# @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8653240759694054; atol = 1e-2) +# +# end +# end +# +# @testset "test QC tnep" begin +# @testset "6-bus case" begin +# resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, gurobi; setting = s) +# @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) +# @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) +# @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) +# end +# @testset "9-bus case" begin +# resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, gurobi; setting = s) +# @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) +# @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) +# @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9517040201768898; atol = 1e-2) +# @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8510801499908695; atol = 1e-2) +# end +# end +# end @testset "test AC tnep" begin @testset "6-bus case" begin resultACP = run_tnepopf("../test/data/tnep/case6_test.m", ACPPowerModel, juniper; setting = s) From 6fcd4acbcec092d85064772ec753a4df667179d7 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 13:05:12 +0200 Subject: [PATCH 06/10] Fix test --- test/runtests.jl | 4 +- test/tnep.jl | 196 +++++++++++++++++++++++------------------------ 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 1a3fc2e0..fd5554d0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ import Juniper using Test -local_test = true +local_test = false ipopt_solver = JuMP.with_optimizer(Ipopt.Optimizer, tol=1e-6, print_level=0) scs_solver = JuMP.with_optimizer(SCS.Optimizer) @@ -24,7 +24,7 @@ cbc = JuMP.with_optimizer(Cbc.Optimizer, tol=1e-4, print_level=0) juniper = JuMP.with_optimizer(Juniper.Optimizer, nl_solver = ipopt_solver, mip_solver= cbc, time_limit= 7200) -if local_test == false +if local_test == true ### ONLY for local testing, not supported intravis due to licensces ############## import Gurobi import Mosek diff --git a/test/tnep.jl b/test/tnep.jl index 402e2342..bcb1f208 100644 --- a/test/tnep.jl +++ b/test/tnep.jl @@ -35,104 +35,104 @@ s = Dict("output" => Dict("branch_flows" => true), "conv_losses_mp" => false) end end -# -# if local_test == true -# @testset "test soc tnep" begin -# @testset "test SOC-BFM tnep" begin -# @testset "6-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) -# end -# @testset "9-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 1.029695717391926; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.9607722492758961; atol = 1e-2) -# end -# end -# @testset "14-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) -# end -# # -# @testset "39-bus case" begin -# resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) -# @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) -# end -# -# end -# -# @testset "test SOC-BIM tnep" begin -# @testset "6-bus case" begin -# resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, gurobi; setting = s) -# @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) -# end -# @testset "9-bus case" begin -# resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, gurobi; setting = s) -# @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) -# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.9468396226925635; atol = 1e-2) -# @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8653240759694054; atol = 1e-2) -# -# end -# end -# -# @testset "test QC tnep" begin -# @testset "6-bus case" begin -# resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, gurobi; setting = s) -# @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) -# @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) -# @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) -# end -# @testset "9-bus case" begin -# resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, gurobi; setting = s) -# @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) -# @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) -# @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9517040201768898; atol = 1e-2) -# @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8510801499908695; atol = 1e-2) -# end -# end -# end + +if local_test == true + @testset "test soc tnep" begin + @testset "test SOC-BFM tnep" begin + @testset "6-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case6_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 31.6; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case9_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["1"]["pf"], 1.029695717391926; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.9607722492758961; atol = 1e-2) + end + end + @testset "14-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case14_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 20; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["7"]["isbuilt"], 1; atol = 1e-2) + end + # + @testset "39-bus case" begin + resultSOCBF = run_tnepopf_bf("../test/data/tnep/case39_test.m", SOCBFConicPowerModel, mosek; setting = s) + @test isapprox(resultSOCBF["objective"], 30.4; atol = 1e-1) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCBF["solution"]["branchdc_ne"]["29"]["isbuilt"], 1; atol = 1e-2) + end + + end + + @testset "test SOC-BIM tnep" begin + @testset "6-bus case" begin + resultSOCWR = run_tnepopf("../test/data/tnep/case6_test.m", SOCWRPowerModel, gurobi; setting = s) + @test isapprox(resultSOCWR["objective"], 31.63; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 0; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["3"]["pf"], -2.29067; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultSOCWR = run_tnepopf("../test/data/tnep/case9_test.m", SOCWRPowerModel, gurobi; setting = s) + @test isapprox(resultSOCWR["objective"], 10.7; atol = 1e-1) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["branchdc_ne"]["1"]["pf"], 0.9468396226925635; atol = 1e-2) + @test isapprox(resultSOCWR["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8653240759694054; atol = 1e-2) + + end + end + + @testset "test QC tnep" begin + @testset "6-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case6_test.m", QCRMPowerModel, gurobi; setting = s) + @test isapprox(resultQC["objective"], 31.6; atol = 1e-1) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["4"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["5"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["6"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["10"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["3"]["pf"], -2.29; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 1.18695; atol = 1e-2) + end + @testset "9-bus case" begin + resultQC = run_tnepopf("../test/data/tnep/case9_test.m", QCRMPowerModel, gurobi; setting = s) + @test isapprox(resultQC["objective"], 10.7; atol = 1e-1) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["1"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["convdc_ne"]["2"]["isbuilt"], 1; atol = 1e-2) + @test isapprox(resultQC["solution"]["branchdc_ne"]["1"]["pf"], 0.9517040201768898; atol = 1e-2) + @test isapprox(resultQC["solution"]["busdc_ne"]["2"]["wdc_ne"], 0.8510801499908695; atol = 1e-2) + end + end +end @testset "test AC tnep" begin @testset "6-bus case" begin resultACP = run_tnepopf("../test/data/tnep/case6_test.m", ACPPowerModel, juniper; setting = s) From b90e40d96ca6bc14f9d4e695f1c5d880f25a0dd5 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 13:14:15 +0200 Subject: [PATCH 07/10] Update Project.toml --- Project.toml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 48f06130..843512f2 100644 --- a/Project.toml +++ b/Project.toml @@ -11,14 +11,12 @@ Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] -Cbc = "≥ 0.4" -InfrastructureModels = "~ 0.4" -Ipopt = "≥ 0.4" +Cbc = "~ 0.4.0" +InfrastructureModels = "~ 0.4.2" +Ipopt = "≥ 0.4.0" PowerModels = "~ 0.15.3" -JuMP = "~0.19.1, ~0.20, ~0.21" -SCS = "≥ 0.6.3" -Memento = "~0.10, ~0.11, ~0.12, ~0.13, ~1.0" -julia = "^1" +SCS = "~ 0.4.0" +julia = "≥ 1.1.0" [extras] Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76" From d03afa3be2803bfd0c1783c9967213dc31aaf3eb Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 13:17:33 +0200 Subject: [PATCH 08/10] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 843512f2..94b27a79 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] Cbc = "~ 0.4.0" -InfrastructureModels = "~ 0.4.2" +InfrastructureModels = "≥ 0.4.2" Ipopt = "≥ 0.4.0" PowerModels = "~ 0.15.3" SCS = "~ 0.4.0" From 7e9567dca26023976520a39432cd7fc95a35d819 Mon Sep 17 00:00:00 2001 From: Hakan Ergun Date: Tue, 14 Apr 2020 13:21:17 +0200 Subject: [PATCH 09/10] update .toml --- Project.toml | 9 ++------- test/REQUIRE | 4 +--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index 94b27a79..a21c91ac 100644 --- a/Project.toml +++ b/Project.toml @@ -11,18 +11,13 @@ Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] -Cbc = "~ 0.4.0" InfrastructureModels = "≥ 0.4.2" -Ipopt = "≥ 0.4.0" PowerModels = "~ 0.15.3" -SCS = "~ 0.4.0" julia = "≥ 1.1.0" [extras] -Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76" -Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" -SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13" +PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["SCS", "Test", "Cbc", "Ipopt"] +test = ["Test", "PowerModels"] diff --git a/test/REQUIRE b/test/REQUIRE index 3a5539a6..1b1448d7 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,6 +1,4 @@ julia 1.1 -Ipopt 0.4 -SCS 0.4 -Cbc 0.4 +PowerModels 0.15.3 From d868807db8aa67c741ed5305feefcb931624ad8a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2020 12:05:56 +0000 Subject: [PATCH 10/10] CompatHelper: add new compat entry for "JuMP" at version "0.21" --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index a21c91ac..11f60a55 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" [compat] InfrastructureModels = "≥ 0.4.2" +JuMP = "0.21" PowerModels = "~ 0.15.3" julia = "≥ 1.1.0"