[Quantproject-developers] QuantProject/b1_ADT/Optimizing/Genetic GeneticOptimizer.cs, 1.29, 1.30 Ge
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2011-08-21 09:52:42
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic
In directory vz-cvs-3.sog:/tmp/cvs-serv25736/Genetic
Modified Files:
GeneticOptimizer.cs Genome.cs NewGenerationEventArgs.cs
Log Message:
Some minor bugs have been fixed, in order to have more (and more correct) information in log files
Index: Genome.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/Genome.cs,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Genome.cs 27 Mar 2010 17:15:54 -0000 1.21
--- Genome.cs 21 Aug 2011 09:52:40 -0000 1.22
***************
*** 164,167 ****
--- 164,172 ----
}
+ private void clone_copyValuesInGenes(int[] valuesToBeCopied)
+ {
+ for (int i = 0 ; i < this.size ; i++)
+ this.genes[i] = valuesToBeCopied[i];
+ }
/// <summary>
***************
*** 171,175 ****
{
Genome returnValue = new Genome(this.genomeManager, this.geneticOptimizer);
! returnValue.CopyValuesInGenes(this.genes);
returnValue.setFitnessValue(this.fitness);
returnValue.meaning = this.meaning;
--- 176,180 ----
{
Genome returnValue = new Genome(this.genomeManager, this.geneticOptimizer);
! returnValue.clone_copyValuesInGenes(this.genes);
returnValue.setFitnessValue(this.fitness);
returnValue.meaning = this.meaning;
***************
*** 185,196 ****
}
! public void CopyValuesInGenes(int[] valuesToBeCopied)
! {
! for (int i = 0 ; i < this.size ; i++)
! this.genes[i] = valuesToBeCopied[i];
! //whenever at least one gene has been written,
! //the current generation number is stored
! this.generation = this.geneticOptimizer.GenerationCounter;
! }
public void SetGeneValue(int geneValue, int genePosition)
--- 190,223 ----
}
! // //old implementation
! // public void CopyValuesInGenes(int[] valuesToBeCopied)
! // {
! // for (int i = 0 ; i < this.size ; i++)
! // this.genes[i] = valuesToBeCopied[i];
! // //whenever at least one gene has been written,
! // //the current generation number is stored
! // this.generation = this.geneticOptimizer.GenerationCounter;
! // }
!
! // //old implementation
! // public void SetGeneValue(int geneValue, int genePosition)
! // {
! // if(geneValue < this.GetMinValueForGenes(genePosition) ||
! // geneValue > this.GetMaxValueForGenes(genePosition) )
! // throw new IndexOutOfRangeException("Gene value not valid for the gene at" +
! // " the given position!");
! // if( geneValue != this.GetGeneValue(genePosition) )
! // // if a new value is stored in the given position, then
! // // fitness has to be calculated again, and so meaning
! // {
! // this.hasFitnessBeenAssigned = false;
! // this.meaning = null;
! // }
! //
! // this.genes[genePosition] = geneValue;
! // //whenever at least one gene has been written,
! // //the current generation number is stored
! // this.generation = this.geneticOptimizer.GenerationCounter;
! // }
public void SetGeneValue(int geneValue, int genePosition)
***************
*** 206,215 ****
this.hasFitnessBeenAssigned = false;
this.meaning = null;
}
-
this.genes[genePosition] = geneValue;
- //whenever at least one gene has been written,
- //the current generation number is stored
- this.generation = this.geneticOptimizer.GenerationCounter;
}
--- 233,241 ----
this.hasFitnessBeenAssigned = false;
this.meaning = null;
+ //only if a new gene value is written,
+ //the current generation number is stored
+ this.generation = this.geneticOptimizer.GenerationCounter;
}
this.genes[genePosition] = geneValue;
}
***************
*** 304,308 ****
return returnValue;
}
-
}
}
--- 330,333 ----
Index: GeneticOptimizer.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/GeneticOptimizer.cs,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** GeneticOptimizer.cs 13 Feb 2011 19:33:37 -0000 1.29
--- GeneticOptimizer.cs 21 Aug 2011 09:52:40 -0000 1.30
***************
*** 305,309 ****
this.currentGeneration.Sort(this.genomeComparer);
if(this.NewGeneration != null)
! this.NewGeneration( this , new NewGenerationEventArgs(
this.currentGeneration , this.generationCounter , this.generationNumber ) );
}
--- 305,309 ----
this.currentGeneration.Sort(this.genomeComparer);
if(this.NewGeneration != null)
! this.NewGeneration( this , new NewGenerationEventArgs( this,
this.currentGeneration , this.generationCounter , this.generationNumber ) );
}
Index: NewGenerationEventArgs.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Optimizing/Genetic/NewGenerationEventArgs.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NewGenerationEventArgs.cs 23 Jul 2005 18:01:02 -0000 1.2
--- NewGenerationEventArgs.cs 21 Aug 2011 09:52:40 -0000 1.3
***************
*** 35,38 ****
--- 35,39 ----
private int generationNumber;
private int generationCounter;
+ private GeneticOptimizer currentGeneticOptimizer;
/// <summary>
***************
*** 57,68 ****
get { return this.generationCounter; }
}
!
public NewGenerationEventArgs( ArrayList generation )
{
this.generation = generation;
}
! public NewGenerationEventArgs( ArrayList generation ,
! int generationCounter , int generationNumber )
{
this.generation = generation;
this.generationCounter = generationCounter;
--- 58,80 ----
get { return this.generationCounter; }
}
! /// <summary>
! /// Genetic optimizer that
! /// has created the current generation
! /// </summary>
! public GeneticOptimizer CurrentGeneticOptimizer
! {
! get { return this.currentGeneticOptimizer; }
! }
!
public NewGenerationEventArgs( ArrayList generation )
{
this.generation = generation;
}
! public NewGenerationEventArgs( GeneticOptimizer currentGeneticOptimizer,
! ArrayList generation ,
! int generationCounter ,
! int generationNumber )
{
+ this.currentGeneticOptimizer = currentGeneticOptimizer;
this.generation = generation;
this.generationCounter = generationCounter;
|