Matlab > Genetic annotator > HELP

6 ビュー (過去 30 日間)
Inderjeet Singh
Inderjeet Singh 2016 年 1 月 21 日
コメント済み: Alan Weiss 2016 年 1 月 21 日
HELP > Coding and Minimizing a Fitness Function Using the Genetic Algorithm > Minimizing Using Additional Arguments
Following line has been given, but it don't tell where to define these values? I tried to write in its fitness function and I tried to enter these values at different places in GA in matlab.
a = 100; b = 1; % define constant values
Please let me know, where to enter these constant values?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 21 日
Define your function as taking two additional arguments, a, and b. Then when you call ga, instead of just giving a handle to your function, like
ga(@myObjectiveFunction, ....)
call
a = 100;
b = 1;
ga(@(x) myObjectiveFunction(x,a,b), .....)
  5 件のコメント
Inderjeet Singh
Inderjeet Singh 2016 年 1 月 21 日
I tried to write it in matlab as shown in image and it gave errors too.
Alan Weiss
Alan Weiss 2016 年 1 月 21 日
You saw that the first time you ran the code it worked fine. You saw that the second time there was an error. What was the difference between these two times? Look hard at the end of the ga call, you will see that the time it worked was when you had a ,2 toward the end of the line. What does this 2 mean? Look at the syntax for ga and see if you can figure it out.
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by