Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/13 10:52:38 (10 years ago)
Author:
mkommend
Message:

#1997: Worked on symbolic data analysis island algorithms:

  • Refactored and removed unnecessary code in symbolic island GA and symbolic island GA evaluator.
  • Added EnumerableItem to ease the passing of rows to the actual evaluator.
  • Added prototype of island offspring selection GA.
  • Corrected build configuration (plugin classes, project settings, ...)
File:
1 edited

Legend:

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

    r9182 r10142  
    7171      get { return (ILookupParameter<IntValue>)Parameters[RandomSamplesParameterName]; }
    7272    }
     73
     74    public IValueParameter<EnumerableItem<int>> RowsParameter {
     75      get { return (IValueParameter<EnumerableItem<int>>)Parameters["Rows"]; }
     76    }
    7377    #endregion
    7478
     
    9397      Parameters.Add(new LookupParameter<IntRange>(FixedSamplesPartitionParameterName, "The data partition which is used to calculate the fitness on the fixed samples."));
    9498      Parameters.Add(new LookupParameter<IntValue>(RandomSamplesParameterName, "The number of random samples used for fitness calculation in each island."));
     99      Parameters.Add(new OptionalValueParameter<EnumerableItem<int>>("Rows", "TODO"));
    95100
    96101      EvaluatorParameter.Hidden = true;
     
    99104    public override IOperation Apply() {
    100105      var evaluator = EvaluatorParameter.ActualValue;
    101       var tree = SymbolicExpressionTreeParameter.ActualValue;
    102106      var problemData = ProblemDataParameter.ActualValue;
    103107
    104       var samplesStart = FitnessCalculationPartitionParameter.ActualValue.Start;
    105       var samplesEnd = FitnessCalculationPartitionParameter.ActualValue.End;
    106       var fixedSamplesStart = FixedSamplesPartitionParameter.ActualValue.Start;
    107       var fixedSamplesEnd = FixedSamplesPartitionParameter.ActualValue.End;
     108      var samples = FitnessCalculationPartitionParameter.ActualValue;
     109      var fixedSamples = FixedSamplesPartitionParameter.ActualValue;
    108110      var randomSamples = RandomSamplesParameter.ActualValue.Value;
    109       var maxRandomSamples = samplesEnd - samplesStart - fixedSamplesEnd + fixedSamplesStart;
    110111
    111       //create rows for evaluation
    112       var fixedRows = Enumerable.Range(fixedSamplesStart, fixedSamplesEnd - fixedSamplesStart);
    113       var randomRows = Enumerable.Range(samplesStart, samplesEnd - samplesStart).Where(r => r < fixedSamplesStart || r >= fixedSamplesEnd);
    114       randomRows = randomRows.SampleRandomWithoutRepetition(RandomParameter.ActualValue, randomSamples, maxRandomSamples);
    115       var rows = fixedRows.Concat(randomRows);
     112      //create fixed rows enumerable
     113      var rows = Enumerable.Range(fixedSamples.Start, fixedSamples.Size);
     114      //create randomly chosen rows enumerable
     115      if (randomSamples > 0) {
     116        if (randomSamples > samples.Size - fixedSamples.Size) {
     117          var error = string.Format("Could not select {0} random samples, because there are {1} total samples present from which {2} where used in the fixed partition. Please lower the number of random samples in the algorithm configuration.", randomSamples, samples.Size, fixedSamples.Size);
     118          throw new OperatorExecutionException(this, error);
     119        }
     120        var randomRows = Enumerable.Range(samples.Start, samples.Size).Where(r => r < fixedSamples.Start || r >= fixedSamples.End);
     121        randomRows = randomRows.SampleRandomWithoutRepetition(RandomParameter.ActualValue, randomSamples, samples.Size - fixedSamples.Size);
    116122
     123        rows = rows.Concat(randomRows);
     124      }
     125      //filter out test rows
     126      rows = rows.Where(r => r < problemData.TestPartition.Start && r > problemData.TestPartition.End);
     127
     128      //execution context is created manually to be able to clear the rows parameter easily
     129      RowsParameter.Value = new EnumerableItem<int>(rows);
    117130      var executionContext = new ExecutionContext(ExecutionContext, evaluator, ExecutionContext.Scope);
    118       var fitness = evaluator.Evaluate(executionContext, tree, problemData, rows);
    119       QualityParameter.ActualValue = new DoubleValue(fitness);
    120       return base.Apply();
     131      var successor = evaluator.Execute(executionContext, this.CancellationToken);
     132      RowsParameter.Value = null;
     133      return new OperationCollection(successor, base.Apply());
    121134    }
    122135  }
Note: See TracChangeset for help on using the changeset viewer.