Octave/Matlab Code for the solution :
Blue and Red pair stands for the positions of the Two volunteers in a given circular campus.
For various random pair of seeds the optimization finally resulted in a set of four nonlinear integral equations.
Solved them using iterative procedure.
The locus of the volunteer positions have come to be on a particular radius(=0.42676) circle with each one on antipodal positions.
Later, based on the antipodal property observed from the computations the value of the radius was found to be exactly 4/(3pi)=0.42441 by evaluating the integral equations in polar form for the unknown radius.
Code starts here :
%%% Two volunteer selection problem
T=[0:0.01:2*pi];
R=[0:0.01:1];
[GridR, GridT]=meshgrid(R, T);
iX=GridR.*cos(GridT);
iY=GridR.*sin(GridT);
dA=GridR*0.01*0.01;
for ini=1:100
%%initialization
P=[rand*cos(rand*2*pi), rand*sin(rand*2*pi)];
Q=[rand*cos(rand*2*pi), rand*sin(rand*2*pi)];
for it=1:40
dD=sum(P.*P-Q.*Q ) ;
sgn=sign(2*(Q(1)-P(1))*iX+2*(Q(2)-P(2))*iY+dD);
%% x0, y0
isgn=1-sgn;
Nume=sum((iX.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
P(1)=Nume/Deno;
Nume=sum((iY.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
P(2)=Nume/Deno;
%% x1, y1
isgn=1+sgn;
Nume=sum((iX.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
Q(1)=Nume/Deno;
Nume=sum((iY.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
Q(2)=Nume/Deno;
endfor
polar( atan2(P(2), P(1)), norm(P),'r*');
hold on;
polar( atan2(Q(2), Q(1)), norm(Q), 'b*');
pause(1)
endfor
Blue and Red pair stands for the positions of the Two volunteers in a given circular campus.
For various random pair of seeds the optimization finally resulted in a set of four nonlinear integral equations.
Solved them using iterative procedure.
The locus of the volunteer positions have come to be on a particular radius(=0.42676) circle with each one on antipodal positions.
Later, based on the antipodal property observed from the computations the value of the radius was found to be exactly 4/(3pi)=0.42441 by evaluating the integral equations in polar form for the unknown radius.
Code starts here :
%%% Two volunteer selection problem
T=[0:0.01:2*pi];
R=[0:0.01:1];
[GridR, GridT]=meshgrid(R, T);
iX=GridR.*cos(GridT);
iY=GridR.*sin(GridT);
dA=GridR*0.01*0.01;
for ini=1:100
%%initialization
P=[rand*cos(rand*2*pi), rand*sin(rand*2*pi)];
Q=[rand*cos(rand*2*pi), rand*sin(rand*2*pi)];
for it=1:40
dD=sum(P.*P-Q.*Q ) ;
sgn=sign(2*(Q(1)-P(1))*iX+2*(Q(2)-P(2))*iY+dD);
%% x0, y0
isgn=1-sgn;
Nume=sum((iX.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
P(1)=Nume/Deno;
Nume=sum((iY.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
P(2)=Nume/Deno;
%% x1, y1
isgn=1+sgn;
Nume=sum((iX.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
Q(1)=Nume/Deno;
Nume=sum((iY.*isgn.*dA)(:));
Deno=sum((isgn.*dA)(:));
Q(2)=Nume/Deno;
endfor
polar( atan2(P(2), P(1)), norm(P),'r*');
hold on;
polar( atan2(Q(2), Q(1)), norm(Q), 'b*');
pause(1)
endfor
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి