Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying eol method in component.py to allow multiple split #213

Open
wants to merge 1 commit into
base: dev-circfutures
Choose a base branch
from

Conversation

jwalzberg
Copy link
Collaborator

We modified one line (line 221) in the eol_process method of component.py to allow for multiple splits between one origin and several destimation options.

Basically, we allowed any key in self.split_dict starting with factype to proceed with the split. It assumes that cost_graph will optimize the pathway and the split will not occur for pathways that do not minimize costs.

Now that any string starting with factype works we can create duplicates of the split between one origin and several destinations in the scenario.yaml file. The modified code is below:

            # Added "startswith" method to allow multiple splits from
            # same source.
            if any(key.startswith(factype) for key in self.split_dict):

@jwalzberg jwalzberg requested a review from rjhanes January 9, 2025 03:33
@jwalzberg jwalzberg added the enhancement New feature or request label Jan 9, 2025
@jwalzberg jwalzberg self-assigned this Jan 9, 2025
@rjhanes
Copy link
Collaborator

rjhanes commented Jan 15, 2025

With the fairly large caveat that I haven't tested this on a data version with the multiple-facility-split feature, I'm not sure this logic will work. The pathway attribute stores the facility types and locations along the supply chain that the component will travel through - landfilling locations for material loss are not included in this pathway, but e.g. pathway would specify that a piece of glass goes from uninstallation through cullet to scm.

I've annotated the current logic below for context. I think the most efficient solution would be to refactor path_split slightly so there's only one loss factor per facility type key, and it's understood that this loss factor is the amount sent to landfill / the amount by which component mass leaving that facility type is reduced. Then the logic below could be updated such that the loss factor is the amount of component sent to the nearest landfill, the component mass is reduced, and the rest of the component proceeds along the processes in pathway.

(Side note: An alternate implementation here would be to use the loss fraction as the probability on a Boolean random variable, and making it so instead of 10% of each component going to landfill, 10% of whole components go to landfill and the rest continue as is. This might be an adjustment to make in the future and would help to capture e.g. window breakage during installation with a little more specificity.)

            if self.pathway:
                location, lifespan, distance, route_id = self.pathway.popleft()
                factype = location.split("_")[0]
                if factype in self.split_dict.keys():
                    # increment the facility inventory and transportation tracker
                    **this is the component moving to the EoL process that has a path_split**
                    self.move_component_to(
                        env, loc=location, dist=distance, route_id=route_id
                    )
                    self.current_location = location

                    yield env.timeout(lifespan)

                    self.move_component_from(env, loc=location)
                    **now the component has left the EoL process with a path_split. a portion of the component now needs**
                    **to go to the next EoL process and the remainder needs to go to the nearest landfill**

                    # locate the two downstream facilities that are closest
                    **this is the landfill according to path_split's current structure**
                    _split_facility_1 = self.context.cost_graph.find_downstream(
                        facility_id=int(location.split("_")[1]),
                        connect_to=self.split_dict[factype]["facility_1"],
                        get_dist=True,
                    )
                   **this is the next EoL process - that should also be specified in the `pathway` attribute**
                    _split_facility_2 = self.context.cost_graph.find_downstream(
                        node_name=location,
                        connect_to=self.split_dict[factype]["facility_2"],
                        get_dist=True,
                    )

                    # Move component fractions to the split facilities
                   **to landfill**
                    self.move_component_to(
                        env,
                        loc=_split_facility_1[0],
                        amt=apply_array_uncertainty(
                            self.split_dict[factype]["fraction"],
                            self.context.model_run
                            ),
                        dist=_split_facility_1[1],
                        route_id=_split_facility_1[2],
                    )
                   **to the next EoL process in pathway**
                    self.move_component_to(
                        env,
                        loc=_split_facility_2[0],
                        amt=1 - apply_array_uncertainty(
                            self.split_dict[factype]["fraction"],
                            self.context.model_run
                            ),
                        dist=_split_facility_2[1],
                        route_id=_split_facility_2[2],
                    )
                elif factype in self.split_dict["pass"]:
                    pass

                else:
                    **this is used for facilities not in path_split**
                    self.move_component_to(
                        env, loc=location, dist=distance, route_id=route_id
                    )

                    self.current_location = location

                    yield env.timeout(lifespan)

                    self.move_component_from(env, loc=location)

            else:
                break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants