Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/03/13 14:52:41 (11 years ago)
Author:
mkommend
Message:

#1997: Added different evaluators for symbolic island algorithms, unit test for consecutive samples evaluator and injected island index into the according scopes.

Location:
branches/DataAnalysis.IslandAlgorithms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.IslandAlgorithms

    • Property svn:ignore
      •  

        old new  
        11*.suo
         2bin
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3

    • Property svn:ignore
      •  

        old new  
         1*.user
        12Plugin.cs
        23bin
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs

    r10156 r10177  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
     29using HeuristicLab.Operators;
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
    3132using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3233using HeuristicLab.Problems.DataAnalysis.Symbolic;
    33 using HeuristicLab.Random;
    3434
    3535namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic {
     
    4141    private const string FixedSamplesPartitionParameterName = "FixedSamplesPartition";
    4242    private const string FixedSamplesPartitionsParameterName = "FixedSamplesPartitions";
    43     private const string RandomSamplesParameterName = "NumberOfRandomSamples";
    4443    private const string EvaluatorParameterName = "IslandEvaluator";
     44    private const string IslandIndexParameterName = "IslandIndex";
    4545    private const string ProblemEvaluatorParameterName = "ProblemEvaluator";
    4646
     
    6262      get { return (IValueParameter<ItemArray<IntRange>>)Parameters[FixedSamplesPartitionsParameterName]; }
    6363    }
    64     public IFixedValueParameter<IntValue> RandomSamplesParameter {
    65       get { return (IFixedValueParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
    66     }
    67     public IValueParameter<ISymbolicDataAnalysisIslandGAEvaluator> EvaluatorParameter {
    68       get { return (IValueParameter<ISymbolicDataAnalysisIslandGAEvaluator>)Parameters[EvaluatorParameterName]; }
     64    public IValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator> EvaluatorParameter {
     65      get { return (IValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>)Parameters[EvaluatorParameterName]; }
    6966    }
    7067    private ILookupParameter<ISingleObjectiveEvaluator> ProblemEvaluatorParameter {
     
    8178      get { return FixedSamplesPartitionsParameter.Value; }
    8279      set { FixedSamplesPartitionsParameter.Value = value; }
    83     }
    84     public int RandomSamples {
    85       get { return RandomSamplesParameter.Value.Value; }
    86       set { RandomSamplesParameter.Value.Value = value; }
    8780    }
    8881    #endregion
     
    10699      Parameters.Add(new FixedValueParameter<IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0)));
    107100      Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island."));
    108       Parameters.Add(new FixedValueParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new IntValue(0)));
    109       Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGAEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm."));
     101      Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm."));
    110102      Parameters.Add(new LookupParameter<ISingleObjectiveEvaluator>(ProblemEvaluatorParameterName, "Internal parameter for name translation", "Evaluator"));
     103
     104      ScopeTreeAssigner<IntValue> islandIndexAssigner = new ScopeTreeAssigner<IntValue>();
     105      islandIndexAssigner.Name = "Insert island index";
     106      islandIndexAssigner.LeftSideParameter.ActualName = IslandIndexParameterName;
     107      var readonlyIslandIndexes = Enumerable.Range(0, NumberOfIslands.Value).Select(x => (IntValue)new IntValue(x).AsReadOnly());
     108      islandIndexAssigner.RightSideParameter.Value = new ItemArray<IntValue>(readonlyIslandIndexes);
    111109
    112110      ScopeTreeAssigner<IntRange> fixedSamplesPartitionCreator = new ScopeTreeAssigner<IntRange>();
     
    115113      fixedSamplesPartitionCreator.RightSideParameter.ActualName = FixedSamplesPartitionsParameterName;
    116114
    117       RandomCreator insertionPoint = OperatorGraph.Iterate().OfType<RandomCreator>().Skip(1).First();
     115      SubScopesCreator insertionPoint = OperatorGraph.Iterate().OfType<SubScopesCreator>().First();
     116      islandIndexAssigner.Successor = fixedSamplesPartitionCreator;
    118117      fixedSamplesPartitionCreator.Successor = insertionPoint.Successor;
    119       insertionPoint.Successor = fixedSamplesPartitionCreator;
     118      insertionPoint.Successor = islandIndexAssigner;
     119
     120      //RandomCreator insertionPoint = OperatorGraph.Iterate().OfType<RandomCreator>().Skip(1).First();
     121      //fixedSamplesPartitionCreator.Successor = insertionPoint.Successor;
     122      //insertionPoint.Successor = fixedSamplesPartitionCreator;
    120123
    121124      RegisterParameterEvents();
     
    131134        ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size;
    132135      };
    133       RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; };
    134136      Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers();
    135137      EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator();
     
    160162    private void ParameterizeEvaluator() {
    161163      var evaluator = EvaluatorParameter.Value;
    162       var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator;
    163       if (islandGAEvaluator != null) {
    164         islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
     164
     165      var randomEvaluator = evaluator as RandomSamplesEvaluator;
     166      if (randomEvaluator != null) {
     167        ReevaluteElites = randomEvaluator.RandomSamples != 0;
     168      }
     169
     170      var consecutiveEvaluator = evaluator as ConsecutiveSamplesEvaluator;
     171      if (consecutiveEvaluator != null) {
     172        consecutiveEvaluator.DataMigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
    165173      }
    166174    }
     
    181189
    182190      if (Problem != null && EvaluatorParameter.Value == null) {
    183         EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator();
     191        EvaluatorParameter.Value = new RandomSamplesEvaluator();
    184192      } else if (Problem == null)
    185193        EvaluatorParameter.Value = null;
Note: See TracChangeset for help on using the changeset viewer.