double lowestRaw=10000;//very small value to acheive the if condition below in the first time
GPIndividual tempInd=null;
for(int i=0;i<((GPIndividual)(state.population.subpops[0].individuals[0])).size();i++){
double temp=((KozaFitness)(((GPIndividual)(state.population.subpops[0].individuals[i])).fitness)).rawFitness();
if(temp<lowestRaw){
lowestRaw=temp;
tempInd=((GPIndividual)(state.population.subpops[0].individuals[i]));
}//end of if
}//end of for
GPIndividual bestInd=(GPIndividual) tempInd.clone();
GPNode add=new Add();
add.setup(state, new Parameter("pop"));
add.children[0]=bestInd.trees[0].child;
GPNode small=new SmallValue();
small.setup(state, new Parameter("pop"));
add.children[1]=small;
add.children[0].parent=add;
add.children[1].parent=add;
GPIndividual newInd=new GPIndividual();
newInd.setup(state, new Parameter("pop"));
newInd.trees[0].child=add;
double biggestRaw=0;
GPIndividual worstInd=null;
for (int i=0;i<state.population.subpops[0].individuals.length;i++){
double temp=((KozaFitness)((GPIndividual)(state.population.subpops[0].individuals[i])).fitness).rawFitness();
if (temp>biggestRaw){
biggestRaw=temp;
worstInd=(GPIndividual)(state.population.subpops[0].individuals[i]);
}
}
worstInd=newInd;
====================================
this is the output of the program
===================================================
Initializing Generation 0
SubPopulation number 0 evaluated succesfully
SubPopulation number 100 evaluated succesfully
SubPopulation number 200 evaluated
succesfully
SubPopulation number 300 evaluated succesfully
SubPopulation number 400 evaluated succesfully
SubPopulation number 500 evaluated succesfully
Subpop 0 best fitness of generation: Fitness: Raw=3558.1477 Adjusted=2.8096614E-4 Hits=0
FATAL ERROR:
No node constraints are defined for the GPNode +
PARAMETER: pop.nc
ALSO: gp.node.nc
Java Result: 1
============================