-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding shell scripts for one line execution of pre and post processin…
…g steps
- Loading branch information
1 parent
e24c0b2
commit f41ea6c
Showing
13 changed files
with
2,994 additions
and
3,551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
This file runs the evecosim.py file with optional arguments. It uses the shell scripts to run the desired | ||
simulations. The shell scripts are located in the same directory as this file. This file requires WSL2 to run without errors. | ||
""" | ||
|
||
import subprocess | ||
import argparse | ||
|
||
|
||
def run_mpc_grid_centralized(): | ||
subprocess.call(['sh', './run-mpc-grid-central.sh']) | ||
return | ||
|
||
|
||
def run_mpc_grid_collocated(): | ||
subprocess.call(['sh', './run-mpc-grid.sh']) | ||
return | ||
|
||
|
||
def run_oneshot_opt(): | ||
subprocess.call(['sh', './run-oneshot.sh']) | ||
return | ||
|
||
|
||
def main(mode): | ||
if mode == 'oneshot': | ||
run_oneshot_opt() | ||
elif mode == 'mpc-grid': | ||
run_mpc_grid_collocated() | ||
elif mode == 'mpc-grid-central': | ||
raise NotImplementedError | ||
else: | ||
raise ValueError(f'Invalid mode: {mode}. Please choose from: oneshot, mpc-grid') | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--mode', type=str, default='oneshot', | ||
help='This flag only included for testing deployment, do not change.') | ||
args = parser.parse_args() | ||
main(args.mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
|
||
cd ../test_cases/battery/feeder_population || exit | ||
|
||
python_file="feeder_population_centralized.py" | ||
text_file="config.txt" | ||
|
||
timestamp_file="exec_timestamp_cen.txt" | ||
|
||
# Function to get the last run time | ||
get_last_run_time() { | ||
if [ -e "$timestamp_file" ]; then | ||
cat "$timestamp_file" | ||
else | ||
echo 0 | ||
fi | ||
} | ||
|
||
# Get the modification times of the files | ||
text_file_time=$(stat -c %Y "$text_file") | ||
last_run_time=$(get_last_run_time) | ||
#printf "Text file time: %s\n" "$(date -d @"$text_file_time")" | ||
#printf "Last run time: %s\n" "$(date -d @"$last_run_time")" | ||
|
||
# Compare the modification times | ||
if [ "$text_file_time" -gt "$last_run_time" ]; then | ||
echo "Feeder config text file has been modified. Running central feeder population..." | ||
date +%s > "$timestamp_file" | ||
python3 "$python_file" | ||
else | ||
echo "No feeder pop config changes detected. Feeder population will not be run." | ||
fi | ||
|
||
cd .. || exit | ||
gridlabd python scenarios.py --scenario 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
|
||
cd ../test_cases/battery/feeder_population || exit | ||
|
||
python_file="feeder_population_collocated.py" | ||
text_file="config.txt" | ||
|
||
timestamp_file="exec_timestamp_coll.txt" | ||
|
||
# Function to get the last run time | ||
get_last_run_time() { | ||
if [ -e "$timestamp_file" ]; then | ||
cat "$timestamp_file" | ||
else | ||
echo 0 | ||
fi | ||
} | ||
|
||
# Get the modification times of the files | ||
text_file_time=$(stat -c %Y "$text_file") | ||
last_run_time=$(get_last_run_time) | ||
#printf "Text file time: %s\n" "$(date -d @"$text_file_time")" | ||
#printf "Last run time: %s\n" "$(date -d @"$last_run_time")" | ||
|
||
# Compare the modification times | ||
if [ "$text_file_time" -gt "$last_run_time" ]; then | ||
echo "Feeder config text file has been modified. Running feeder population..." | ||
date +%s > "$timestamp_file" | ||
python3 "$python_file" | ||
else | ||
echo "No feeder pop config changes detected. Feeder population will not be run." | ||
fi | ||
|
||
cd .. || exit | ||
gridlabd python scenarios.py --scenario 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
cd .. | ||
python3 app.py | ||
cd analysis || exit | ||
python3 load_post_opt_costs.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.