Skip to content

Commit 0fe3ea9

Browse files
committed
implement drift and bias in levels
1 parent d7e42f1 commit 0fe3ea9

53 files changed

Lines changed: 146704 additions & 119710 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ baseline_controllers/alpha/v2/lev1/results/constant-flow_param=0.0_data_log.pkl
5959
*.pkl
6060
*.pkl
6161
*.pkl
62+
*.pkl

baseline_controllers/epsilon/evaluate_baseline_controllers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
'''
1+
22
# install pystorms from the current directory (this should be commented out in final version once pystorms source code isn't changing all the time)
33
import subprocess
44
import sys
55
subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', '-y', 'pystorms'])
66
subprocess.check_call([sys.executable, '-m', 'pip', 'cache', 'purge'])
77
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '.'])
8-
'''
8+
99
import pystorms # this will be the first line of the program when dev is done
1010

1111
import pyswmm
@@ -23,7 +23,7 @@
2323
evaluating = 'equal-filling'
2424
verbose = True
2525
version = "2" # options are "1" and "2"
26-
level = "1" # options are "1" , "2", and "3"
26+
level = "3" # options are "1" , "2", and "3"
2727
plot = True # plot True significantly increases the memory usage.
2828
# set the working directory to the directory of this script
2929
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -159,8 +159,9 @@
159159
if verbose and env.env.sim.current_time.minute == 0 and env.env.sim.current_time.hour % 2 == 0:
160160
u_print = u_open_pct.flatten()
161161
y_measured = env.state(level=level).reshape(-1,1)
162-
print(" y_measured, u")
163-
print(np.c_[np.array(env.config['states'][:11]),np.round(y_measured[:11],2) , np.round(u_print.reshape(-1,1),3)])
162+
y_actual = env.state(level="1").reshape(-1,1)
163+
print(" y_actual, y_measured, u")
164+
print(np.c_[np.array(env.config['states'][:11]),np.round(y_actual[:11],2),np.round(y_measured[:11],2) , np.round(u_print.reshape(-1,1),3)])
164165
print("current time, end time")
165166
print(env.env.sim.current_time, env.env.sim.end_time)
166167
print("\n")

baseline_controllers/epsilon/optimize_parameters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def objective(input_data):
270270
# if flood cost is more than zero, ensure it's more than one
271271
if flood_cost > 0.0 and flood_cost < 1.0:
272272
flood_cost = 1.0
273+
elif any(np.array(data['final_weir_settings']) < 0.01): # weirs ending completely closed
274+
flood_cost = 1.0
273275
elif flood_cost <= 0.0:
274276
flood_cost = max(data['peak_filling_degrees'].values())
275277

@@ -303,6 +305,8 @@ def constraint(input_data):
303305
# if flood cost is more than zero, ensure it's more than one
304306
if flood_cost > 0.0 and flood_cost < 1.0:
305307
flood_cost = 1.0
308+
elif any(np.array(data['final_weir_settings']) < 0.01): # weirs ending completely closed
309+
flood_cost = 1.0
306310
elif flood_cost <= 0.0:
307311
flood_cost = max(data['peak_filling_degrees'].values())
308312

13.6 KB
Loading

0 commit comments

Comments
 (0)