Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/14 20:47:50 (10 years ago)
Author:
bburlacu
Message:

#1772: Added SymbolicDataAnalysisGenealogyView, updated generic analyzer and operators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterCrossoverOperator.cs

    r10278 r10285  
    3333    where TVertex : class,IGenealogyGraphNode<TContent>, new()
    3434    where TContent : class,IItem {
    35 
    36     private string parentsParameterName;
    37     public string ParentsParameterName {
    38       get { return parentsParameterName; }
    39       set {
    40         if (parentsParameterName != null && Parameters.ContainsKey(parentsParameterName)) Parameters.Remove(parentsParameterName); // remove old parameter
    41         parentsParameterName = value;
    42         if (!Parameters.ContainsKey(parentsParameterName)) Parameters.Add(new ScopeTreeLookupParameter<TContent>(parentsParameterName));
    43       }
    44     }
    45     private string childParameterName;
    46     public string ChildParameterName {
    47       get { return childParameterName; }
    48       set {
    49         if (childParameterName != null && Parameters.ContainsKey(childParameterName)) Parameters.Remove(childParameterName);
    50         childParameterName = value;
    51         if (!Parameters.ContainsKey(childParameterName)) Parameters.Add(new LookupParameter<TContent>(childParameterName));
    52       }
    53     }
    54 
    55     public IScopeTreeLookupParameter<TContent> ParentsParameter {
    56       get { return (IScopeTreeLookupParameter<TContent>)Parameters[ParentsParameterName]; }
    57     }
    58 
    59     public ILookupParameter<TContent> ChildParameter {
    60       get { return (ILookupParameter<TContent>)Parameters[ChildParameterName]; }
    61     }
     35    private const string defaultParentsParameterName = "Parents";
     36    private const string defaultChildParameterName = "Child";
     37    public IScopeTreeLookupParameter<TContent> ParentsParameter;
     38    public ILookupParameter<TContent> ChildParameter;
    6239
    6340    protected AfterCrossoverOperator(AfterCrossoverOperator<TGraph, TVertex, TContent> original, Cloner cloner)
    6441      : base(original, cloner) {
    65       ParentsParameterName = original.ParentsParameterName;
    66       ChildParameterName = original.ChildParameterName;
    6742    }
    6843    public override IDeepCloneable Clone(Cloner cloner) {
     
    7045    }
    7146
    72     public AfterCrossoverOperator() { }
     47    public AfterCrossoverOperator() {
     48      ParentsParameter = new ScopeTreeLookupParameter<TContent>(defaultParentsParameterName);
     49      ChildParameter = new LookupParameter<TContent>(defaultChildParameterName);
     50      Parameters.Add(ParentsParameter);
     51      Parameters.Add(ChildParameter);
     52    }
    7353
    7454    public override IOperation Apply() {
    7555      //      var parentVertices = ParentsParameter.ActualValue.Select(x => GenealogyGraph[x].Last()).ToList();
    7656      var lastGen = GenealogyGraph.Ranks[Generations.Value].ToList();
    77       var parentVertices = ExecutionContext.Scope.SubScopes.Select(s => lastGen[int.Parse(s.Name)]).ToList();
     57      var parentVertices = ExecutionContext.Scope.SubScopes.Select(s => lastGen[int.Parse(s.Name)]).ToList(); // because the individuals in the execution scope are copies of the ones in the graph
     58
    7859      var childVertex = new TVertex {
    7960        Content = ChildParameter.ActualValue,
     
    8566        v.AddForwardArc(childVertex);
    8667      }
     68      //      if (parentVertices[0].Content == parentVertices[1].Content)
     69      //        throw new Exception("Self-crossover");
    8770      return base.Apply();
    8871    }
Note: See TracChangeset for help on using the changeset viewer.