Optimization Error for car model
1 次查看(过去 30 天)
显示 更早的评论
Dear All,
I am trying to optimised a few parameters to achieve minimum fuel consumption. My parameters include gear ratio, throttle, vehicle and driver mass and it must be within a speed limit of 40km/h.
However, when I tried to optimised those parameters, it showed matrix dimensions must agree and failure in initial nonlinear constraint function evaluation. I tried to search online but I cannot figured out what problem is that.
It would be great if someone can tell me what is wrong with my model.
Thank you very much.
Wei Kang Chang
4 个评论
Swarooph
2019-3-19
Hei Wei,
2 points here:
- I downloaded the files and incorporated the changes Walter has suggested (which are correct). Since these files are in the PreLoadFcn callback, they will be executed only when you open the model. After making these changes, did you close the model, reopen it and then tried again? When I do this, I am able to run the model to get the scope output as shown below. Can you try the same and see if you are just able to run the model first without the optimization?
2. After fixing the above issue, I used your session file and try to run the optimization. I was able to get a few initial runs but then got the error about a missing custom objective function as shown below. It seems like you are missing a MATLAB file or a custom objective function specification here. Either you may have forgotten to include it in your question or you may have not gotten this from the original source..
回答(1 个)
Swarooph
2019-3-26
The following seems to fix your problem but I don’t know if this is what you really wanted to do:
- Set FCMin to “Minimize the function output”. Originally it was set to be “Constrain function output to be <= 0”. Did you mean to constrain FCMin to be <=0 ? Does that make sense for the variable/function you are trying to optimize for which seems to be fuel consumption?
- Once I do (1), I am able to run the optimization without issues. Note that I did terminate the optimization before it converged or terminated automatically just to show that it is able to run iterations and do optimization.
That fixes your error issue. But to be honest, I am not completely convinced you have set up this optimization problem correctly. At the very least, your speed profile needs to have a lower bound of zero so that the car doesn’t go backwards. I also don’t know if you are plotting the right value for fuel consumption cost (FCMin plot). Should it be an average metric? So, take mean of all the fuel consumption values over the drive cycle instead of an array of fuel consumption values? Just some thoughts for you to think about.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vehicle Scenarios 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!