-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_opt_wq.jl
36 lines (27 loc) · 930 Bytes
/
test_opt_wq.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
##### Load dependencies and network data #####
using wq_robust_mpc
using Revise
using Plots
net_name = "Net1" # "Threenode", "Net1", "Net3"
network = load_network(net_name)
##### Optimization functions #####
# optimization inputs
sim_days = 1
Δk = 60 * 15
Δt = 60 * 5
kb = 0.5 # (1/day)
kw = 0 # (m/day)
disc_method = "implicit-upwind" # "explicit-central", "implicit-upwind"
source_cl = repeat([0.25], network.n_r)
b_loc, _ = get_booster_inputs(network, net_name, sim_days, Δk, Δt) # booster control locations
x0 = 0.25 # initial conditions
x_bounds = (0.2, 4)
u_bounds = (0, 5)
# optimize water quality
c_r, c_j, c_tk, c_m, c_v, c_p, u = optimize_wq(network, sim_days, Δt, Δk, source_cl, b_loc, x0; kb=kb, kw=kw, disc_method=disc_method, x_bounds=x_bounds, u_bounds=u_bounds)
# plot optimization results
plot(c_tk[1, 1:end-1])
plot(c_j[5, 1:end-1])
plot(c_p[8, 1:end-1])
plot(c_m[1, 1:end-1])
plot(u[1, 1:end-1])