実験結果とモデルのフ​ィッティングのために​GAを使いたい

10 views (last 30 days)
功紀
功紀 on 17 May 2023
MATLAB初心者です。
実験結果を表すモデルが以下の微分方程式で記述できるときに、GAを用いて定数a,b,c,dを求めたいと考えています(質問用に式は簡略化されています)。
x'=ax+by
y'=cx+dy
まず関数を以下のように定義しました。
function L=dxdt1(x,t,a,b,c,d)
L=zeros(2,1);
L(1)=a*x(1)+b*x(2);
L(2)=c*x(1)+d*x(2);
end
次にGAの目的関数として以下のように定義しました。
ここでXおよびYはtspanに対応する実験値を示しています。
function M=ga_func_dxdw1(a,b,c,d)
type dxdt1.m
rng default
a=optimvar('a');
b=optimvar('b');
c=optimvar('c');
d=optimvar('d');
y0=[1 0];
tspan=[0 1 2 3 4 5];
[t,x]=ode45(@(t,x) dxdt1(t,x,a,b,c,d),tspan,y0);
X=[1 0.7 0.5 0.4 0.2 0.1]';
Y=[0 0.3 0.2 0.1 0.09 0.05]';
M=sum((X-x(:,1)).^2/sum(X)+(X2-x(:,2)).^2/sum(Y);
end
このようにして目的関数Mを(実験値-計算値)^2に似た式で設定し、以下のようにGAを実行しました。
type ga_func_dxdw1.m
FitnessFunction=optimproblem("Objective",ga_func_dxdw1(a,b,c,d));
options = optimoptions("ga",'PopulationSize',200,"PlotFcn","gaplotbestf");
[Sol,fval]=solve(FitnessFunction,"Solver","ga","Options",options)
実行した結果、「変数aが認識されません」というエラーが出てしまい、間違いを正す方法がわからないという次第であります。
考え方について至らない点がございますがどうぞよろしくお願いします。

Answers (0)

Categories

Find more on 常微分方程式 in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!