GA in Matlab 2014???

3 次查看(过去 30 天)
Hi Everyone, I'm researching GA in Matlab for My thesis. I have a Problem with it. I solve Problem with 5 Vars: x1; x2; x3; x4; x5 I want to setup lower bound and upper bound for 5 Vars as follow: lb=[0.3 0.4 0.5 1 2] ub=[0.9 0.9 0.9 5 6] I want the x value: x1= 0.3; 0.35; 0.4;.....0.9 x2= 0.4; 0.45; 0.5;.....0.9 x3= 0.5; 0.55; 0.6;.....0.9 x4=1; 2; 3;...5 x5=2; 3; 4;...6 How do you do? Thank you so much.
  1 个评论
Joep
Joep 2015-4-7
编辑:Joep 2015-4-7
Sorry needed to rewrite it to read your question.
Hi Everyone, I'm researching GA in Matlab for My thesis. I have a Problem with it. I solve Problem with 5 Vars: x1; x2; x3; x4; x5 I want to setup lower bound and upper bound for 5 Vars as follow:
lb=[0.3 0.4 0.5 1 2]
ub=[0.9 0.9 0.9 5 6]
I want the x value:
x1= 0.3; 0.35; 0.4;.....0.9
x2= 0.4; 0.45; 0.4;.....0.9
x3= 0.4; 0.45; 0.5;.....0.9
x4=1; 2; 3;...5
x5=2;3;4...6
How do you do? Thank you so much.
x2 and x3 looks me wrong in your question.

请先登录,再进行评论。

采纳的回答

Mohammad Abouali
Mohammad Abouali 2015-4-7
编辑:Mohammad Abouali 2015-4-7
Since you have discrete values for x1 to x5 you need to define it as an integer problem. (I know x1,x2,x3 are not integer input so read to the end).
IntCon in:
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon,options)
IntCon list all the parameters that need integer value. which in your case would be IntCon=1:5 since all your variables need to be expressed as integer.
x4 and x5 are already integer so no problem there. but you need to change x1, x2,and x3.
define:
xx1=0.3:0.05:0.9
xx2=0.4:0.05:0.9
xx3=0.4:0.05:0.9
Now define the lower bound and upper bound as:
LB=[1 1 1 1 2]
UB=[numel(xx1) numel(xx2) numel(xx3) 5 6]
Your original function is defined as fitnessfcn(x1,x2,x3,x4,x5) but now by defining LB,UB, IntCon as mentioned above x1,x2,x3 are fed integer values which you don't want it. for example GA will varry x1 from 1 to 13. You need to change your function definition. Wherever, it was x1 you need to replace it with xx1(x1). This way, correct value is used. Let's say your original function was
fitnessfcn=@(x1,x2,x3,x4,x5) x1+x2+x3+x4+x5;
You need to change it to
fitnessfcn=@(x1,x2,x3,x4,x5) xx1(x1)+xx2(x2)+xx3(x3)+x4+x5;
this way, x1 varies from 1 to 13 but x1=1 will return xx1(1) which is 0.3. Therefore, practically x1=1 is mapped to 0.3, x1=2 is mapped to 0.35 and so on.
  2 个评论
KHANH NGUYEN
KHANH NGUYEN 2015-4-7
Thank you so much. I'll consider it again.
Mohammad Abouali
Mohammad Abouali 2015-4-7
You are welcome.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by