Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/31/17 16:53:34 (8 years ago)
Author:
bburlacu
Message:

#1772: Add option when generating schemas to only consider parents that have produced a minimum number of offspring.

File:
1 edited

Legend:

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

    r14427 r14627  
    201201                     select v;
    202202
    203       var schemas = GenerateSchemas(vertices, MinimumSchemaLength, StrictSchemaMatching).ToList();
     203      var schemas = GenerateSchemas(vertices, MinimumSchemaLength, 0, StrictSchemaMatching).ToList();
    204204
    205205      #region create schemas and add subscopes representing the individuals
     
    223223    }
    224224
    225     public static IEnumerable<ISymbolicExpressionTree> GenerateSchemas(IEnumerable<IGenealogyGraphNode<ISymbolicExpressionTree>> vertices, int minimumSchemaLength, bool strict = true) {
     225    public static IEnumerable<ISymbolicExpressionTree> GenerateSchemas(IEnumerable<IGenealogyGraphNode<ISymbolicExpressionTree>> vertices, int minimumSchemaLength, int minOffspringCount = 1, bool strict = true) {
    226226      var anySubtreeSymbol = new AnySubtreeSymbol();
    227       var groups = vertices.GroupBy(x => x.Parents.First()).OrderByDescending(g => g.Count());
     227      var groups = vertices.GroupBy(x => x.Parents.First()).Where(g => g.Count() >= minOffspringCount).OrderByDescending(g => g.Count());
    228228      var hash = new HashSet<string>();
    229229      foreach (var g in groups) {
     
    249249          }
    250250          SchemaUtil.ReplaceSubtree(node, replacement, true);
     251          //          var replacement = anySubtreeSymbol.CreateTreeNode();
    251252          //          var replacement = new AnyNodeSymbol(node.Symbol.MinimumArity, node.Symbol.MinimumArity).CreateTreeNode();
    252253          //          ReplaceSubtree(node, replacement, true);
     254          //          SchemaUtil.ReplaceSubtree(node, replacement, false);
    253255          replaced = true;
    254256        }
Note: See TracChangeset for help on using the changeset viewer.