You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frommat_dp_coreimportResources, Processes, GeConstraint, LeConstraint, Measurer=Resources()
iron_ore=r.create("Iron Ore", "metric tonnes")
iron=r.create("Iron", "metric tonnes")
coal=r.create("Coal", "metric tonnes")
carbon_dioxide=r.create("CO2", "metric tonnes")
steel=r.create("Steel", "metric tonnes")
rail=r.create("Steel Rail", "metres")
wagon=r.create("Railway Wagon", "units")
p=Processes()
coal_mine=p.create("Coal Mine", (carbon_dioxide, 0.2), (coal, 1.0))
iron_mine=p.create("Iron Ore Mine", (carbon_dioxide, 0.2), (iron_ore, 1.0))
iron_furnace=p.create("Iron Blast Furnace", (carbon_dioxide, 0.5), (iron, 1.0), (coal, -0.4), (iron_ore, -1.2))
steel_mill=p.create("Steel Mill", (carbon_dioxide, 0.7), (iron, -0.9), (coal, -0.5), (steel, 1.0))
rail_factory=p.create("Rail Manufacturing Factory", (carbon_dioxide, 0.1), (steel, -0.1), (rail, 1.0))
rail_wagon_factory=p.create("Wagon Manufacturing Factory", (carbon_dioxide, 0.3), (steel, -4.0), (wagon, 1.0))
environment=p.create("The Atmosphere", (carbon_dioxide, -1.0))
rail_buy=p.create("Economy demanding rail", (rail, -1))
wagon_buy=p.create("Economy demanding wagons", (wagon, -1))
# Constraintsrail_demand=GeConstraint("Demand for rail", rail_buy, 500)
wagon_demand=GeConstraint("Demand for wagons", wagon_buy, 5)
objective=environmentconstraints= [rail_demand, wagon_demand]
measure=Measure(r, p, constraints, objective)
# .cumulative_resource()# This example of cumulative_resource() is not yet operational# See issue NUMBER_HERE for details.print("---\n\n1) All cumulative resource flows from everything to everything:")
# print(measure.cumulative_resource()) # Option 1print("---\n\n2) All cumulative resource flows from everything to the wagon factory:")
print(measure.cumulative_resource(process=rail_wagon_factory)) # Option 2print("---\n\n3) Cumulative resource flows of iron from everything to everything::")
print(measure.cumulative_resource(resource=iron)) # Option 3print("---\n\n4) Cumulative amount of CO2 leading up to all the production rail factory:")
print(measure.cumulative_resource(process=rail_factory, resource=carbon_dioxide)) # Option 4
Produces the following error:
PS ######\mat-dp-core\examples> poetry run python .\test.py
---
1) All cumulative resource flows from everything to everything:
---
2) All cumulative resource flows from everything to the wagon factory:
######\mat-dp-core\mat_dp_core\maths_core\solve.py:201: OptimizeWarning: A_eq does not appear to be of full row rank. To improve performance, check the problem formulation for redundant equality constraints.
res = linprog(
Traceback (most recent call last):
File "######\mat-dp-core\examples\test.py", line 255, in <module>
print(measure.cumulative_resource(process=rail_wagon_factory)) # Option 2
File "######\mat-dp-core\mat_dp_core\measure.py", line 758, in cumulative_resource
self.cumulative_resource_matrix[:, process.index],
File "######\mat-dp-core\mat_dp_core\maths_core\solvers.py", line 386, in cumulative_resource_matrix
self._exact_solver.cumulative_resource_matrix
File "######\mat-dp-core\mat_dp_core\maths_core\solvers.py", line 214, in cumulative_resource_matrix
construct_cumulative_resource_matrix(
File "######\mat-dp-core\mat_dp_core\maths_core\solvers.py", line 134, in construct_cumulative_resource_matrix
[
File "######\mat-dp-core\mat_dp_core\maths_core\solvers.py", line 135, in <listcomp>
solve(
File "######\mat-dp-core\mat_dp_core\maths_core\solve.py", line 237, in solve
raise Overconstrained.from_vector(
mat_dp_core.maths_core.exceptions.Overconstrained: Overconstrained problem:
resources:
Coal => 60.200000007230194: increase runs of Iron Blast Furnace, Steel Mill or decrease runs of Coal Mine
CO2 => 12.040000001446039: increase runs of The Atmosphere or decrease runs of Coal Mine, Iron Ore Mine, Iron Blast Furnace, Steel Mill, Rail Manufacturing Factory, Wagon Manufacturing Factory
eq_constraints:
Coal Mine - 1.255813953488226*Iron Ore Mine == 0 => -60.200000007230194
Coal Mine - 1.0465116279069493*Iron Blast Furnace == 0 => -60.200000007230194
Coal Mine - 1.1627906976743299*Steel Mill == 0 => -60.200000007230194
Coal Mine - 8.305647840271908*Rail Manufacturing Factory == 0 => -60.200000007230194
Coal Mine - 0.0830564784122155*Wagon Manufacturing Factory == 0 => -60.200000007230194
PS ######\mat-dp-core\examples>
The text was updated successfully, but these errors were encountered:
Code to reproduce error:
Produces the following error:
The text was updated successfully, but these errors were encountered: