component_level_recovery_activities_model

class pyrecodes.component_recovery_model.component_level_recovery_activities_model.ComponentLevelRecoveryActivitiesModel(recovery_model_parameters: dict, REPAIR_ACTIVITY_NAME='Repair')

Bases: AbstractRecoveryModel

Component recovery model that considers multiple recovery activities defined on a component level.

This model accounts for several impeding factors and a single repair activity.

Attributes:

damage_level (float): The damage level of the component (between 0 and 1). damage_to_functionality_relation (relation.Relation): The relation to get the functionality level based on the current damage level. recovery_activities (dict): A dictionary of recovery activities parameters. REPAIR_ACTIVITY_NAME (str): The name of the repair activity - one that actually reduces the damage level.

check_preceding_activities() None

Check if preceding activities are finished for all recovery activities and set the preceding_activities_finished attribute accordingly.

damage_level: float
damage_to_functionality_relation: Relation
find_recovery_activity_that_demands_the_resource(resource_name: str) RecoveryActivity

Find the recovery activity that demands the resource resource_name.

Args:

resource_name (str): The name of the resource.

Returns:

RecoveryActivity: The recovery activity that demands the resource.

Raises:

ValueError: If no recovery activity demands the resource.

get_damage_level() float

Get the current damage level of the component. It’s 1 - the progress level of the repair activity.

Returns:

float: The damage level (between 0 and 1).

get_demand() dict

Get the resource demand needed to meet the demand of all recovery activities currently in progress.

Returns:

dict: A dictionary of resource demands for active recovery activities.

preceding_activities_finished(recovery_activity_object: RecoveryActivity) bool

Check if preceding activities for a single recovery activity are finished.

Args:

recovery_activity_object (RecoveryActivity): The recovery activity to check.

Returns:

bool: True if all preceding activities are finished, False otherwise.

recover(time_step: int) None

Perform recovery for a time step. Increase the level of all activities that are not finished, for which all preceding activities are finished and the resource demand is met.

Args:

time_step (int): The time step for which recovery is performed.

TODO: Not sure if there should be a for loop with start and end time steps or just get the length and multiply by the rate. Compare computational time.

recovery_activities: dict
set_activities_demand_to_met() None

Set the demand for recovery activities to met. This is done before resource are distributed at each time step, as resource distribution can only reduce the percent of met demand of a component - this is an iRe-CoDeS assumption.

set_initial_damage_level(damage_level: float) None

Set the initial damage level. The damage level must be between 0 and 1.

Sets the progress level of all activities to 0 and the progress level of the repair activity to 1 - damage_level.

Args:

damage_level (float): The initial damage level (between 0 and 1).

set_initial_repair_activity_state(damage_level: float) None

Set the initial state of the repair activity. Initial level is 1 - damage_level and the rate is damage_level / duration to ensure that the component is repaired in the specified duration.

Args:

damage_level (float): The initial damage level (between 0 and 1).

set_met_demand_for_recovery_activities(resource_name: str, percent_of_met_demand: float) None

Set the percent of met demand for a recovery activity that requires the resource resource_name. This method is called during resource distribution.

Args:

resource_name (str): The name of the resource. percent_of_met_demand (float): The percent of met demand (between 0 and 1).:

TODO:

Add recovery activity name as input parameter. This will allow the same resource to be demanded by multiple recovery activities. Not possible at the moment.

set_parameters(parameters: dict) None

Set parameters for all recovery activities. Parameters are preceding activities, duration, and demand of activities.

Args:

parameters (dict): Parameters for the recovery model.