Skip to content

Commit

Permalink
refactor: autoformat commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeboute committed Nov 10, 2023
1 parent 16d5603 commit b73798c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions plan4grid/AIPlan4GridAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def __init__(
self.debug = debug
self._nb_gen_actions = _nb_gen_actions
self._nb_sto_actions = _nb_sto_actions
self.up_status=0
self.actionlist = []
self.up_status = 0
self.action_list = []

if self.debug:
level = DEBUG
Expand Down Expand Up @@ -482,7 +482,7 @@ def get_UP_actions(self, step: int, verbose: bool = True) -> tuple[list[ActionSp
up_plan = upp.solve()
end_ = perf_counter()
time_act = end_ - beg_
self.up_status=0
self.up_status = 0
if not up_plan:
self.logger.info("No feasible plan found!")
self.up_status = 1
Expand Down Expand Up @@ -529,14 +529,14 @@ def progress(self) -> tuple[float, float, bool]:
if self.check_congestions() or self.check_topology():
actions, beg_, end_ = self.get_UP_actions(self.env.nb_time_step)
global_time_act += end_ - beg_
if self.up_status==0:
self.actionlist=actions
if self.up_status == 0:
self.action_list = actions
else:
self.logger.info(
f"No congestion detected over the tactical horizon, no UP problem will be solved at time step {self.env.nb_time_step}"
)
beg_ = perf_counter()
self.actionlist = [self.env.action_space({}) for _ in range(self.tactical_horizon)]
self.action_list = [self.env.action_space({}) for _ in range(self.tactical_horizon)]
end_ = perf_counter()
global_time_act += end_ - beg_
i = 0
Expand All @@ -546,13 +546,13 @@ def progress(self) -> tuple[float, float, bool]:
lines_to_reconnect_in_next_action = [
line_id for line_id in self.lines_to_reconnect if line_id[1] == 1
]
if self.actionlist[0] != self.env.action_space({}):
self.logger.info(f"UP agent has returned actions to be applied:\n\n {self.actionlist[0]}\n")
obs, reward, done, info = self.env.step(self.actionlist[0])
if self.action_list[0] != self.env.action_space({}):
self.logger.info(f"UP agent has returned actions to be applied:\n\n {self.action_list[0]}\n")
obs, reward, done, info = self.env.step(self.action_list[0])
if self.tactical_horizon > 1:
self.actionlist = self.actionlist[1:] + [self.env.action_space({})]
self.action_list = self.action_list[1:] + [self.env.action_space({})]
else:
self.actionlist = [self.env.action_space({})]
self.action_list = [self.env.action_space({})]
opp_attack = self.env._oppSpace.last_attack
reward = _aux_add_data(
reward,
Expand All @@ -561,7 +561,7 @@ def progress(self) -> tuple[float, float, bool]:
efficient_storing,
end_,
beg_,
self.actionlist[0],
self.action_list[0],
obs,
info,
self.env.nb_time_step,
Expand All @@ -573,14 +573,14 @@ def progress(self) -> tuple[float, float, bool]:
self.update_states()
if self.check_congestions() or self.check_topology():
actions, beg_, end_ = self.get_UP_actions(self.env.nb_time_step)
if self.up_status==0:
self.actionlist=actions
if self.up_status == 0:
self.action_list = actions
global_time_act += end_ - beg_
else:
self.logger.info(
f"No congestion detected over the tactical horizon, no UP problem will be solved at time step {self.env.nb_time_step}"
)
if len(lines_to_reconnect_in_next_action) > 0:
self.actionlist[0].line_change_status = lines_to_reconnect_in_next_action
self.action_list[0].line_change_status = lines_to_reconnect_in_next_action
i += 1
return reward, global_time_act, done

0 comments on commit b73798c

Please sign in to comment.