Cost Graph¶
The Cost Graph is a directed network-based representation of the supply chain superstructure. It is used to store information about the supply chain such as costs and distances. During simulation, the Cost Graph is queried by the DES to calculate pathway characteristics and determine the preferred end-of-life pathway for technology components.
-
class
celavi.costgraph.
CostGraph
(step_costs_file: str, fac_edges_file: str, transpo_edges_file: str, locations_file: str, routes_file: str, pathway_crit_history_filename: str, circular_components: list, component_initial_mass: float, path_dict: dict, sc_begin: List[str] = ['manufacturing'], sc_end: List[str] = ['landfilling'], sc_in_circ: List[str] = [], sc_out_circ: List[str] = [], year: float = 2000.0, start_year: float = 2000.0, verbose: int = 0, save_copy=False, save_name='netw.csv', run=0, random_state=Generator(PCG64) at 0x1DF807ABD60)¶ Reads in supply chain data, creates a network of processing steps and facilities in a circular supply chain, identifies preferred end-of-life pathways through the supply chain, calculates supply chain characteristics such as pathway cost.
-
__init__
(step_costs_file: str, fac_edges_file: str, transpo_edges_file: str, locations_file: str, routes_file: str, pathway_crit_history_filename: str, circular_components: list, component_initial_mass: float, path_dict: dict, sc_begin: List[str] = ['manufacturing'], sc_end: List[str] = ['landfilling'], sc_in_circ: List[str] = [], sc_out_circ: List[str] = [], year: float = 2000.0, start_year: float = 2000.0, verbose: int = 0, save_copy=False, save_name='netw.csv', run=0, random_state=Generator(PCG64) at 0x1DF807ABD60)¶ Reads in small datasets to DataFrames and stores the path to the large locations dataset for later use.
- Parameters
step_costs_file (str) – Path to file listing processing steps and cost calculation methods by facility type.
fac_edges_file (str) – Path to file listing intra-facility edges by facility type.
transpo_edges_file (str) – Path to file listing inter-facility edges and transportation cost calculation methods.
locations_file (str) – Path to dataset of facility locations.
routes_file (str) – Path to dataset of routes between facilities.
pathway_crit_history_filename (str) – Path to file where the history of whatever criterion is used to decide between circularity pathways is saved.
circular_components (list) – Names of components for which this CostGraph is built.
component_initial_mass (float) – Average mass of a single technology component at the beginning of the model run. Units: metric tons (tonnes).
path_dict (Dict) – Dictionary of case-study-specific parameters to be passed into the cost methods. Can be of any structure as defined in the scenario config file.
sc_begin (List[str]) – List of processing step(s) where supply chain paths begin.
sc_end (List[str]) – List of processing step(s) where supply chain paths terminate.
sc_in_circ (List[str]) – Facility type(s) that process material for re-circulation within the supply chain.
sc_out_circ (List[str]) – Facility type(s) that process material for re-circulation outside the supply chain
year (float) – Simulation year provided by the DES at CostGraph instantiation.
start_year (float) – Year at beginning of the model run.
verbose (int) – Integer specifying how much info CostGraph should provide as it works. 0 = No information other than return values 1 = Info on when key methods start and stop >1 = Detailed info on facilities, nodes, and edges
save_copy (bool) – Whether or not to save the initial Cost Graph network structure as a CSV file (edge list).
save_name (str) – CSV file name where the initial Cost Graph network structure is saved (edge list).
run (int) – Model run number for evaluating uncertainty within a scenario
random_state (np.random.default_rng) – Instantiated random number generator for uncertainty analysis.
-
static
get_node_names
(facilityID: List[Union[int, str]], subgraph_steps: list)¶ Generates a list of unique node names from a list of processing steps and a unique facility ID
- Parameters
facilityID ([int, str]) – Unique facility identifier.
subgraph_steps (list of strings) – List of processing steps at this facility
- Returns
List of unique node IDs created from processing step and facility ID
- Return type
list of strings
-
all_element_combos
(list1: list, list2: list)¶ Converts two lists into a list of tuples where each tuple contains one element from each list: [(list1[0], list2[0]), (list1[0], list2[1]), …] Exactly two lists of any length must be specified.
- Parameters
list1 – list of any data type
list2 – list of any data type
- Returns
- Return type
A list of 2-tuples
-
list_of_tuples
(list1: list, list2: list, list3: list = None, list4: list = None)¶ Converts two or three lists into a list of two- or three-tuples where each tuple contains the corresponding elements from each list: [(list1[0], list2[0]), (list1[1], list2[1]), …] or [(list1[0], list2[0], list3[0]), (list1[1], list2[1], list3[1]), …]
Two or three lists may be specified. All three lists must be the same length.
- Parameters
list1 – list of any data type
list2 – list of any data type
list3 – list of any data type (optional)
list4 – list of any data type
- Returns
- Return type
A list of n-tuples where n can be 2, 3, or 4
-
find_nearest
(source: str, crit: str)¶ Method that finds the nearest nodes to source and returns that node name, the path length to the nearest node, and the path to the nearest node as a list of nodes.
Original code source: https://stackoverflow.com/questions/50723854/networkx-finding-the-shortest-path-to-one-of-multiple-nodes-in-graph
- Parameters
source – Name of node where this path begins.
crit – Criteria to calculate path “length”. May be cost or dict.
- Returns
[0] name of node “closest” to source
[1] “length” of path between source and the closest node
[2] list of nodes defining the path between source and the closest node
-
get_edges
(facility_df: pandas.core.frame.DataFrame, u_edge='step', v_edge='next_step')¶ Converts two columns of node names into a list of string tuples for intra-facility edge definition with networkx
- Parameters
facility_df – DataFrame listing processing steps (u_edge) and the next processing step (v_edge) by facility type
u_edge – unique processing steps within a facility type
v_edge – steps to which the processing steps in u_edge connect
- Returns
- Return type
list of string tuples that define edges within a facility type
-
get_nodes
(facility_df: pandas.core.frame.DataFrame)¶ Generates a data structure that defines all nodes and node attributes for a single facility.
- Parameters
facility_df (pd.DataFrame) –
DataFrame containing unique facility IDs, processing steps, and the name of the method (if any) used to calculate processing costs
- Columns:
facility_id : int
step : str
connects : str
step_cost_method : str
- Returns
Data structure used to define a networkx DiGraph. Attributes (dictionary keys) are: processing step, cost method, facility ID, and region identifiers.
- Return type
List[(str, Dict)]
-
build_facility_graph
(facility_df: pandas.core.frame.DataFrame)¶ Creates networkx DiGraph object containing nodes, intra-facility edges, and all relevant attributes for a single facility.
- Parameters
facility_df (pd.DataFrame) –
DataFrame with a single row that defines a supply chain facility.
- Columns:
facility_id : int
facility_type : str
lat : float
long : float
region_id_1 : str
region_id_2 : str
region_id_3 : str
region_id_4 : str
- Returns
Directed graph representation of one supply chain facility.
- Return type
networkx.DiGraph
-
build_supplychain_graph
()¶ Reads in the locations data set line by line. Each line becomes a DiGraph representing a single facility. Facility DiGraphs are added onto a supply chain DiGraph and connected with inter-facility edges. Edges within facilities have no cost or distance. Edges between facilities have costs defined in the interconnections dataset and distances defined in the routes dataset.
-
choose_paths
(source: str = None, crit: str = 'cost')¶ Calculate total pathway costs (sum of all node and edge costs) over all possible pathways between source and target nodes. Other “costs” such as distance or environmental impacts may be used as well with modifications to the crit argument of the find_nearest call.
- Parameters
source (str) – Node name in the format “facilitytype_facilityid”.
crit (str) – Criterion on which “shortest” path is defined. Defaults to cost.
- Returns
Dictionary containing the source node, target node, path between source and target, and the pathway “cost” (criterion).
- Return type
Dict
-
find_upstream_neighbor
(node_id: int, connect_to: str = 'manufacturing', crit: str = 'dist')¶ Given a node in the network, find the “nearest” upstream neighbor to that node that is of the type specified by connect_to. “Nearest” is determined according to the crit parameter.
- Parameters
node_id (int) – facility_id of a node in the supply chain network. No default.
connect_to (str) – facility_type of the upstream node.
crit (str) – Criteron used to decide which manufacturing node is “nearest”. Defaults to distance.
- Returns
_nearest_facility_id – Integer identifying the “closest” upstream node of type connect_to that connects to the node with the provided node_id. Returns None if node_id does not exist in the network or if the node_id does not connect to any nodes of the connect_to type.
- Return type
int
-
find_downstream
(node_name: str = None, facility_id: int = None, connect_to: str = 'landfill', crit: str = 'dist', get_dist: bool = False)¶ Given a node (node_name and/or facility_id) in the network, find the node’s “nearest” downstream neighbor of type connect_to. “Nearest” is specified by the crit parameter.
- Parameters
node_name (str) – Full node name of the starting node.
facility_id (int) – Unique facility ID for the starting node.
connect_to (str) – Facility type to connect to.
crit (str) – Criterion on which “shortest” pathway is determined.
get_dist (bool) – If True, also return the transportation distance to the downstream node and the route_id along which material is transported.
- Returns
Facility ID of the closest (according to “crit”) facility of type “connect_to” downstream of the node indicated by node_id. Optionally returns the distance to the downstream node and the route_id along which material is transported to the downstream node.
- Return type
int or (int, float, str)
-
update_costs
(path_dict)¶ Re-calculates all edge costs based on arguments passed to cost methods.
- Parameters
path_dict (Dict) – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
-
save_costgraph_outputs
()¶ Performs postprocessing on CostGraph outputs being saved to file and saves to user-specified filenames and directories
-
Cost Methods¶
Cost Methods are user-defined functions for calculating process costs.
-
class
celavi.costmethods.
CostMethods
(start_year, seed, run)¶ Functions for calculating processing and transportation costs throughout the supply chain. The methods in this Class must be re-written to correspond to each case study; in general, these methods are not reusable across different supply chains or technologies.
-
__init__
(start_year, seed, run)¶ Provide a random number generator and model run to all uncertain CostMethods.
- Parameters
seed (np.random.default_rng) – Instantiated random number generator for uncertainty analysis.
run (int) – Model run number.
-
static
zero_method
(path_dict)¶ Cost method that returns a cost of zero under all circumstances.
- Parameters
path_dict (dict) – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes.
- Returns
Use this method for any processing step or transportation edge with no associated cost.
- Return type
float
-
landfilling
(path_dict)¶ Linear tipping fee model based on historical national average tipping fees.
- Parameters
path_dict (dict) – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
_fee – Landfill tipping fee in USD/metric ton
- Return type
float
-
rotor_teardown
(path_dict)¶ Cost (USD/metric ton) of removing one metric ton of blade from the turbine. The cost of removing a single blade is calculated as one-third the rotor teardown cost, and this cost is divided by blade mass to calculate rotor teardown per metric ton of blade material.
- Parameters
path_dict (dict) – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
_cost – Cost in USD per metric ton of removing a blade from an in-use turbine. Equivalent to 1/3 the rotor teardown cost divided by the blade mass.
- Return type
float
-
segmenting
(path_dict)¶ Cost method for blade segmenting into 30m sections performed on-site at the wind power plant.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
- Return type
Cost (USD/metric ton) of cutting a turbine blade into 30-m segments
-
coarse_grinding_onsite
(path_dict)¶ Cost method for coarsely grinding turbine blades onsite at a wind power plant. This calculation uses industrial learning-by-doing to gradually reduce costs over time.
The coarse grinding, coarse grinding onsite, and fine grinding cost models allow for array uncertainty in the initial cost or in the learning rate, or random uncertainty in the actual cost which depends on cumulative mass processed. The logic for applying array uncertainty in these cost models is as follows: IF the uncertainty type is ‘array’ AND there are no parameter arrays in the cost uncertainty dictionary, THEN the learning rate must have an array of values which are applied separately to each model run. This logic is different from the uncertainty logic applied to all other cost models, which do not have parameters stored outside the cost uncertainty dictionary.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Current cost of coarse grinding one metric ton of segmented blade
material onsite at a wind power plant.
-
coarse_grinding
(path_dict)¶ Cost method for coarsely grinding turbine blades at a mechanical recycling facility. This calculation uses industrial learning-by-doing to gradually reduce costs over time.
The coarse grinding, coarse grinding onsite, and fine grinding cost models allow for array uncertainty in the initial cost or in the learning rate, or random uncertainty in the actual cost which depends on cumulative mass processed. The logic for applying array uncertainty in these cost models is as follows: IF the uncertainty type is ‘array’ AND there are no parameter arrays in the cost uncertainty dictionary, THEN the learning rate must have an array of values which are applied separately to each model run. This logic is different from the uncertainty logic applied to all other cost models, which do not have parameters stored outside the cost uncertainty dictionary.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Current cost of coarse grinding one metric ton of segmented blade
material in a mechanical recycling facility.
-
fine_grinding
(path_dict)¶ Cost method for finely grinding turbine blades at a mechanical recycling facility. This calculation uses industrial learning-by-doing to gradually reduce costs over time.
The coarse grinding, coarse grinding onsite, and fine grinding cost models allow for array uncertainty in the initial cost or in the learning rate, or random uncertainty in the actual cost which depends on cumulative mass processed. The logic for applying array uncertainty in these cost models is as follows: IF the uncertainty type is ‘array’ AND there are no parameter arrays in the cost uncertainty dictionary, THEN the learning rate must have an array of values which are applied separately to each model run. This logic is different from the uncertainty logic applied to all other cost models, which do not have parameters stored outside the cost uncertainty dictionary.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Net cost (process cost plus landfilling cost minus revenue) of fine
grinding one metric ton of blade material at a mechanical recycling
facility and disposing of material losses in a landfill.
-
coprocessing
(path_dict)¶ Cost method that calculates revenue from sale of coarsely-ground blade material to cement co-processing plant.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Revenue (USD/metric ton) from selling 1 metric ton of ground blade
to cement co-processing plant
-
segment_transpo
(path_dict)¶ Calculate segment transportation cost in USD/metric ton
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Cost of transporting one segmented blade one kilometer. Units
USD/blade
-
shred_transpo
(path_dict)¶ Cost method for calculating shredded blade transportation costs (truck) in USD/metric ton.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Cost of transporting 1 metric ton of shredded blade material by
one kilometer. Units (USD/metric ton.)
-
manufacturing
(path_dict)¶ Cost method for calculating blade manufacturing costs in USD/metric ton. Data sourced from Murray et al. (2019), a techno-economic analysis of a thermoplastic blade compared to the standard thermoset epoxy blade using a 61.5m blade as basis. The baseline cost for the thermoset blade ($11.44/kg) is used here, converted to USD / metric ton.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
- Return type
Cost of manufacturing 1 metric ton of new turbine blade.
-
blade_transpo
(path_dict)¶ Cost of transporting 1 metric ton of complete wind blade by 1 km. Currently the segment transportation cost is used as proxy.
- Parameters
path_dict – Dictionary of variable structure containing cost parameters for calculating and updating processing costs for circularity pathway processes
- Returns
Cost of transporting one segmented blade one kilometer. Units
USD/blade
-
Wind Blade path_dict Structure¶
Because the circular_pathways and in particular the cost uncertainty dictionaries can vary in structure, here we include the complete dictionary for the wind blade case study. This version of the dictionary is for a single model run that does not include uncertainty. Quantities that may take on array-based uncertainty are indicated with comments.
circular_pathways:
sc_begin: manufacturing
sc_end:
- landfilling
- cement co-processing
- next use
learning:
coarse grinding:
component : blade
initial cumul: 1.0
cumul:
learn rate: -0.05 # Define a list for array-based uncertainty.
steps:
- coarse grinding
- coarse grinding onsite
fine grinding:
component : blade
initial cumul: 1.0
cumul:
learn rate: -0.05 # Define a list for array-based uncertainty.
steps:
- fine grinding
cost uncertainty:
landfilling:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
m: 1.5921 # Define a list for array-based uncertainty.
b: 59.23 # Define a list for array-based uncertainty.
rotor teardown:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
m: 1467.08 # Define a list for array-based uncertainty.
b: 29626.0 # Define a list for array-based uncertainty.
segmenting:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
b: 27.56 # Define a list for array-based uncertainty.
coarse grinding onsite:
uncertainty:
actual cost:
c: 0.5
loc: 0.8
scale: 0.4
initial cost: 106 # Define a list for array-based uncertainty.
coarse grinding:
uncertainty:
actual cost:
c: 0.5
loc: 0.8
scale: 0.4
initial cost: 106 # Define a list for array-based uncertainty.
fine grinding:
uncertainty:
actual cost:
c: 0.5
loc: 0.8
scale: 0.4
initial cost: 143 # Define a list for array-based uncertainty.
revenue:
c: 0.5
loc: 0.8
scale: 0.4
b: 273 # Define a list for array-based uncertainty.
coprocessing:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
b: 10.37 # Define a list for array-based uncertainty.
segment transpo:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
cost 1: 4.35 # Before 2001; 2002-2003; Define a list for array-based uncertainty.
cost 2: 8.70 # 2001-2002; 2003-2019; Define a list for array-based uncertainty.
cost 3: 13.05 # 2019-2031; Define a list for array-based uncertainty.
cost 4: 17.40 # 2031-2044; Define a list for array-based uncertainty.
cost 5: 21.75 # 2044-2050; Define a list for array-based uncertainty.
shred transpo:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
m: 0.0011221 # Define a list for array-based uncertainty.
b: 0.0739 # Define a list for array-based uncertainty.
manufacturing:
uncertainty:
c: 0.5
loc: 0.8
scale: 0.4
b: 11440.0 # Define a list for array-based uncertainty.
path_split:
fine grinding:
fraction: 0.3 # Define a list for array-based uncertainty.
facility_1: landfilling
facility_2: next use
pass:
next use
permanent_lifespan_facility:
- landfilling
- cement co-processing
- next use
vkmt :
component mass :
year :