forked from lanl-ansi/PowerModels.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tnep.jl
85 lines (57 loc) · 2.38 KB
/
tnep.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
function check_tnep_status(sol)
for (idx,val) in sol["ne_branch"]
@test val["built"] == 0.0 || val["built"] == 1.0
end
end
@testset "test soc tnep" begin
@testset "3-bus case" begin
result = run_tnep("../test/data/case3_tnep.m", SOCWRPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 2; atol = 1e-2)
end
@testset "5-bus rts case" begin
result = run_tnep("../test/data/case5_tnep.m", SOCWRPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 1; atol = 1e-2)
end
end
@testset "test dc tnep" begin
@testset "3-bus case" begin
result = run_tnep("../test/data/case3_tnep.m", DCPPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 2; atol = 1e-2)
end
@testset "5-bus case" begin
result = run_tnep("../test/data/case5_tnep.m", DCPPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 1; atol = 1e-2)
end
end
@testset "test dc-losses tnep" begin
@testset "3-bus case" begin
result = run_tnep("../test/data/case3_tnep.m", DCPLLPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 2; atol = 1e-2)
end
@testset "5-bus case" begin
result = run_tnep("../test/data/case5_tnep.m", DCPLLPowerModel, pajarito_solver)
check_tnep_status(result["solution"])
@test result["status"] == :Optimal
@test isapprox(result["objective"], 0; atol = 1e-2)
end
end
if (Pkg.installed("AmplNLWriter") != nothing && Pkg.installed("CoinOptServices") != nothing)
@testset "test ac tnep" begin
@testset "5-bus case" begin
result = run_tnep("../test/data/case5_tnep.m", ACPPowerModel, BonminNLSolver(["bonmin.bb_log_level=0", "bonmin.nlp_log_level=0"]))
check_tnep_status(result["solution"])
@test result["status"] == :LocalOptimal
@test isapprox(result["objective"], 1; atol = 1e-2)
end
end
end