Utilities
Bisection Search (pywr.utils.bisect)
- class pywr.utils.bisect.BisectionSearchModel(**kwargs)
Bases:
ModelA Pywr model that performs a bisection search.
When a BisectionSearchModel is run it performs multiple simulations using a bisection algorithm to find the largest value of a parameter that satisfies all defined constraints. The bisection proceeds until a minimum gap (epsilon) is reached. After the bisection the best feasible value is re-run to ensure the model ends with corresponding recorder values. If no feasible solutions are found then an error is raised.
- Parameters:
- bisect_parameterParameter
The parameter to vary during the bisection process. This parameter must have a double_size of 1 and have lower and upper bounds defined; the bisection is undertaken between these bounds.
- bisect_epsilonfloat
- The termination criterion for the bisection process. When the bisection has narrowed to a gap
of less than the bisect_epsilon the process is terminated.
- error_on_infeasiblebool (default True)
If true a ValueError is raised if no feasible solution is found during the bisection process. If false no error is raised if there is no feasible solution, and a solution using the lower bounds of the bisection parameter is the final result.
- classmethod load_from_dict(cls, dict data: Dict[str, Any], model=None, path=None, solver=None, solver_args=None) 'Model'
Load data from a dictionary.
- Parameters:
- datadict
The model data as a dictionary.
- modelModel (optional)
An existing model to append to.
- pathstr (optional)
Path to the model document for relative path names.
- solverSolver (optional)
The solver to use for the model. If None, the first available solver is used.
- solver_argsdict (optional)
Additional arguments to pass to the solver constructor.
- run()
Perform a bisection search using repeated simulation.