standard_irecodes_component

class pyrecodes.component.standard_irecodes_component.StandardiReCoDeSComponent

Bases: Component

Implementation of the Component interface to define standard functionality of a component in pyrecodes.

class DemandTypes(value)

Bases: Enum

Enum Class to specify the strings used for component’s demand types.
Two demand types are currently considered in pyrecodes: operation and recovery demand.
OPERATION_DEMAND = 'OperationDemand'
RECOVERY_DEMAND = 'RecoveryDemand'
class SupplyTypes(value)

Bases: Enum

Enum Class to specify the strings used for component’s supply types.
Only one supply type is currently considered in pyrecodes.
SUPPLY = 'Supply'
add_resources(supply_or_demand: str, type: str, resource_dict: dict) None
Add resources to the component’s supply or demand, depending on the supply_or_demand parameter.
The type parameter specifies the type of the supply or demand.
The resource_dict parameter is a dict with resource names as keys and resource parameters as values.
check_if_functional(time_step: int) None
Check if the component is functional at time_step. Component is considered functional if its functionality level is higher than 0.
If the component is functional at time_step, add time_step to the component’s “functional” list.
construct(component_name: str, component_parameters: dict) None
form_resource(resource_name: str, resource_parameters: dict, default_resource_class_name='ConcreteResource', default_resource_file_name='concrete_resource') None
Form a resource object based on the resource_name and resource_parameters.
Default resource class is ConcreteResource. Specify a different default resource class if needed.
Check out the resource parameters dict in the component library files in the examples to get the dict structure.
TODO: Add the dict structure here. Future work.
get_current_resource_amount(supply_or_demand: str, type: str, resource_name: str) float
Get the current amount of a resource resource_name in component’s supply or demand and the type of the supply or demand.
In case resource is not in component’s supply or demand, returns 0.
get_damage_level() float

Get the current damage level of the component.

get_locality() list

Get component locality ids.

has_operation_demand() bool

Check whether the component has any operation demand - if it needs any resource to operate.

has_resource_supply(resource_name: str) bool

Check whether the component has a supply of the resource resource_name.

recover(time_step: int)

Recover the component as defined in its recovery model.

set_initial_damage_level(damage_level: float) None

Set the initial damage level of the component. Damage level must be between 0 and 1.

set_locality(locality_id: [<class 'int'>]) None

Set component locality ids. Locality id is a list of integers.

set_met_demand_for_recovery_activities(resource_name: str, percent_of_met_demand: float) None
Set the demand_met for the component’s recovery activity that require the resource resource_name.
This is how recovery resource constraints are captured.
This method is called once the resource distribution is performed at a time step.
Note: At this point, two recovery activities CANNOT ask for the same resource!
TODO: Add recovery_activity as input, then it would be possible. Future work.
set_name(name: str) None

Set component name.

set_operation_demand(operation_demand_parameters: dict) None
Set component’s operation demand as defined in operation_demand_parameters.
Check out the operation_demand in the component library files in the examples to get the dict structure.
TODO: Add the dict structure here. Future work.
set_recovery_model(recovery_model_parameters: dict) None
Set component recovery model as defined in recovery_model_parameters dict.
The data provided in the recovery_model_parameters depends on the recovery model type.
set_recovery_model_activities_demand_to_met()

Set the demand of all component’s recovery activities as met.

set_recovery_time_steps(recovery_time_steps: list) None
set_supply(supply_parameters: dict) None
Set component’s supply as defined in supply_parameters.
Check out the supply_parameters in the examples to get the dict structure.
TODO: Add the dict structure here. Future work.
unmet_demand_can_affect_resource_supply(resource_name: str) bool

Check if the component has a supply of the resource resource_name and if the supply can be affected by unmet demand - i.e., if the UnmetDemandToAmountRelation is not constant.

update(time_step: int) None
Update component’s state based on its current damage level and damage-to-functionality relation.
This includes updating component’s functionality_level, checking if the component is functional at time_step and updating its supply, operation and recovery demand.
update_functionality() None

Update component’s functionality level by calling the recovery model’s get_functionality_level method.

update_operation_demand() None

Update component’s operation demand based on its current functionality level.

update_recovery_demand()
Update component’s recovery demand based on its currently active recovery activities.
Before resources are distributed, it is assumed that all recovery demand is met.
It is important that this method is called before the resource distribution in a time step of the resilience assessment.
update_resources_based_on_component_functionality(supply_or_demand: str, type: str) None

Update component’s supply or demand based on its current functionality level.

update_supply_based_on_component_functionality() None

Update component’s supply based on its current functionality level.

update_supply_based_on_consumption(resource_name: str, consumed_amount: float) None
Update component’s supply based on how much of its consumable resource is consumed.
If resource is non-consumable, this method does nothing.
This method is called during resource distribution.
update_supply_based_on_unmet_demand(percent_of_met_demand: float) None
Update component’s supply based on how much of its operation demand is met.
This is how component interdependencies are captured.
This method is called during resource distribution.