optimize_network
Simulate candidate edits to pipes, demands, pumps, or tanks to find the combination that minimizes or maximizes a selected metric, using copies so the base model stays unchanged.
Instructions
Search for the best combination of edits by evaluating an explicit grid of candidate choices on COPIES of a loaded network. For each variable (pipe diameter, junction demand, pump speed, or add_tank placement) you list the choices to try — for add_tank, the nodes to attach a tank to (junctions or reservoirs; plus, by default, the baseline with no tank, so 'try a tank at J2 vs R1 vs none' is one variable); every combination is validated against the EPANET engine and simulated, and the combination that minimizes/maximizes the chosen metric is returned with its full aggregate results. The base model and its stored results are NEVER modified. The search space (product of all choice lists) must fit within maxEvaluations (default 20, up to 100).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| quality | No | Also run water-quality analysis. Requires the model to have quality configured ([OPTIONS] Quality). | |
| networkId | Yes | The network id returned by load_network. | |
| objective | Yes | ||
| variables | Yes | The assets and candidate values to search over. Every combination is evaluated on a copy of the model; the base model is never modified. | |
| maxEvaluations | No | Maximum number of candidate combinations to evaluate (default 20). The full search space (product of all values lists) must fit within this limit. |