Skip to content

Generalized Superstructure for recovering rare earth elements from an end-of-life product.#136

Merged
ksbeattie merged 191 commits intoprommis:mainfrom
ChrisLaliwala:PR-Superstructure_V2
Dec 8, 2025
Merged

Generalized Superstructure for recovering rare earth elements from an end-of-life product.#136
ksbeattie merged 191 commits intoprommis:mainfrom
ChrisLaliwala:PR-Superstructure_V2

Conversation

@ChrisLaliwala
Copy link
Contributor

@ChrisLaliwala ChrisLaliwala commented Mar 18, 2025

Addresses Issue:

Summary/Motivation:

The PR introduces a generalized superstructure function that can be used to find the optimal processing pathway for recovering critical minerals from different end-of-life (EOL) products based on user-specified inputs. The user has the option to maximize the net present value (NPV), or minimize the cost of recovery (COR). Additionally, the user can also consider the valorization of byproducts, and the ability to perform multi-objective optimization considering the LCA emission metric of Global Warming Potential.

Changes proposed in this PR:

  • Generalized superstructure function

Reviewer's checklist / merge requirements:

  • The head branch (i.e. the "source" of the changes) is not the main branch on the PR author's fork
  • Documentation
  • Tests
  • Diagnostic tests for models

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.md file
    at the top level of this directory.

  2. I represent I am authorized to make the contributions and grant the license. If my employer has
    rights to intellectual property that includes these contributions, I represent that I have
    received permission to make contributions and grant the required license on behalf of that
    employer.

…ase studies. Superstructures currently exist as python notebooks and the frameworks for the superstructures consider economic and environmental objectives. Superstructures need to be expanded to include more processes for byproduct and iron recovery though.
@ChrisLaliwala ChrisLaliwala changed the title Generalized Superstructure for recovering rare earth elements from an end-of-life product. Generalized Superstructure (version 2) for recovering rare earth elements from an end-of-life product. Mar 18, 2025
@codecov
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

❌ Patch coverage is 99.67923% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.46%. Comparing base (5be8de8) to head (af8f97b).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...is/superstructure/report_superstructure_results.py 98.88% 0 Missing and 3 partials ⚠️
...mmis/superstructure/check_superstructure_inputs.py 99.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
+ Coverage   83.07%   85.46%   +2.38%     
==========================================
  Files          62       67       +5     
  Lines        7422     8669    +1247     
  Branches      818     1150     +332     
==========================================
+ Hits         6166     7409    +1243     
  Misses       1078     1078              
- Partials      178      182       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lbianchi-lbl lbianchi-lbl added the Priority:Normal Normal Priority Issue or PR label Mar 31, 2025
Copy link
Contributor

@agarciadiego agarciadiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of typo fixing but other than that looks good to me

@agarciadiego
Copy link
Contributor

Also please check if you can increase coverage since the code coverage overall is low. @OOAmusat can you help review coverage?

@ChrisLaliwala
Copy link
Contributor Author

ChrisLaliwala commented Nov 18, 2025

Also please check if you can increase coverage since the code coverage overall is low. @OOAmusat can you help review coverage?

@agarciadiego This has to do with Gurobi solver not being available on GitHub repository (so the tests are skipped). When I run the tests locally, the code has 100% coverage.

Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
ChrisLaliwala and others added 9 commits November 18, 2025 15:51
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
Co-authored-by: agarciadiego <40575271+agarciadiego@users.noreply.github.com>
@agarciadiego
Copy link
Contributor

Also please check if you can increase coverage since the code coverage overall is low. @OOAmusat can you help review coverage?

@agarciadiego This has to do with Gurobi solver not being available on GitHub repository (so the tests are skipped). When I run the tests locally, the code has 100% coverage.

But we could test a lot of lines of code (i.e., the existence and values of the parameters) without testing the solve.

… need for solving the model. uses a mock model instead. This should increase code coverage.
@ChrisLaliwala
Copy link
Contributor Author

ChrisLaliwala commented Nov 19, 2025

Also please check if you can increase coverage since the code coverage overall is low. @OOAmusat can you help review coverage?

@agarciadiego This has to do with Gurobi solver not being available on GitHub repository (so the tests are skipped). When I run the tests locally, the code has 100% coverage.

But we could test a lot of lines of code (i.e., the existence and values of the parameters) without testing the solve.

The uncovered code was all from the file "report_superstructure_results.py". This function takes in a solved model and outputs the results to the console in a way that is easy for the user to interpret. Since Gurobi is not available on the GitHub repository, all the tests were skipped for this file, leading to poor code coverage. I have added the test file - "test_report_superstructure_results_no_model_solve.py", which tests "report_superstructure_results.py" by making a mock model. This allows full code coverage of "report_superstructure_results.py" without the need for solving the model.

The Codecov report now shows that tests fully cover all code. All remaining missing coverage is in the test files (which I don't think Codecov should be including when calculating code coverage).

@agarciadiego
Copy link
Contributor

Also please check if you can increase coverage since the code coverage overall is low. @OOAmusat can you help review coverage?

@agarciadiego This has to do with Gurobi solver not being available on GitHub repository (so the tests are skipped). When I run the tests locally, the code has 100% coverage.

But we could test a lot of lines of code (i.e., the existence and values of the parameters) without testing the solve.

The uncovered code was all from the file "report_superstructure_results.py". This function takes in a solved model and outputs the results to the console in a way that is easy for the user to interpret. Since Gurobi is not available on the GitHub repository, all the tests were skipped for this file, leading to poor code coverage. I have added the test file - "test_report_superstructure_results_no_model_solve.py", which tests "report_superstructure_results.py" by making a mock model. This allows full code coverage of "report_superstructure_results.py" without the need for solving the model.

The Codecov report now shows that tests fully cover all code. All remaining missing coverage is in the test files (which I don't think Codecov should be including when calculating code coverage).

Thank you, the coverage looks a lot better

@ksbeattie ksbeattie enabled auto-merge (squash) November 24, 2025 17:54
@ksbeattie ksbeattie merged commit c1bbcc6 into prommis:main Dec 8, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:High High Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants