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

Figure out how to use a path split with more than 2 options #208

Open
jwalzberg opened this issue Dec 6, 2024 · 3 comments
Open

Figure out how to use a path split with more than 2 options #208

jwalzberg opened this issue Dec 6, 2024 · 3 comments
Assignees

Comments

@jwalzberg
Copy link
Collaborator

Look into the "path_split" function in the component.py.

@jwalzberg jwalzberg self-assigned this Dec 6, 2024
@jwalzberg
Copy link
Collaborator Author

Search for self.split_dict

rjhanes added a commit that referenced this issue Jan 21, 2025
Updates issue branch for #208 with recent commits
@rjhanes
Copy link
Collaborator

rjhanes commented Jan 21, 2025

Porting over comment from closed related PR:

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.)

ETA: I think heading toward a stochastic, whole-component split would make way more sense for the glass case study. I'm going to create a related issue (#225 ) to implement this functionality with the option to either lose a mass fraction or proportion of whole components, depending on the facility type.

For this issue Keep the current functionality that only uses mass fractions (of whole components) to implement path splitting.

            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

@rjhanes
Copy link
Collaborator

rjhanes commented Jan 21, 2025

See related data and YAML updates in data repo commits:

1ea4b795bb556d10be4a7e9592a952414c426668

656ddf510a3becccc92901cfd3b9d719c1c75265

a6e22342f9fd80871a515e90ecdb865a9d45b79a

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

No branches or pull requests

2 participants