Define SwolfPy optimization constraints safely
Translate process-capacity and routing assumptions into an auditable optimization setup without overclaiming the mathematical optimum.
Start with the objective basis
Record the project state, scenario functional unit, exact LCIA method, and whether collection is included before changing routing fractions.
Process-capacity constraints serialize directly
{
"WTE": {
"limit": 100,
"KeyType": "Process",
"ConstType": "<="
}
}String-key process constraints are a natural fit for the MCP JSON object. Record the physical unit and source of every numeric limit in the study record.
Tuple-key constraints need special care
The direct SwolfPy Python API also demonstrates WasteToProcess and Emission constraints keyed by Python tuples. JSON object keys are strings, and the current MCP adapter forwards the mapping without converting a JSON representation back into tuple keys.
Warning
Do not copy tuple-key Python examples verbatim into an MCP JSON request and assume they are equivalent. Until the adapter has an explicit normalized schema, use direct Python for those constraint types or verify the serialized form against the running adapter.
Run a development optimization first
optimize(
result_id=...,
functional_unit={"baseline": 1},
method=[...],
constraints={"WTE": {...}},
n_iter=5,
collection=false
)Use a small n_iter to confirm the pipeline. Increase search effort for a study and check stability across repeated starts/settings.
Validate the modeled optimum
- Confirm routing fractions still satisfy normalization constraints.
- Check every process-capacity or routing constraint numerically.
- Recalculate the objective on the optimized state.
- Inspect mass flows for physical plausibility.
- Compare against the unoptimized baseline.
- Repeat with more than one start or search setting.
Warning
The lowest modeled LCIA score is an optimum within the encoded model and constraints, not a deployment recommendation.