Add estimations (inverse use of balance model) - #489
Conversation
Signed-off-by: GOELLER Adrien <adrien.goeller@rte-france.com>
There was a problem hiding this comment.
Pull request overview
Adds a new “estimation” (inverse balance-model) framework, exposing a generic EstimationEngine on top of SectionStudy plus root-finding methods to estimate environmental/load parameters that match a target obstacle distance.
Changes:
- Introduces
EstimationEnginewith helpers to estimate temperature, wind pressure, and load mass by solving an inverse distance problem. - Adds optimization methods (Bisection/Brent/Newton) and a standardized
EstimationResult. - Adds integration-style tests and exposes the engine via a lazy
SectionStudy.estimation_engineproperty.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/core/models/test_estimation.py | Adds tests for EstimationResult, root-finding methods, and EstimationEngine behavior/state preservation. |
| src/mechaphlowers/core/models/estimation/result.py | Defines the EstimationResult dataclass and __repr__. |
| src/mechaphlowers/core/models/estimation/methods.py | Implements bisection, Brent (scipy-backed), and Newton solvers. |
| src/mechaphlowers/core/models/estimation/engine.py | Implements inverse estimation logic over SectionStudy with state save/restore. |
| src/mechaphlowers/core/models/estimation/init.py | Exposes the estimation public API. |
| src/mechaphlowers/api/section_study.py | Adds a lazy-loaded estimation_engine property to SectionStudy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
| self.maxiter = maxiter | ||
| self.dx = dx | ||
|
|
||
| def solve( |
There was a problem hiding this comment.
Why not use numeric.scipy.newton? (Or replace numeric.scipy.newton with this implementation?)
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| from __future__ import annotations |
There was a problem hiding this comment.
Why write this line? What is its effect?
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| from __future__ import annotations |
There was a problem hiding this comment.
Why write this line? What is its effect?
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Co-Authored-By: Github Copilot Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
| def method(self, value: OptimizationMethod) -> None: | ||
| self._method = value | ||
|
|
||
| def estimate( |
| @property | ||
| def method(self) -> OptimizationMethod: | ||
| return self._method | ||
|
|
||
| @method.setter | ||
| def method(self, value: OptimizationMethod) -> None: | ||
| self._method = value |
There was a problem hiding this comment.
Why define a getter and a setter?
| wind_pressure: float | None = None, | ||
| ice_thickness: float | None = None, | ||
| ) -> EstimationResult: | ||
| """Find the cable temperature that yields a target distance to an obstacle. |
There was a problem hiding this comment.
Is it possible to check the study has been "solved" before computing temperature?
| obstacle_point: np.ndarray, | ||
| target_distance: float, | ||
| bounds: tuple[float, float] = (0.0, 200.0), | ||
| wind_pressure: float | None = None, |
There was a problem hiding this comment.
I guess this is only about the wind component that is perpendicular to the span frame?
I guess a wind_direction argument would be useful, same as .solve_change_state.
|


Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
cf. #111
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)