Why is my multi-objective optimization with gamultobj (NSGA-II) not working?

3 次查看(过去 30 天)
Dear MATLAB Community,
I am doing a research project right now where my goal is to implement an optimization algorithm in order to optimize the charging current sequence of a battery during fast charging. In order to accomplish that, I implemented a fitness function for my optimzation problem, that is calculating the cell voltage and temperature at every time step t over the charging time. I do this because my objectives depend on the individual voltage and temperature values. In order to calculate the voltages and temperature I used ode45 and ode15s solvers to solve my differential equations. However, when I start my optimization, I always receive NaN's for my values starting at a certain timestep. I therefore excluded my model to be wrong since it works for approx. the first 100 timesteps before it throws out NaN's. I alerady tried to manipulate all settings of the solvers including Step Sizes etc., but it all doesn't work.
What is also strange, is that when I test my fitness function with a series of predefined current values, it works out fine and no NaN is thrown out. Is anyone here an expert with gamultobj or another optimization tool and can explain to me why this error is showing up? I did not share any code since there is no easy way of presenting my large code set :(
I would be very grateful for any help, thanks!

采纳的回答

Torsten
Torsten 2023-11-13
移动:Torsten 2023-11-13
Extract your optimization parameters at the time when the integrator returns NaN values. Are they reasonable ? If you think they are, start your integrator as a stand-alone application with these parameters and see why NaN values are produced.

更多回答(1 个)

Harald
Harald 2023-11-13
Hi Paul,
I suspect that the genetic algorithm is generating some starting values that don't go well with your ODEs for one or another reason. If you can't share your project, I can only suggest what I would do:
  1. Set a conditional breakpoint in your fitness function to break if the results of trying to solve the ODE contain NaN.
  2. Check whether solving the ODEs outside behaves the same way outside of the optimization process if parameters are set the same way as inside the optimization process.
  3. If that's the case, dive more deeply into the ODEs. For example, repeat 1. but now checking whether the function supplied to the ODE solver is throwing NaN.
Best wishes,
Harald
  2 个评论
Paul Lindner
Paul Lindner 2023-11-20
Thanks for your answer you were right it was indeed producing values the ODE's couldn't handle!
Harald
Harald 2023-11-20
Hi Paul,
it's great that you have been able to resolve the problem. If the answer was helpful for doing so, please consider clicking the "accept" button for it.
Best wishes,
Harald

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by