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:
1 deleted
5 edited
2 moved

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/HeuristicLab.Algorithms.DataAnalysis.Symbolic.csproj

    r10142 r10177  
    123123  </ItemGroup>
    124124  <ItemGroup>
     125    <Compile Include="ConsecutiveSamplesEvaluator.cs" />
    125126    <Compile Include="SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs" />
    126     <Compile Include="ISymbolicDataAnalysisIslandGAEvaluator .cs" />
     127    <Compile Include="ISymbolicDataAnalysisIslandAlgorithmEvaluator .cs" />
    127128    <Compile Include="ScopeTreeAssigner.cs" />
    128129    <Compile Include="Plugin.cs" />
    129130    <Compile Include="Properties\AssemblyInfo.cs" />
    130     <Compile Include="SymbolicDataAnalysisIslandGAEvaluator.cs" />
     131    <Compile Include="RandomSamplesEvaluator .cs" />
    131132    <Compile Include="SymbolicDataAnalysisIslandGeneticAlgorithm.cs" />
    132133  </ItemGroup>
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/ISymbolicDataAnalysisIslandAlgorithmEvaluator .cs

    r10176 r10177  
    2323
    2424namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic {
    25   public interface ISymbolicDataAnalysisIslandGAEvaluator : ISingleObjectiveEvaluator {
     25  public interface ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator : ISingleObjectiveEvaluator {
    2626  }
    2727}
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/RandomSamplesEvaluator .cs

    r10156 r10177  
    3434namespace HeuristicLab.Algorithms.DataAnalysis.Symbolic {
    3535  [StorableClass]
    36   public sealed class SymbolicDataAnalysisIslandGAEvaluator : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGAEvaluator {
     36  public sealed class RandomSamplesEvaluator : SingleSuccessorOperator, IStochasticOperator, ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator {
    3737    private const string RandomParameterName = "Random";
    3838    private const string ProblemDataParameterName = "ProblemData";
     
    5656      get { return (ILookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
    5757    }
    58     public IValueLookupParameter<IntRange> FitnessCalculationPartitionParameter {
    59       get { return (IValueLookupParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; }
     58    public ILookupParameter<IntRange> FitnessCalculationPartitionParameter {
     59      get { return (ILookupParameter<IntRange>)Parameters[FitnessCalculationPartitionParameterName]; }
    6060    }
    6161    public ILookupParameter<IntRange> FixedSamplesPartitionParameter {
    6262      get { return (ILookupParameter<IntRange>)Parameters[FixedSamplesPartitionParameterName]; }
    6363    }
    64     public ILookupParameter<IntValue> RandomSamplesParameter {
    65       get { return (ILookupParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
     64    public IFixedValueParameter<IntValue> RandomSamplesParameter {
     65      get { return (IFixedValueParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
     66    }
     67    #endregion
     68
     69    #region properties
     70
     71    public int RandomSamples {
     72      get { return RandomSamplesParameter.Value.Value; }
     73      set { RandomSamplesParameter.Value.Value = value; }
    6674    }
    6775    #endregion
    6876
    6977    [StorableConstructor]
    70     private SymbolicDataAnalysisIslandGAEvaluator(bool deserializing) : base(deserializing) { }
    71     private SymbolicDataAnalysisIslandGAEvaluator(SymbolicDataAnalysisIslandGAEvaluator original, Cloner cloner)
     78    private RandomSamplesEvaluator(bool deserializing) : base(deserializing) { }
     79    private RandomSamplesEvaluator(RandomSamplesEvaluator original, Cloner cloner)
    7280      : base(original, cloner) {
    7381    }
    7482    public override IDeepCloneable Clone(Cloner cloner) {
    75       return new SymbolicDataAnalysisIslandGAEvaluator(this, cloner);
     83      return new RandomSamplesEvaluator(this, cloner);
    7684    }
    7785
    78     public SymbolicDataAnalysisIslandGAEvaluator()
     86    public RandomSamplesEvaluator()
    7987      : base() {
    8088      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator to use."));
     
    8290      Parameters.Add(new LookupParameter<IOperator>(EvaluatorParameterName, "The evaluator provided by the symbolic data analysis  problem."));
    8391      Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The quality which is calculated by the encapsulated evaluator."));
    84       Parameters.Add(new ValueLookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
     92      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
    8593      Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples."));
    86       Parameters.Add(new LookupParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island."));
    87 
    88       EvaluatorParameter.Hidden = true;
     94      Parameters.Add(new FixedValueParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new IntValue()));
    8995    }
    9096
     
    95101      var samples = FitnessCalculationPartitionParameter.ActualValue;
    96102      var fixedSamples = FixedSamplesPartitionParameter.ActualValue;
    97       var randomSamples = RandomSamplesParameter.ActualValue.Value;
     103      var randomSamples = RandomSamples;
    98104
    99105      //create fixed rows enumerable
  • 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;
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs

    r10156 r10177  
    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>();
     
    116114
    117115      SubScopesCreator insertionPoint = OperatorGraph.Iterate().OfType<SubScopesCreator>().First();
     116      islandIndexAssigner.Successor = fixedSamplesPartitionCreator;
    118117      fixedSamplesPartitionCreator.Successor = insertionPoint.Successor;
    119       insertionPoint.Successor = fixedSamplesPartitionCreator;
     118      insertionPoint.Successor = islandIndexAssigner;
    120119
    121120      RegisterParameterEvents();
     
    131130        ReevaluateImmigrants = FixedSamples >= Problem.FitnessCalculationPartition.Size;
    132131      };
    133       RandomSamplesParameter.Value.ValueChanged += (o, e) => { ReevaluteElites = RandomSamples != 0; };
    134132      Analyzer.Operators.PropertyChanged += (o, e) => ParameterizeAnalyzers();
    135133      EvaluatorParameter.ValueChanged += (o, e) => ParameterizeEvaluator();
     
    160158    private void ParameterizeEvaluator() {
    161159      var evaluator = EvaluatorParameter.Value;
    162       var islandGAEvaluator = evaluator as SymbolicDataAnalysisIslandGAEvaluator;
    163       if (islandGAEvaluator != null) {
    164         islandGAEvaluator.RandomSamplesParameter.ActualName = RandomSamplesParameterName;
     160
     161      var randomEvaluator = evaluator as RandomSamplesEvaluator;
     162      if (randomEvaluator != null) {
     163        ReevaluteElites = randomEvaluator.RandomSamples != 0;
     164      }
     165
     166      var consecutiveEvaluator = evaluator as ConsecutiveSamplesEvaluator;
     167      if (consecutiveEvaluator != null) {
     168        consecutiveEvaluator.DataMigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
    165169      }
    166170    }
     
    181185
    182186      if (Problem != null && EvaluatorParameter.Value == null) {
    183         EvaluatorParameter.Value = new SymbolicDataAnalysisIslandGAEvaluator();
     187        EvaluatorParameter.Value = new RandomSamplesEvaluator();
    184188      } else if (Problem == null)
    185189        EvaluatorParameter.Value = null;
Note: See TracChangeset for help on using the changeset viewer.