dcsimg
Performance issue in coding
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vignesh_kp
Posted On:   Friday, May 27, 2011 01:07 PM

im using 6 methods which are similiar to each other .im using method call inside the iteration loop.I got an issue in their performance i takes nearly 45 min for 1000 iteration but i have to reduce to 1 min.please help me in solving this issue.and also i will update some other module herewith please help me to resolve it public Vector fitcalc1(int[] city,int count,int popul,int[] demand,double[][] distance) { Vector ve=new Vector(); int[][] ci=new int[100][100]; double fit[]=new double[100]; int cco[]=new int[100]; // System.out.println("count="+count); int t=0,h=0,de=0;int ds=0; for(int i=0;i { ds++; de=de+demand[city[i]]; if(de <   More>>

im using 6 methods which are similiar to each other .im using method call inside the iteration loop.I got an issue in their performance i takes nearly 45 min for 1000 iteration but i have to reduce to 1 min.please help me in solving this issue.and also i will update some other module herewith please help me to resolve it



public Vector fitcalc1(int[] city,int count,int popul,int[] demand,double[][] distance)
{
Vector ve=new Vector();
int[][] ci=new int[100][100];
double fit[]=new double[100];
int cco[]=new int[100];
// System.out.println("count="+count);
int t=0,h=0,de=0;int ds=0;
for(int i=0;i
{
ds++;
de=de+demand[city[i]];
if(de <=100)
{
// System.out.println("h="+h+" "+"t="+t);

ci[t][h]=city[i];
h++;
if(i <(count-1))
cco[t]=h;
}
else
{
de=0;
cco[t]=h-1;
t++;h=0;
ci[t][h]=city[i];
h++;
if(i <(count-1))
cco[t]=h;
}
}


for(int m1=0;m1 <3;m1++)
{
ve.add(cco[m1]);
}

for(int i=0;i <=t;i++)
{
for(int fg=0;fg <=cco[i];fg++)
{

ve.add(ci[i][fg]);
}

}
return ve;
}



public Vector conver(double ra[][],int city[],int noc,int popu)
{
int ci,cj;
Vector ve=new Vector();
double temp[]=new double[50];
int tempc[]=new int[50];
int city1[][]=new int[50][50];
for(ci=0;ci
{
for(cj=0;cj
temp[cj]=ra[ci][cj];
tempc[cj]=city[cj];
}

double t1;
int t2;
for(int ck=0;ck
{
for(int cf=0;cf
{
if(temp[ck]
{
t1=temp[ck];
temp[ck]=temp[cf];
temp[cf]=t1;
t2=tempc[ck];
tempc[ck]=tempc[cf];
tempc[cf]=t2;
}
}
}
for(int cy=0;cy
{
city1[ci][cy]=tempc[cy];

}
}
for(int ck=0;ck
{
for(int cf=0;cf
{
ve.add(city1[ck][cf]);
}
}
return ve;
}



public Vector formula(double rand[][],double bra[],double lb[][],int iter,int noc,int popul,double velo[][])
{
Vector ve=new Vector();
double velocity[][]=new double[100][100];
double w=.41;
int c1=2,c2=2;

//System.out.println("fh==="+iter);
if(iter==0)
{
for(int fk=0;fk
{
for(int ff=0;ff
{
double q=Math.random();
double q1=Math.random();

velocity[fk][ff]=1*w+c1*q*(lb[fk][ff]-rand[fk][ff])+c2*q1*(bra[ff]-rand[fk][ff]);
// System.out.println("random number1=="+q+"random number2==="+q1);
}
}
}
else
{
for(int fk=0;fk
{
for(int ff=0;ff
{
double q=Math.random();
double q1=Math.random();
velocity[fk][ff]=velo[fk][ff]*w+q*c1*(lb[fk][ff]-rand[fk][ff])+c2*q1*(bra[ff]-rand[fk][ff]);
DecimalFormat d=new DecimalFormat("#.###");
String h=d.format(velocity[fk][ff]);

velocity[fk][ff] = Double.valueOf(h).doubleValue();
//System.out.println("random number1=="+q+"random number2==="+q1);
}
}


}


for(int vk=0;vk
{
for(int vf=0;vf
{
rand[vk][vf]=velocity[vk][vf]+rand[vk][vf];
DecimalFormat d=new DecimalFormat("#.###");
String h1=d.format(rand[vk][vf]);

rand[vk][vf] = Double.valueOf(h1).doubleValue();
}
}

for(int ck1=0;ck1
{
for(int cf1=0;cf1
{
ve.add(rand[ck1][cf1]);
}

}
for(int ck1=0;ck1
{
for(int cf1=0;cf1
{
ve.add(velocity[ck1][cf1]);
}

}

return ve;
}

   <<Less
About | Sitemap | Contact