diff --git a/instance1.py b/instance1.py index 364811c05529b19f890baaee84fa54c3e4298c99..1dbe89760ef947e84397bbfef19c39a835e62db4 100755 --- a/instance1.py +++ b/instance1.py @@ -41,7 +41,7 @@ def run_expe(expe_num, user_category, window_size, clean_log): wl_folder = f'{WL_DIR}/expe{expe_num}' pf = f"{ROOT_DIR}/platform/average_metacentrum.xml" wl = f"{WL_DIR}/empty_workload.json" - uf = f"{ROOT_DIR}/sched_input/user_description_file.json" + uf = f"{EXPE_DIR}/cmd/user_description_file.json" # Demand response window, from 12 to (12 + window_size) on day2 dm_window = [(24+12)*3600, (int) ((24+12+window_size)*3600)] diff --git a/scripts/util.py b/scripts/util.py index d5801a7ce1fd7694fab88d16eecebf2b2d421a8c..d2dc481b42a8c1668a96d3f3a4376e98e8247c29 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -2,6 +2,8 @@ import os import os.path import subprocess +import numpy as np +import pandas from matplotlib import figure, pyplot as plt from evalys.jobset import JobSet from evalys.metrics import compute_load @@ -90,4 +92,37 @@ def plot_load_and_details(expe_file): plt.xlim(begin, end) fig.savefig(expe_file + '_viz.png') plt.show() - plt.close(fig) \ No newline at end of file + plt.close(fig) + +def energy_consumed_in(window, OUT_DIR): + """Return the energy consumed during the time window (in kWh).""" + # The problem is that batsim time series don't always have the specific + # timestamp, we need to extrapolate + data = pandas.read_csv(OUT_DIR + "/_consumed_energy.csv") + energy = [0, 0] + for i in range(2): + first_greater = data[data['time'].ge(window[i])].index[0] + df_entry = data.iloc[first_greater] + energy[i] = df_entry['energy'] + delta_energy = (df_entry['time'] - window[i]) * df_entry['epower'] + energy[i] -= delta_energy + + return (energy[1] - energy[0]) / 3600 / 1000 + + +def scheduling_metrics_in(window, OUT_DIR): + """Return the usual scheduling metrics for the subpart of jobs that have their submission time within the time window.""" + [inf, sup] = window + data = pandas.read_csv(OUT_DIR + "/_jobs.csv") + data_in_window = data[(data.submission_time + >= inf) & (data.submission_time <= sup)] + + out = {} + out["makespan"] = data_in_window["finish_time"].max() - inf + out["#jobs"] = len(data_in_window.index) + out["mean_waiting_time"] = data_in_window["waiting_time"].mean() + out["max_waiting_time"] = data_in_window["waiting_time"].max() + out["mean_slowdown"] = data_in_window["stretch"].mean() + out["max_slowdown"] = data_in_window["stretch"].max() + + return out \ No newline at end of file