Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10347 for branches


Ignore:
Timestamp:
01/16/14 16:37:56 (11 years ago)
Author:
bburlacu
Message:

#1772: Small changes to the GenealogyGraph. Added generic Fragment class and interface. Added the SymbolicDataAnalysisPopulationDiversityAnalyzer. Added specialized tracking operators for symbolic data analysis. Merged trunk changes.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
16 added
22 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.cs

    r9456 r10347  
    2020#endregion
    2121
     22using System.Drawing;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Core.Views;
     
    5253      symbolicExpressionTreeChart.Enabled = Content != null;
    5354    }
     55
     56    public void HighlightNode(ISymbolicExpressionTreeNode node, Color color) {
     57      symbolicExpressionTreeChart.HighlightNode(node, color);
     58    }
     59
     60    public void HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color color) {
     61      symbolicExpressionTreeChart.HighlightSubtree(subtree, color);
     62    }
    5463  }
    5564}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r10302 r10347  
    168168    }
    169169
     170    public void HighlightNode(ISymbolicExpressionTreeNode node, Color color) {
     171      var visualNode = GetVisualSymbolicExpressionTreeNode(node);
     172      if (visualNode == null) return;
     173      visualNode.LineColor = color;
     174      RepaintNode(visualNode);
     175    }
     176
     177    public void HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color color) {
     178      foreach (var node in subtree.IterateNodesBreadth())
     179        HighlightNode(node, color);
     180    }
     181
    170182    private void GenerateImage() {
    171183      using (Graphics graphics = Graphics.FromImage(image)) {
     
    267279    #region methods for painting the symbolic expression tree
    268280
    269     private void DrawFunctionTree(ISymbolicExpressionTree tree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
    270       var layoutNodes = layoutAdapter.Convert(tree).ToList();
     281    private void DrawFunctionTree(ISymbolicExpressionTree symbolicExpressionTree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
     282      var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList();
    271283      layoutEngine.Reset();
    272284      layoutEngine.Root = layoutNodes[0];
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r10302 r10347  
    187187    <Compile Include="Formatters\SymbolicExpressionTreeGraphvizFormatter.cs" />
    188188    <Compile Include="Formatters\SymbolicExpressionTreeLatexFormatter.cs" />
    189     <Compile Include="Interfaces\IFragment.cs" />
    190189    <Compile Include="Interfaces\ILayoutAdapter.cs" />
    191190    <Compile Include="Interfaces\ILayoutNode.cs" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r10302 r10347  
    121121    #endregion
    122122
    123     private System.Windows.Forms.SplitContainer splitContainer;
    124     private MainForm.WindowsForms.ViewHost viewHost;
    125     private System.Windows.Forms.Panel panel1;
    126     private System.Windows.Forms.Panel panel2;
    127     private GenealogyGraphChart genealogyGraphChart;
     123    protected System.Windows.Forms.SplitContainer splitContainer;
     124    protected MainForm.WindowsForms.ViewHost viewHost;
     125    protected System.Windows.Forms.Panel panel1;
     126    protected System.Windows.Forms.Panel panel2;
     127    protected GenealogyGraphChart genealogyGraphChart;
    128128
    129129  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs

    r10302 r10347  
    77  [View("GenealogyGraphView")]
    88  [Content(typeof(GenealogyGraph), IsDefaultView = false)]
    9   public sealed partial class GenealogyGraphView : ItemView {
     9  public partial class GenealogyGraphView : ItemView {
    1010    public new IGenealogyGraph Content {
    1111      get { return (IGenealogyGraph)base.Content; }
     
    3131    #region Event Handlers (Content)
    3232
    33     public void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {
     33    public virtual void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {
    3434      var content = ((VisualGenealogyGraphNode)sender).Data.Content;
    3535      if (content != null) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r10302 r10347  
    161161  </ItemGroup>
    162162  <ItemGroup>
    163     <EmbeddedResource Include="GenealogyGraphView.resx">
    164       <DependentUpon>GenealogyGraphView.cs</DependentUpon>
    165     </EmbeddedResource>
    166163    <EmbeddedResource Include="Properties\Resources.resx">
    167164      <Generator>ResXFileCodeGenerator</Generator>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r10300 r10347  
    1515  where T : class,IItem {
    1616
    17     private AfterCrossoverOperator<T> afterCrossoverOperator;
    18     private AfterManipulatorOperator<T> afterManipulatorOperator;
    19     private BeforeManipulatorOperator<T> beforeManipulatorOperator;
    2017    public string CrossoverParentsParameterName { get; set; }
    2118    public string CrossoverChildParameterName { get; set; }
     
    2421    public IScopeTreeLookupParameter<DoubleValue> QualityParameter;
    2522    public IScopeTreeLookupParameter<T> PopulationParameter;
     23
     24    public ICrossoverOperator<T> BeforeCrossoverOperator { get; set; }
     25    public ICrossoverOperator<T> AfterCrossoverOperator { get; set; }
     26    public IManipulatorOperator<T> BeforeManipulatorOperator { get; set; }
     27    public IManipulatorOperator<T> AfterManipulatorOperator { get; set; }
    2628
    2729    private const string PopulationParameterName = "Population";
     
    130132      : base(original, cloner) {
    131133    }
     134    [StorableHook(HookType.AfterDeserialization)]
     135    private void AfterDeserialization() {
     136      // the instrumented operators
     137      if (!Parameters.ContainsKey(CrossoverParameterName))
     138        Parameters.Add(new LookupParameter<ICrossover>(CrossoverParameterName, "The crossover operator."));
     139      if (!Parameters.ContainsKey(ManipulatorParameterName))
     140        Parameters.Add(new LookupParameter<IManipulator>(ManipulatorParameterName, "The manipulator operator."));
     141      if (!Parameters.ContainsKey(SolutionCreatorParameterName))
     142        Parameters.Add(new LookupParameter<ISolutionCreator>(SolutionCreatorParameterName, "The solution creator operator."));
     143      // the analyzer parameters
     144      if (!Parameters.ContainsKey(EnableCrossoverTrackingParameterName))
     145        Parameters.Add(new ValueParameter<BoolValue>(EnableCrossoverTrackingParameterName, new BoolValue(true)));
     146      if (!Parameters.ContainsKey(EnableManipulatorTrackingParameterName))
     147        Parameters.Add(new ValueParameter<BoolValue>(EnableManipulatorTrackingParameterName, new BoolValue(true)));
     148      if (!Parameters.ContainsKey(EnableSolutionCreatorTrackingParameterName))
     149        Parameters.Add(new ValueParameter<BoolValue>(EnableSolutionCreatorTrackingParameterName, new BoolValue(true)));
     150      // parameters required by the analyzer to do its work
     151      if (!Parameters.ContainsKey(GenerationsParameterName))
     152        Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
     153      if (!Parameters.ContainsKey(ResultsParameterName))
     154        Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
     155      if (!Parameters.ContainsKey(PopulationParameterName)) {
     156        PopulationParameter = new ScopeTreeLookupParameter<T>(PopulationParameterName);
     157        Parameters.Add(PopulationParameter);
     158      }
     159      if (!Parameters.ContainsKey(QualityParameterName)) {
     160        QualityParameter = new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName);
     161        Parameters.Add(QualityParameter);
     162      }
     163    }
    132164
    133165    public bool EnabledByDefault {
     
    146178        // at the beginning we add the before/after operators to the instrumented operators
    147179        if (EnableCrossoverTracking.Value) {
    148           if (afterCrossoverOperator == null) {
    149             afterCrossoverOperator = new AfterCrossoverOperator<T>();
    150             afterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
    151             afterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
    152           }
    153           var instrumentedCrossover = (InstrumentedOperator)Crossover;
    154           instrumentedCrossover.AfterExecutionOperators.Add(afterCrossoverOperator);
     180          if (BeforeCrossoverOperator != null) {
     181            BeforeCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
     182            BeforeCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
     183            var instrumentedCrossover = (InstrumentedOperator)Crossover;
     184            instrumentedCrossover.BeforeExecutionOperators.Add(BeforeCrossoverOperator);
     185          }
     186          if (AfterCrossoverOperator != null) {
     187            AfterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
     188            AfterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
     189            var instrumentedCrossover = (InstrumentedOperator)Crossover;
     190            instrumentedCrossover.AfterExecutionOperators.Add(AfterCrossoverOperator);
     191          }
    155192        }
    156193
    157194        if (EnableManipulatorTracking.Value && Manipulator != null) {
    158           if (beforeManipulatorOperator == null) {
    159             beforeManipulatorOperator = new BeforeManipulatorOperator<T>();
    160             beforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    161           }
    162           if (afterManipulatorOperator == null) {
    163             afterManipulatorOperator = new AfterManipulatorOperator<T>();
    164             afterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    165           }
    166           var instrumentedManipulator = (InstrumentedOperator)Manipulator;
    167           instrumentedManipulator.BeforeExecutionOperators.Add(beforeManipulatorOperator);
    168           instrumentedManipulator.AfterExecutionOperators.Add(afterManipulatorOperator);
     195          if (BeforeManipulatorOperator == null) {
     196            BeforeManipulatorOperator = new BeforeManipulatorOperator<T>();
     197            BeforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     198            var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     199            instrumentedManipulator.BeforeExecutionOperators.Add(BeforeManipulatorOperator);
     200          }
     201          if (AfterManipulatorOperator == null) {
     202            AfterManipulatorOperator = new AfterManipulatorOperator<T>();
     203            AfterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     204            var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     205            instrumentedManipulator.AfterExecutionOperators.Add(AfterManipulatorOperator);
     206          }
    169207        }
    170208      } else {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs

    r10302 r10347  
    7676  }
    7777
     78  [StorableClass]
     79  [Item("GenealogyGraph", "")]
     80  public class GenealogyGraph<T> : DirectedGraph, IGenealogyGraph<T> where T : class, IItem {
     81    [Storable]
     82    private Dictionary<double, LinkedList<IGenealogyGraphNode<T>>> ranks;
     83    public Dictionary<double, LinkedList<IGenealogyGraphNode<T>>> Ranks {
     84      get { return ranks; }
     85      set { ranks = value; }
     86    }
     87    protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner)
     88      : base(original, cloner) {
     89    }
     90    public override IDeepCloneable Clone(Cloner cloner) {
     91      return new GenealogyGraph<T>(this, cloner);
     92    }
     93    [StorableConstructor]
     94    protected GenealogyGraph(bool deserializing) : base(deserializing) { }
     95    public GenealogyGraph() {
     96      Ranks = new Dictionary<double, LinkedList<IGenealogyGraphNode<T>>>();
     97    }
     98    public override void AddVertex(IVertex vertex) {
     99      var node = (IGenealogyGraphNode<T>)vertex;
     100      if (!Ranks.ContainsKey(node.Rank))
     101        Ranks[node.Rank] = new LinkedList<IGenealogyGraphNode<T>>();
     102      Ranks[node.Rank].AddLast(node);
     103      base.AddVertex(vertex);
     104    }
     105    public override void RemoveVertex(IVertex vertex) {
     106      var node = (IGenealogyGraphNode<T>)vertex;
     107      if (Ranks.ContainsKey(node.Rank)) {
     108        Ranks[node.Rank].Remove(node);
     109      }
     110      base.RemoveVertex(vertex);
     111    }
     112    public event EventHandler GraphUpdated;
     113    private void OnGraphUpdated(object sender, EventArgs args) {
     114      var updated = GraphUpdated;
     115      if (updated != null) updated(sender, args);
     116    }
     117
     118    public new List<IGenealogyGraphNode<T>> this[object content] {
     119      get {
     120        var result = base[content];
     121        return result != null ? result.Cast<IGenealogyGraphNode<T>>().ToList() : null;
     122      }
     123    }
     124  }
    78125}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphArc.cs

    r10285 r10347  
    2626    new IGenealogyGraphNode Source { get; set; }
    2727    new IGenealogyGraphNode Target { get; set; }
     28    object Data { get; set; }
    2829  }
    2930
    3031  public interface IGenealogyGraphArc<T> : IGenealogyGraphArc where T : class, IItem {
    31     T Data { get; set; }
     32    new T Data { get; set; }
    3233  }
    3334}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/HeuristicLab.EvolutionTracking-3.4.csproj

    r10278 r10347  
    106106      <Private>False</Private>
    107107    </Reference>
    108     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    109       <Private>False</Private>
    110     </Reference>
    111     <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    112       <Private>False</Private>
    113     </Reference>
    114     <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    115       <Private>False</Private>
    116     </Reference>
    117108    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    118109      <SpecificVersion>False</SpecificVersion>
     
    138129    <Compile Include="DirectedGraph\Interfaces\IVertex.cs" />
    139130    <Compile Include="DirectedGraph\Vertex.cs" />
     131    <Compile Include="Fragment.cs" />
     132    <Compile Include="Interfaces\IFragment.cs" />
     133    <Compile Include="Operators\BeforeCrossoverOperator.cs" />
    140134    <Compile Include="Operators\AfterCrossoverOperator.cs" />
    141135    <Compile Include="Operators\AfterManipulatorOperator.cs" />
     
    143137    <Compile Include="Operators\BeforeManipulatorOperator.cs" />
    144138    <Compile Include="Operators\EvolutionTrackingOperator.cs" />
    145     <Compile Include="FPGraph.cs">
    146       <SubType>Code</SubType>
    147     </Compile>
    148139    <Compile Include="GenealogyGraph\GenealogyGraph.cs" />
    149140    <Compile Include="GenealogyGraph\GenealogyGraphArc.cs" />
     
    152143    <Compile Include="GenealogyGraph\Interfaces\IGenealogyGraphArc.cs" />
    153144    <Compile Include="GenealogyGraph\Interfaces\IGenealogyGraphNode.cs" />
     145    <Compile Include="Operators\Interfaces\IManipulatorOperator.cs" />
     146    <Compile Include="Operators\Interfaces\ICrossoverOperator.cs" />
    154147    <Compile Include="Plugin.cs">
    155148      <SubType>Code</SubType>
    156149    </Compile>
    157150    <Compile Include="Properties\AssemblyInfo.cs" />
    158     <Compile Include="SymbolGraph.cs">
    159       <SubType>Code</SubType>
    160     </Compile>
    161   </ItemGroup>
    162   <ItemGroup>
    163     <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    164       <Project>{06d4a186-9319-48a0-bade-a2058d462eea}</Project>
    165       <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
    166     </ProjectReference>
    167151  </ItemGroup>
    168152  <ItemGroup>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterCrossoverOperator.cs

    r10300 r10347  
    2020#endregion
    2121
    22 using System.Linq;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    2928  [StorableClass]
    3029  [Item("AfterCrossoverOperator", "A generic operator that can record genealogical relationships between crossover parents and children.")]
    31   public class AfterCrossoverOperator<T> : EvolutionTrackingOperator
    32     where T : class,IItem {
     30  public class AfterCrossoverOperator<T> : EvolutionTrackingOperator, ICrossoverOperator<T> where T : class,IItem {
    3331    private const string defaultParentsParameterName = "Parents";
    3432    private const string defaultChildParameterName = "Child";
    35     public IScopeTreeLookupParameter<T> ParentsParameter;
    36     public ILookupParameter<T> ChildParameter;
     33    public IScopeTreeLookupParameter<T> ParentsParameter { get; set; }
     34    public ILookupParameter<T> ChildParameter { get; set; }
    3735
    3836    protected AfterCrossoverOperator(AfterCrossoverOperator<T> original, Cloner cloner)
     
    5149
    5250    public override IOperation Apply() {
    53       //      var parentVertices = ParentsParameter.ActualValue.Select(x => GenealogyGraph[x].Last()).ToList();
    54       var lastGen = GenealogyGraph.Ranks[Generations.Value].ToList();
    55       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
    56 
    57       var childVertex = new GenealogyGraphNode<T> {
    58         Content = ChildParameter.ActualValue,
    59         Rank = parentVertices[0].Rank + 1
    60       };
    61       GenealogyGraph.AddVertex(childVertex);
    62       foreach (var v in parentVertices) {
    63         childVertex.AddReverseArc(v);
    64         v.AddForwardArc(childVertex);
    65       }
    66       //      if (parentVertices[0].Content == parentVertices[1].Content)
    67       //        throw new Exception("Self-crossover");
    6851      return base.Apply();
    6952    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterManipulatorOperator.cs

    r10300 r10347  
    2828  [StorableClass]
    2929  [Item("AfterCrossoverOperator", "Performs an action after the crossover operator is applied.")]
    30   public class AfterManipulatorOperator<T> : EvolutionTrackingOperator
    31     where T : class,IItem {
     30  public class AfterManipulatorOperator<T> : EvolutionTrackingOperator, IManipulatorOperator<T> where T : class,IItem {
    3231
    3332    private const string ChildParameterName = "Child";
    34     public ILookupParameter<T> ChildParameter;
     33    public ILookupParameter<T> ChildParameter { get; set; }
    3534
    3635    protected AfterManipulatorOperator(AfterManipulatorOperator<T> original, Cloner cloner)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterSolutionCreatorOperator.cs

    r10300 r10347  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Parameters;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2425
     
    2930    where T : class,IItem {
    3031
     32    private const string CurrentScopeParameterName = "CurrentScope";
     33
     34    public ScopeParameter CurrentScopeParameter {
     35      get { return (ScopeParameter)Parameters[CurrentScopeParameterName]; }
     36    }
     37    public IScope CurrentScope { get { return CurrentScopeParameter.ActualValue; } }
     38
    3139    public override IOperation Apply() {
    3240      return base.Apply();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs

    r10300 r10347  
    2929  [StorableClass]
    3030  [Item("AfterCrossoverOperator", "Performs an action after the crossover operator is applied.")]
    31   public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator
    32     where T : class,IItem {
     31  public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator, IManipulatorOperator<T> where T : class,IItem {
    3332
    3433    private const string ChildParameterName = "Child";
    35     public ILookupParameter<T> ChildParameter;
     34    public ILookupParameter<T> ChildParameter { get; set; }
    3635
    3736    protected BeforeManipulatorOperator(BeforeManipulatorOperator<T> original, Cloner cloner)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r10300 r10347  
    219219      <DependentUpon>SlidingWindowDataView.cs</DependentUpon>
    220220    </Compile>
     221    <Compile Include="SymbolicDataAnalysisGenealogyGraphView.cs">
     222      <SubType>UserControl</SubType>
     223    </Compile>
    221224    <Compile Include="TextualSymbolicDataAnalysisModelView.cs">
    222225      <SubType>UserControl</SubType>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/MultiSymbolicDataAnalysisExpressionCrossover.cs

    r9456 r10347  
    109109      InitializeOperators();
    110110      name = "MultiSymbolicDataAnalysisExpressionCrossover";
     111
     112      SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator";
    111113    }
    112114
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r10302 r10347  
    174174  <ItemGroup>
    175175    <Compile Include="Analyzers\SymbolicDataAnalysisGenealogyAnalyzer.cs" />
     176    <Compile Include="Analyzers\SymbolicDataAnalysisPopulationDiversityAnalyzer.cs" />
    176177    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" />
    177178    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs" />
     
    193194    <Compile Include="SlidingWindow\SlidingWindowQualitiesAnalyzer.cs" />
    194195    <Compile Include="SlidingWindow\SlidingWindowVisualizer.cs" />
     196    <Compile Include="SymbolGraph\FPGraph.cs" />
     197    <Compile Include="SymbolGraph\SymbolGraph.cs" />
    195198    <Compile Include="SymbolicDataAnalysisExpressionTreeMatching.cs" />
    196199    <Compile Include="SymbolicDataAnalysisExpressionTreeSimilarityCalculator.cs" />
     
    290293    <Compile Include="Symbols\VariableConditionTreeNode.cs" />
    291294    <Compile Include="Symbols\VariableTreeNode.cs" />
     295    <Compile Include="Tracking\SymbolicDataAnalysExpressionAfterCrossoverOperator.cs" />
     296    <Compile Include="Tracking\SymbolicDataAnalysExpressionBeforeCrossoverOperator.cs" />
     297    <Compile Include="Tracking\SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs" />
     298    <Compile Include="Tracking\SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs" />
    292299    <None Include="HeuristicLab.snk" />
    293300    <None Include="Plugin.cs.frame" />
     
    335342    </ProjectReference>
    336343  </ItemGroup>
    337   <ItemGroup>
    338     <Folder Include="Tracking\" />
    339   </ItemGroup>
     344  <ItemGroup />
    340345  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    341346  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowQualitiesAnalyzer.cs

    r10269 r10347  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    25 using System.Text;
    26 using System.Threading;
    2723using HeuristicLab.Analysis;
    2824using HeuristicLab.Common;
    2925using HeuristicLab.Core;
    3026using HeuristicLab.Data;
    31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3227using HeuristicLab.Optimization;
    3328using HeuristicLab.Parameters;
     
    5853    }
    5954
    60     public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreter
    61     {
    62       get  {return(ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
     55    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreter {
     56      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
    6357    }
    6458
     
    7064    }
    7165
    72    
     66
    7367
    7468    [StorableConstructor]
    7569    private SlidingWindowQualitiesAnalyzer(bool deserializing) : base(deserializing) { }
    7670
    77     public SlidingWindowQualitiesAnalyzer() { 
     71    public SlidingWindowQualitiesAnalyzer() {
    7872      Parameters.Add(new ValueLookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    7973      Parameters.Add(new LookupParameter<IEvaluator>(EvaluatorParameterName, ""));
     
    8175      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, ""));
    8276
    83       ProblemDataParameter.Hidden = true;}
     77      ProblemDataParameter.Hidden = true;
     78    }
    8479
    8580    [StorableHook(HookType.AfterDeserialization)]
     
    8782    }
    8883
    89     public override IOperation Apply()
    90     {
     84    public override IOperation Apply() {
    9185      if (FitnessCalculationPartitionParameter.ActualValue == null)
    9286        // do nothing because the sliding window hasn't been initialized yet
     
    9791      if (!results.ContainsKey("Best training solution")) return base.Apply();
    9892
    99       var problemData = (IRegressionProblemData) ProblemDataParameter.ActualValue;
     93      var problemData = (IRegressionProblemData)ProblemDataParameter.ActualValue;
    10094      var evaluator =
    101         (SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>) EvaluatorParameter.ActualValue;
     95        (SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>)EvaluatorParameter.ActualValue;
    10296      var context = new Core.ExecutionContext(ExecutionContext, evaluator, new Scope());
    10397      var fitnessCalculationPartition = FitnessCalculationPartitionParameter.ActualValue;
    10498
    105       var bestSolution = (ISymbolicDataAnalysisSolution) results["Best training solution"].Value;
     99      var bestSolution = (ISymbolicDataAnalysisSolution)results["Best training solution"].Value;
    106100      var bestModel = bestSolution.Model;
    107101      var bestTree = bestModel.SymbolicExpressionTree;
     
    110104        results.Add(new Result(SlidingWindowQualitiesResultName, new DataTable(SlidingWindowQualitiesResultName)));
    111105      }
    112       var swQualitiesTable = (DataTable) results[SlidingWindowQualitiesResultName].Value;
     106      var swQualitiesTable = (DataTable)results[SlidingWindowQualitiesResultName].Value;
    113107
    114108      // compute before quality
    115109      var beforeQuality = 0.0;
    116110      if (!swQualitiesTable.Rows.ContainsKey("Before Quality"))
    117         swQualitiesTable.Rows.Add(new DataRow("Before Quality") {VisualProperties = {StartIndexZero = true}});
    118       if (fitnessCalculationPartition.Start > problemData.TrainingPartition.Start)
    119       {
     111        swQualitiesTable.Rows.Add(new DataRow("Before Quality") { VisualProperties = { StartIndexZero = true } });
     112      if (fitnessCalculationPartition.Start > problemData.TrainingPartition.Start) {
    120113        var beforeRange = new IntRange(problemData.TrainingPartition.Start, fitnessCalculationPartition.Start);
    121114        beforeQuality = evaluator.Evaluate(context, bestTree, problemData, Enumerable.Range(beforeRange.Start, beforeRange.Size));
     
    124117
    125118      // compute current quality
    126       var currentQuality = ((DoubleValue) results["CurrentBestQuality"].Value).Value;
     119      var currentQuality = ((DoubleValue)results["CurrentBestQuality"].Value).Value;
    127120      if (!swQualitiesTable.Rows.ContainsKey("Current Quality"))
    128         swQualitiesTable.Rows.Add(new DataRow("Current Quality") {VisualProperties = {StartIndexZero = true}});
     121        swQualitiesTable.Rows.Add(new DataRow("Current Quality") { VisualProperties = { StartIndexZero = true } });
    129122      swQualitiesTable.Rows["Current Quality"].Values.Add(currentQuality);
    130123
    131124      // compute after quality
    132       if (fitnessCalculationPartition.End < problemData.TrainingPartition.End)
    133       {
     125      if (fitnessCalculationPartition.End < problemData.TrainingPartition.End) {
    134126        var afterRange = new IntRange(fitnessCalculationPartition.End, problemData.TrainingPartition.End);
    135127        var afterQuality = evaluator.Evaluate(context, bestTree, problemData,
    136128          Enumerable.Range(afterRange.Start, afterRange.Size));
    137129        if (!swQualitiesTable.Rows.ContainsKey("After Quality"))
    138           swQualitiesTable.Rows.Add(new DataRow("After Quality") {VisualProperties = {StartIndexZero = true}});
     130          swQualitiesTable.Rows.Add(new DataRow("After Quality") { VisualProperties = { StartIndexZero = true } });
    139131        swQualitiesTable.Rows["After Quality"].Values.Add(afterQuality);
    140132      }
    141133      // compute test quality
    142134      if (!swQualitiesTable.Rows.ContainsKey("Test Quality"))
    143         swQualitiesTable.Rows.Add(new DataRow("Test Quality") {VisualProperties = {StartIndexZero = true}});
    144       var regressionSolution = (IRegressionSolution) bestSolution;
     135        swQualitiesTable.Rows.Add(new DataRow("Test Quality") { VisualProperties = { StartIndexZero = true } });
     136      var regressionSolution = (IRegressionSolution)bestSolution;
    145137      swQualitiesTable.Rows["Test Quality"].Values.Add(regressionSolution.TestRSquared);
    146138      return base.Apply();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeMatching.cs

    r10302 r10347  
    55using HeuristicLab.Core;
    66using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     7using HeuristicLab.EvolutionTracking;
    78using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    89using HeuristicLab.Problems.DataAnalysis.Symbolic;
     
    7980  }
    8081
    81   public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment> {
     82  public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment<ISymbolicExpressionTreeNode>> {
    8283    public SymbolicExpressionTreeNodeSimilarityComparer SimilarityComparer { get; set; }
    8384
    84     public bool Equals(IFragment x, IFragment y) {
     85    public bool Equals(IFragment<ISymbolicExpressionTreeNode> x, IFragment<ISymbolicExpressionTreeNode> y) {
    8586      if (SimilarityComparer == null)
    8687        throw new ArgumentNullException("SimilarityComparer needs to be initialized first.");
    87       return x.Length == y.Length && SymbolicExpressionTreeMatching.Match(x.Root, y.Root, SimilarityComparer) == x.Length;
    88     }
    89 
    90     public int GetHashCode(IFragment fragment) {
     88      return x.Root.GetLength() == y.Root.GetLength() && SymbolicExpressionTreeMatching.Match(x.Root, y.Root, SimilarityComparer) == x.Root.GetLength();
     89    }
     90
     91    public int GetHashCode(IFragment<ISymbolicExpressionTreeNode> fragment) {
    9192      return fragment.Root.Symbol.Name.ToLower().GetHashCode();
    9293    }
     
    162163
    163164public static class SymbolicExpressionTreeMatching {
    164   public static bool ContainsFragment(this ISymbolicExpressionTreeNode root, IFragment fragment, SymbolicExpressionTreeNodeSimilarityComparer comparer) {
     165  public static bool ContainsFragment(this ISymbolicExpressionTreeNode root, IFragment<ISymbolicExpressionTreeNode> fragment, SymbolicExpressionTreeNodeSimilarityComparer comparer) {
    165166    return FindMatches(root, fragment.Root, comparer).Any();
    166167  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r10293 r10347  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     30using HeuristicLab.EvolutionTracking;
    3031using HeuristicLab.Optimization;
    3132using HeuristicLab.Parameters;
     
    355356      // add tracking analyzer
    356357      foreach (var op in operators.OfType<SymbolicDataAnalysisGenealogyAnalyzer>()) {
     358        //        op.BeforeCrossoverOperator = new SymbolicDataAnalysExpressionBeforeCrossoverOperator();
     359        //        op.AfterCrossoverOperator = new SymbolicDataAnalysExpressionAfterCrossoverOperator();
     360        op.BeforeCrossoverOperator = new BeforeCrossoverOperator<ISymbolicExpressionTree>();
     361        op.AfterCrossoverOperator = new AfterCrossoverOperator<ISymbolicExpressionTree>();
     362        op.BeforeManipulatorOperator = new BeforeManipulatorOperator<ISymbolicExpressionTree>();
     363        op.AfterManipulatorOperator = new AfterManipulatorOperator<ISymbolicExpressionTree>();
    357364        // get crossover parameter names
    358         var crossover = operators.OfType<ISymbolicExpressionTreeCrossover>().First();
    359         op.CrossoverParentsParameterName = crossover.ParentsParameter.Name;
    360         op.CrossoverChildParameterName = crossover.ChildParameter.Name;
     365        var crossover = operators.OfType<ISymbolicExpressionTreeCrossover>().FirstOrDefault();
     366        if (crossover != null) {
     367          op.CrossoverParentsParameterName = crossover.ParentsParameter.Name;
     368          op.CrossoverChildParameterName = crossover.ChildParameter.Name;
     369        }
    361370        // get munipulator parameter names
    362         var manipulator = operators.OfType<ISymbolicExpressionTreeManipulator>().First();
    363         op.ManipulatorChildParameterName = manipulator.SymbolicExpressionTreeParameter.Name;
     371        var manipulator = operators.OfType<ISymbolicExpressionTreeManipulator>().FirstOrDefault();
     372        if (manipulator != null) {
     373          op.ManipulatorChildParameterName = manipulator.SymbolicExpressionTreeParameter.Name;
     374        }
    364375      }
    365376    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r10300 r10347  
    2929using HeuristicLab.Data;
    3030using HeuristicLab.Encodings.PermutationEncoding;
     31using HeuristicLab.EvolutionTracking;
    3132using HeuristicLab.Optimization;
    3233using HeuristicLab.Parameters;
     
    386387      if (TSPGenealogyAnalyzer != null) {
    387388        if (TSPCrossover != null) {
     389          TSPGenealogyAnalyzer.BeforeCrossoverOperator = new BeforeCrossoverOperator<Permutation>();
     390          TSPGenealogyAnalyzer.AfterCrossoverOperator = new AfterCrossoverOperator<Permutation>();
    388391          TSPGenealogyAnalyzer.CrossoverParentsParameterName = TSPCrossover.ParentsParameter.Name;
    389392          TSPGenealogyAnalyzer.CrossoverChildParameterName = TSPCrossover.ChildParameter.Name;
    390393        }
    391394        if (TSPManipulator != null) {
     395          TSPGenealogyAnalyzer.BeforeManipulatorOperator = new BeforeManipulatorOperator<Permutation>();
     396          TSPGenealogyAnalyzer.AfterManipulatorOperator = new AfterManipulatorOperator<Permutation>();
    392397          TSPGenealogyAnalyzer.ManipulatorChildParameterName = TSPManipulator.PermutationParameter.Name;
    393398        }
Note: See TracChangeset for help on using the changeset viewer.