forked from WISPO-POP/CATS-CaliforniaTestSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_opf.jl
More file actions
48 lines (39 loc) · 1.11 KB
/
run_opf.jl
File metadata and controls
48 lines (39 loc) · 1.11 KB
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
#########################################################################################################
# run_opf.jl
#
# Run a DC power flow
#
#########################################################################################################
###########
## Setup ##
###########
# Load Julia Packages
#--------------------
using PowerModels
using JuMP
using CSV, JSON
using DataFrames
using Ipopt
# User input
#-----------
save_to_JSON = false
# Specify solver
#----------------
# const IPOPT_ENV = Ipopt.Env()
solver = Ipopt.Optimizer # JuMP.optimizer_with_attributes(() -> Ipopt.Optimizer(), "print_level" => 1)
# Load Data
# ---------
# Load the MATPOWER data file
data = PowerModels.parse_file("MATPOWER/CaliforniaTestSystem.m")
###########
## Solve ##
###########
solution = PowerModels.solve_opf(data, DCPPowerModel, solver)
# Save solution dictionary to JSON
if save_to_JSON == true
stringdata = JSON.json(solution)
# write the file with the stringdata variable information
open("pf_solution.json", "w") do f
write(f, stringdata)
end
end