head_iteration

This module contains utility functions related to the head iteration.

prepshot._model.head_iteration.compute_error(old_waterhead, new_waterhead)[source]

Calculate the error of the water head.

Parameters
  • old_waterhead (pandas.DataFrame) -- The water head before the solution.

  • new_waterhead (pandas.DataFrame) -- The water head after the solution.

Returns

The error of the water head.

Return type

float

prepshot._model.head_iteration.initialize_waterhead(stations, year, month, hour, params)[source]

Initialize water head.

Parameters
  • stations (List[str]) -- List of stations.

  • year (List[int]) -- List of years.

  • month (List[int]) -- List of months.

  • hour (List[int]) -- List of hours.

  • params (Dict[str, Any]) -- Dictionary of parameters for the model.

Returns

A tuple of two pandas.DataFrame objects, the first one is the old water head, the second one is the new water head.

Return type

Tuple[pd.DataFrame, pd.DataFrame]

prepshot._model.head_iteration.process_model_solution(model, stations, year, month, hour, params, old_waterhead, new_waterhead)[source]

Process the solution of the model, updating the water head data.

Parameters
  • model (object) -- Model to be solved.

  • stations (list) -- List f hydropower stations.

  • year (list) -- List of years.

  • month (list) -- List of months.

  • hour (list) -- List of hours.

  • params (dict) -- Dictionary of parameters for the model.

  • old_waterhead (pandas.DataFrame) -- The water head before the solution.

  • new_waterhead (pandas.DataFrame) -- The water head after the solution.

Returns

True if the model is solved, False otherwise.

Return type

bool

prepshot._model.head_iteration.run_model_iteration(model, params, error_threshold=0.001, max_iterations=5)[source]

Run the model iteratively.

Parameters
  • model (object) -- Model to be solved.

  • params (dict) -- Dictionary of parameters for the model.

  • error_threshold (float, optional) -- The error threshold, by default 0.001

  • max_iterations (int, optional) -- The maximum number of iterations, by default 5

Returns

True if the model is solved, False otherwise.

Return type

bool