Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10285


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

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

Location:
branches/HeuristicLab.EvolutionTracking
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.Designer.cs

    r10271 r10285  
    1 namespace HeuristicLab.EvolutionTracking.Views {
    2   partial class GenealogyGraphChart {
     1using HeuristicLab.Core;
     2
     3namespace HeuristicLab.EvolutionTracking.Views {
     4  partial class GenealogyGraphChart<TGraph, TVertex, TContent>
     5    where TGraph : class, IGenealogyGraph<TVertex, TContent>
     6    where TVertex : class, IGenealogyGraphNode<TContent>, new()
     7    where TContent : class, IItem {
    38    /// <summary>
    49    /// Required designer variable.
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r10271 r10285  
    66using System.Windows.Forms;
    77using HeuristicLab.Common;
     8using HeuristicLab.Core;
    89using HeuristicLab.Visualization;
    910
    1011namespace HeuristicLab.EvolutionTracking.Views {
    11   public partial class GenealogyGraphChart : ChartControl {
    12     private GenealogyGraph genealogyGraph;
     12  public partial class GenealogyGraphChart<TGraph, TVertex, TContent> : ChartControl
     13    where TGraph : class, IGenealogyGraph<TVertex, TContent>
     14    where TVertex : class, IGenealogyGraphNode<TContent>, new()
     15    where TContent : class,IItem {
     16    private TGraph genealogyGraph;
    1317
    1418    private const double XIncrement = 30;
     
    1620    private const double Diameter = 20;
    1721
    18     public GenealogyGraph GenealogyGraph {
     22    public TGraph GenealogyGraph {
    1923      get { return genealogyGraph; }
    2024      set {
     
    6266      return arc;
    6367    }
    64 
    6568    private bool DrawInProgress { get; set; } // do not try to update the chart while the drawing is not finished
    6669    private VisualGenealogyGraphNode SelectedVisualNode { get; set; }
     
    7174      if (clicked != null) clicked(sender, e);
    7275    }
    73 
    7476    public GenealogyGraphChart() {
    7577      InitializeComponent();
    7678    }
    77 
    7879    protected virtual void DrawGraph(double xIncrement, double yIncrement, double diameter) {
    7980      Chart.UpdateEnabled = false;
     
    104105        }
    105106        y -= yIncrement;
    106       }
     107        x = 0;
     108      }
     109
    107110      // add arcs
    108111      foreach (var node in GenealogyGraph.Nodes) {
     
    116119          var pen = new Pen(Color.Transparent);
    117120          var visualArc = AddArc(Chart, visualParent, visualNode, pen);
    118           arcMap.Add(Tuple.Create(visualParent, visualNode), visualArc);
     121          if (!arcMap.ContainsKey(Tuple.Create(visualParent, visualNode)))
     122            arcMap.Add(Tuple.Create(visualParent, visualNode), visualArc);
    119123        }
    120124      }
     
    126130      DrawInProgress = false;
    127131    }
    128 
    129     protected override void pictureBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {
     132    protected override void pictureBox_MouseMove(object sender, MouseEventArgs e) {
    130133      if (!DrawInProgress) {
    131134        switch (e.Button) {
     
    142145      base.pictureBox_MouseMove(sender, e);
    143146    }
    144 
    145147    protected override void pictureBox_MouseUp(object sender, MouseEventArgs e) {
    146148      Cursor = Cursors.Default;
     
    189191      base.pictureBox_MouseUp(sender, e);
    190192    }
    191 
    192193    private void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
    193194      if (node.Brush != null) return;
     
    207208      }
    208209    }
    209 
    210210    void MarkSelectedNode() {
    211211      var center = SelectedVisualNode.Center;
     
    222222      }
    223223    }
    224 
    225 
    226224    private static VisualGenealogyGraphArc AddArc(IChart chart, VisualGenealogyGraphNode source, VisualGenealogyGraphNode target, Pen pen, Brush brush = null) {
    227225      var arc = new VisualGenealogyGraphArc(chart, source, target, pen) { Brush = brush };
     
    232230      return arc;
    233231    }
    234 
    235232    public virtual void ClearPrimitives() {
    236233      foreach (var primitive in Chart.Group.Primitives) {
     
    267264    }
    268265  }
    269 
    270266  internal static class Util {
    271267    public static Color GetColor(this IGenealogyGraphNode node) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs

    r10271 r10285  
    6060    protected override void OnContentChanged() {
    6161      base.OnContentChanged();
    62       genealogyGraphChart.GenealogyGraph = Content ?? null;
     62      //      genealogyGraphChart.GenealogyGraph = Content ?? null;
    6363    }
    6464    private void Content_GraphChanged(object sender, EventArgs e) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r10269 r10285  
    122122      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
    123123    </Compile>
    124     <Compile Include="GenealogyGraphView.cs">
    125       <SubType>UserControl</SubType>
    126     </Compile>
    127     <Compile Include="GenealogyGraphView.Designer.cs">
    128       <DependentUpon>GenealogyGraphView.cs</DependentUpon>
    129     </Compile>
    130124    <Compile Include="Plugin.cs" />
    131125    <Compile Include="Primitives\LabeledEllipse.cs" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r10278 r10285  
    1 using HeuristicLab.Common;
     1using System.Collections.Generic;
     2using System.Linq;
     3using HeuristicLab.Common;
    24using HeuristicLab.Core;
    35using HeuristicLab.Data;
     
    1820    private AfterManipulatorOperator<TGraph, TVertex, TContent> afterManipulatorOperator;
    1921    private BeforeManipulatorOperator<TGraph, TVertex, TContent> beforeManipulatorOperator;
    20     //    private AfterSolutionCreatorOperator<TGraph, TVertex, TContent> afterSolutionCreatorOperator;
    2122    public string CrossoverParentsParameterName { get; set; }
    2223    public string CrossoverChildParameterName { get; set; }
    2324    public string ManipulatorChildParameterName { get; set; }
    2425
    25     private string solutionCreatorIndividualParameterName;
    26     public string SolutionCreatorIndividualParameterName {
    27       get { return solutionCreatorIndividualParameterName; }
    28       set {
    29         if (solutionCreatorIndividualParameterName != null && Parameters.ContainsKey(solutionCreatorIndividualParameterName)) {
    30           Parameters.Remove(solutionCreatorIndividualParameterName);
    31         }
    32         solutionCreatorIndividualParameterName = value;
    33         if (!Parameters.ContainsKey(solutionCreatorIndividualParameterName)) {
    34           Parameters.Add(new ScopeTreeLookupParameter<TContent>(solutionCreatorIndividualParameterName));
    35         }
    36       }
    37     }
     26    public IScopeTreeLookupParameter<DoubleValue> QualityParameter;
     27    public IScopeTreeLookupParameter<TContent> PopulationParameter;
     28
     29    private const string PopulationParameterName = "Population";
     30    private const string QualityParameterName = "Quality";
    3831
    3932    private const string GenerationsParameterName = "Generations";
     
    5245    public ILookupParameter<ResultCollection> ResultsParameter {
    5346      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    54     }
    55     public IScopeTreeLookupParameter<TContent> PopulationParameter {
    56       get { return (IScopeTreeLookupParameter<TContent>)Parameters[solutionCreatorIndividualParameterName]; }
    5747    }
    5848    public ILookupParameter<IntValue> GenerationsParameter {
     
    7666    public ILookupParameter<ISolutionCreator> SolutionCreatorParameter {
    7767      get { return (ILookupParameter<ISolutionCreator>)Parameters[SolutionCreatorParameterName]; }
    78     }
    79     public IntValue Generations {
    80       get { return GenerationsParameter.ActualValue; }
    8168    }
    8269    #endregion
     
    10390    public ResultCollection Results {
    10491      get { return ResultsParameter.ActualValue; }
     92    }
     93    public IntValue Generations {
     94      get { return GenerationsParameter.ActualValue; }
    10595    }
    10696    public IGenealogyGraph<TVertex, TContent> GenealogyGraph {
     
    131121      Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
    132122      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
     123      PopulationParameter = new ScopeTreeLookupParameter<TContent>(PopulationParameterName);
     124      QualityParameter = new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName);
     125      Parameters.Add(PopulationParameter);
     126      Parameters.Add(QualityParameter);
    133127    }
    134128    public override IDeepCloneable Clone(Cloner cloner) {
     
    144138
    145139    public override IOperation Apply() {
    146       // wire the before- and after operators
    147       //      if (EnableSolutionCreatorTracking.Value) {
    148       //        if (afterSolutionCreatorOperator == null) {
    149       //          afterSolutionCreatorOperator = new AfterSolutionCreatorOperator<TGraph, TVertex, TContent>();
    150       //          afterSolutionCreatorOperator.NewIndividualParameterName = SolutionCreatorIndividualParameterName;
    151       //        }
    152       //        var instrumentedSolutionCreator = (InstrumentedOperator)SolutionCreator;
    153       //        instrumentedSolutionCreator.AfterExecutionOperators.Add(afterSolutionCreatorOperator);
    154       //      }
    155 
    156140      if (Generations.Value == 0) {
    157141        foreach (var individual in PopulationParameter.ActualValue) {
     
    162146          GenealogyGraph.AddVertex(vertex);
    163147        }
     148        // at the beginning we add the before/after operators to the instrumented operators
     149        if (EnableCrossoverTracking.Value) {
     150          if (afterCrossoverOperator == null) {
     151            afterCrossoverOperator = new AfterCrossoverOperator<TGraph, TVertex, TContent>();
     152            afterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
     153            afterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
     154          }
     155          var instrumentedCrossover = (InstrumentedOperator)Crossover;
     156          instrumentedCrossover.AfterExecutionOperators.Add(afterCrossoverOperator);
     157        }
     158
     159        if (EnableManipulatorTracking.Value && Manipulator != null) {
     160          if (beforeManipulatorOperator == null) {
     161            beforeManipulatorOperator = new BeforeManipulatorOperator<TGraph, TVertex, TContent>();
     162            beforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     163          }
     164          if (afterManipulatorOperator == null) {
     165            afterManipulatorOperator = new AfterManipulatorOperator<TGraph, TVertex, TContent>();
     166            afterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     167          }
     168          var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     169          instrumentedManipulator.BeforeExecutionOperators.Add(beforeManipulatorOperator);
     170          instrumentedManipulator.AfterExecutionOperators.Add(afterManipulatorOperator);
     171        }
    164172      } else {
    165         // add missing individuals in the current generation
     173        // add missing elite individuals in the current generation
     174        // TODO: optimize for speed
     175        var currGen = new HashSet<TContent>(GenealogyGraph.Ranks[Generations.Value].Select(x => x.Content));
    166176        foreach (var individual in PopulationParameter.ActualValue) {
    167           if (!GenealogyGraph.Contains(individual)) continue;
     177          if (currGen.Contains(individual)) continue;
    168178          // it is an elite which was already added to the graph in the previous generation
    169179          var vertex = new TVertex {
    170180            Content = individual,
    171             Rank = Generations.Value
     181            Rank = Generations.Value,
     182            IsElite = true
    172183          };
    173184          GenealogyGraph.AddVertex(vertex);
    174185        }
    175186      }
    176 
    177       if (EnableCrossoverTracking.Value) {
    178         if (afterCrossoverOperator == null) {
    179           afterCrossoverOperator = new AfterCrossoverOperator<TGraph, TVertex, TContent>();
    180           afterCrossoverOperator.ParentsParameterName = CrossoverParentsParameterName;
    181           afterCrossoverOperator.ChildParameterName = CrossoverChildParameterName;
     187      // update qualities for the nodes in the graph
     188      var population = PopulationParameter.ActualValue.ToList();
     189      var qualities = QualityParameter.ActualValue.ToList();
     190      for (int i = 0; i < population.Count; ++i) {
     191        foreach (var v in GenealogyGraph[population[i]]) {
     192          v.Quality = qualities[i].Value;
    182193        }
    183         var instrumentedCrossover = (InstrumentedOperator)Crossover;
    184         instrumentedCrossover.AfterExecutionOperators.Add(afterCrossoverOperator);
    185       }
    186 
    187       if (EnableManipulatorTracking.Value) {
    188         if (beforeManipulatorOperator == null) {
    189           beforeManipulatorOperator = new BeforeManipulatorOperator<TGraph, TVertex, TContent>();
    190           beforeManipulatorOperator.ChildParameterName = ManipulatorChildParameterName;
    191         }
    192         if (afterManipulatorOperator == null) {
    193           afterManipulatorOperator = new AfterManipulatorOperator<TGraph, TVertex, TContent>();
    194           afterManipulatorOperator.ChildParameterName = ManipulatorChildParameterName;
    195         }
    196         var instrumentedManipulator = (InstrumentedOperator)Manipulator;
    197         instrumentedManipulator.BeforeExecutionOperators.Add(beforeManipulatorOperator);
    198         instrumentedManipulator.AfterExecutionOperators.Add(afterManipulatorOperator);
    199194      }
    200195
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Interfaces/IVertex.cs

    r10271 r10285  
    4242  }
    4343
    44   public interface IVertex<T> : IVertex {
     44  public interface IVertex<T> : IVertex
     45  where T : class,IItem {
    4546    T Content { get; set; }
    4647  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Vertex.cs

    r10278 r10285  
    7777    // (they do not appear in the nodes Dictionary). It is the programmers responsibility to
    7878    // enforce the correct and desired behavior.
    79     public void AddForwardArc(IVertex target, double weight = 0.0, object data = null) {
    80       var e = new Arc { Source = this, Target = target, Data = data, Weight = weight };
     79    public void AddForwardArc(IVertex target, double w = 0.0, object data = null) {
     80      var e = new Arc { Source = this, Target = target, Data = data, Weight = w };
    8181      if (OutArcs == null) OutArcs = new List<IArc> { e };
    8282      else OutArcs.Add(e);
     
    9292      if (InArcs == null) { InArcs = new List<IArc> { arc }; } else { InArcs.Add(arc); }
    9393    }
    94     public void AddReverseArc(IVertex source, double weight = 0.0, object data = null) {
    95       var e = new Arc { Source = source, Target = this, Data = data, Weight = weight };
     94    public void AddReverseArc(IVertex source, double w = 0.0, object data = null) {
     95      var e = new Arc { Source = source, Target = this, Data = data, Weight = w };
    9696      if (InArcs == null) InArcs = new List<IArc> { e };
    9797      else InArcs.Add(e);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphArc.cs

    r10278 r10285  
    2727  [StorableClass]
    2828  [Item("GenealogyGraphArc", "A graph arc connecting two GenealogyGraphNodes and holding some data.")]
    29   public class GenealogyGraphArc<T> : Arc, IGenealogyGraphArc where T : class,IItem {
     29  public class GenealogyGraphArc : Arc, IGenealogyGraphArc {
     30    [StorableConstructor]
     31    protected GenealogyGraphArc(bool deserializing) : base(deserializing) { }
     32    protected GenealogyGraphArc(GenealogyGraphArc original, Cloner cloner)
     33      : base(original, cloner) {
     34    }
     35
     36    public GenealogyGraphArc() { }
     37
     38    public override IDeepCloneable Clone(Cloner cloner) {
     39      return new GenealogyGraphArc(this, cloner);
     40    }
     41    public new IGenealogyGraphNode Source { get; set; }
     42    public new IGenealogyGraphNode Target { get; set; }
     43
     44
     45  }
     46
     47  [StorableClass]
     48  [Item("GenealogyGraphArc", "")]
     49  public class GenealogyGraphArc<T> : GenealogyGraphArc where T : class,IItem {
    3050    [StorableConstructor]
    3151    protected GenealogyGraphArc(bool deserializing) : base(deserializing) { }
     
    3454      Data = (T)original.Data.Clone();
    3555    }
     56    public GenealogyGraphArc() { }
     57
    3658    public override IDeepCloneable Clone(Cloner cloner) {
    3759      return new GenealogyGraphArc<T>(this, cloner);
    3860    }
    39     public new IGenealogyGraphNode Source { get; set; }
    40     public new IGenealogyGraphNode Target { get; set; }
    41     public new T Data { get; set; }
     61    public new T Data {
     62      get {
     63        return (T)base.Data;
     64      }
     65      set {
     66        base.Data = value;
     67      }
     68    }
    4269  }
    4370}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs

    r10278 r10285  
    4343    public new List<IGenealogyGraphArc> InArcs {
    4444      get {
    45         return base.InArcs.Cast<IGenealogyGraphArc>().ToList();
     45        return base.InArcs == null ? null : base.InArcs.Cast<IGenealogyGraphArc>().ToList();
    4646      }
    4747    }
    4848    public new List<IGenealogyGraphArc> OutArcs {
    4949      get {
    50         return base.OutArcs.Cast<IGenealogyGraphArc>().ToList();
     50        return base.OutArcs == null ? null : base.OutArcs.Cast<IGenealogyGraphArc>().ToList();
    5151      }
    5252    }
     
    109109      return Quality.CompareTo(other.Quality);
    110110    }
     111
     112    public new void AddForwardArc(IVertex target, double w = 0, object data = null) {
     113      var e = new GenealogyGraphArc { Source = this, Target = (IGenealogyGraphNode)target, Data = data, Weight = w };
     114      base.AddForwardArc(e);
     115    }
     116    public new void AddReverseArc(IVertex source, double w = 0.0, object data = null) {
     117      var e = new GenealogyGraphArc { Source = (IGenealogyGraphNode)source, Target = this, Data = data, Weight = w };
     118      base.AddReverseArc(e);
     119    }
    111120  }
    112121
    113122  [StorableClass]
    114123  [Item("GenealogyGraphNode", "A genealogy graph node which also has a Content")]
    115   public class GenealogyGraphNode<T> : GenealogyGraphNode, IGenealogyGraphNode<T> {
     124  public class GenealogyGraphNode<T> : GenealogyGraphNode, IGenealogyGraphNode<T> where T : class,IItem {
    116125    public T Content { get; set; }
     126
    117127  }
    118128}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphArc.cs

    r10278 r10285  
    2020#endregion
    2121
     22using HeuristicLab.Core;
     23
    2224namespace HeuristicLab.EvolutionTracking {
    2325  public interface IGenealogyGraphArc : IArc {
    2426    new IGenealogyGraphNode Source { get; set; }
    2527    new IGenealogyGraphNode Target { get; set; }
    26     object Data { get; set; }
     28  }
     29
     30  public interface IGenealogyGraphArc<T> : IGenealogyGraphArc where T : class, IItem {
     31    T Data { get; set; }
    2732  }
    2833}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphNode.cs

    r10278 r10285  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Core;
    2425
    2526namespace HeuristicLab.EvolutionTracking {
     
    2728    IEnumerable<IGenealogyGraphNode> Ancestors();
    2829    IEnumerable<IGenealogyGraphNode> Descendants();
    29 
    3030    new List<IGenealogyGraphArc> InArcs { get; }
    3131    new List<IGenealogyGraphArc> OutArcs { get; }
     
    3636  }
    3737
    38   public interface IGenealogyGraphNode<T> : IGenealogyGraphNode, IVertex<T> { }
     38  public interface IGenealogyGraphNode<T> : IGenealogyGraphNode, IVertex<T> where T : class,IItem {
     39
     40  }
    3941
    4042}
  • 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    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterManipulatorOperator.cs

    r10278 r10285  
    3333    where TContent : class,IItem {
    3434
    35     private string childParameterName;
    36     public string ChildParameterName {
    37       get { return childParameterName; }
    38       set {
    39         if (childParameterName != null && Parameters.ContainsKey(childParameterName)) Parameters.Remove(childParameterName);
    40         childParameterName = value;
    41         if (!Parameters.ContainsKey(childParameterName)) Parameters.Add(new LookupParameter<TContent>(childParameterName));
    42       }
    43     }
     35    private const string ChildParameterName = "Child";
     36    public ILookupParameter<TContent> ChildParameter;
    4437
    45     #region parameter properties
    46     public ILookupParameter<TContent> ChildParameter {
    47       get { return (ILookupParameter<TContent>)Parameters[ChildParameterName]; }
    48     }
    49     #endregion
    5038    protected AfterManipulatorOperator(AfterManipulatorOperator<TGraph, TVertex, TContent> original, Cloner cloner)
    5139      : base(original, cloner) {
     
    5543    }
    5644
    57     public AfterManipulatorOperator() { }
     45    public AfterManipulatorOperator() {
     46      ChildParameter = new LookupParameter<TContent>(ChildParameterName);
     47      Parameters.Add(ChildParameter);
     48    }
    5849
    5950    public override IOperation Apply() {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs

    r10278 r10285  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    3234    where TVertex : class,IGenealogyGraphNode<TContent>, new()
    3335    where TContent : class,IItem {
    34     private string childParameterName;
    35     public string ChildParameterName {
    36       get { return childParameterName; }
    37       set {
    38         if (childParameterName != null && Parameters.ContainsKey(childParameterName)) Parameters.Remove(childParameterName);
    39         childParameterName = value;
    40         if (!Parameters.ContainsKey(childParameterName)) Parameters.Add(new LookupParameter<TContent>(childParameterName));
    41       }
    42     }
    4336
    44     #region parameter properties
    45     public ILookupParameter<TContent> ChildParameter {
    46       get { return (ILookupParameter<TContent>)Parameters[ChildParameterName]; }
    47     }
    48     #endregion
     37    private const string ChildParameterName = "Child";
     38    public ILookupParameter<TContent> ChildParameter;
     39
    4940    protected BeforeManipulatorOperator(BeforeManipulatorOperator<TGraph, TVertex, TContent> original, Cloner cloner)
    5041      : base(original, cloner) {
     
    5445    }
    5546
    56     public BeforeManipulatorOperator() { }
     47    public BeforeManipulatorOperator() {
     48      ChildParameter = new LookupParameter<TContent>(ChildParameterName);
     49      Parameters.Add(ChildParameter);
     50    }
    5751
    5852    public override IOperation Apply() {
    5953      if (GenealogyGraph.Contains(ChildParameter.ActualValue)) {
    6054        // if the individual has been affected by crossover before mutation, we keep it in the graph and feed a clone of it to the mutation operator
    61         ChildParameter.ActualValue = (TContent)ChildParameter.ActualValue.Clone();
     55        var child = ChildParameter.ActualValue;
     56        var clone = (TContent)child.Clone();
     57        var vertex = GenealogyGraph[child].Last();
     58        vertex.Content = clone;
     59        GenealogyGraph.Ranks[vertex.Rank].Remove(vertex);
     60        var newVertex = new TVertex {
     61          Content = child,
     62          Rank = vertex.Rank
     63        };
     64        vertex.Rank -= 0.5;
     65        if (!GenealogyGraph.Ranks.ContainsKey(vertex.Rank)) {
     66          GenealogyGraph.Ranks[vertex.Rank] = new LinkedList<TVertex>();
     67        }
     68        GenealogyGraph.Ranks[vertex.Rank].AddLast(vertex);
     69
     70        newVertex.AddForwardArc(vertex);
     71        vertex.AddReverseArc(vertex);
     72      } else {
     73        // mutation should never happen without crossover
    6274      }
    6375      return base.Apply();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/EvolutionTrackingOperator.cs

    r10278 r10285  
    3333    where TContent : class,IItem {
    3434    // evolution tracking-related parameters
    35     private const string ResultsParameterName = "Results";
    36     private const string PopulationGraphParameterName = "PopulationGraph";
    37     private const string GenerationsParameterName = "Generations";
     35    private const string resultsParameterName = "Results";
     36    private const string populationGraphParameterName = "PopulationGraph";
     37    private const string generationsParameterName = "Generations";
    3838
    3939    public ILookupParameter<ResultCollection> ResultsParameter {
    40       get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
     40      get { return (ILookupParameter<ResultCollection>)Parameters[resultsParameterName]; }
    4141    }
    4242    public ILookupParameter<IntValue> GenerationsParameter {
    43       get { return (ILookupParameter<IntValue>)Parameters[GenerationsParameterName]; }
     43      get { return (ILookupParameter<IntValue>)Parameters[generationsParameterName]; }
    4444    }
    4545    public ResultCollection Results {
     
    5252      get {
    5353        IResult result;
    54         if (!Results.ContainsKey(PopulationGraphParameterName)) {
    55           result = new Result(PopulationGraphParameterName, new GenealogyGraph<TVertex, TContent>());
     54        if (!Results.ContainsKey(populationGraphParameterName)) {
     55          result = new Result(populationGraphParameterName, new GenealogyGraph<TVertex, TContent>());
    5656          Results.Add(result);
    5757        } else {
    58           result = Results[PopulationGraphParameterName];
     58          result = Results[populationGraphParameterName];
    5959        }
    6060        var graph = (GenealogyGraph<TVertex, TContent>)result.Value;
     
    6363    }
    6464    public EvolutionTrackingOperator() {
    65       Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName));
    66       Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
     65      Parameters.Add(new LookupParameter<IntValue>(generationsParameterName));
     66      Parameters.Add(new LookupParameter<ResultCollection>(resultsParameterName));
    6767    }
    6868    protected EvolutionTrackingOperator(EvolutionTrackingOperator<TGraph, TVertex, TContent> original, Cloner cloner)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/SymbolGraph.cs

    r10278 r10285  
    7676    public IVertex Target { get; set; }
    7777    public double Weight { get; set; }
     78
     79    public object Data { get; set; }
    7880  }
    7981}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r10271 r10285  
    167167      <Private>False</Private>
    168168    </Reference>
     169    <Reference Include="HeuristicLab.Visualization-3.3, Version=3.3.0.9491, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     170      <SpecificVersion>False</SpecificVersion>
     171      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Visualization-3.3.dll</HintPath>
     172    </Reference>
    169173    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    170174      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath>
     
    195199      <DependentUpon>InteractiveSymbolicExpressionTreeChart.cs</DependentUpon>
    196200    </Compile>
    197     <Compile Include="LatexSymbolicDataAnalysisModelView.cs" />
     201    <Compile Include="LatexSymbolicDataAnalysisModelView.cs">
     202      <SubType>UserControl</SubType>
     203    </Compile>
    198204    <Compile Include="LatexSymbolicDataAnalysisModelView.designer.cs">
    199205      <DependentUpon>LatexSymbolicDataAnalysisModelView.cs</DependentUpon>
     
    212218    <Compile Include="SlidingWindowDataView.Designer.cs">
    213219      <DependentUpon>SlidingWindowDataView.cs</DependentUpon>
     220    </Compile>
     221    <Compile Include="SymbolicDataAnalysisGenealogyView.cs">
     222      <SubType>UserControl</SubType>
     223    </Compile>
     224    <Compile Include="SymbolicDataAnalysisGenealogyView.Designer.cs">
     225      <DependentUpon>SymbolicDataAnalysisGenealogyView.cs</DependentUpon>
    214226    </Compile>
    215227    <Compile Include="TextualSymbolicDataAnalysisModelView.cs">
     
    295307      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4</Name>
    296308      <Private>False</Private>
     309    </ProjectReference>
     310    <ProjectReference Include="..\..\HeuristicLab.EvolutionTracking.Views\3.4\HeuristicLab.EvolutionTracking.Views-3.4.csproj">
     311      <Project>{318dfe8c-ca23-4f1b-a4ac-62b425060241}</Project>
     312      <Name>HeuristicLab.EvolutionTracking.Views-3.4</Name>
     313    </ProjectReference>
     314    <ProjectReference Include="..\..\HeuristicLab.EvolutionTracking\3.4\HeuristicLab.EvolutionTracking-3.4.csproj">
     315      <Project>{1f75cea3-464f-4a6f-b2f0-04b9841ebc16}</Project>
     316      <Name>HeuristicLab.EvolutionTracking-3.4</Name>
    297317    </ProjectReference>
    298318    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
     
    323343      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    324344    </Content>
     345  </ItemGroup>
     346  <ItemGroup>
     347    <EmbeddedResource Include="SymbolicDataAnalysisGenealogyView.resx">
     348      <DependentUpon>SymbolicDataAnalysisGenealogyView.cs</DependentUpon>
     349    </EmbeddedResource>
    325350  </ItemGroup>
    326351  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r10278 r10285  
    358358      // add tracking analyzer
    359359      foreach (var op in operators.OfType<GenealogyAnalyzer<TGraph, TVertex, ISymbolicExpressionTree>>()) {
     360        // get crossover parameter names
    360361        var crossover = operators.OfType<ISymbolicExpressionTreeCrossover>().First();
    361362        op.CrossoverParentsParameterName = crossover.ParentsParameter.Name;
    362363        op.CrossoverChildParameterName = crossover.ChildParameter.Name;
     364        // get munipulator parameter names
    363365        var manipulator = operators.OfType<ISymbolicExpressionTreeManipulator>().First();
    364366        op.ManipulatorChildParameterName = manipulator.SymbolicExpressionTreeParameter.Name;
    365         var creator = operators.OfType<ISymbolicExpressionTreeCreator>().First();
    366         op.SolutionCreatorIndividualParameterName = creator.SymbolicExpressionTreeParameter.Name;
    367367      }
    368368    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSingleObjectiveProblem.cs

    r9456 r10285  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     28using HeuristicLab.EvolutionTracking;
    2729using HeuristicLab.Optimization;
    2830using HeuristicLab.Parameters;
    2931using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32
     33using TGraph = HeuristicLab.EvolutionTracking.IGenealogyGraph<HeuristicLab.EvolutionTracking.GenealogyGraphNode<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>,
     34                                                              HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>;
     35using TVertex = HeuristicLab.EvolutionTracking.GenealogyGraphNode<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>;
    3036
    3137namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    115121        op.MaximizationParameter.ActualName = MaximizationParameterName;
    116122      }
     123
     124      foreach (var op in Operators.OfType<GenealogyAnalyzer<TGraph, TVertex, ISymbolicExpressionTree>>()) {
     125        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     126        op.PopulationParameter.ActualName = Evaluator.SymbolicExpressionTreeParameter.ActualName;
     127      }
    117128    }
    118129  }
Note: See TracChangeset for help on using the changeset viewer.