-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_sensitivity.py
More file actions
38 lines (30 loc) · 1.24 KB
/
Copy pathgenerate_sensitivity.py
File metadata and controls
38 lines (30 loc) · 1.24 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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
SRV = 4000
DUR = 192
# Load data
df = pd.read_csv('Paper_Workspace/resources/machine_usage_sample_clean.csv')
df['frac'] = df['cpu_util_percent'] / 100.0
p_idles = [100.0, 150.0, 200.0]
labels = ['Optimistic (100W)', 'Baseline (150W)', 'Pessimistic (200W)']
res = []
for p, l in zip(p_idles, labels):
w_watt = p * (1 - df['frac'])
# Apply Power Usage Effectiveness (PUE) of 1.2
w_mwh = (w_watt.mean() * SRV * DUR * 1.2) / 1000000
res.append({'Scenario': l, 'Wasted_MWh': w_mwh})
d_res = pd.DataFrame(res)
plt.figure(figsize=(9, 5))
sns.barplot(data=d_res, x='Scenario', y='Wasted_MWh', palette='YlOrRd')
plt.title('Sensitivity Analysis: Wasted Energy vs P_idle Assumption (8 Days)')
plt.ylabel('Wasted Energy (MWh)')
plt.xlabel('Idle Power Scenario')
for p in plt.gca().patches:
plt.gca().annotate(f'{p.get_height():,.0f} MWh',
(p.get_x() + p.get_width() / 2., p.get_height()),
ha='center', va='center', xytext=(0, 8), textcoords='offset points')
plt.tight_layout()
plt.savefig('Paper_Workspace/resources/figure8_sensitivity_analysis.png', dpi=150)
print("Saved figure8_sensitivity_analysis.png")