Changeset 6233
- Timestamp:
- 05/19/11 13:52:12 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/Cloner.cs
r5445 r6233 41 41 /// <param name="item">The object which should be cloned.</param> 42 42 /// <returns>A clone of the given object.</returns> 43 public IDeepCloneable Clone(IDeepCloneable obj) {44 if (obj == null) return null;45 IDeepCloneable clone;46 if (mapping.TryGetValue(obj, out clone))47 return clone;48 else49 return obj.Clone(this);50 }51 /// <summary>52 /// Creates a deep clone of a given deeply cloneable object.53 /// </summary>54 /// <param name="item">The object which should be cloned.</param>55 /// <returns>A clone of the given object.</returns>56 43 public T Clone<T>(T obj) where T : class, IDeepCloneable { 57 44 if (obj == null) return null; -
trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemCollectionView.cs
r5445 r6233 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Collections; … … 49 50 } 50 51 52 private Color backupColor = Color.Empty; 51 53 protected override void SetEnabledStateOfControls() { 54 if (backupColor == Color.Empty) backupColor = base.itemsListView.BackColor; 52 55 base.SetEnabledStateOfControls(); 53 base.itemsListView.Enabled = !this.Locked; 56 if (ReadOnly || Locked) 57 base.itemsListView.BackColor = ListView.DefaultBackColor; 58 else 59 base.itemsListView.BackColor = backupColor; 54 60 } 55 61 … … 70 76 bool check = e.NewValue == CheckState.Checked; 71 77 if (Content.ItemChecked(checkedItem) != check) { 72 Content.SetItemCheckedState(checkedItem, check); 78 if (!ReadOnly && !Locked) Content.SetItemCheckedState(checkedItem, check); 79 else e.NewValue = e.CurrentValue; 73 80 } 74 81 } -
trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemListView.cs
r5445 r6233 20 20 #endregion 21 21 22 using System.Drawing; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.Collections; … … 51 52 } 52 53 54 private Color backupColor = Color.Empty; 53 55 protected override void SetEnabledStateOfControls() { 56 if(backupColor == Color.Empty) backupColor = base.itemsListView.BackColor; 54 57 base.SetEnabledStateOfControls(); 55 base.itemsListView.Enabled = !this.Locked; 58 if (ReadOnly || Locked) 59 base.itemsListView.BackColor = ListView.DefaultBackColor; 60 else 61 base.itemsListView.BackColor = backupColor; 56 62 } 57 63 … … 72 78 bool check = e.NewValue == CheckState.Checked; 73 79 if (Content.ItemChecked(checkedItem) != check) { 74 Content.SetItemCheckedState(checkedItem, check); 80 if (!ReadOnly && !Locked) Content.SetItemCheckedState(checkedItem, check); 81 else e.NewValue = e.CurrentValue; 75 82 } 76 83 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs
r6109 r6233 21 21 22 22 using System; 23 using System.ComponentModel; 23 24 using System.Windows.Forms; 24 25 using HeuristicLab.Core.Views; 25 26 using HeuristicLab.MainForm; 26 27 using HeuristicLab.MainForm.WindowsForms; 27 using System.ComponentModel;28 28 29 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 91 91 if (double.TryParse(initialFrequencyTextBox.Text, out freq) && freq >= 0.0) { 92 92 Content.InitialFrequency = freq; 93 } 93 } 94 94 } 95 95 #endregion -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarView.cs
r5809 r6233 39 39 } 40 40 41 public override bool ReadOnly { 42 get { 43 if ((Content != null) && Content.ReadOnly) return true; 44 return base.ReadOnly; 45 } 46 set { 47 if ((Content != null) && Content.ReadOnly) base.ReadOnly = true; 48 else base.ReadOnly = value; 49 } 50 } 51 41 52 public SymbolicExpressionGrammarView() { 42 53 InitializeComponent(); 43 54 symbols = new CheckedItemList<ISymbol>(); 44 55 symbols.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<ISymbol>>(symbols_CheckedItemsChanged); 56 } 57 58 protected override void RegisterContentEvents() { 59 base.RegisterContentEvents(); 60 Content.ReadOnlyChanged += new EventHandler(Content_ReadOnlyChanged); 61 } 62 protected override void DeregisterContentEvents() { 63 base.DeregisterContentEvents(); 64 Content.ReadOnlyChanged -= new EventHandler(Content_ReadOnlyChanged); 45 65 } 46 66 … … 50 70 } 51 71 52 protected override void SetEnabledStateOfControls() { 53 base.SetEnabledStateOfControls(); 54 checkedItemListView.Enabled = Content != null; 55 checkedItemListView.ReadOnly = ReadOnly; 72 private void Content_ReadOnlyChanged(object sender, EventArgs e) { 73 ReadOnly = Content.ReadOnly; 56 74 } 57 75 … … 69 87 } else { 70 88 ClearSymbols(); 71 foreach ( Symbol symbol in Content.Symbols) {89 foreach (ISymbol symbol in Content.Symbols) { 72 90 if (!(symbol is IReadOnlySymbol)) { 73 91 symbol.Changed += new EventHandler(symbol_Changed); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs
r5809 r6233 83 83 subtree.Grammar.SetSubtreeCount(invokeSymbol, duplicatedDefunBranch.NumberOfArguments, duplicatedDefunBranch.NumberOfArguments); 84 84 85 foreach ( Symbol symbol in subtree.Grammar.Symbols) {85 foreach (ISymbol symbol in subtree.Grammar.Symbols) { 86 86 if (subtree.Grammar.IsAllowedChildSymbol(symbol, matchingInvokeSymbol)) 87 87 subtree.Grammar.AddAllowedChildSymbol(symbol, invokeSymbol); … … 93 93 } 94 94 95 foreach ( Symbol symbol in subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol))95 foreach (ISymbol symbol in subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol)) 96 96 if (symbol != invokeSymbol) //avoid duplicate entry invokesymbol / invokesymbol 97 97 subtree.Grammar.AddAllowedChildSymbol(invokeSymbol, symbol); 98 98 for (int i = 0; i < subtree.Grammar.GetMaximumSubtreeCount(matchingInvokeSymbol); i++) { 99 foreach ( Symbol symbol in subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol, i).Except(subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol)))99 foreach (ISymbol symbol in subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol, i).Except(subtree.Grammar.GetAllowedChildSymbols(matchingInvokeSymbol))) 100 100 subtree.Grammar.AddAllowedChildSymbol(invokeSymbol, symbol, i); 101 101 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r6009 r6233 38 38 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; 39 39 private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar"; 40 private const string ClonedSymbolicExpressionTreeGrammarParameterName = "ClonedSymbolicExpressionTreeGrammar"; 40 41 #region Parameter Properties 41 42 public IValueLookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter { … … 47 48 public IValueLookupParameter<ISymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { 48 49 get { return (IValueLookupParameter<ISymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; } 50 } 51 public ILookupParameter<ISymbolicExpressionGrammar> ClonedSymbolicExpressionTreeGrammarParameter { 52 get { return (ILookupParameter<ISymbolicExpressionGrammar>)Parameters[ClonedSymbolicExpressionTreeGrammarParameterName]; } 49 53 } 50 54 #endregion … … 57 61 } 58 62 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 59 get { return SymbolicExpressionTreeGrammarParameter.ActualValue; }63 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } 60 64 } 61 65 #endregion … … 69 73 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0).")); 70 74 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, "The tree grammar that defines the correct syntax of symbolic expression trees that should be created.")); 75 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 71 76 } 72 77 … … 74 79 return new ProbabilisticTreeCreator(this, cloner); 75 80 } 81 [StorableHook(HookType.AfterDeserialization)] 82 private void AfterDeserialization() { 83 if (!Parameters.ContainsKey(ClonedSymbolicExpressionTreeGrammarParameterName)) 84 Parameters.Add(new LookupParameter<ISymbolicExpressionGrammar>(ClonedSymbolicExpressionTreeGrammarParameterName, "An immutable clone of the concrete grammar that is actually used to create and manipulate trees.")); 85 } 86 87 public override IOperation Apply() { 88 if (ClonedSymbolicExpressionTreeGrammarParameter.ActualValue == null) { 89 SymbolicExpressionTreeGrammarParameter.ActualValue.ReadOnly = true; 90 IScope globalScope = ExecutionContext.Scope; 91 while (globalScope.Parent != null) 92 globalScope = globalScope.Parent; 93 94 globalScope.Variables.Add(new Variable(ClonedSymbolicExpressionTreeGrammarParameterName, (ISymbolicExpressionGrammar)SymbolicExpressionTreeGrammarParameter.ActualValue.Clone())); 95 } 96 return base.Apply(); 97 } 76 98 77 99 protected override ISymbolicExpressionTree Create(IRandom random) { 78 100 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 79 80 101 } 81 102 … … 165 186 select s) 166 187 .ToList(); 188 if (allowedSymbols.Count == 0) return false; 167 189 var weights = allowedSymbols.Select(x => x.InitialFrequency).ToList(); 168 190 var selectedSymbol = allowedSymbols.SelectRandom(weights, random); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs
r5809 r6233 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Parameters; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 55 54 } 56 55 57 public sealedoverride IOperation Apply() {56 public override IOperation Apply() { 58 57 SymbolicExpressionTree = Create(Random); 59 58 return base.Apply(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammar.cs
r5809 r6233 21 21 22 22 23 using System; 24 using HeuristicLab.Core; 23 25 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 24 public interface ISymbolicExpressionGrammar : ISymbolicExpressionGrammarBase {26 public interface ISymbolicExpressionGrammar : ISymbolicExpressionGrammarBase, IStatefulItem { 25 27 ISymbol ProgramRootSymbol { get; } 26 28 ISymbol StartSymbol { get; } … … 30 32 int MinimumFunctionArguments { get; set; } 31 33 int MaximumFunctionArguments { get; set; } 34 35 bool ReadOnly { get; set; } 36 event EventHandler ReadOnlyChanged; 32 37 } 33 38 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs
r5809 r6233 20 20 #endregion 21 21 22 using System .Linq;22 using System; 23 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 … … 28 29 public abstract class SymbolicExpressionGrammar : SymbolicExpressionGrammarBase, ISymbolicExpressionGrammar { 29 30 #region fields & properties 31 [Storable(DefaultValue = false)] 32 private bool readOnly; 33 public bool ReadOnly { 34 get { return readOnly; } 35 set { 36 if (readOnly != value) { 37 readOnly = value; 38 OnReadOnlyChanged(); 39 } 40 } 41 } 42 30 43 [Storable] 31 44 private int minimumFunctionDefinitions; … … 102 115 protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner) 103 116 : base(original, cloner) { 104 programRootSymbol = (ProgramRootSymbol)cloner.Clone(original.programRootSymbol); 105 startSymbol = (StartSymbol)cloner.Clone(original.StartSymbol); 106 defunSymbol = (Defun)cloner.Clone(original.defunSymbol); 107 symbols = original.symbols 108 .ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value)); 117 programRootSymbol = cloner.Clone(original.programRootSymbol); 118 startSymbol = cloner.Clone(original.StartSymbol); 119 defunSymbol = cloner.Clone(original.defunSymbol); 120 109 121 maximumFunctionArguments = original.maximumFunctionArguments; 110 122 minimumFunctionArguments = original.minimumFunctionArguments; … … 140 152 } 141 153 } 154 155 public event EventHandler ReadOnlyChanged; 156 protected virtual void OnReadOnlyChanged() { 157 var handler = ReadOnlyChanged; 158 if (handler != null) 159 handler(this, EventArgs.Empty); 160 } 161 162 #region IStatefulItem 163 void IStatefulItem.InitializeState() { } 164 void IStatefulItem.ClearState() { 165 ReadOnly = false; 166 } 167 #endregion 142 168 } 143 169 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6009 r6233 81 81 cachedMinExpressionDepth = new Dictionary<string, int>(); 82 82 } 83 [StorableHook(HookType.AfterDeserialization)] 84 private void AfterDeserialization() { 85 foreach (ISymbol symbol in symbols.Values) 86 RegisterSymbolEvents(symbol); 87 } 88 83 89 protected SymbolicExpressionGrammarBase(SymbolicExpressionGrammarBase original, Cloner cloner) 84 90 : base(original, cloner) { … … 87 93 cachedMinExpressionDepth = new Dictionary<string, int>(); 88 94 95 96 symbols = original.symbols.ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value)); 89 97 symbolSubtreeCount = new Dictionary<string, Tuple<int, int>>(original.symbolSubtreeCount); 90 symbols = new Dictionary<string, ISymbol>(original.symbols);91 98 92 99 allowedChildSymbols = new Dictionary<string, List<string>>(); … … 97 104 foreach (var element in original.allowedChildSymbolsPerIndex) 98 105 allowedChildSymbolsPerIndex.Add(element.Key, new List<string>(element.Value)); 106 107 foreach (ISymbol symbol in symbols.Values) 108 RegisterSymbolEvents(symbol); 99 109 } 100 110 … … 114 124 protected void AddSymbol(ISymbol symbol) { 115 125 if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined."); 126 RegisterSymbolEvents(symbol); 116 127 symbols.Add(symbol.Name, symbol); 117 128 symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0)); 129 ClearCaches(); 130 } 131 132 private void RegisterSymbolEvents(ISymbol symbol) { 133 symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging); 134 symbol.NameChanged += new EventHandler(Symbol_NameChanged); 135 } 136 private void DeregisterSymbolEvents(ISymbol symbol) { 137 symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging); 138 symbol.NameChanged -= new EventHandler(Symbol_NameChanged); 139 } 140 141 private void Symbol_NameChanging(object sender, CancelEventArgs<string> e) { 142 if (symbols.ContainsKey(e.Value)) e.Cancel = true; 143 } 144 private void Symbol_NameChanged(object sender, EventArgs e) { 145 ISymbol symbol = (ISymbol)sender; 146 string oldName = symbols.Where(x => x.Value == symbol).First().Key; 147 string newName = symbol.Name; 148 149 symbols.Remove(oldName); 150 symbols.Add(newName, symbol); 151 152 var subtreeCount = symbolSubtreeCount[oldName]; 153 symbolSubtreeCount.Remove(oldName); 154 symbolSubtreeCount.Add(newName, subtreeCount); 155 156 List<string> allowedChilds; 157 if (allowedChildSymbols.TryGetValue(oldName, out allowedChilds)) { 158 allowedChildSymbols.Remove(oldName); 159 allowedChildSymbols.Add(newName, allowedChilds); 160 } 161 162 for (int i = 0; i < GetMaximumSubtreeCount(symbol); i++) { 163 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(oldName, i), out allowedChilds)) { 164 allowedChildSymbolsPerIndex.Remove(Tuple.Create(oldName, i)); 165 allowedChildSymbolsPerIndex.Add(Tuple.Create(newName, i), allowedChilds); 166 } 167 } 168 169 foreach (var parent in Symbols) { 170 if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds)) 171 if (allowedChilds.Remove(oldName)) 172 allowedChilds.Add(newName); 173 174 for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) { 175 if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds)) 176 if (allowedChilds.Remove(oldName)) allowedChilds.Add(newName); 177 } 178 } 179 118 180 ClearCaches(); 119 181 } … … 126 188 symbolSubtreeCount.Remove(symbol.Name); 127 189 128 129 190 foreach (var parent in Symbols) { 130 191 List<string> allowedChilds; … … 137 198 } 138 199 } 200 DeregisterSymbolEvents(symbol); 139 201 ClearCaches(); 140 202 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs
r5809 r6233 36 36 } 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 foreach (ISymbol symbol in base.Symbols) 39 cloner.RegisterClonedObject(symbol, symbol); 38 40 return new SymbolicExpressionTreeGrammar(this, cloner); 39 41 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs
r5809 r6233 45 45 protected SymbolicExpressionTreeTerminalNode() : base() { } 46 46 47 protected SymbolicExpressionTreeTerminalNode( Symbol symbol)47 protected SymbolicExpressionTreeTerminalNode(ISymbol symbol) 48 48 : base() { 49 49 // symbols are reused -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs
r5809 r6233 42 42 } 43 43 public SymbolicExpressionTreeTopLevelNode() : base() { } 44 public SymbolicExpressionTreeTopLevelNode( Symbol symbol) : base(symbol) { }44 public SymbolicExpressionTreeTopLevelNode(ISymbol symbol) : base(symbol) { } 45 45 46 46 -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs
r5809 r6233 38 38 } 39 39 40 public override bool CanChangeDescription {41 get { return false; }42 }43 44 40 [StorableConstructor] 45 41 private Argument(bool deserializing) : base(deserializing) { } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs
r5809 r6233 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 38 37 public string FunctionName { 39 38 get { return functionName; } 40 set {41 if (value == null) throw new ArgumentNullException();42 functionName = value;43 }44 39 } 45 40 … … 53 48 public InvokeFunction(string functionName) 54 49 : base("Invoke: " + functionName, InvokeFunction.InvokeFunctionDescription) { 55 this. FunctionName = functionName;50 this.functionName = functionName; 56 51 } 57 52 -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs
r5809 r6233 43 43 } 44 44 public override bool CanChangeName { 45 get { return false; }45 get { return !(this is IReadOnlySymbol); } 46 46 } 47 47 public override bool CanChangeDescription { … … 56 56 initialFrequency = original.initialFrequency; 57 57 } 58 protected Symbol()59 : base() {60 initialFrequency = 1.0;61 }62 58 63 59 protected Symbol(string name, string description) … … 65 61 initialFrequency = 1.0; 66 62 } 67 68 63 69 64 public virtual ISymbolicExpressionTreeNode CreateTreeNode() { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs
r5942 r6233 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HeuristicLab.Data;27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 using HeuristicLab.Parameters;30 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 using System;33 29 34 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 149 145 } else { 150 146 var mainBranch = startNode.GetSubtree(0); 147 var product = MakeProduct(mainBranch, beta); 151 148 startNode.RemoveSubtree(0); 152 var scaledMainBranch = MakeSum(MakeProduct(beta, mainBranch), alpha); 149 startNode.AddSubtree(product); 150 151 var scaledMainBranch = MakeSum(product, alpha); 152 startNode.RemoveSubtree(0); 153 153 startNode.AddSubtree(scaledMainBranch); 154 154 } … … 159 159 return treeNode; 160 160 } else { 161 var node = (new Addition()).CreateTreeNode(); 161 var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault(); 162 if (addition == null) addition = new Addition(); 163 var node = addition.CreateTreeNode(); 162 164 var alphaConst = MakeConstant(alpha); 163 165 node.AddSubtree(treeNode); … … 167 169 } 168 170 169 private static ISymbolicExpressionTreeNode MakeProduct( double beta, ISymbolicExpressionTreeNode treeNode) {171 private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) { 170 172 if (beta.IsAlmost(1.0)) { 171 173 return treeNode; 172 174 } else { 173 var node = (new Multiplication()).CreateTreeNode(); 175 var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault(); 176 if (multipliciation == null) multipliciation = new Multiplication(); 177 var node = multipliciation.CreateTreeNode(); 174 178 var betaConst = MakeConstant(beta); 175 179 node.AddSubtree(treeNode); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
r5942 r6233 21 21 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 94 95 } else { 95 96 var mainBranch = startNode.GetSubtree(0); 97 var product = MakeProduct(mainBranch, beta); 96 98 startNode.RemoveSubtree(0); 97 var scaledMainBranch = MakeSum(MakeProduct(beta, mainBranch), alpha); 99 startNode.AddSubtree(product); 100 101 var scaledMainBranch = MakeSum(product, alpha); 102 startNode.RemoveSubtree(0); 98 103 startNode.AddSubtree(scaledMainBranch); 99 104 } … … 104 109 return treeNode; 105 110 } else { 106 var node = (new Addition()).CreateTreeNode(); 111 var addition = treeNode.Grammar.Symbols.OfType<Addition>().FirstOrDefault(); 112 if (addition == null) addition = new Addition(); 113 var node = addition.CreateTreeNode(); 107 114 var alphaConst = MakeConstant(alpha); 108 115 node.AddSubtree(treeNode); … … 112 119 } 113 120 114 private static ISymbolicExpressionTreeNode MakeProduct( double beta, ISymbolicExpressionTreeNode treeNode) {121 private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) { 115 122 if (beta.IsAlmost(1.0)) { 116 123 return treeNode; 117 124 } else { 118 var node = (new Multiplication()).CreateTreeNode(); 125 var multipliciation = treeNode.Grammar.Symbols.OfType<Multiplication>().FirstOrDefault(); 126 if (multipliciation == null) multipliciation = new Multiplication(); 127 var node = multipliciation.CreateTreeNode(); 119 128 var betaConst = MakeConstant(beta); 120 129 node.AddSubtree(treeNode); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r5975 r6233 75 75 } 76 76 77 private newvoid RecalculateResults() {77 private void RecalculateResults() { 78 78 ModelLength = Model.SymbolicExpressionTree.Length; 79 79 ModelDepth = Model.SymbolicExpressionTree.Depth; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs
r5809 r6233 23 23 using System.Linq; 24 24 using System.Windows.Forms; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Core; 27 using HeuristicLab.Core.Views; 28 using HeuristicLab.Data; 25 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 26 30 using HeuristicLab.MainForm; 27 31 using HeuristicLab.MainForm.WindowsForms; 28 using HeuristicLab.Core;29 using HeuristicLab.Data;30 using HeuristicLab.Core.Views;31 using HeuristicLab.Collections;32 32 33 33 … … 81 81 protected override void OnContentChanged() { 82 82 base.OnContentChanged(); 83 variableNamesView.Content.Clear(); 83 84 UpdateControl(); 84 85 } … … 162 163 } else { 163 164 var existingEntries = variableNamesView.Content.Select(x => x.Value); 164 165 165 166 // temporarily deregister to prevent circular calling of events 166 167 DeregisterVariableNamesViewContentEvents(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionEnsembleSolution.cs
r6184 r6233 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Core;24 23 namespace HeuristicLab.Problems.DataAnalysis { 25 24 public interface IRegressionEnsembleSolution : IRegressionSolution { 26 IRegressionEnsembleModel Model { get; }25 new IRegressionEnsembleModel Model { get; } 27 26 IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows); 28 27 }
Note: See TracChangeset
for help on using the changeset viewer.