utility_distribution_model¶
- class pyrecodes.resource_distribution_model.utility_distribution_model.UtilityDistributionModel(resource_name: str, resource_parameters: dict, components: list[Component])¶
Bases:
AbstractResourceDistributionModel
Class to distribute resources in the system. This is the simplest distribution model, which distributes resources based on the priority of the components.Resource distribution is done using the system matrix, containing the supply and demand of each component.No physical laws (e.g., power flow or water flow physics) are considered in the distribution of resources.- add_supplier(component_row_id: int, suppliers: list) tuple[list, bool] ¶
- deepcopy(input: list)¶
Method to deepcopy a dict or a list. Alternative to copy.deepcopy as it is too expensive.
Copied from System class! Consider moving to a separate module.
- distribute(time_step: int) None ¶
- fill_system_matrix()¶
- get_best_path_functionality(locality_pairs: list, transfer_service_demand: float) float ¶
- get_component_priorities()¶
- get_demand(component_row_id: int) float ¶
- get_locality_pairs(supplier_start_locality: int, supplier_end_locality: int, component_localities: list) list ¶
Finds non-duplicate locality pairs between supplier and component.
- get_optimal_path(start_locality: int, end_locality: int) float ¶
Method outputs the supply capacity and the localities of the optimal path between two localities. If transfer services are not needed to transfer the resource, transfer service distribution model should not be assigned (stay None) and the method will return math.inf as the optimal path supply capacity. Works only when start and end locality are different. If they are the same, method get_path_functionality returns the appropriate values.
- get_path_functionality(start_locality, end_locality, transfer_service_demand)¶
- Method calculates path functionality by comparing the transfer service supply
of the optimal path with the demand.
- get_scope(scope='All') list ¶
Get the scope of the Re-CoDeS Resilience Calculator to get total supply and demand.
Scope can be ‘All’ or ‘Locality X’, where X is the locality number.
This method works only if you have the system matrix in the distribution model.
- get_total_consumption(scope='All') float ¶
- get_total_demand(scope='All') float ¶
- get_total_supply(scope='All') float ¶
- get_transfer_service_demand(component_row_id: int, demand_type: str) float ¶
Method assumes that the transfer service demand is the same as the demand for the utility resource.
- meet_component_demand(suppliers: dict, component_row_id: int, component_demand_type: str)¶
- modify_demand_to_account_for_resource_transfer(supplier_start_locality: int, supplier_end_locality: int, component_demand: float, component_localities: list[int], transfer_service_demand: float) float ¶
- put_current_supplier_on_top(suppliers)¶
- reduce_component_supply(component_row_id: int, percent_of_met_demand: float)¶
- reset_supplier_order(suppliers: list) list ¶
- reset_suppliers(initial_suppliers: list) list ¶
- resource_name: str¶
- set_component_row_based_on_demand_type(component_priorities_id: list[int], component_demand_types: list[str])¶
- set_demand_met_indicator(component_row_id: int, percent_of_met_demand: float)¶
- set_met_demand_for_recovery_activities(component_row_id: int, percent_of_met_demand: float)¶
- suppliers_meet_component_demand(suppliers, component_demand, component_localities, transfer_service_demand)¶
- system_matrix: SingleResourceSystemMatrixCreator¶
- transfer_service_distribution_model: ResourceDistributionModel¶
- update_consumed_amounts(suppliers: dict, initial_suppliers: dict) None ¶
- update_supplier_resource_amount(supplier: dict, current_supply: float) None ¶
- update_suppliers_based_on_consumption(suppliers: list)¶