How can I use Genetic Algorithm toolbox to calibrate a model?

2 ビュー (過去 30 日間)
Sahar khalili
Sahar khalili 2022 年 2 月 28 日
コメント済み: Alan Weiss 2022 年 3 月 3 日
Hi, this is my first time I use Optimize Live Editor Task.
I have a function, which calculates some outputs throughot the time,
= solvemodel_v12(m_start,m_stop,initfile,'lake',inputfile,'timeseries', parafile,'lake');
Each output is calculated throughout the time step (if it is a year, we would have 365 values for every output).
I have the observation of an output Tzt, and now I want to calibrate my model to minimize RMSQ, and during the calibration process, I would like parameters in the parafile excelsheet to be changed, which its maximum and minimum values are also indicated in that excelsheet. I don't know how I can use FA in live editor task to calibrate this model.

回答 (1 件)

Alan Weiss
Alan Weiss 2022 年 2 月 28 日
編集済み: Alan Weiss 2022 年 2 月 28 日
It is entirely possible that I have misunderstood your question in some way. Feel freee to ask again with more explanation if my answer is not relevant.
First, it is not at all clear to me that ga is the best tool for this task. Why not use lsqnonlin, which is generally faster and more accurate?
But if you have a good reason for using ga then you can write the objective as something like
function Tzt = ...
myfun(m_start,m_stop,initfile,'lake',inputfile,'timeseries', parafile,'lake');
[~,~,~,~,~,~,Tzt,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~,~] = ...
solvemodel_v12(m_start,m_stop,initfile,'lake',inputfile,'timeseries', parafile,'lake');
Call ga like this:
fun = @(parafile)sum((myfun(m_start,m_stop,initfile,'lake',inputfile,'timeseries', parafile,'lake') ...
- (theExpectedValue)).^2);
[sol,fval,efag,output] = ga(fun,nvar,A,b,Aeq,beq,lb,ub,nlcon)
Put in any necessary constraints in the ga call as well.
The solution sol has the new values for the parafile variables. You can write this out to the Excel file after ga runs.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  6 件のコメント
Alan Weiss
Alan Weiss 2022 年 3 月 3 日
Yes, you have to get the data into MATLAB.
Alan Weiss
MATLAB mathematical toolbox documentation


Community Treasure Hunt

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

Start Hunting!

Translated by