gaに関して発生したerrorについて

5 views (last 30 days)
yokoyama
yokoyama on 5 Dec 2019
Answered: Etsuo Maeda on 12 Dec 2019
simulinkで構築したモデルの姿勢の最適化をするためにgaを使おうとしたら,以下のようなエラーが発生しました.
エラー: ga (line 393)
関数への入力引数にコロン演算子が含まれています。コロン演算子を入力するには、代わりに ':' を使用してください。
エラー: Gatry2 (line 16)
[X,Y]=ga(ObjectiveFunction,16,A,b,Aeq,beq,lb,ub,nonliner,ConstraintFunction,options);
このエラーの原因がどの部分で,どう書くのが正しいのか知りたいです.
以下が私の書いたgaのプログラムです.
sim('seniorCar1205ga');
ObjectiveFunction = @gatry; %gatry:gaで最小を求めたい関数プログラム
nvars = 16; % Number of variables
ConstraintFunction = @gatry;
lb=[0.1358 0.0997 -0.7927 -0.3667 -0.4854 -0.2115 -0.2137 -0.2013 -0.2418 -0.2096 -0.2701 -0.2798 -0.2188 -0.2144 -0.2045 -0.200005];
ub=[0.5358 0.4997 -0.3927 0.1667 -0.2854 0.2115 0.2137 0.2013 0.2418 0.2096 0.2701 0.2798 0.2188 0.2144 0.2045 0.200005];
A=[];
b=[];
Aeq=[];
beq=[];
nonliner=[];
options=optimoptions('ga','PopulationSize',24,'generations',40,'Display','iter','EliteCount',1,'PlotFcns',{@gaplotbestf},'UseParallel',true);
[X,Y]=ga(ObjectiveFunction,16,A,b,Aeq,beq,lb,ub,nonliner,ConstraintFunction,options);

Accepted Answer

Etsuo Maeda
Etsuo Maeda on 12 Dec 2019
回答がついていないようなので・・・
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,IntCon,options)
の構文で、IntConに関数を与えていることが原因です。
制約をかけるならnonlconに関数を与えてください。
HTH

More Answers (0)

Categories

Find more on Simulink Design Optimization in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!