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

Allow editing of Node production/consumption Amounts... to update the LCA Result #12

Open
michaelweinold opened this issue Sep 13, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@michaelweinold
Copy link
Collaborator

Currently, the dashboard returns a list of nodes in the supply chain tree like so:

UID Activity Description Supply Amount Branch
1 Cardboard 100 1
2 Paper 45 [1,2]
3 Wood Pulp 60 [1,2,3]
4 Electricity 110 [1,2,3,4]

The user should be able to say:

"I know we actually use only 30kg of Paper to make 100kg of Cardboard!"

and then edit this Supply Amount in the second row.

Of course, this would mean that correspondingly less Supply Amount of all activities feeding into Paper would be required. Of course, all this would also affect the overall LCA score.

@michaelweinold michaelweinold added the enhancement New feature or request label Sep 13, 2024
@michaelweinold michaelweinold self-assigned this Sep 13, 2024
@michaelweinold
Copy link
Collaborator Author

...maybe there is a way propagate edits from the table back to the dict of dicts, which is returned by NewNodeEachVisitGraphTraversal.calculate(lca, cutoff=0.01). Would this make it easier to re-compute upstream Supply Amounts and the overall score?

{'nodes': {-1: Node(unique_id=-1, activity_datapackage_id=-1, activity_index=-1, reference_product_datapackage_id=-1, reference_product_index=-1, reference_product_production_amount=1.0, depth=0, supply_amount=1.0, cumulative_score=0.3768834121437975, direct_emissions_score=0.0, direct_emissions_score_outside_specific_flows=0.0, remaining_cumulative_score_outside_specific_flows=0.0, terminal=False),
  0: Node(unique_id=0, activity_datapackage_id=235, activity_index=234, reference_product_datapackage_id=542, reference_product_index=153, reference_product_production_amount=0.9988390803337097, depth=1, supply_amount=1.0011622689671917, cumulative_score=0.3768834121437976, direct_emissions_score=0.015464815391143152, direct_emissions_score_outside_specific_flows=1.0495129317330404e-05, remaining_cumulative_score_outside_specific_flows=0.3614290918819718, terminal=False),
  1: Node(unique_id=1, activity_datapackage_id=79, activity_index=78, reference_product_datapackage_id=431, reference_product_index=42, reference_product_production_amount=0.9359190464019775, depth=2, supply_amount=0.013377550027867835, cumulative_score=0.004254062537767607, direct_emissions_score=0.00012451661922425745, direct_emissions_score_outside_specific_flows=3.694040387367938e-06, remaining_cumulative_score_outside_specific_flows=0.004133239958930717, terminal=True),
  2: Node(unique_id=2, activity_datapackage_id=311, activity_index=310, reference_product_datapackage_id=435, reference_product_index=46, reference_product_production_amount=0.9928678274154663, depth=2, supply_amount=0.09230018343308832, cumulative_score=0.041779131103952524, direct_emissions_score=0.001482884746645427, direct_emissions_score_outside_specific_flows=4.342210964385475e-05, remaining_cumulative_score_outside_specific_flows=0.04033966846695095, terminal=False),
(...)
 'edges': [Edge(consumer_index=-1, consumer_unique_id=-1, producer_index=234, producer_unique_id=0, product_index=153, amount=1),
  Edge(consumer_index=234, consumer_unique_id=0, producer_index=78, producer_unique_id=1, product_index=42, amount=0.012520303865276812),
  Edge(consumer_index=234, consumer_unique_id=0, producer_index=310, producer_unique_id=2,
(...)
 'flows': [Flow(flow_datapackage_id=1726, flow_index=947, activity_unique_id=19, activity_id=374, activity_index=373, amount=0.016917697121138834, score=0.016917697121138834),
  Flow(flow_datapackage_id=1726, flow_index=947, activity_unique_id=3, activity_id=301, activity_index=300, amount=0.013172648927940041, score=0.013172648927940041),
  Flow(flow_datapackage_id=1726, flow_index=947, activity_unique_id=4, activity_id=53, activity_index=52, amount=0.007941925100944729, score=0.007941925100944729),
(...)
}

@cmutel
Copy link
Member

cmutel commented Sep 13, 2024

Any time you change the matrix you need to start graph traversal again. It will break the matrix factorization cache, and change all LCA results.

@cmutel
Copy link
Member

cmutel commented Sep 13, 2024

I would do this by keeping a separate datapackage in memory, following https://github.com/brightway-lca/from-the-ground-up/blob/main/2%20-%20Building%20and%20using%20matrices%20in%20bw2calc.ipynb, as then you don't need to touch the SQLite database.

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

No branches or pull requests

2 participants