Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: About solve the differential function
Replies: 1   Last Post: Sep 15, 2013 3:02 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Yang Bin

Posts: 1
Registered: 9/11/13
About solve the differential function
Posted: Sep 11, 2013 4:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi all,
I want to realize the method in Guo's paper[1] by matlab. But what I get from the following code is wrong. I wonder how to correct it.
Thanks.

[code]
function eightRobots
clc;
clear;

N=8; %Number of robots
jssum=1000;

%parameter from Pareto-optimal solutions
k=42.886;
c=99.0034;
b=35.3917;
a=64.8640;
m=42.4166;

d_ixsum=zeros(N,jssum);
d_iysum=zeros(N,jssum);
g_ix=d_ixsum;
g_iy=d_iysum;
g_x=d_iysum;
g_y=d_iysum;
p_ix=d_iysum;
p_iy=d_iysum;

%robots' initial position
g_x(:,1)=[-2 -3 -2.8 -2 3.8 2.8 3.2 0.5];
g_y(:,1)=[-0.1 -1.2 -2.5 -2 -2 1 2.5 3.5];

g_ix(:,1)=g_x(:,1);
g_iy(:,1)=g_y(:,1);
p_ix(:,1)=1;
p_iy(:,1)=1;

for i=1:N
for j=1:N
if (i~=j)
d_ix(j)=(g_ix(i,1)-g_ix(j,1))/sqrt((g_ix(i,1)-g_ix(j,1))^2+(g_iy(i,1)-g_iy(j,1))^2);
d_iy(j)=(g_iy(i,1)-g_iy(j,1))/sqrt((g_ix(i,1)-g_ix(j,1))^2+(g_iy(i,1)-g_iy(j,1))^2);
d_ixsum(i,1)=d_ixsum(i,1)+d_ix(j);
d_iysum(i,1)=d_iysum(i,1)+d_iy(j);
end
end
end
mm=1;

for t=0.0001:0.0001:1
mm=mm+1;
for i=1:N
%sigmoid function h
z_ix=4*(g_ix(i,mm-1)^2+g_iy(i,mm-1)^2-1)*g_ix(i,mm-1);
z_iy=4*(g_ix(i,mm-1)^2+g_iy(i,mm-1)^2-1)*g_iy(i,mm-1);

f_z_ix=1-2/(exp(z_ix)+1);
f_z_iy=1-2/(exp(z_iy)+1);

tempDisx=d_ixsum(i,mm-1);
tempDisy=d_iysum(i,mm-1);

tempPix=p_ix(i,mm-1);
tempPiy=p_iy(i,mm-1);
tempeqx=-c*tempPix+k*f_z_ix+b*tempDisx;
tempeqy=-c*tempPiy+k*f_z_iy+b*tempDisy;
if (mm==2)
tempeqx=p_ix(i,1);
tempeqy=p_iy(i,1);
end

p_ix(i,mm)=subs(dsolve('Dx=-c*x+k*f_z_ix+b*tempDisx','x(0)=tempeqx'));
p_iy(i,mm)=subs(dsolve('Dy=-c*y+k*f_z_iy+b*tempDisy','y(0)=tempeqy'));
if (mm==3)
mm
p_ix(i,mm)
p_iy(i,mm)
end

Gix=g_ix(i,mm-1);
Giy=g_iy(i,mm-1);

tempPix=p_ix(i,mm);
tempPiy=p_iy(i,mm);

tempGx=subs(-a*z_ix+m*tempPix);
tempGy=subs(-a*z_iy+m*tempPiy);

tempGxx=g_ix(i,mm-1);
tempGyy=g_iy(i,mm-1);

g_ix(i,mm)=subs(dsolve('Dx=-a*z_ix+m*tempPix','x(0) = tempGxx'));
g_iy(i,mm)=subs(dsolve('Dy=-a*z_iy+m*tempPiy','y(0) = tempGyy'));
end

for i=1:N
for j=1:N
if (i~=j)
d_ix(j)=(g_ix(i,mm)-g_ix(j,mm))/sqrt((g_ix(i,mm)-g_ix(j,mm))^2+(g_iy(i,mm)-g_iy(j,mm))^2);
d_iy(j)=(g_iy(i,mm)-g_iy(j,mm))/sqrt((g_ix(i,mm)-g_ix(j,mm))^2+(g_iy(i,mm)-g_iy(j,mm))^2);
d_ixsum(i,mm)=d_ixsum(i,mm)+d_ix(j);
d_iysum(i,mm)=d_iysum(i,mm)+d_iy(j);
end
end
end

g_x(:,mm)=g_ix(:,mm);
g_y(:,mm)=g_iy(:,mm);
g_y(1,mm-1)
clf
plot(g_ix(:,1),g_iy(:,1),'o')
hold all
circle(0,0,1);
axis([-5 5 -5 5]);
pause(.01)
end
end
[/code]

[1]. Hongliang Guo, Yan Meng, Yaochu Jin. A cellular mechanism for multi-robot construction via evolutionary multi-objective optimization of a gene regulatory network.BioSystems, 2009.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.