Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/14 13:05:47 (11 years ago)
Author:
mkommend
Message:

#1997: Changed data partition parameters to PercentValue types to enable the use relative numbers and fixed calculation of island partitions.

Location:
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/ConsecutiveSamplesEvaluator.cs

    r10230 r10353  
    6363      get { return (ILookupParameter<IntRange>)Parameters[FixedSamplesPartitionParameterName]; }
    6464    }
    65     public IFixedValueParameter<IntValue> ConsecutiveSamplesParameter {
    66       get { return (IFixedValueParameter<IntValue>)Parameters[ConsecutiveSamplesParameterName]; }
     65    public IFixedValueParameter<PercentValue> ConsecutiveSamplesParameter {
     66      get { return (IFixedValueParameter<PercentValue>)Parameters[ConsecutiveSamplesParameterName]; }
    6767    }
    68     public IFixedValueParameter<IntValue> OverlapParameter {
    69       get { return (IFixedValueParameter<IntValue>)Parameters[OverlapParameterName]; }
     68    public IFixedValueParameter<PercentValue> OverlapParameter {
     69      get { return (IFixedValueParameter<PercentValue>)Parameters[OverlapParameterName]; }
    7070    }
    7171    public IValueLookupParameter<IntValue> DataMigrationIntervalParameter {
     
    8686    #region properties
    8787
    88     public int ConsecutiveSamples {
     88    public double ConsecutiveSamples {
    8989      get { return ConsecutiveSamplesParameter.Value.Value; }
    9090      set { ConsecutiveSamplesParameter.Value.Value = value; }
    9191    }
    9292
    93     public int Overlap {
     93    public double Overlap {
    9494      get { return OverlapParameter.Value.Value; }
    9595      set { OverlapParameter.Value.Value = value; }
     
    113113      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
    114114      Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples."));
    115       Parameters.Add(new FixedValueParameter<IntValue>(ConsecutiveSamplesParameterName, "The number of consecutive samples used for fitness calculation in each island.", new IntValue()));
    116       Parameters.Add(new FixedValueParameter<IntValue>(OverlapParameterName, "The overlap for the consecutive samples used for every island.", new IntValue()));
     115      Parameters.Add(new FixedValueParameter<PercentValue>(ConsecutiveSamplesParameterName, "The relative number of consecutive samples used for fitness calculation in each island.", new PercentValue()));
     116      Parameters.Add(new FixedValueParameter<PercentValue>(OverlapParameterName, "The relative overlap for the consecutive samples used for every island.", new PercentValue()));
    117117      Parameters.Add(new ValueLookupParameter<IntValue>(DataMigrationIntervalParameterName, "The number of generations that should pass between data migration phases."));
    118118      Parameters.Add(new LookupParameter<IntValue>(IslandIndexParameterName, "The index of the current island."));
     
    139139          var islandIndex = IslandIndexParameter.ActualValue.Value;
    140140          var iteration = islandIndex + (generation / dataMigrationInterval);
    141           var consecutiveRows = GenerateRows(samples, fixedSamples, ConsecutiveSamples, Overlap, iteration);
     141          var consecutiveSamples = (int)ConsecutiveSamples * samples.Size;
     142          var overlap = (int)Overlap * consecutiveSamples;
     143          var consecutiveRows = GenerateRows(samples, fixedSamples, consecutiveSamples, overlap, iteration);
    142144          rows = rows.Concat(consecutiveRows);
    143145        }
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/RandomSamplesEvaluator .cs

    r10230 r10353  
    6868      get { return (IValueLookupParameter<IntValue>)Parameters[DataMigrationIntervalParameterName]; }
    6969    }
    70     public IFixedValueParameter<IntValue> RandomSamplesParameter {
    71       get { return (IFixedValueParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
     70    public IFixedValueParameter<PercentValue> RandomSamplesParameter {
     71      get { return (IFixedValueParameter<PercentValue>)Parameters[RandomSamplesParameterName]; }
    7272    }
    7373    public ILookupParameter<IntValue> IterationsParameter {
     
    8181    #region properties
    8282
    83     public int RandomSamples {
     83    public double RandomSamples {
    8484      get { return RandomSamplesParameter.Value.Value; }
    8585      set { RandomSamplesParameter.Value.Value = value; }
     
    104104      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, "The data partition used to calculate the fitness"));
    105105      Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples."));
    106       Parameters.Add(new FixedValueParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new IntValue()));
     106      Parameters.Add(new FixedValueParameter<PercentValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island.", new PercentValue()));
    107107      Parameters.Add(new ValueLookupParameter<IntValue>(DataMigrationIntervalParameterName, "The number of generations that should pass between data migration phases."));
    108108      Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "The number of performed iterations."));
     
    116116      var samples = FitnessCalculationPartitionParameter.ActualValue;
    117117      var fixedSamples = FixedSamplesPartitionParameter.ActualValue;
    118       var randomSamples = RandomSamples;
     118      var randomSamples = (int)RandomSamples * samples.Size;
    119119
    120120      var dataMigrationInterval = DataMigrationIntervalParameter.ActualValue.Value;
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandGeneticAlgorithm.cs

    r10230 r10353  
    5656
    5757    #region parameters
    58     public IFixedValueParameter<IntValue> FixedSamplesParameter {
    59       get { return (IFixedValueParameter<IntValue>)Parameters[FixedSamplesParameterName]; }
     58    public IFixedValueParameter<PercentValue> FixedSamplesParameter {
     59      get { return (IFixedValueParameter<PercentValue>)Parameters[FixedSamplesParameterName]; }
    6060    }
    6161    public IValueParameter<ItemArray<IntRange>> FixedSamplesPartitionsParameter {
     
    7171
    7272    #region properties
    73     public int FixedSamples {
     73    public double FixedSamples {
    7474      get { return FixedSamplesParameter.Value.Value; }
    7575      set { FixedSamplesParameter.Value.Value = value; }
     
    9797    public SymbolicDataAnalysisIslandGeneticAlgorithm()
    9898      : base() {
    99       Parameters.Add(new FixedValueParameter<IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0)));
     99      Parameters.Add(new FixedValueParameter<PercentValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new PercentValue(0.2)));
    100100      Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island."));
    101101      Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm."));
     
    174174    }
    175175
    176     protected override void Problem_Reset(object sender, EventArgs e) {
    177       FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    178       base.Problem_Reset(sender, e);
    179     }
    180 
    181176    protected override void OnProblemChanged() {
    182177      Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
    183       FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    184178
    185179      if (Problem != null && EvaluatorParameter.Value == null) {
     
    201195      var samplesEnd = Problem.FitnessCalculationPartition.End;
    202196      var totalSamples = Problem.FitnessCalculationPartition.Size;
    203       var fixedSamples = FixedSamples;
     197      var fixedSamples = (int)(FixedSamples * totalSamples);
    204198      var islands = NumberOfIslands.Value;
    205199
    206       int offset = (int)Math.Ceiling(((double)(totalSamples - fixedSamples)) / (islands - 1));
     200      double shift = (double)((totalSamples - fixedSamples)) / (islands - 1);
     201      int offset = (int)Math.Floor(shift);
     202      double remainder = shift - offset;
     203
    207204      List<IntRange> partitions = new List<IntRange>();
    208205      for (int i = 0; i < islands; i++) {
    209         var partitionStart = samplesStart + offset * i;
     206        var partitionStart = samplesStart + offset * i + (int)(remainder * i);
    210207        partitions.Add(new IntRange(partitionStart, partitionStart + fixedSamples));
    211208      }
    212209
    213       //it can be the case that the last partitions exceeds the allowed samples
    214       //move the last partition forward.
     210      //if the last partitions exceeds the allowed samples move the last partition forward.
    215211      int exceedsSamples = partitions[partitions.Count - 1].End - samplesEnd;
    216212      if (exceedsSamples > 0) {
  • branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.DataAnalysis.Symbolic/3.3/SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm.cs

    r10230 r10353  
    5656
    5757    #region parameters
    58     public IFixedValueParameter<IntValue> FixedSamplesParameter {
    59       get { return (IFixedValueParameter<IntValue>)Parameters[FixedSamplesParameterName]; }
     58    public IFixedValueParameter<PercentValue> FixedSamplesParameter {
     59      get { return (IFixedValueParameter<PercentValue>)Parameters[FixedSamplesParameterName]; }
    6060    }
    6161    public IValueParameter<ItemArray<IntRange>> FixedSamplesPartitionsParameter {
     
    7171
    7272    #region properties
    73     public int FixedSamples {
     73    public double FixedSamples {
    7474      get { return FixedSamplesParameter.Value.Value; }
    7575      set { FixedSamplesParameter.Value.Value = value; }
     
    9797    public SymbolicDataAnalysisIslandOffspringSelectionGeneticAlgorithm()
    9898      : base() {
    99       Parameters.Add(new FixedValueParameter<IntValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new IntValue(0)));
     99      Parameters.Add(new FixedValueParameter<PercentValue>(FixedSamplesParameterName, "The number of fixed samples used for fitness calculation in each island.", new PercentValue(0.2)));
    100100      Parameters.Add(new ValueParameter<ItemArray<IntRange>>(FixedSamplesPartitionsParameterName, "The fixed samples partitions used for fitness calculation for every island."));
    101101      Parameters.Add(new OptionalValueParameter<ISymbolicDataAnalysisIslandGeneticAlgorithmEvaluator>(EvaluatorParameterName, "The evaluator of the algorithm."));
     
    170170    }
    171171
    172     protected override void Problem_Reset(object sender, EventArgs e) {
    173       FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    174       base.Problem_Reset(sender, e);
    175     }
    176 
    177172    protected override void OnProblemChanged() {
    178173      Problem.FitnessCalculationPartition.ValueChanged += Problem_Reset;
    179       FixedSamples = Problem.FitnessCalculationPartition.Size / NumberOfIslands.Value;
    180174
    181175      if (Problem != null && EvaluatorParameter.Value == null) {
     
    197191      var samplesEnd = Problem.FitnessCalculationPartition.End;
    198192      var totalSamples = Problem.FitnessCalculationPartition.Size;
    199       var fixedSamples = FixedSamples;
     193      var fixedSamples = (int)(FixedSamples * totalSamples);
    200194      var islands = NumberOfIslands.Value;
    201195
    202       int offset = (int)Math.Ceiling(((double)(totalSamples - fixedSamples)) / (islands - 1));
     196      double shift = (double)((totalSamples - fixedSamples)) / (islands - 1);
     197      int offset = (int)Math.Floor(shift);
     198      double remainder = shift - offset;
     199
    203200      List<IntRange> partitions = new List<IntRange>();
    204201      for (int i = 0; i < islands; i++) {
    205         var partitionStart = samplesStart + offset * i;
     202        var partitionStart = samplesStart + offset * i + (int)(remainder * i);
    206203        partitions.Add(new IntRange(partitionStart, partitionStart + fixedSamples));
    207204      }
Note: See TracChangeset for help on using the changeset viewer.