[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank WFMul
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2006-08-08 09:37:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22189/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank Modified Files: WFMultiOneRankGenomeManager.cs Log Message: Adapted to the new IGenomeManager interface: - properties MinValueForGenes and MaxValueForGenes have been replaced by GetMinValueForGenes(int genePosition) and GetMaxValueForGenes(int genePosition) methods. - property CurrentGeneticOptimizer has been deleted from the interface. Index: WFMultiOneRankGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardMultiOneRank/WFMultiOneRankGenomeManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WFMultiOneRankGenomeManager.cs 14 Mar 2006 14:13:41 -0000 1.3 --- WFMultiOneRankGenomeManager.cs 8 Aug 2006 09:37:34 -0000 1.4 *************** *** 52,68 **** get { return this.numberOfTickersInPortfolio; } } ! public int MinValueForGenes ! { ! get { return -this.numberOfEligibleTickers; } ! } ! public int MaxValueForGenes ! { ! get { return this.numberOfEligibleTickers - 1; } ! } ! public GeneticOptimizer CurrentGeneticOptimizer ! { ! get{ return this.currentGeneticOptimizer; } ! set{ this.currentGeneticOptimizer = value; } ! } public WFMultiOneRankGenomeManager( --- 52,68 ---- get { return this.numberOfTickersInPortfolio; } } ! // public int MinValueForGenes ! // { ! // get { return -this.numberOfEligibleTickers; } ! // } ! // public int MaxValueForGenes ! // { ! // get { return this.numberOfEligibleTickers - 1; } ! // } ! // public GeneticOptimizer CurrentGeneticOptimizer ! // { ! // get{ return this.currentGeneticOptimizer; } ! // set{ this.currentGeneticOptimizer = value; } ! // } public WFMultiOneRankGenomeManager( *************** *** 115,118 **** --- 115,126 ---- #endregion + public int GetMinValueForGenes( int genePosition ) + { + return -this.numberOfEligibleTickers; + } + public int GetMaxValueForGenes( int genePosition ) + { + return this.numberOfEligibleTickers - 1; + } #region GetFitnessValue *************** *** 208,216 **** // in this implementation only one gene is mutated // the new value has to be different from all the other genes of the genome - int newValueForGene = GenomeManagement.RandomGenerator.Next( - genome.MinValueForGenes , - genome.MaxValueForGenes + 1 ); int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next( genome.Size ); while( GenomeManipulator.IsTickerContainedInGenome( newValueForGene , genome ) ) --- 216,224 ---- // in this implementation only one gene is mutated // the new value has to be different from all the other genes of the genome int genePositionToBeMutated = GenomeManagement.RandomGenerator.Next( genome.Size ); + int newValueForGene = GenomeManagement.RandomGenerator.Next( + genome.GetMinValueForGenes( genePositionToBeMutated ) , + genome.GetMaxValueForGenes( genePositionToBeMutated ) + 1 ); while( GenomeManipulator.IsTickerContainedInGenome( newValueForGene , genome ) ) *************** *** 220,225 **** { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.MinValueForGenes , ! genome.MaxValueForGenes + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , --- 228,233 ---- { newValueForGene = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( genePositionToBeMutated ) , ! genome.GetMaxValueForGenes( genePositionToBeMutated ) + 1 ); } GenomeManagement.MutateOneGene( genome , mutationRate , *************** *** 257,272 **** } #endregion ! public int GetNewGeneValue( Genome genome , int i ) { // in this implementation new gene values must be different from // the others already stored in the given genome ! int returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); while(GenomeManipulator.IsTickerContainedInGenome(returnValue, genome) ) //the portfolio can't have a long position and a short one for the same ticker { ! returnValue = GenomeManagement.RandomGenerator.Next(genome.MinValueForGenes, ! genome.MaxValueForGenes + 1); } --- 265,282 ---- } #endregion ! public int GetNewGeneValue( Genome genome , int genePosition ) { // in this implementation new gene values must be different from // the others already stored in the given genome ! int returnValue = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( genePosition ) , ! genome.GetMaxValueForGenes( genePosition ) + 1 ); while(GenomeManipulator.IsTickerContainedInGenome(returnValue, genome) ) //the portfolio can't have a long position and a short one for the same ticker { ! returnValue = GenomeManagement.RandomGenerator.Next( ! genome.GetMinValueForGenes( genePosition ) , ! genome.GetMaxValueForGenes( genePosition ) + 1); } |