필터 지우기
필터 지우기

GA in Matlab 2014???

조회 수: 3 (최근 30일)
KHANH NGUYEN
KHANH NGUYEN 2015년 4월 7일
댓글: Mohammad Abouali 2015년 4월 7일
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