Improve readability

This commit is contained in:
Marek Wolan
2023-06-27 12:56:15 +01:00
parent 79ecb8e0b9
commit 0bff2d2f36

View File

@@ -78,23 +78,31 @@ def calculate_reward_function(
start_step = ier_value.get_start_step() start_step = ier_value.get_start_step()
stop_step = ier_value.get_end_step() stop_step = ier_value.get_end_step()
if step_count >= start_step and step_count <= stop_step: if step_count >= start_step and step_count <= stop_step:
if not ier_value.get_is_running(): reference_blocked = reference_ier.get_is_running()
if reference_ier.get_is_running(): live_blocked = ier_value.get_is_running()
ier_reward = ( ier_reward = (
config_values.green_ier_blocked config_values.green_ier_blocked * ier_value.get_mission_criticality()
* ier_value.get_mission_criticality() )
if live_blocked and not reference_blocked:
_LOGGER.debug(
f"Applying reward of {ier_reward} because IER {ier_key} is blocked"
)
reward_value += ier_reward
elif live_blocked and reference_blocked:
_LOGGER.debug(
(
f"IER {ier_key} is blocked in the reference and live environments. "
f"Penalty of {ier_reward} was NOT applied."
) )
_LOGGER.debug( )
f"Applying reward of {ier_reward} because IER {ier_key} is blocked" elif not live_blocked and reference_blocked:
) _LOGGER.debug(
reward_value += ier_reward (
else: f"IER {ier_key} is blocked in the reference env but not in the live one. "
_LOGGER.debug( f"Penalty of {ier_reward} was NOT applied."
(
f"IER {ier_key} is blocked in the reference and live environments. "
f"Therefore, no penalty was applied."
)
) )
)
return reward_value return reward_value