Improve readability

This commit is contained in:
Marek Wolan
2023-06-27 12:56:15 +01:00
parent cdeb6abf60
commit de91a50581

View File

@@ -78,21 +78,29 @@ 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( _LOGGER.debug(
f"Applying reward of {ier_reward} because IER {ier_key} is blocked" f"Applying reward of {ier_reward} because IER {ier_key} is blocked"
) )
reward_value += ier_reward reward_value += ier_reward
else: elif live_blocked and reference_blocked:
_LOGGER.debug( _LOGGER.debug(
( (
f"IER {ier_key} is blocked in the reference and live environments. " f"IER {ier_key} is blocked in the reference and live environments. "
f"Therefore, no penalty was applied." f"Penalty of {ier_reward} was NOT applied."
)
)
elif not live_blocked and reference_blocked:
_LOGGER.debug(
(
f"IER {ier_key} is blocked in the reference env but not in the live one. "
f"Penalty of {ier_reward} was NOT applied."
) )
) )