Info

この質問は閉じられています。 編集または回答するには再度開いてください。

in every iteration of ga i wanna get the values generated by vector x(1), x(2) to get the optimized value?

1 回表示 (過去 30 日間)
Arunachalam  D
Arunachalam D 2015 年 4 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Program
clc
clear all
x(1)=randi([6,100]);
x(2)=randi([2,4]);
fun=@(x) x(1)+x(2)+100;
[x, fval]=ga(fun,2)
Output
Optimization terminated: maximum number of generations exceeded.
x =
-23.2216 -17.4776
fval =
59.3009
here i am getting negative values.. please help how to code this..thank you
  1 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 4 月 12 日
Arunachalam - what is the purpose of the code
x(1)=randi([6,100]);
x(2)=randi([2,4]);
Do you think that it is necessary for the fitness function that you are trying to minimize, fun? You mention how you are getting negative values for your x. This makes sense since the Genetic Algorithm is minimizing your fitness function. What do you expect to see instead?

回答 (1 件)

Alan Weiss
Alan Weiss 2015 年 4 月 13 日
If you want to constraint your parameters to be positive, include bounds.
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