Skip to content
Engineering Decision Intelligence
TutorialVersion 0.6.0

Compare SwolfPy scenarios and optimize waste allocation

Update project parameters, create scenarios, compare functional units and methods, and review constrained optimization results.

1. Inspect the baseline project

text
get_project_summary(result_id=...)

Record the current parameters before changing them. Do not edit waste fractions from memory.

2. Update waste-fraction parameters

text
update_parameters(
  result_id=...,
  parameters=[...]
)

Fractions for each source must satisfy the project's sum constraints. Keep a copy of the baseline list before mutation.

The public direct-package tutorial demonstrates a residential-waste split with parameters named frac_of_RWC_from_SF_COl_to_LF and frac_of_RWC_from_SF_COl_to_WTE, set so the two fractions sum to 1. Always discover and preserve the current parameter list instead of assuming those names exist in every template.

3. Create a named scenario

text
create_scenario(
  result_id=...,
  scenario_name="baseline",
  input_dict={"SF_COl": {"Mixed_Paper": 1.0}}
)

The public tutorial uses this one-Mg/year Mixed_Paper scenario as a compact example. A scenario name is not enough for reproducibility; retain the exact input_dict that defines the scenario activity.

4. Run a comparative LCA grid

text
run_comparative_lca(
  result_id=...,
  functional_units=[{...}, {...}],
  methods=[[...], [...]]
)

Use run_comparative_lca_async for a larger functional-unit × method grid.

5. Inspect one LCA result

text
contribution_analysis(lca_result_id=...)
get_mass_flows(lca_result_id=..., process="...")

Keep the project result_id and the lca_result_id separate.

6. Run constrained optimization separately

text
optimize(
  result_id=...,
  functional_unit={...},
  method=[...],
  constraints={...},
  n_iter=30,
  collection=false
)

The optimizer minimizes the selected LCIA score by changing waste fractions under the supplied constraints. Use optimize_async for longer searches.

Warning

The underlying SwolfPy Python API supports tuple-key WasteToProcess and Emission constraints. JSON object keys cannot preserve Python tuple keys, and the current MCP adapter passes the constraints mapping through without a dedicated tuple-key normalization layer. Process-level string-key constraints serialize cleanly; treat tuple-key constraint shapes as a direct-Python workflow until the MCP schema is extended.

Review the modeled optimum

  • Allowed treatment routes and fraction constraints.
  • Collection, facility-capacity, geography, and logistics assumptions.
  • Functional unit and LCIA method.
  • Process-model validity and real-world implementability.

Warning

The lowest modeled LCIA score is not automatically a feasible waste-management plan.