forked from lanl-ansi/PowerModels.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.jl
41 lines (28 loc) · 1.58 KB
/
docs.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
@testset "code snippets from docs" begin
@testset "DATA.md - The Network Data Dictionary" begin
network_data = PowerModels.parse_file("../test/data/matpower/case14.m")
@test length(network_data["bus"]) == 14
@test length(network_data["branch"]) == 20
end
@testset "README.md - Modifying Network Data" begin
network_data = PowerModels.parse_file("../test/data/matpower/case3.m")
result = run_opf(network_data, ACPPowerModel, JuMP.optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0))
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5906.88; atol = 1e0)
network_data["load"]["3"]["pd"] = 0.0
network_data["load"]["3"]["qd"] = 0.0
result = run_opf(network_data, ACPPowerModel, JuMP.optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0))
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 2937.16; atol = 1e0)
end
@testset "README.md - JuMP Model Inspection" begin
pm = instantiate_model("../test/data/matpower/case3.m", ACPPowerModel, PowerModels.build_opf)
#pretty print the model to the terminal
#print(pm.model)
@test num_nonlinear_constraints(pm.model) == 12
@test JuMP.num_variables(pm.model) == 28
result = optimize_model!(pm, optimizer=JuMP.optimizer_with_attributes(Ipopt.Optimizer, "print_level"=>0))
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5906.88; atol = 1e0)
end
end