필터 지우기
필터 지우기

I have a system of nonlinear equations an i would like to use a genetic algorithm to solve it .How do i go about it.

조회 수: 1 (최근 30일)
function F= TRIAL3(x,V1,W1,W,w,z,Z1,Z,p,p1,q1,q,c1,V,v,j)
a=[x(1);x(2);x(3);x(4);x(5)];
r=[x(6);x(7);x(8);x(9);x(10)];
s=[x(11);x(12);x(13);x(14);x(15)];
b=x(16);
g=x(17);
d=x(18);
h=x(19);
F=[(V1*((c1- W*r - Z*s)+(p*b- W*r*b.^2 -Z*s*b.^2 - j*d*b) +(q*g- W*r*g.^2- Z*s*g.^2 - j*h*g)))-1*a - a*b.^2 - a*g.^2;
(W1*((c1- V*a - Z*s)+(p*b- V*a*b.^2 -Z*s*b.^2 - j*d*b) +(q*g- V*a*g.^2 - Z*s*g.^2 - j*h*g)))-1*r - r*b.^2 - r*g.^2;
(Z1*((c1- V*a- W*r)+ (p*b- V*r*b.^2 -W*r*b.^2 - j*d*b) +(q*g- V*a*g.^2 - W*r*g.^2 - j*h*g)))-1*s - s*b.^2 - s*g.^2;
((a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)\(p1*V*a+ p1*W*r + p1*Z*s - a'*v*j*d - r'*W'*j*d +s'*Z'*j*d))-b;
((a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)\(q1*V*a+ q1*W*r + q1*Z*s - a'*v*j*h - r'*W'*j*h +s'*Z'*j*h))-g;
(0.2*p1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*b - 0.2*s'*z*j*b)- d;
(0.2*q1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*g - 0.2*s'*z*j*g)- h];
The constants are all matrices as well. How do I implement it with Matlab GA? The errors I keep getting says not enough input argument when I use the GA.It works with fslove but I would like to implement it with ga.

답변 (1개)

Torsten
Torsten 2018년 6월 14일
function res= TRIAL3(x,V1,W1,W,w,z,Z1,Z,p,p1,q1,q,c1,V,v,j)
a=[x(1);x(2);x(3);x(4);x(5)];
r=[x(6);x(7);x(8);x(9);x(10)];
s=[x(11);x(12);x(13);x(14);x(15)];
b=x(16);
g=x(17);
d=x(18);
h=x(19);
F=[(V1*((c1- W*r - Z*s)+(p*b- W*r*b.^2 -Z*s*b.^2 - j*d*b) +(q*g- W*r*g.^2- Z*s*g.^2 - j*h*g)))-1*a - a*b.^2 - a*g.^2;
(W1*((c1- V*a - Z*s)+(p*b- V*a*b.^2 -Z*s*b.^2 - j*d*b) +(q*g- V*a*g.^2 - Z*s*g.^2 - j*h*g)))-1*r - r*b.^2 - r*g.^2;
(Z1*((c1- V*a- W*r)+ (p*b- V*r*b.^2 -W*r*b.^2 - j*d*b) +(q*g- V*a*g.^2 - W*r*g.^2 - j*h*g)))-1*s - s*b.^2 - s*g.^2;
((a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)\(p1*V*a+ p1*W*r + p1*Z*s - a'*v*j*d - r'*W'*j*d +s'*Z'*j*d))-b;
((a'*v*V*a + a'*v*W*r +a'*v*Z*s + r'*w*V*a + r'*w*W*r+ r'*w*Z*s + s'*z*V*a+ s'*z*W*r +s'*z*Z*s)\(q1*V*a+ q1*W*r + q1*Z*s - a'*v*j*h - r'*W'*j*h +s'*Z'*j*h))-g;
(0.2*p1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*b - 0.2*s'*z*j*b)- d;
(0.2*q1*j - 0.2*a'*v*j*b - 0.2*r'*w*j*g - 0.2*s'*z*j*g)- h];
res = sum(F.^2);
Best wishes
Torsten.
  댓글 수: 2
Honey Adams
Honey Adams 2018년 6월 14일
Thanks once again for your assistance.i set all the contsraints to [], and left the nonlinear constraint function constraints to @TRIAL3.and the integer variable indices blank. error i received was too many output argument.
Torsten
Torsten 2018년 6월 14일
편집: Torsten 2018년 6월 14일
Use "Trial3" with the modification from above as the objective function, not as the constraint function.
If this does not work, please post the complete code.
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

카테고리

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