예제 #1
0
        public override IOperation Apply()
        {
            if (SimilarityParameter.ActualValue == null || SimilarityParameter.ActualValue.Value.IsAlmost(-1.0))
            {
                UpdateCounter.Value++;
                if (UpdateCounter.Value != UpdateInterval.Value)
                {
                    return(base.Apply());
                }
                UpdateCounter.Value = 0;
                var trees = SymbolicExpressionTreeParameter.ActualValue.ToList();

                SimilarityParameter.ActualValue = new DoubleValue();

                var operations = new OperationCollection {
                    Parallel = true
                };
                foreach (var tree in trees)
                {
                    var op = new SymbolicDataAnalysisExpressionTreeSimilarityCalculator(DistanceCalculatorParameter.Value)
                    {
                        CurrentSymbolicExpressionTree = tree,
                        MaximumTreeDepth = MaximumSymbolicExpressionTreeDepth.Value
                    };
                    var operation = ExecutionContext.CreateChildOperation(op, ExecutionContext.Scope);
                    operations.Add(operation);
                }
                return(new OperationCollection {
                    operations, ExecutionContext.CreateOperation(this)
                });
            }

            var results = ResultsParameter.ActualValue;
            // population diversity
            DataTable populationDiversityTable;

            if (!results.ContainsKey("PopulationDiversity"))
            {
                populationDiversityTable = new DataTable("PopulationDiversity")
                {
                    VisualProperties = { YAxisTitle = "Diversity" }
                };
                results.Add(new Result("PopulationDiversity", populationDiversityTable));
            }
            populationDiversityTable = (DataTable)results["PopulationDiversity"].Value;
            if (!populationDiversityTable.Rows.ContainsKey("Diversity"))
            {
                populationDiversityTable.Rows.Add(new DataRow("Diversity")
                {
                    VisualProperties = { StartIndexZero = true }
                });
            }

            int length     = SymbolicExpressionTreeParameter.ActualValue.Length;
            var similarity = SimilarityParameter.ActualValue.Value / (length * (length - 1) / 2.0);
            var diversity  = 1 - similarity;

            SimilarityParameter.ActualValue.Value = -1.0;

            populationDiversityTable.Rows["Diversity"].Values.Add(diversity);

            return(base.Apply());
        }
    public override IOperation Apply() {
      if (SimilarityParameter.ActualValue == null || SimilarityParameter.ActualValue.Value.IsAlmost(-1.0)) {
        UpdateCounter.Value++;
        if (UpdateCounter.Value != UpdateInterval.Value) return base.Apply();
        UpdateCounter.Value = 0;
        var trees = SymbolicExpressionTreeParameter.ActualValue.ToList();

        SimilarityParameter.ActualValue = new DoubleValue();

        var operations = new OperationCollection { Parallel = true };
        foreach (var tree in trees) {
          var op = new SymbolicDataAnalysisExpressionTreeSimilarityCalculator(DistanceCalculatorParameter.Value) {
            CurrentSymbolicExpressionTree = tree,
            MaximumTreeDepth = MaximumSymbolicExpressionTreeDepth.Value
          };
          var operation = ExecutionContext.CreateChildOperation(op, ExecutionContext.Scope);
          operations.Add(operation);
        }
        return new OperationCollection { operations, ExecutionContext.CreateOperation(this) };
      }

      var results = ResultsParameter.ActualValue;
      // population diversity
      DataTable populationDiversityTable;
      if (!results.ContainsKey("PopulationDiversity")) {
        populationDiversityTable = new DataTable("PopulationDiversity") { VisualProperties = { YAxisTitle = "Diversity" } };
        results.Add(new Result("PopulationDiversity", populationDiversityTable));
      }
      populationDiversityTable = (DataTable)results["PopulationDiversity"].Value;
      if (!populationDiversityTable.Rows.ContainsKey("Diversity"))
        populationDiversityTable.Rows.Add(new DataRow("Diversity") { VisualProperties = { StartIndexZero = true } });

      int length = SymbolicExpressionTreeParameter.ActualValue.Length;
      var similarity = SimilarityParameter.ActualValue.Value / (length * (length - 1) / 2.0);
      var diversity = 1 - similarity;
      SimilarityParameter.ActualValue.Value = -1.0;

      populationDiversityTable.Rows["Diversity"].Values.Add(diversity);

      return base.Apply();
    }
 protected SymbolicDataAnalysisExpressionTreeSimilarityCalculator(
   SymbolicDataAnalysisExpressionTreeSimilarityCalculator original, Cloner cloner)
   : base(original, cloner) {
 }
 protected SymbolicDataAnalysisExpressionTreeSimilarityCalculator(
     SymbolicDataAnalysisExpressionTreeSimilarityCalculator original, Cloner cloner)
     : base(original, cloner)
 {
 }