Skip to content

Commit

Permalink
pour l'article 1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrecuer committed May 18, 2023
1 parent fce7beb commit ec0c991
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ def play_baseline(text, debit, t_c, **params):
label_eau = f'T_eau_retour={coeffs[0]:.2f} * T_eau_départ + {coeffs[1]:.2f}'

title = f'BASELINE ENERGETIQUE pour un débit de {debit} m3/h'
title = f'{title}et pour R = {_r_:.2e} K/W'
title = f'{title} et pour R = {_r_:.2e} K/W'
title = f'{title} ts={ts}'

label_power = "puissance en W pour maintien à 20 °C"

print(ts)
plt.figure(figsize=(20,10))
ax1 = plt.subplot(311)
plt.title(title)
plt.plot(xr, t_ext_week, label="Text °C")
plt.legend(loc="upper left")
ax2 = ax1.twinx()
ax2.set_ylim([t_c-1, t_c+1])
ax2.set_ylim([t_c-0.05, t_c+0.05])
plt.plot(xr, t_int, label="Tint °C", color="green")
plt.legend()

Expand Down
12 changes: 7 additions & 5 deletions energy_gym/evaluation_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class EvaluateGisement:
def __init__(self, env, **params):
"""initialisation"""
self._n = params.get("N", MAX_EPISODES)
print(f'on va jouer {self._n} épisodes')
self._env = env
# numéro de l'épisode
self.nb_episode = 0
Expand Down Expand Up @@ -222,8 +221,10 @@ def close(self):
self._stats = self._stats[self._stats[:,5].argsort()]
stats_moy = np.mean(self._stats, axis=0).round(1)
stats_moy_m1 = np.mean(self._stats[:self._n//2,:], axis=0).round(1)
title = f'Conso solution optimale : {stats_moy[1]}'
title = f'{title} / Conso loi d\'eau maintien à tc : {stats_moy[2]}\n'
title = f'Conso hebdomadaire moyenne solution optimale :'
title = f'{title} {int(stats_moy[1]/1000)} kWh'
title = f'{title} / Conso hebdomadaire moyenne loi d\'eau maintien à tc :'
title = f'{title} {int(stats_moy[2]/1000)} kWh\n'
gain = round(100*(stats_moy[2]-stats_moy[1])/stats_moy[2], 2)
title = f'{title} Pourcentage de gain : {gain} %'
gain_m1 = round(100*(stats_moy_m1[2]-stats_moy_m1[1])/stats_moy_m1[2], 2)
Expand All @@ -238,9 +239,10 @@ def close(self):
plt.plot(xr, self._stats[:,4]*1e-9, label = "C * 1e-9 J/K")
plt.legend()
plt.subplot(313)
label = "ECONOMIES sur maintien à tc en W"
plt.fill_between(xr, 0, self._stats[:, 2] - self._stats[:, 1],
label = "ECONOMIES sur maintien à tc en kWh"
plt.fill_between(xr, 0, (self._stats[:, 2] - self._stats[:, 1])/1000,
color="blue", alpha=0.6, label=label)
plt.legend()
plt.show()
plt.close()

Expand Down
20 changes: 15 additions & 5 deletions energy_gym/heatgym.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,21 @@ def _render(self, zone_confort=None, zones_occ=None,
self._ax1.clear()
self._ax2.clear()
self._ax3.clear()
self._ax1.plot(self._xr, self.text[self.pos:self.pos+self.wsize+1])
self._ax2.plot(self._xr[0:self.i], self.tint[0:self.i])
self._ax3.plot(self._xr[0:self.i], self.action[0:self.i])
self._ax1.plot(self._xr, self.text[self.pos:self.pos+self.wsize+1], label="Text °C")
if (self.tint == np.zeros(self.tint.shape[0])).all():
self._ax2.plot(self._xr[0:self.i], self.tint[0:self.i], label="Tint agent °C")
self._ax3.plot(self._xr[0:self.i], self.action[0:self.i], label="action agent")
# données externes
if extra_datas is not None and not stepbystep:
self._ax2.plot(self._xr[0:self.wsize], extra_datas[:,1], color="orange")
self._ax2.plot(self._xr[0:self.wsize],
extra_datas[:,1],
color="orange",
label="Tint solution optimale °C")
energy = extra_datas[:,0] * (self.action_space.n - 1)
self._ax3.plot(self._xr[0:self.wsize], energy, color="orange")
self._ax3.plot(self._xr[0:self.wsize],
energy,
color="orange",
label="action solution optimale")
if self.i :
if zone_confort is not None :
self._ax2.add_patch(zone_confort)
Expand All @@ -430,6 +437,9 @@ def _render(self, zone_confort=None, zones_occ=None,
self._ax2.add_patch(occ)
# si stepbystep est True, on affiche l'image et le mode snapshot est sans effet
# si snapshot est False, qu'on soit en mode stepbystep ou pas, on affiche l'image
self._ax1.legend()
self._ax2.legend()
self._ax3.legend()
if stepbystep or not snapshot:
plt.show()
if stepbystep:
Expand Down

0 comments on commit ec0c991

Please sign in to comment.