forked from lanl-ansi/PowerModels.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opf-obj.jl
117 lines (87 loc) · 3.71 KB
/
opf-obj.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
### Tests for OPF objective variants ###
@testset "linear objective" begin
data = PowerModels.parse_file("data/matpower/case5.m")
data["gen"]["1"]["cost"] = [1400.0, 1.0]
data["gen"]["4"]["cost"] = [1.0]
data["gen"]["5"]["cost"] = []
@testset "nlp solver" begin
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5420.3; atol = 1e0)
end
@testset "conic solver" begin
result = run_opf(data, SOCWRConicPowerModel, scs_solver)
@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 3095.88; atol = 1e0)
end
@testset "lp solver" begin
result = run_dc_opf(data, cbc_solver)
@test result["termination_status"] == OPTIMAL
# @test isapprox(result["objective"], 4679.05; atol = 1e0) # Problem upstream with JuMP.SecondOrderCone or JuMP.RotatedSecondOrderCone?
end
end
@testset "quadratic objective" begin
data = PowerModels.parse_file("data/matpower/case5.m")
data["gen"]["1"]["cost"] = [1.0, 1400.0, 1.0]
data["gen"]["4"]["cost"] = [1.0]
data["gen"]["5"]["cost"] = []
@testset "nlp solver" begin
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5420.46; atol = 1e0)
end
@testset "conic solver" begin
result = run_opf(data, SOCWRConicPowerModel, scs_solver)
@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 3096.04; atol = 1e0)
end
end
@testset "nlp objective" begin
data = PowerModels.parse_file("data/matpower/case5.m")
data["gen"]["1"]["cost"] = [100.0, 300.0, 1400.0, 1.0]
data["gen"]["4"]["cost"] = [1.0]
data["gen"]["5"]["cost"] = []
@testset "opf objective" begin
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5452.04; atol = 1e0)
end
@testset "opb objective" begin
result = run_opb(data, SOCWRPowerModel, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 2999.80; atol = 1e0)
end
end
@testset "dcline objectives" begin
data = PowerModels.parse_file("data/matpower/case5_dc.m")
@testset "nlp objective" begin
data["dcline"]["1"]["cost"] = [100.0, 300.0, 4000.0, 1.0]
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 18160.3; atol = 1e0)
end
@testset "qp objective" begin
data["dcline"]["1"]["cost"] = [1.0, 4000.0, 1.0]
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 18157.2; atol = 1e0)
end
@testset "linear objective" begin
data["dcline"]["1"]["cost"] = [4000.0, 1.0]
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 18157.2; atol = 1e0)
end
@testset "constant objective" begin
data["dcline"]["1"]["cost"] = [1.0]
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 17757.2; atol = 1e0)
end
@testset "empty objective" begin
data["dcline"]["1"]["cost"] = []
result = run_ac_opf(data, ipopt_solver)
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 17756.2; atol = 1e0)
end
end