Sorry I didn't clarify that: I define the initial random positions, I store them in a variable, say pos_in, and then I call the functions (the different versions) with pos_in as input, so the initial positions are the same in every case.

On 28/01/13 14:07, Serge Steer wrote:
If the initial position of your sphere are randomly set, it can be normal than you do not have the same number of iteration from one simulation to an other one.
can you check using
rand("seed",0)
to force identical initial points for your various tests.

Serge Steer
Le 28/01/2013 16:18, Ezequiel Soulé a écrit :
The algorithm essentially starts with a set of spheres in random positions and in a relatively dense state, and runs an iterative process where the spheres are moved in each iteration in order to reduce the overlaps.
The core of the script is more or less like this

    superp=calc_D_superp_dobcel(pos);   //this line uses an external function 
to calculate a matrix with the overlap between paritcles, defined as 
superp(i,j)=max(R(i)+R(j)-D(i,j),0) . D(i,j) is the distance between the 
spheres and R is the radius. pos is a 3-colum matrix containging the 
coordinates of the position of each sphere
control=0; //number of iterations

sup_2(int(control/max_mov*20)+1)=sumsupant/max_mov*20;   // this defines a 
third control system as will be described bellow. **

while  max(superp)>tol   // the maximum value of superp controls when the 
system is considered overlap-free and the algorithm is finished


...
// Several lines where the positions of each sphere are modified, acording to 
the values of the matrix superp
...
superp=calc_D_superp_dobcel(pos); //matrix superp is re-calculated with the new positions


control=control+1;

  if  control>max_mov  then  break;  end    // control by maximum number of 
iterations
//the following belongs to the third control system: if length(sup_2)==int(control/max_mov*20) then sup_2(int(control/max_mov*20)+1)=sum(superp)/max_mov*20; //**
     else//**
        sup_2(int(control/max_mov*20)+1)=sup_2(int(control/max_mov*20)+1)  +  
sum(superp)/max_mov*20;    //**
    end      //**
if length(sup_2)>4.5 then //**
       if  sup_2($-1)>0.85*sup_2($-2)  &  sup_2($-2)>0.85*sup_2($-3)  then  
break;  end      //**
       if  sup_2($-1)>0.7*sup_2($-2)  &  sup_2($-2)>0.7<
  span styl
e="color:rgb(92,92,92)">*sup_2($-3)  &  sup_2($-3)>0.6*sup_2($-4)  then  break; 
 end     //**
   end      //**

end//ends while loop

The third control system essentially controls if the overlap is decreasing as the iterations proceed. It defines a new variable, sup_2, that stores the average value of sum(superp) in max_mov/20 iterations. If this average does not decrease fast enough (>15% decrease in two or >30%decrease in three consecutive groups of max_mov/20 iterations), it considers that it will not converge and breaks. Now, this third control system seems to be problem. As you can see, non of its lines (marked with ** for more clarity), affects the values of superp (at least, it shouldn´t). But still, the value of superp is modified when I include this control system. The other problem I had was with a similar algorithm, without the third control system, but just adding a "pause" rigth after the last end. This will also modify the values of superp and the number of iterations. As I said, the error in superp is not important (it is in the order of 1.d-15), but this difference propagates exponentially through the iterations and can significantly modify (like a 30%) the total number of iterations (I was trying to evaluate if the third control really worked, but I couldn´t do it because the algortihm CONVERGES with a different number of iterations...)


_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to