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.
0 个评论
回答(1 个)
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!