Minimization Algorithm (fmincon)

6 views (last 30 days)
I am trying to set up a minimization code using the function fmincon. My code describes a chemical reactor, which receives a series of temperatures and molar fractions as input data (lines 44-149 in the Matlab code, if "clearvars" is line 1). In particular, I have carried out 20 experiments, each of whose has been analyzed at 9 diverse temperatures (220, 240, 260, 280, 300, 320, 340, 360, 380 °C): the molar fractions getting out of the reactor (180 for each species, i.e. 9*20, lines 151-178) have to be compared to the ones predicted by the model. I need to find four parameters (k0_alpha3, k0_K_CO, Eapp_alpha3, DH_K_CO) so that the difference between the predicted and the measured CH4 molar fractions (yCH4out_model and yCH4out, respectively) is minimum. The code I have implemented runs, but it is strongly affected by the initial-guess values and seems not to minimize the aforementioned quantity at all. I have also plotted the predicted values vs the measured ones for each experiment (20 plots) with respect to temperature and a clear difference is observable: a manual modification of the parameters can simply enhance my results, wich means that there might be something "fishy" in my code. What can I do to improve my results? The file of interest has been attached.
Thanks in advance, Riccardo Rinaldi
  2 Comments
Torsten
Torsten on 19 Oct 2018
Is it really correct that you integrate from w=0 up to w=Mcat ?
Riccardo Rinaldi
Riccardo Rinaldi on 19 Oct 2018
Yes, it is. The reactor is quite small and the catalyst mass is around 0.1 g. I think I am forgetting something in the options for the optimization, so that the difference between the model predictions and the experimental values is kept at its minimum. Are there any tools to improve my minimization? Why is the solution stuck to the initial values? Thank you, Riccardo

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 19 Oct 2018
After reading your code I decided that, based on the suggestions in Optimizing a Simulation or ODE, it might be better to take larger finite difference steps, so I set 'FiniteDifferenceStepSize',1e-4 in the options. The resulting Fval was reduced quite a bit, but the plots did not look so close to me. Then I tried 'FiniteDifferenceStepSize',1e-3,'FiniteDifferenceType','central', and again the resulting Fval was reduced quite a bit (down to 2.57e-2) but the plots still did not match very well.
It is possible that, like many least-squares problems, you must start from a wide variety of initial points to get a global minimum. See MultiStart using lsqcurvefit or lsqnonlin for a discussion.
I can also suggest that it might be better to scale your problem so that each coordinate has about the same range. This essentially means taking different units for some coordinates, so that the problem does not have such disparate sizes in the different coordinates.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
Riccardo Rinaldi
Riccardo Rinaldi on 20 Oct 2018
Thank you very much, Mr. Weiss. Following your tips, I changed the units of my parameters, so that the optimization was run with same-order-of-magnitude numbers. Besides, I set more severe lower and upper boundaries. By combining these two things, I obtained significantly better results. You definitely should win the Nobel Prize! Best wishes, Riccardo Rinaldi

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!