Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/21/15 01:03:12 (9 years ago)
Author:
bburlacu
Message:

#1772: Properly remove older generations in the genealogy graph. Fix namespaces in the schema diversification operators.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification
Files:
4 edited

Legend:

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

    r12951 r12958  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Tracking {
     28namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2929  [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")]
    3030  [StorableClass]
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs

    r12952 r12958  
    3333using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3434
    35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Tracking {
     35namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3636  [Item("SchemaCreator", "An operator that builds schemas based on the heredity relationship in the genealogy graph.")]
    3737  [StorableClass]
     
    5959      get { return (IFixedValueParameter<PercentValue>)Parameters[ReplacementRatioParameterName]; }
    6060    }
    61 
    62     private IFixedValueParameter<BoolValue> RandomReplacementParameter {
    63       get { return (IFixedValueParameter<BoolValue>)Parameters[RandomReplacementParameterName]; }
    64     }
    6561    #endregion
    6662
     
    7066    }
    7167    #endregion
     68
     69    private SchemaEvaluator schemaEvaluator;
     70    private SchemaCleanupOperator schemaCleanupOperator;
     71    private DataReducer changedTreesReducer;
     72    private DataTableValuesCollector valuesCollector;
     73    private ResultsCollector resultsCollector;
     74
     75    private void ParameterizeOperators() {
     76      schemaEvaluator = new SchemaEvaluator();
     77      schemaCleanupOperator = new SchemaCleanupOperator();
     78
     79      changedTreesReducer = new DataReducer();
     80      changedTreesReducer.ParameterToReduce.ActualName = schemaEvaluator.ChangedTreesParameter.ActualName;
     81      changedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
     82      changedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
     83      changedTreesReducer.TargetParameter.ActualName = "NumberOfChangedTrees";
     84
     85      valuesCollector = new DataTableValuesCollector();
     86      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfChangedTrees"));
     87      valuesCollector.DataTableParameter.ActualName = "Diversification";
     88
     89      resultsCollector = new ResultsCollector();
     90      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Diversification"));
     91    }
    7292
    7393    public SchemaCreator() {
     
    7797      Parameters.Add(new FixedValueParameter<PercentValue>(ReplacementRatioParameterName, new PercentValue(0.2)));
    7898      Parameters.Add(new FixedValueParameter<BoolValue>(RandomReplacementParameterName, new BoolValue(false)));
     99
     100      ParameterizeOperators();
    79101    }
    80102
     
    98120      var anySubtreeSymbol = new AnySubtreeSymbol();
    99121
    100       var schemaEvaluator = new SchemaEvaluator();
    101122      var scopes = new ScopeList(this.ExecutionContext.Scope.SubScopes);
    102       var schemaCleanupOperator = new SchemaCleanupOperator();
    103 
    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"));
     123
     124      if (schemaEvaluator == null || schemaCleanupOperator == null || changedTreesReducer == null || valuesCollector == null || resultsCollector == null)
     125        ParameterizeOperators();
    116126
    117127      var reduceChangedTrees = ExecutionContext.CreateChildOperation(changedTreesReducer);
    118128      var collectValues = ExecutionContext.CreateChildOperation(valuesCollector);
    119       var collectResults = ExecutionContext.CreateChildOperation(resultCollector);
     129      var collectResults = ExecutionContext.CreateChildOperation(resultsCollector);
    120130
    121131      var oc = new OperationCollection();
     
    132142        var indices = arcs.Select(x => ((IFragment<ISymbolicExpressionTreeNode>)x.Data).Index1).Distinct().ToArray();
    133143        Array.Sort(indices);
    134         var nodesToReplace = indices.Where(x => x >= 2).Select(x => nodes[x]).ToList();
     144        var nodesToReplace = indices.Select(x => nodes[x]).ToList();
    135145        for (int i = nodesToReplace.Count - 1; i >= 0; --i) {
    136146          var node = nodesToReplace[i];
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaEvaluator.cs

    r12952 r12958  
    3131using HeuristicLab.Random;
    3232
    33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Tracking {
     33namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3434  [Item("SchemaEvaluator", "An operator that builds schemas based on the heredity relationship in the genealogy graph.")]
    3535  [StorableClass]
     
    9595      get { return (LookupParameter<IntValue>)Parameters[ChangedTreesParameterName]; }
    9696    }
    97 
    9897    #endregion
    9998
     
    180179
    181180      var s = SchemaParameter.ActualValue;
    182       var matchingIndividuals = new ScopeList(from ind in individuals
    183                                               let t = (ISymbolicExpressionTree)ind.Variables["SymbolicExpressionTree"].Value
    184                                               where qm.Match(t, s)
    185                                               select ind);
     181      var matchingIndividuals = new ScopeList();
     182      foreach (var ind in individuals) {
     183        var t = (ISymbolicExpressionTree)ind.Variables["SymbolicExpressionTree"].Value;
     184        if (t.Length >= s.Length && qm.Match(t, s))
     185          matchingIndividuals.Add(ind);
     186      }
    186187
    187188      if (matchingIndividuals.Count < MinimumSchemaFrequency.Value * individuals.Count) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/UpdateEstimatedValuesOperator.cs

    r12951 r12958  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Tracking {
     31namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3232  [Item("UpdateEstimatedValuesOperator", "Put the estimated values of the tree in the scope to be used by the phenotypic similarity calculator")]
    3333  [StorableClass]
     
    8282      else
    8383        variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(estimatedValues)));
    84       var quality = (DoubleValue)variables["Quality"].Value;
    85       if (double.IsNaN(quality.Value))
    86         quality.Value = 0.0;
    8784      return base.Apply();
    8885    }
Note: See TracChangeset for help on using the changeset viewer.