Sobieski problem solved with MDF+SLSQP leads to random results.
Summary
The Sobieski problem solved with MDF formulation and SLSQP solver does not always yield the same result.
Gemseo version
4.0.1
Platform info
Reproduced on Win and Linux
Environment info
Python 3.9 env with gemseo installed with pip in full mode [all]
Steps to reproduce
Run the Sobieski tutorial with MDF and SLSQP and remark that each run provides a different result.
What is the current bug behavior?
Random result and sometimes, far from the optimum expected.
What is the expected correct behavior?
A predictable result, with an objective function close to 3963.
Relevant logs and/or screenshots
Not relevant.
Possible fixes
Commit da673420 seems to be the guilty:
In the following, couplings_adjoint may differ between two runs. It yields to a different order of the lines in the coupled adjoint problem. If the problem is ill-conditionned, it may lead to different results, and then to a different total derivative.
couplings_adjoint =
list(
set(self.all_couplings)
- set(residual_variables.keys())
- set(residual_variables.values())
)
self.jac = self.assembly.total_derivatives(
self.local_data,
outputs,
inputs,
couplings_adjoint,
tol=self.linear_solver_tolerance,
mode=self.linearization_mode,
matrix_type=self.matrix_type,
use_lu_fact=self.use_lu_fact,
exec_cache_tol=exec_cache_tol,
force_no_exec=force_no_exec,
linear_solver=self.linear_solver,
residual_variables=residual_variables,
**self.linear_solver_options,
)
The following produces a deterministic result:
couplings_adjoint = sorted
list(
set(self.all_couplings)
- set(residual_variables.keys())
- set(residual_variables.values())
))