Changeset 10347 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 01/16/14 16:37:56 (11 years ago)
- 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 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Core.Views; … … 52 53 symbolicExpressionTreeChart.Enabled = Content != null; 53 54 } 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 } 54 63 } 55 64 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r10302 r10347 168 168 } 169 169 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 170 182 private void GenerateImage() { 171 183 using (Graphics graphics = Graphics.FromImage(image)) { … … 267 279 #region methods for painting the symbolic expression tree 268 280 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(); 271 283 layoutEngine.Reset(); 272 284 layoutEngine.Root = layoutNodes[0]; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
r10302 r10347 187 187 <Compile Include="Formatters\SymbolicExpressionTreeGraphvizFormatter.cs" /> 188 188 <Compile Include="Formatters\SymbolicExpressionTreeLatexFormatter.cs" /> 189 <Compile Include="Interfaces\IFragment.cs" />190 189 <Compile Include="Interfaces\ILayoutAdapter.cs" /> 191 190 <Compile Include="Interfaces\ILayoutNode.cs" /> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.Designer.cs
r10302 r10347 121 121 #endregion 122 122 123 pr ivateSystem.Windows.Forms.SplitContainer splitContainer;124 pr ivateMainForm.WindowsForms.ViewHost viewHost;125 pr ivateSystem.Windows.Forms.Panel panel1;126 pr ivateSystem.Windows.Forms.Panel panel2;127 pr ivateGenealogyGraphChart 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; 128 128 129 129 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs
r10302 r10347 7 7 [View("GenealogyGraphView")] 8 8 [Content(typeof(GenealogyGraph), IsDefaultView = false)] 9 public sealedpartial class GenealogyGraphView : ItemView {9 public partial class GenealogyGraphView : ItemView { 10 10 public new IGenealogyGraph Content { 11 11 get { return (IGenealogyGraph)base.Content; } … … 31 31 #region Event Handlers (Content) 32 32 33 public v oid graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {33 public virtual void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) { 34 34 var content = ((VisualGenealogyGraphNode)sender).Data.Content; 35 35 if (content != null) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj
r10302 r10347 161 161 </ItemGroup> 162 162 <ItemGroup> 163 <EmbeddedResource Include="GenealogyGraphView.resx">164 <DependentUpon>GenealogyGraphView.cs</DependentUpon>165 </EmbeddedResource>166 163 <EmbeddedResource Include="Properties\Resources.resx"> 167 164 <Generator>ResXFileCodeGenerator</Generator> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r10300 r10347 15 15 where T : class,IItem { 16 16 17 private AfterCrossoverOperator<T> afterCrossoverOperator;18 private AfterManipulatorOperator<T> afterManipulatorOperator;19 private BeforeManipulatorOperator<T> beforeManipulatorOperator;20 17 public string CrossoverParentsParameterName { get; set; } 21 18 public string CrossoverChildParameterName { get; set; } … … 24 21 public IScopeTreeLookupParameter<DoubleValue> QualityParameter; 25 22 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; } 26 28 27 29 private const string PopulationParameterName = "Population"; … … 130 132 : base(original, cloner) { 131 133 } 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 } 132 164 133 165 public bool EnabledByDefault { … … 146 178 // at the beginning we add the before/after operators to the instrumented operators 147 179 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 } 155 192 } 156 193 157 194 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 } 169 207 } 170 208 } else { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r10302 r10347 76 76 } 77 77 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 } 78 125 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraphArc.cs
r10285 r10347 26 26 new IGenealogyGraphNode Source { get; set; } 27 27 new IGenealogyGraphNode Target { get; set; } 28 object Data { get; set; } 28 29 } 29 30 30 31 public interface IGenealogyGraphArc<T> : IGenealogyGraphArc where T : class, IItem { 31 T Data { get; set; }32 new T Data { get; set; } 32 33 } 33 34 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/HeuristicLab.EvolutionTracking-3.4.csproj
r10278 r10347 106 106 <Private>False</Private> 107 107 </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>117 108 <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 118 109 <SpecificVersion>False</SpecificVersion> … … 138 129 <Compile Include="DirectedGraph\Interfaces\IVertex.cs" /> 139 130 <Compile Include="DirectedGraph\Vertex.cs" /> 131 <Compile Include="Fragment.cs" /> 132 <Compile Include="Interfaces\IFragment.cs" /> 133 <Compile Include="Operators\BeforeCrossoverOperator.cs" /> 140 134 <Compile Include="Operators\AfterCrossoverOperator.cs" /> 141 135 <Compile Include="Operators\AfterManipulatorOperator.cs" /> … … 143 137 <Compile Include="Operators\BeforeManipulatorOperator.cs" /> 144 138 <Compile Include="Operators\EvolutionTrackingOperator.cs" /> 145 <Compile Include="FPGraph.cs">146 <SubType>Code</SubType>147 </Compile>148 139 <Compile Include="GenealogyGraph\GenealogyGraph.cs" /> 149 140 <Compile Include="GenealogyGraph\GenealogyGraphArc.cs" /> … … 152 143 <Compile Include="GenealogyGraph\Interfaces\IGenealogyGraphArc.cs" /> 153 144 <Compile Include="GenealogyGraph\Interfaces\IGenealogyGraphNode.cs" /> 145 <Compile Include="Operators\Interfaces\IManipulatorOperator.cs" /> 146 <Compile Include="Operators\Interfaces\ICrossoverOperator.cs" /> 154 147 <Compile Include="Plugin.cs"> 155 148 <SubType>Code</SubType> 156 149 </Compile> 157 150 <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>167 151 </ItemGroup> 168 152 <ItemGroup> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterCrossoverOperator.cs
r10300 r10347 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 29 28 [StorableClass] 30 29 [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 { 33 31 private const string defaultParentsParameterName = "Parents"; 34 32 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; } 37 35 38 36 protected AfterCrossoverOperator(AfterCrossoverOperator<T> original, Cloner cloner) … … 51 49 52 50 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 graph56 57 var childVertex = new GenealogyGraphNode<T> {58 Content = ChildParameter.ActualValue,59 Rank = parentVertices[0].Rank + 160 };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");68 51 return base.Apply(); 69 52 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterManipulatorOperator.cs
r10300 r10347 28 28 [StorableClass] 29 29 [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 { 32 31 33 32 private const string ChildParameterName = "Child"; 34 public ILookupParameter<T> ChildParameter ;33 public ILookupParameter<T> ChildParameter { get; set; } 35 34 36 35 protected AfterManipulatorOperator(AfterManipulatorOperator<T> original, Cloner cloner) -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterSolutionCreatorOperator.cs
r10300 r10347 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Parameters; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 29 30 where T : class,IItem { 30 31 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 31 39 public override IOperation Apply() { 32 40 return base.Apply(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs
r10300 r10347 29 29 [StorableClass] 30 30 [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 { 33 32 34 33 private const string ChildParameterName = "Child"; 35 public ILookupParameter<T> ChildParameter ;34 public ILookupParameter<T> ChildParameter { get; set; } 36 35 37 36 protected BeforeManipulatorOperator(BeforeManipulatorOperator<T> original, Cloner cloner) -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 10346
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r10300 r10347 219 219 <DependentUpon>SlidingWindowDataView.cs</DependentUpon> 220 220 </Compile> 221 <Compile Include="SymbolicDataAnalysisGenealogyGraphView.cs"> 222 <SubType>UserControl</SubType> 223 </Compile> 221 224 <Compile Include="TextualSymbolicDataAnalysisModelView.cs"> 222 225 <SubType>UserControl</SubType> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/MultiSymbolicDataAnalysisExpressionCrossover.cs
r9456 r10347 109 109 InitializeOperators(); 110 110 name = "MultiSymbolicDataAnalysisExpressionCrossover"; 111 112 SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator"; 111 113 } 112 114 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r10302 r10347 174 174 <ItemGroup> 175 175 <Compile Include="Analyzers\SymbolicDataAnalysisGenealogyAnalyzer.cs" /> 176 <Compile Include="Analyzers\SymbolicDataAnalysisPopulationDiversityAnalyzer.cs" /> 176 177 <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" /> 177 178 <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs" /> … … 193 194 <Compile Include="SlidingWindow\SlidingWindowQualitiesAnalyzer.cs" /> 194 195 <Compile Include="SlidingWindow\SlidingWindowVisualizer.cs" /> 196 <Compile Include="SymbolGraph\FPGraph.cs" /> 197 <Compile Include="SymbolGraph\SymbolGraph.cs" /> 195 198 <Compile Include="SymbolicDataAnalysisExpressionTreeMatching.cs" /> 196 199 <Compile Include="SymbolicDataAnalysisExpressionTreeSimilarityCalculator.cs" /> … … 290 293 <Compile Include="Symbols\VariableConditionTreeNode.cs" /> 291 294 <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" /> 292 299 <None Include="HeuristicLab.snk" /> 293 300 <None Include="Plugin.cs.frame" /> … … 335 342 </ProjectReference> 336 343 </ItemGroup> 337 <ItemGroup> 338 <Folder Include="Tracking\" /> 339 </ItemGroup> 344 <ItemGroup /> 340 345 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 341 346 <!-- 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 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.Linq; 25 using System.Text;26 using System.Threading;27 23 using HeuristicLab.Analysis; 28 24 using HeuristicLab.Common; 29 25 using HeuristicLab.Core; 30 26 using HeuristicLab.Data; 31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;32 27 using HeuristicLab.Optimization; 33 28 using HeuristicLab.Parameters; … … 58 53 } 59 54 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]; } 63 57 } 64 58 … … 70 64 } 71 65 72 66 73 67 74 68 [StorableConstructor] 75 69 private SlidingWindowQualitiesAnalyzer(bool deserializing) : base(deserializing) { } 76 70 77 public SlidingWindowQualitiesAnalyzer() { 71 public SlidingWindowQualitiesAnalyzer() { 78 72 Parameters.Add(new ValueLookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 79 73 Parameters.Add(new LookupParameter<IEvaluator>(EvaluatorParameterName, "")); … … 81 75 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "")); 82 76 83 ProblemDataParameter.Hidden = true;} 77 ProblemDataParameter.Hidden = true; 78 } 84 79 85 80 [StorableHook(HookType.AfterDeserialization)] … … 87 82 } 88 83 89 public override IOperation Apply() 90 { 84 public override IOperation Apply() { 91 85 if (FitnessCalculationPartitionParameter.ActualValue == null) 92 86 // do nothing because the sliding window hasn't been initialized yet … … 97 91 if (!results.ContainsKey("Best training solution")) return base.Apply(); 98 92 99 var problemData = (IRegressionProblemData) 93 var problemData = (IRegressionProblemData)ProblemDataParameter.ActualValue; 100 94 var evaluator = 101 (SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>) 95 (SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>)EvaluatorParameter.ActualValue; 102 96 var context = new Core.ExecutionContext(ExecutionContext, evaluator, new Scope()); 103 97 var fitnessCalculationPartition = FitnessCalculationPartitionParameter.ActualValue; 104 98 105 var bestSolution = (ISymbolicDataAnalysisSolution) 99 var bestSolution = (ISymbolicDataAnalysisSolution)results["Best training solution"].Value; 106 100 var bestModel = bestSolution.Model; 107 101 var bestTree = bestModel.SymbolicExpressionTree; … … 110 104 results.Add(new Result(SlidingWindowQualitiesResultName, new DataTable(SlidingWindowQualitiesResultName))); 111 105 } 112 var swQualitiesTable = (DataTable) 106 var swQualitiesTable = (DataTable)results[SlidingWindowQualitiesResultName].Value; 113 107 114 108 // compute before quality 115 109 var beforeQuality = 0.0; 116 110 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) { 120 113 var beforeRange = new IntRange(problemData.TrainingPartition.Start, fitnessCalculationPartition.Start); 121 114 beforeQuality = evaluator.Evaluate(context, bestTree, problemData, Enumerable.Range(beforeRange.Start, beforeRange.Size)); … … 124 117 125 118 // compute current quality 126 var currentQuality = ((DoubleValue) 119 var currentQuality = ((DoubleValue)results["CurrentBestQuality"].Value).Value; 127 120 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 } }); 129 122 swQualitiesTable.Rows["Current Quality"].Values.Add(currentQuality); 130 123 131 124 // compute after quality 132 if (fitnessCalculationPartition.End < problemData.TrainingPartition.End) 133 { 125 if (fitnessCalculationPartition.End < problemData.TrainingPartition.End) { 134 126 var afterRange = new IntRange(fitnessCalculationPartition.End, problemData.TrainingPartition.End); 135 127 var afterQuality = evaluator.Evaluate(context, bestTree, problemData, 136 128 Enumerable.Range(afterRange.Start, afterRange.Size)); 137 129 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 } }); 139 131 swQualitiesTable.Rows["After Quality"].Values.Add(afterQuality); 140 132 } 141 133 // compute test quality 142 134 if (!swQualitiesTable.Rows.ContainsKey("Test Quality")) 143 swQualitiesTable.Rows.Add(new DataRow("Test Quality") { VisualProperties = {StartIndexZero = true}});144 var regressionSolution = (IRegressionSolution) 135 swQualitiesTable.Rows.Add(new DataRow("Test Quality") { VisualProperties = { StartIndexZero = true } }); 136 var regressionSolution = (IRegressionSolution)bestSolution; 145 137 swQualitiesTable.Rows["Test Quality"].Values.Add(regressionSolution.TestRSquared); 146 138 return base.Apply(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeMatching.cs
r10302 r10347 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 7 using HeuristicLab.EvolutionTracking; 7 8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 9 using HeuristicLab.Problems.DataAnalysis.Symbolic; … … 79 80 } 80 81 81 public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment > {82 public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment<ISymbolicExpressionTreeNode>> { 82 83 public SymbolicExpressionTreeNodeSimilarityComparer SimilarityComparer { get; set; } 83 84 84 public bool Equals(IFragment x, IFragmenty) {85 public bool Equals(IFragment<ISymbolicExpressionTreeNode> x, IFragment<ISymbolicExpressionTreeNode> y) { 85 86 if (SimilarityComparer == null) 86 87 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) { 91 92 return fragment.Root.Symbol.Name.ToLower().GetHashCode(); 92 93 } … … 162 163 163 164 public 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) { 165 166 return FindMatches(root, fragment.Root, comparer).Any(); 166 167 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r10293 r10347 28 28 using HeuristicLab.Data; 29 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HeuristicLab.EvolutionTracking; 30 31 using HeuristicLab.Optimization; 31 32 using HeuristicLab.Parameters; … … 355 356 // add tracking analyzer 356 357 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>(); 357 364 // 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 } 361 370 // 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 } 364 375 } 365 376 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r10300 r10347 29 29 using HeuristicLab.Data; 30 30 using HeuristicLab.Encodings.PermutationEncoding; 31 using HeuristicLab.EvolutionTracking; 31 32 using HeuristicLab.Optimization; 32 33 using HeuristicLab.Parameters; … … 386 387 if (TSPGenealogyAnalyzer != null) { 387 388 if (TSPCrossover != null) { 389 TSPGenealogyAnalyzer.BeforeCrossoverOperator = new BeforeCrossoverOperator<Permutation>(); 390 TSPGenealogyAnalyzer.AfterCrossoverOperator = new AfterCrossoverOperator<Permutation>(); 388 391 TSPGenealogyAnalyzer.CrossoverParentsParameterName = TSPCrossover.ParentsParameter.Name; 389 392 TSPGenealogyAnalyzer.CrossoverChildParameterName = TSPCrossover.ChildParameter.Name; 390 393 } 391 394 if (TSPManipulator != null) { 395 TSPGenealogyAnalyzer.BeforeManipulatorOperator = new BeforeManipulatorOperator<Permutation>(); 396 TSPGenealogyAnalyzer.AfterManipulatorOperator = new AfterManipulatorOperator<Permutation>(); 392 397 TSPGenealogyAnalyzer.ManipulatorChildParameterName = TSPManipulator.PermutationParameter.Name; 393 398 }
Note: See TracChangeset
for help on using the changeset viewer.