Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/17/15 00:31:53 (8 years ago)
Author:
bburlacu
Message:

#1772: Add tracking of the number of trees that are mutated during the diversification phase by the SchemaEvaluator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs

    r12951 r12952  
    2222using System;
    2323using System.Linq;
     24using HeuristicLab.Analysis;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2829using HeuristicLab.EvolutionTracking;
     30using HeuristicLab.Operators;
     31using HeuristicLab.Optimization.Operators;
    2932using HeuristicLab.Parameters;
    3033using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    99102      var schemaCleanupOperator = new SchemaCleanupOperator();
    100103
     104      var changedTreesReducer = new DataReducer();
     105      changedTreesReducer.ParameterToReduce.ActualName = schemaEvaluator.ChangedTreesParameter.ActualName;
     106      changedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     107      changedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
     108      changedTreesReducer.TargetParameter.ActualName = "NumberOfChangedTrees";
     109
     110      var valuesCollector = new DataTableValuesCollector();
     111      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfChangedTrees"));
     112      valuesCollector.DataTableParameter.ActualName = "Diversification";
     113
     114      var resultCollector = new ResultsCollector();
     115      resultCollector.CollectedValues.Add(new LookupParameter<DataTable>("Diversification"));
     116
     117      var reduceChangedTrees = ExecutionContext.CreateChildOperation(changedTreesReducer);
     118      var collectValues = ExecutionContext.CreateChildOperation(valuesCollector);
     119      var collectResults = ExecutionContext.CreateChildOperation(resultCollector);
     120
    101121      var oc = new OperationCollection();
    102122
     
    114134        var nodesToReplace = indices.Where(x => x >= 2).Select(x => nodes[x]).ToList();
    115135        for (int i = nodesToReplace.Count - 1; i >= 0; --i) {
     136          var node = nodesToReplace[i];
     137
     138          // do not replace the node with a wildcard if it would result in a length < MinimumSchemaLength
     139          if ((schema.Length - node.GetLength() + 1) < MinimumSchemaLength)
     140            continue;
     141
    116142          var replacement = anySubtreeSymbol.CreateTreeNode();
    117           ReplaceSubtree(nodesToReplace[i], replacement, false);
     143          ReplaceSubtree(node, replacement, false);
    118144          replaced = true;
    119145        }
     
    131157      var cleanup = ExecutionContext.CreateChildOperation(schemaCleanupOperator);
    132158      // return an operation collection containing all the scope operations + base.Apply()
    133       return new OperationCollection { oc, cleanup, base.Apply() };
     159      return new OperationCollection { oc, reduceChangedTrees, collectValues, collectResults, cleanup, base.Apply() };
    134160    }
    135161
Note: See TracChangeset for help on using the changeset viewer.