- Timestamp:
- 02/28/20 10:43:50 (5 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 54 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP
- Property svn:mergeinfo changed
/trunk (added) merged: 17376-17378,17380,17384-17386,17402,17413,17421-17423,17426-17428,17430,17437,17441,17445,17450
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis (added) merged: 17427
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Algorithms.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis.Views (added) merged: 17445
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/CrossValidationView.cs
r17180 r17456 223 223 224 224 private async void startButton_Click(object sender, EventArgs e) { 225 await Content.StartAsync(); 225 try { 226 await Content.StartAsync(); 227 } catch (Exception ex) { 228 ErrorHandling.ShowErrorDialog(this, ex); 229 } 226 230 } 227 231 private void pauseButton_Click(object sender, EventArgs e) { -
branches/3040_VectorBasedGP/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 (added) merged: 17427
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessBase.cs
r17180 r17456 22 22 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Algorithms.GradientDescent; 25 26 using HeuristicLab.Common; … … 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 using H EAL.Attic;32 using HeuristicLab.PluginInfrastructure; 32 33 using HeuristicLab.Problems.DataAnalysis; 33 34 … … 57 58 58 59 #region parameter properties 59 public I ValueParameter<IMeanFunction> MeanFunctionParameter {60 get { return (I ValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; }61 } 62 public I ValueParameter<ICovarianceFunction> CovarianceFunctionParameter {63 get { return (I ValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; }60 public IConstrainedValueParameter<IMeanFunction> MeanFunctionParameter { 61 get { return (IConstrainedValueParameter<IMeanFunction>)Parameters[MeanFunctionParameterName]; } 62 } 63 public IConstrainedValueParameter<ICovarianceFunction> CovarianceFunctionParameter { 64 get { return (IConstrainedValueParameter<ICovarianceFunction>)Parameters[CovarianceFunctionParameterName]; } 64 65 } 65 66 public IValueParameter<IntValue> MinimizationIterationsParameter { … … 106 107 : base() { 107 108 Problem = problem; 108 Parameters.Add(new ValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.", new MeanConst()));109 Parameters.Add(new ValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.", new CovarianceSquaredExponentialIso()));109 Parameters.Add(new ConstrainedValueParameter<IMeanFunction>(MeanFunctionParameterName, "The mean function to use.")); 110 Parameters.Add(new ConstrainedValueParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function to use.")); 110 111 Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20))); 111 112 Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); … … 193 194 194 195 solutionCreator.OperatorParameter.ActualName = SolutionCreatorParameterName; 196 197 foreach (var meanfunction in ApplicationManager.Manager.GetInstances<IMeanFunction>().OrderBy(s => s.ItemName)) 198 MeanFunctionParameter.ValidValues.Add(meanfunction); 199 200 var defaultMeanFunction = MeanFunctionParameter.ValidValues.OfType<MeanConst>().FirstOrDefault(); 201 if (defaultMeanFunction != null) { 202 MeanFunctionParameter.Value = defaultMeanFunction; 203 } 204 205 foreach (var covarianceFunction in ApplicationManager.Manager.GetInstances<ICovarianceFunction>().OrderBy(s => s.ItemName)) 206 CovarianceFunctionParameter.ValidValues.Add(covarianceFunction); 207 208 var defaultCovarianceFunctionParameter = CovarianceFunctionParameter.ValidValues.OfType<CovarianceSquaredExponentialIso>().FirstOrDefault(); 209 if (defaultCovarianceFunctionParameter != null) { 210 CovarianceFunctionParameter.Value = defaultCovarianceFunctionParameter; 211 } 195 212 } 196 213 -
branches/3040_VectorBasedGP/HeuristicLab.Clients.Hive
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive (added) merged: 17445
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Clients.Hive.Slave
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.Slave (added) merged: 17445
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Clients.Hive.Slave/3.3/Executor.cs
r17180 r17456 46 46 public bool IsStopping { get; set; } 47 47 public bool IsPausing { get; set; } 48 public bool HasFailed { get; set; } 48 49 49 50 public Exception CurrentException; … … 84 85 85 86 task.Start(); 86 if (!startTaskSem.WaitOne(Settings.Default.ExecutorSemTimeouts) ) {87 if (!startTaskSem.WaitOne(Settings.Default.ExecutorSemTimeouts) && !HasFailed) { 87 88 throw new TimeoutException("Timeout when starting the task. TaskStarted event was not fired."); 88 89 } … … 159 160 #region Task Events 160 161 private void Task_TaskFailed(object sender, EventArgs e) { 162 HasFailed = true; 161 163 IsStopping = true; 162 164 EventArgs<Exception> ex = (EventArgs<Exception>)e; 163 165 CurrentException = ex.Value; 164 166 executorQueue.AddMessage(ExecutorMessageType.TaskFailed); 167 startTaskSem.Set(); // cancel waiting for startup 165 168 } 166 169 -
branches/3040_VectorBasedGP/HeuristicLab.Clients.Hive/3.3/Tasks/EngineTask.cs
r17180 r17456 80 80 81 81 public override async void Start() { 82 Item.Prepare(initialOperation); 83 await Item.StartAsync(); 82 try { 83 Item.Prepare(initialOperation); 84 await Item.StartAsync(); 85 } catch (Exception e) { 86 engine_ExceptionOccurred(Item, new EventArgs<Exception>(e)); 87 } 84 88 } 85 89 -
branches/3040_VectorBasedGP/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs
r17180 r17456 101 101 OnTaskStopped(); 102 102 } else { 103 await Item.StartAsync(); 103 try { 104 await Item.StartAsync(); 105 } catch (Exception e) { 106 optimizer_ExceptionOccurred(Item, new EventArgs<Exception>(e)); 107 } 104 108 } 105 109 } -
branches/3040_VectorBasedGP/HeuristicLab.Clients.OKB.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.OKB.Views (added) merged: 17445
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBAlgorithmView.cs
r17180 r17456 325 325 } 326 326 private async void startButton_Click(object sender, EventArgs e) { 327 await Content.StartAsync(); 327 try { 328 await Content.StartAsync(); 329 } catch (Exception ex) { 330 ErrorHandling.ShowErrorDialog(this, ex); 331 } 328 332 } 329 333 private void pauseButton_Click(object sender, EventArgs e) { -
branches/3040_VectorBasedGP/HeuristicLab.CodeEditor/3.4/CodeEditor.cs
r17180 r17456 282 282 public override void ScrollToPosition(int line, int column) { 283 283 var segment = GetSegmentAtLocation(line, column); 284 TextEditor.CaretOffset = segment.Offset + segment.Length;284 TextEditor.CaretOffset = segment.Offset; 285 285 TextEditor.ScrollToLine(line); 286 286 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 17437,17441
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/BalancedTreeCreator.cs
r17347 r17456 76 76 } 77 77 78 private class SymbolCacheEntry {79 public int MinSubtreeCount;80 public int MaxSubtreeCount;81 public int[] MaxChildArity;82 }83 84 private class SymbolCache {85 public SymbolCache(ISymbolicExpressionGrammarBase grammar) {86 Grammar = grammar;87 }88 89 public ISymbolicExpressionTreeNode SampleNode(IRandom random, ISymbol parent, int childIndex, int minArity, int maxArity) {90 var symbols = new List<ISymbol>();91 var weights = new List<double>();92 foreach (var child in AllowedSymbols.Where(x => !(x is StartSymbol || x is Defun))) {93 var t = Tuple.Create(parent, child);94 if (!allowedCache.TryGetValue(t, out bool[] allowed)) { continue; }95 if (!allowed[childIndex]) { continue; }96 97 if (symbolCache.TryGetValue(child, out SymbolCacheEntry cacheItem)) {98 if (cacheItem.MinSubtreeCount < minArity) { continue; }99 if (cacheItem.MaxSubtreeCount > maxArity) { continue; }100 }101 102 symbols.Add(child);103 weights.Add(child.InitialFrequency);104 }105 if (symbols.Count == 0) {106 throw new ArgumentException("SampleNode: parent symbol " + parent.Name107 + " does not have any allowed child symbols with min arity " + minArity108 + " and max arity " + maxArity + ". Please ensure the grammar is properly configured.");109 }110 var symbol = symbols.SampleProportional(random, 1, weights).First();111 var node = symbol.CreateTreeNode();112 if (node.HasLocalParameters) {113 node.ResetLocalParameters(random);114 }115 return node;116 }117 118 public ISymbolicExpressionGrammarBase Grammar {119 get { return grammar; }120 set {121 grammar = value;122 RebuildCache();123 }124 }125 126 public IList<ISymbol> AllowedSymbols { get; private set; }127 128 public SymbolCacheEntry this[ISymbol symbol] {129 get { return symbolCache[symbol]; }130 }131 132 public bool[] this[ISymbol parent, ISymbol child] {133 get { return allowedCache[Tuple.Create(parent, child)]; }134 }135 136 public bool HasUnarySymbols { get; private set; }137 138 private void RebuildCache() {139 AllowedSymbols = Grammar.AllowedSymbols.Where(x => x.InitialFrequency > 0 && !(x is ProgramRootSymbol)).ToList();140 141 allowedCache = new Dictionary<Tuple<ISymbol, ISymbol>, bool[]>();142 symbolCache = new Dictionary<ISymbol, SymbolCacheEntry>();143 144 SymbolCacheEntry TryAddItem(ISymbol symbol) {145 if (!symbolCache.TryGetValue(symbol, out SymbolCacheEntry cacheItem)) {146 cacheItem = new SymbolCacheEntry {147 MinSubtreeCount = Grammar.GetMinimumSubtreeCount(symbol),148 MaxSubtreeCount = Grammar.GetMaximumSubtreeCount(symbol)149 };150 symbolCache[symbol] = cacheItem;151 }152 return cacheItem;153 }154 155 foreach (var parent in AllowedSymbols) {156 var parentCacheEntry = TryAddItem(parent);157 var maxChildArity = new int[parentCacheEntry.MaxSubtreeCount];158 159 if (!(parent is StartSymbol || parent is Defun)) {160 HasUnarySymbols |= parentCacheEntry.MaxSubtreeCount == 1;161 }162 163 foreach (var child in AllowedSymbols) {164 var childCacheEntry = TryAddItem(child);165 var allowed = new bool[parentCacheEntry.MaxSubtreeCount];166 167 for (int childIndex = 0; childIndex < parentCacheEntry.MaxSubtreeCount; ++childIndex) {168 allowed[childIndex] = Grammar.IsAllowedChildSymbol(parent, child, childIndex);169 maxChildArity[childIndex] = Math.Max(maxChildArity[childIndex], allowed[childIndex] ? childCacheEntry.MaxSubtreeCount : 0);170 }171 allowedCache[Tuple.Create(parent, child)] = allowed;172 }173 parentCacheEntry.MaxChildArity = maxChildArity;174 }175 }176 177 private ISymbolicExpressionGrammarBase grammar;178 private Dictionary<Tuple<ISymbol, ISymbol>, bool[]> allowedCache;179 private Dictionary<ISymbol, SymbolCacheEntry> symbolCache;180 }181 182 78 public static ISymbolicExpressionTree CreateExpressionTree(IRandom random, ISymbolicExpressionGrammar grammar, int targetLength, int maxDepth, double irregularityBias = 1) { 183 79 // even lengths cannot be achieved without symbols of odd arity 184 80 // therefore we randomly pick a neighbouring odd length value 185 81 var tree = MakeStump(random, grammar); // create a stump consisting of just a ProgramRootSymbol and a StartSymbol 186 CreateExpression(random, tree.Root.GetSubtree(0), targetLength - 2, maxDepth - 2, irregularityBias); // -2 because the stump has length 2 and depth 282 CreateExpression(random, tree.Root.GetSubtree(0), targetLength - tree.Length, maxDepth - 2, irregularityBias); // -2 because the stump has length 2 and depth 2 187 83 return tree; 84 } 85 86 private static ISymbolicExpressionTreeNode SampleNode(IRandom random, ISymbolicExpressionTreeGrammar grammar, IEnumerable<ISymbol> allowedSymbols, int minChildArity, int maxChildArity) { 87 var candidates = new List<ISymbol>(); 88 var weights = new List<double>(); 89 90 foreach (var s in allowedSymbols) { 91 var minSubtreeCount = grammar.GetMinimumSubtreeCount(s); 92 var maxSubtreeCount = grammar.GetMaximumSubtreeCount(s); 93 94 if (maxChildArity < minSubtreeCount || minChildArity > maxSubtreeCount) { continue; } 95 96 candidates.Add(s); 97 weights.Add(s.InitialFrequency); 98 } 99 var symbol = candidates.SampleProportional(random, 1, weights).First(); 100 var node = symbol.CreateTreeNode(); 101 if (node.HasLocalParameters) { 102 node.ResetLocalParameters(random); 103 } 104 return node; 188 105 } 189 106 190 107 public static void CreateExpression(IRandom random, ISymbolicExpressionTreeNode root, int targetLength, int maxDepth, double irregularityBias = 1) { 191 108 var grammar = root.Grammar; 192 var symbolCache = new SymbolCache(grammar); 193 var entry = symbolCache[root.Symbol]; 194 var arity = random.Next(entry.MinSubtreeCount, entry.MaxSubtreeCount + 1); 109 var minSubtreeCount = grammar.GetMinimumSubtreeCount(root.Symbol); 110 var maxSubtreeCount = grammar.GetMinimumSubtreeCount(root.Symbol); 111 var arity = random.Next(minSubtreeCount, maxSubtreeCount + 1); 112 int openSlots = arity; 113 114 var allowedSymbols = grammar.AllowedSymbols.Where(x => !(x is ProgramRootSymbol || x is GroupSymbol || x is Defun || x is StartSymbol)).ToList(); 115 bool hasUnarySymbols = allowedSymbols.Any(x => grammar.GetMinimumSubtreeCount(x) <= 1 && grammar.GetMaximumSubtreeCount(x) >= 1); 116 117 if (!hasUnarySymbols && targetLength % 2 == 0) { 118 // without functions of arity 1 some target lengths cannot be reached 119 targetLength = random.NextDouble() < 0.5 ? targetLength - 1 : targetLength + 1; 120 } 121 195 122 var tuples = new List<NodeInfo>(targetLength) { new NodeInfo { Node = root, Depth = 0, Arity = arity } }; 196 int openSlots = arity; 197 123 124 // we use tuples.Count instead of targetLength in the if condition 125 // because depth limits may prevent reaching the target length 198 126 for (int i = 0; i < tuples.Count; ++i) { 199 127 var t = tuples[i]; 200 128 var node = t.Node; 201 var parentEntry = symbolCache[node.Symbol];202 129 203 130 for (int childIndex = 0; childIndex < t.Arity; ++childIndex) { 204 131 // min and max arity here refer to the required arity limits for the child node 205 int maxChildArity = t.Depth == maxDepth - 1 ? 0 : Math.Min(parentEntry.MaxChildArity[childIndex], targetLength - openSlots); 206 int minChildArity = Math.Min((openSlots - tuples.Count > 1 && random.NextDouble() < irregularityBias) ? 0 : 1, maxChildArity); 207 var child = symbolCache.SampleNode(random, node.Symbol, childIndex, minChildArity, maxChildArity); 208 var childEntry = symbolCache[child.Symbol]; 209 var childArity = random.Next(childEntry.MinSubtreeCount, childEntry.MaxSubtreeCount + 1); 132 int minChildArity = 0; 133 int maxChildArity = 0; 134 135 var allowedChildSymbols = allowedSymbols.Where(x => grammar.IsAllowedChildSymbol(node.Symbol, x, childIndex)).ToList(); 136 137 // if we are reaching max depth we have to fill the slot with a leaf node (max arity will be zero) 138 // otherwise, find the maximum value from the grammar which does not exceed the length limit 139 if (t.Depth < maxDepth - 1 && openSlots < targetLength) { 140 141 // we don't want to allow sampling a leaf symbol if it prevents us from reaching the target length 142 // this should be allowed only when we have enough open expansion points (more than one) 143 // the random check against the irregularity bias helps to increase shape variability when the conditions are met 144 int minAllowedArity = allowedChildSymbols.Min(x => grammar.GetMaximumSubtreeCount(x)); 145 if (minAllowedArity == 0 && (openSlots - tuples.Count <= 1 || random.NextDouble() > irregularityBias)) { 146 minAllowedArity = 1; 147 } 148 149 // finally adjust min and max arity according to the expansion limits 150 int maxAllowedArity = allowedChildSymbols.Max(x => grammar.GetMaximumSubtreeCount(x)); 151 maxChildArity = Math.Min(maxAllowedArity, targetLength - openSlots); 152 minChildArity = Math.Min(minAllowedArity, maxChildArity); 153 } 154 155 // sample a random child with the arity limits 156 var child = SampleNode(random, grammar, allowedChildSymbols, minChildArity, maxChildArity); 157 158 // get actual child arity limits 159 minChildArity = Math.Max(minChildArity, grammar.GetMinimumSubtreeCount(child.Symbol)); 160 maxChildArity = Math.Min(maxChildArity, grammar.GetMaximumSubtreeCount(child.Symbol)); 161 minChildArity = Math.Min(minChildArity, maxChildArity); 162 163 // pick a random arity for the new child node 164 var childArity = random.Next(minChildArity, maxChildArity + 1); 210 165 var childDepth = t.Depth + 1; 211 166 node.AddSubtree(child); … … 244 199 return tree; 245 200 } 201 202 public void CreateExpression(IRandom random, ISymbolicExpressionTreeNode seedNode, int maxTreeLength, int maxTreeDepth) { 203 CreateExpression(random, seedNode, maxTreeLength, maxTreeDepth, IrregularityBias); 204 } 246 205 #endregion 247 206 } -
branches/3040_VectorBasedGP/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r17180 r17456 25 25 namespace HeuristicLab.MainForm.WindowsForms { 26 26 internal sealed partial class ProgressView : UserControl { 27 private readonly Control control; 28 public Control Control { 29 get { return control; } 30 } 31 32 private readonly IProgress content; 33 public IProgress Content { 34 get { return content; } 35 } 36 37 public ProgressView(Control control, IProgress content) 27 public Control TargetControl { get; } 28 public IProgress Content { get; } 29 30 public ProgressView(Control targetControl, IProgress content) 38 31 : base() { 39 if ( control == null) throw new ArgumentNullException("control");40 if ( control.Parent == null) throw new InvalidOperationException("A Progress can only be shown on controls that have a Parent-control. Therefore, Dialogs and Forms cannot have an associated ProgressView.");41 if (content == null) throw new ArgumentNullException( "content");32 if (targetControl == null) throw new ArgumentNullException(nameof(targetControl)); 33 if (targetControl.Parent == null) throw new InvalidOperationException("A Progress can only be shown on controls that have a Parent-control. Therefore, Dialogs and Forms cannot have an associated ProgressView."); 34 if (content == null) throw new ArgumentNullException(nameof(content)); 42 35 InitializeComponent(); 43 36 44 this. control = control;45 this. content = content;37 this.TargetControl = targetControl; 38 this.Content = content; 46 39 47 40 if (content.ProgressState != ProgressState.Finished) … … 52 45 protected override void Dispose(bool disposing) { 53 46 DeregisterContentEvents(); 54 HideProgress(); 55 56 if (disposing && (components != null)) { 47 48 if (!TargetControl.IsDisposed) 49 HideProgress(); 50 51 if (disposing && components != null) { 57 52 components.Dispose(); 58 53 } … … 101 96 102 97 private void ShowProgress() { 103 if ( Control.InvokeRequired) {104 Control.Invoke((Action)ShowProgress);98 if (TargetControl.InvokeRequired) { 99 TargetControl.Invoke((Action)ShowProgress); 105 100 return; 106 101 } 107 102 if (Parent != null) return; 108 103 109 Left = ( Control.ClientRectangle.Width / 2) - (Width / 2);110 Top = ( Control.ClientRectangle.Height / 2) - (Height / 2);104 Left = (TargetControl.ClientRectangle.Width / 2) - (Width / 2); 105 Top = (TargetControl.ClientRectangle.Height / 2) - (Height / 2); 111 106 Anchor = AnchorStyles.None; 112 107 … … 115 110 UpdateButtonsState(); 116 111 117 Control.SuspendRepaint(); 118 Control.Enabled = false; 119 Parent = Control.Parent; 112 TargetControl.SuspendRepaint(); 113 TargetControl.Enabled = false; 114 RegisterTargetControlEvents(); 115 Parent = TargetControl.Parent; 120 116 BringToFront(); 121 Control.ResumeRepaint(true);117 TargetControl.ResumeRepaint(true); 122 118 Visible = true; 123 119 } 124 120 125 121 private void HideProgress() { 126 if ( Control.InvokeRequired) {127 Control.Invoke((Action)HideProgress);122 if (TargetControl.InvokeRequired) { 123 TargetControl.Invoke((Action)HideProgress); 128 124 return; 129 125 } … … 131 127 132 128 Visible = false; 133 Control.SuspendRepaint();134 Control.Enabled = true;135 Control.ResumeRepaint(true);129 TargetControl.SuspendRepaint(); 130 TargetControl.Enabled = true; 131 DeregisterTargetControlEvents(); 136 132 Parent = null; 133 TargetControl.ResumeRepaint(TargetControl.Visible); 134 } 135 136 137 private void RegisterTargetControlEvents() { 138 TargetControl.Disposed += TargetControl_Disposed; 139 TargetControl.VisibleChanged += TargetControl_VisibleChanged; 140 TargetControl.ParentChanged += TargetControl_ParentChanged; 141 } 142 143 private void DeregisterTargetControlEvents() { 144 TargetControl.Disposed -= TargetControl_Disposed; 145 TargetControl.VisibleChanged -= TargetControl_VisibleChanged; 146 TargetControl.ParentChanged -= TargetControl_ParentChanged; 147 } 148 149 private void TargetControl_Disposed(object sender, EventArgs e) { 150 Dispose(); 151 } 152 private void TargetControl_VisibleChanged(object sender, EventArgs e) { 153 Visible = TargetControl.Visible; 154 } 155 private void TargetControl_ParentChanged(object sender, EventArgs e) { 156 Parent = TargetControl.Parent; 137 157 } 138 158 139 159 private void UpdateProgressState() { 140 if ( Control.InvokeRequired) {141 Control.Invoke((Action)UpdateProgressState);160 if (TargetControl.InvokeRequired) { 161 TargetControl.Invoke((Action)UpdateProgressState); 142 162 return; 143 163 } … … 150 170 151 171 private void UpdateProgressMessage() { 152 if ( Control.InvokeRequired) {153 Control.Invoke((Action)UpdateProgressMessage);154 return; 155 } 156 157 messageLabel.Text = content.Message;172 if (TargetControl.InvokeRequired) { 173 TargetControl.Invoke((Action)UpdateProgressMessage); 174 return; 175 } 176 177 messageLabel.Text = Content.Message; 158 178 } 159 179 … … 167 187 case ProgressMode.Determinate: 168 188 progressBar.Style = ProgressBarStyle.Continuous; 169 progressBar.Value = (int)Math.Round(progressBar.Minimum + content.ProgressValue * (progressBar.Maximum - progressBar.Minimum));189 progressBar.Value = (int)Math.Round(progressBar.Minimum + Content.ProgressValue * (progressBar.Maximum - progressBar.Minimum)); 170 190 break; 171 191 case ProgressMode.Indeterminate: … … 174 194 break; 175 195 default: 176 throw new NotImplementedException($"Invalid Progress Mode: { content.ProgressMode}");196 throw new NotImplementedException($"Invalid Progress Mode: {Content.ProgressMode}"); 177 197 } 178 198 } 179 199 180 200 private void UpdateButtonsState() { 181 if ( Control.InvokeRequired) {182 Control.Invoke((Action)UpdateButtonsState);201 if (TargetControl.InvokeRequired) { 202 TargetControl.Invoke((Action)UpdateButtonsState); 183 203 return; 184 204 } 185 205 186 206 stopButton.Visible = Content.CanBeStopped; 187 stopButton.Enabled = Content.CanBeStopped && content.ProgressState == ProgressState.Started;207 stopButton.Enabled = Content.CanBeStopped && Content.ProgressState == ProgressState.Started; 188 208 189 209 cancelButton.Visible = Content.CanBeCanceled; 190 cancelButton.Enabled = Content.CanBeCanceled && content.ProgressState == ProgressState.Started;210 cancelButton.Enabled = Content.CanBeCanceled && Content.ProgressState == ProgressState.Started; 191 211 } 192 212 -
branches/3040_VectorBasedGP/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Optimization.Views (added) merged: 17445
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Optimization.Views/3.3/IOptimizerView.cs
r17180 r17456 137 137 #region Control events 138 138 protected virtual async void startButton_Click(object sender, EventArgs e) { 139 await Content.StartAsync(); 139 try { 140 await Content.StartAsync(); 141 } catch (Exception ex) { 142 ErrorHandling.ShowErrorDialog(this, ex); 143 } 140 144 } 141 145 protected virtual void pauseButton_Click(object sender, EventArgs e) { -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis (added) merged: 17422-17423
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic (added) merged: 17402,17413
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification (added) merged: 17450
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views (added) merged: 17421
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SolutionComparisonView.cs
r17180 r17456 91 91 var newDs = new Dataset(variableNames, variableValues); 92 92 var newProblemData = new ClassificationProblemData(newDs, variableNames.Take(variableNames.Length - 1), variableNames.Last()); 93 94 foreach (var classValue in problemData.ClassValues) { 95 newProblemData.SetClassName(classValue, problemData.GetClassName(classValue)); 96 } 93 97 newProblemData.PositiveClass = problemData.PositiveClass; 98 94 99 newProblemData.TrainingPartition.Start = problemData.TrainingPartition.Start; 95 100 newProblemData.TrainingPartition.End = problemData.TrainingPartition.End; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer.cs
r17180 r17456 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 24 using HEAL.Attic; 25 using HeuristicLab.Analysis; 22 26 using HeuristicLab.Common; 23 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 24 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HeuristicLab.Optimization; 25 31 using HeuristicLab.Parameters; 26 using HEAL.Attic;27 32 28 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 38 43 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 39 44 private const string EstimationLimitsParameterName = "EstimationLimits"; 45 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 46 private const string ValidationPartitionParameterName = "ValidationPartition"; 47 private const string AnalyzeTestErrorParameterName = "Analyze Test Error"; 40 48 41 49 #region parameter properties … … 55 63 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 56 64 } 65 public ILookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter { 66 get { return (ILookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; } 67 } 68 public IValueLookupParameter<IntRange> ValidationPartitionParameter { 69 get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; } 70 } 71 public IFixedValueParameter<BoolValue> AnalyzeTestErrorParameter { 72 get { return (IFixedValueParameter<BoolValue>)Parameters[AnalyzeTestErrorParameterName]; } 73 } 74 public bool AnalyzeTestError { 75 get { return AnalyzeTestErrorParameter.Value.Value; } 76 set { AnalyzeTestErrorParameter.Value.Value = value; } 77 } 57 78 #endregion 58 79 … … 66 87 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 67 88 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic classification model.")); 89 Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "Maximal length of the symbolic expression.") { Hidden = true }); 90 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition.")); 91 Parameters.Add(new FixedValueParameter<BoolValue>(AnalyzeTestErrorParameterName, "Flag whether the test error should be displayed in the Pareto-Front", new BoolValue(false))); 92 68 93 } 69 94 public override IDeepCloneable Clone(Cloner cloner) { … … 87 112 return model.CreateClassificationSolution((IClassificationProblemData)ProblemDataParameter.ActualValue.Clone()); 88 113 } 114 115 public override IOperation Apply() { 116 var operation = base.Apply(); 117 var paretoFront = TrainingBestSolutionsParameter.ActualValue; 118 119 IResult result; 120 ScatterPlot qualityToTreeSize; 121 if (!ResultCollection.TryGetValue("Pareto Front Analysis", out result)) { 122 qualityToTreeSize = new ScatterPlot("Quality vs Tree Size", ""); 123 qualityToTreeSize.VisualProperties.XAxisMinimumAuto = false; 124 qualityToTreeSize.VisualProperties.XAxisMaximumAuto = false; 125 qualityToTreeSize.VisualProperties.YAxisMinimumAuto = false; 126 qualityToTreeSize.VisualProperties.YAxisMaximumAuto = false; 127 128 qualityToTreeSize.VisualProperties.XAxisMinimumFixedValue = 0; 129 qualityToTreeSize.VisualProperties.XAxisMaximumFixedValue = MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value; 130 qualityToTreeSize.VisualProperties.YAxisMinimumFixedValue = 0; 131 qualityToTreeSize.VisualProperties.YAxisMaximumFixedValue = 1; 132 ResultCollection.Add(new Result("Pareto Front Analysis", qualityToTreeSize)); 133 } else { 134 qualityToTreeSize = (ScatterPlot)result.Value; 135 } 136 137 int previousTreeLength = -1; 138 var sizeParetoFront = new LinkedList<ISymbolicClassificationSolution>(); 139 foreach (var solution in paretoFront.OrderBy(s => s.Model.SymbolicExpressionTree.Length)) { 140 int treeLength = solution.Model.SymbolicExpressionTree.Length; 141 if (!sizeParetoFront.Any()) sizeParetoFront.AddLast(solution); 142 if (solution.TrainingAccuracy > sizeParetoFront.Last.Value.TrainingAccuracy) { 143 if (treeLength == previousTreeLength) 144 sizeParetoFront.RemoveLast(); 145 sizeParetoFront.AddLast(solution); 146 } 147 previousTreeLength = treeLength; 148 } 149 150 qualityToTreeSize.Rows.Clear(); 151 var trainingRow = new ScatterPlotDataRow("Training Accuracy", "", sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, x.TrainingAccuracy, x))); 152 trainingRow.VisualProperties.PointSize = 8; 153 qualityToTreeSize.Rows.Add(trainingRow); 154 155 if (AnalyzeTestError) { 156 var testRow = new ScatterPlotDataRow("Test Accuracy", "", 157 sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, x.TestAccuracy, x))); 158 testRow.VisualProperties.PointSize = 8; 159 qualityToTreeSize.Rows.Add(testRow); 160 } 161 162 var validationPartition = ValidationPartitionParameter.ActualValue; 163 if (validationPartition.Size != 0) { 164 var problemData = ProblemDataParameter.ActualValue; 165 var validationIndizes = Enumerable.Range(validationPartition.Start, validationPartition.Size).ToList(); 166 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, validationIndizes).ToList(); 167 OnlineCalculatorError error; 168 var validationRow = new ScatterPlotDataRow("Validation Accuracy", "", 169 sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, 170 OnlineAccuracyCalculator.Calculate(targetValues, x.GetEstimatedClassValues(validationIndizes), out error)))); 171 validationRow.VisualProperties.PointSize = 7; 172 qualityToTreeSize.Rows.Add(validationRow); 173 } 174 175 return operation; 176 } 89 177 } 90 178 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views (added) merged: 17378,17380,17430
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r17180 r17456 38 38 } 39 39 40 protected override void SetEnabledStateOfControls() { 41 base.SetEnabledStateOfControls(); 42 43 var tree = Content?.Model?.SymbolicExpressionTree; 44 btnOptimizeConstants.Enabled = tree != null && SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(tree); 45 } 46 40 47 protected override void UpdateModel(ISymbolicExpressionTree tree) { 41 48 var model = new SymbolicRegressionModel(Content.ProblemData.TargetVariable, tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit); … … 46 53 protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicExpressionTree tree, IProgress progress) { 47 54 const int constOptIterations = 50; 48 const int maxRepetitions = 1000; 55 const int maxRepetitions = 100; 56 const double minimumImprovement = 1e-10; 49 57 var regressionProblemData = Content.ProblemData; 50 58 var model = Content.Model; 51 59 progress.CanBeStopped = true; 52 var prevResult = 0.0;60 double prevResult = 0.0, improvement = 0.0; 53 61 var result = 0.0; 54 62 int reps = 0; … … 59 67 applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit, 60 68 iterationCallback: (args, func, obj) => { 61 double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported69 double newProgressValue = progress.ProgressValue + (1.0 / (constOptIterations + 2) / maxRepetitions); // (constOptIterations + 2) iterations are reported 62 70 progress.ProgressValue = Math.Min(newProgressValue, 1.0); 63 71 }); 64 72 reps++; 65 } while (prevResult < result && reps < maxRepetitions && 73 improvement = result - prevResult; 74 } while (improvement > minimumImprovement && reps < maxRepetitions && 66 75 progress.ProgressState != ProgressState.StopRequested && 67 76 progress.ProgressState != ProgressState.CancelRequested); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Views (added) merged: 17377-17378,17380,17430
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
r17180 r17456 57 57 this.grpViewHost = new System.Windows.Forms.GroupBox(); 58 58 this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart(); 59 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 59 60 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 60 61 this.splitContainer.Panel1.SuspendLayout(); … … 148 149 this.btnSimplify.Text = "Simplify"; 149 150 this.btnSimplify.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 151 this.toolTip.SetToolTip(this.btnSimplify, "Simplifies the model structure based on mathematical simplification rules."); 150 152 this.btnSimplify.UseVisualStyleBackColor = true; 151 153 this.btnSimplify.Click += new System.EventHandler(this.btnSimplify_Click); … … 162 164 this.btnOptimizeConstants.Text = "Optimize"; 163 165 this.btnOptimizeConstants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 166 this.toolTip.SetToolTip(this.btnOptimizeConstants, "Optimizes the numerical constants of the model. \r\nIf the algorithm converges, opt" + 167 "imization is stopped."); 164 168 this.btnOptimizeConstants.UseVisualStyleBackColor = true; 165 169 this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click); … … 226 230 protected System.Windows.Forms.Button btnOptimizeConstants; 227 231 private System.Windows.Forms.Label treeStatusValue; 232 private System.Windows.Forms.ToolTip toolTip; 228 233 } 229 234 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r17180 r17456 168 168 private void Content_Changed(object sender, EventArgs e) { 169 169 UpdateView(); 170 SetEnabledStateOfControls(); 170 171 } 171 172 … … 192 193 193 194 progress.Start("Calculate Impact and Replacement Values ..."); 195 cancellationTokenSource = new CancellationTokenSource(); 194 196 progress.CanBeStopped = true; 195 cancellationTokenSource = new CancellationTokenSource();196 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));197 197 try { 198 await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation 199 } catch (OperationCanceledException) { } 200 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 201 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 202 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 203 } 204 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 205 progress.Finish(); 198 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree)); 199 try { 200 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation 201 } catch (OperationCanceledException) { } 202 203 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 204 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 205 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 206 } 207 208 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 209 } finally { 210 progress.Finish(); 211 } 212 206 213 progress.CanBeStopped = false; 207 214 PaintNodeImpacts(); … … 313 320 private async void btnOptimizeConstants_Click(object sender, EventArgs e) { 314 321 progress.Start("Optimizing Constants ..."); 315 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 316 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 317 await Task.Delay(500); // wait for progressbar to finish animation 318 UpdateModel(newTree); // UpdateModel calls Progress.Finish (via Content_Changed) 322 cancellationTokenSource = new CancellationTokenSource(); 323 progress.CanBeStopped = true; 324 try { 325 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 326 327 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); 328 try { 329 await Task.Delay(300, cancellationTokenSource.Token); // wait for progressbar to finish animation 330 } catch (OperationCanceledException) { } 331 UpdateModel(newTree); // triggers progress.Finish after calculating the node impacts when model is changed 332 } catch { 333 progress.Finish(); 334 } 319 335 } 320 336 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/ArithmeticExpressionGrammar.cs
r17180 r17456 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 using HEAL.Attic;27 27 using HeuristicLab.PluginInfrastructure; 28 28 … … 31 31 [StorableType("FCBA02B7-5D29-42F5-A64C-A60AD8EA475D")] 32 32 [Item("ArithmeticExpressionGrammar", "Represents a grammar for functional expressions using only arithmetic operations.")] 33 public class ArithmeticExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {33 public class ArithmeticExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 34 34 35 35 [StorableConstructor] … … 56 56 var factorVariableSymbol = new FactorVariable(); 57 57 58 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol };58 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol }; 59 59 var functionSymbols = new List<Symbol>() { add, sub, mul, div }; 60 60 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r17180 r17456 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 30 [StorableType("44B0829C-1CB5-4BE9-9514-BBA54FAB2912")] 31 31 [Item("FullFunctionalExpressionGrammar", "Represents a grammar for functional expressions using all available functions.")] 32 public class FullFunctionalExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {32 public class FullFunctionalExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 33 33 [StorableConstructor] 34 34 protected FullFunctionalExpressionGrammar(StorableConstructorFlag _) : base(_) { } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r17455 r17456 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HEAL.Attic;28 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 29 29 [StorableType("36A22322-0627-4E25-A468-F2A788AF6D46")] 30 30 [Item("TypeCoherentExpressionGrammar", "Represents a grammar for functional expressions in which special syntactic constraints are enforced so that boolean and real-valued expressions are not mixed.")] 31 public class TypeCoherentExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {31 public class TypeCoherentExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 32 32 private const string ArithmeticFunctionsName = "Arithmetic Functions"; 33 33 private const string TrigonometricFunctionsName = "Trigonometric Functions"; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17455 r17456 160 160 <Compile Include="Formatters\SymbolicDataAnalysisExpressionMathematicaFormatter.cs" /> 161 161 <Compile Include="Formatters\SymbolicDataAnalysisExpressionCSharpFormatter.cs" /> 162 <Compile Include="Grammars\DataAnalysisGrammar.cs" /> 162 163 <Compile Include="Hashing\HashExtensions.cs" /> 163 164 <Compile Include="Hashing\HashUtil.cs" /> -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisGrammar.cs
r17180 r17456 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 23 using HEAL.Attic;24 24 25 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 26 26 [StorableType("5b0720d7-b1f0-4c2f-893e-cd2549e20e9e")] 27 27 public interface ISymbolicDataAnalysisGrammar : ISymbolicExpressionGrammar { 28 void ConfigureVariableSymbols(IDataAnalysisProblemData problemData); 28 29 } 29 30 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16768 r17456 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 181 202 182 203 [ThreadStatic] 183 private Dictionary<string, double[]> cachedData;204 private static Dictionary<string, double[]> cachedData; 184 205 185 206 [ThreadStatic] 186 private IDataset dataset;207 private static IDataset cachedDataset; 187 208 188 209 private void InitCache(IDataset dataset) { 189 this.dataset = dataset;210 cachedDataset = dataset; 190 211 cachedData = new Dictionary<string, double[]>(); 191 212 foreach (var v in dataset.DoubleVariables) { … … 196 217 public void InitializeState() { 197 218 cachedData = null; 198 dataset = null;219 cachedDataset = null; 199 220 EvaluatedSolutions = 0; 200 221 } 201 222 202 223 private double[] GetValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 203 if (cachedData == null || this.dataset != dataset) {224 if (cachedData == null || cachedDataset != dataset) { 204 225 InitCache(dataset); 205 226 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
r17180 r17456 99 99 100 100 [ThreadStatic] 101 private IDataset dataset;101 private static IDataset cachedDataset; 102 102 103 103 private static readonly HashSet<byte> supportedOpCodes = new HashSet<byte>() { … … 127 127 if (!rows.Any()) return Enumerable.Empty<double>(); 128 128 129 if (cachedData == null || this.dataset != dataset) {129 if (cachedData == null || cachedDataset != dataset) { 130 130 InitCache(dataset); 131 131 } … … 152 152 153 153 private void InitCache(IDataset dataset) { 154 this.dataset = dataset;154 cachedDataset = dataset; 155 155 156 156 // free handles to old data … … 178 178 cachedData = null; 179 179 } 180 dataset = null;180 cachedDataset = null; 181 181 EvaluatedSolutions = 0; 182 182 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r17455 r17456 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Common.Resources; … … 31 32 using HeuristicLab.Optimization; 32 33 using HeuristicLab.Parameters; 33 using HEAL.Attic;34 34 using HeuristicLab.PluginInfrastructure; 35 35 using HeuristicLab.Problems.Instances; … … 212 212 protected virtual void UpdateGrammar() { 213 213 var problemData = ProblemData; 214 var ds = problemData.Dataset;215 214 var grammar = SymbolicExpressionTreeGrammar; 215 216 216 grammar.MaximumFunctionArguments = MaximumFunctionArguments.Value; 217 217 grammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value; 218 foreach (var varSymbol in grammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableBase>()) { 219 if (!varSymbol.Fixed) { 220 varSymbol.AllVariableNames = problemData.InputVariables.Select(x => x.Value).Where(x => ds.VariableHasType<double>(x)); 221 varSymbol.VariableNames = problemData.AllowedInputVariables.Where(x => ds.VariableHasType<double>(x)); 222 } 223 } 224 foreach (var factorSymbol in grammar.Symbols.OfType<BinaryFactorVariable>()) { 225 if (!factorSymbol.Fixed) { 226 factorSymbol.AllVariableNames = problemData.InputVariables.Select(x => x.Value).Where(x => ds.VariableHasType<string>(x)); 227 factorSymbol.VariableNames = problemData.AllowedInputVariables.Where(x => ds.VariableHasType<string>(x)); 228 factorSymbol.VariableValues = factorSymbol.VariableNames 229 .ToDictionary(varName => varName, varName => ds.GetStringValues(varName).Distinct().ToList()); 230 } 231 } 232 foreach (var factorSymbol in grammar.Symbols.OfType<FactorVariable>()) { 233 if (!factorSymbol.Fixed) { 234 factorSymbol.AllVariableNames = problemData.InputVariables.Select(x => x.Value).Where(x => ds.VariableHasType<string>(x)); 235 factorSymbol.VariableNames = problemData.AllowedInputVariables.Where(x => ds.VariableHasType<string>(x)); 236 factorSymbol.VariableValues = factorSymbol.VariableNames 237 .ToDictionary(varName => varName, 238 varName => ds.GetStringValues(varName).Distinct() 239 .Select((n, i) => Tuple.Create(n, i)) 240 .ToDictionary(tup => tup.Item1, tup => tup.Item2)); 241 } 242 } 218 219 grammar.ConfigureVariableSymbols(problemData); 243 220 } 244 221 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views (added) merged: 17426
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r17276 r17456 25 25 using System.Threading; 26 26 using System.Threading.Tasks; 27 using System.Windows.Forms; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Data; … … 40 41 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 42 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 private bool attachedToProgress = false;43 43 44 44 public new IClassificationSolution Content { … … 87 87 } 88 88 } 89 protected override void OnHidden(EventArgs e) { 90 base.OnHidden(e); 89 protected override void OnVisibleChanged(EventArgs e) { 90 base.OnVisibleChanged(e); 91 if (!this.Visible) { 92 cancellationToken.Cancel(); 93 } 94 } 95 96 protected override void OnClosed(FormClosedEventArgs e) { 97 base.OnClosed(e); 91 98 cancellationToken.Cancel(); 92 93 if (attachedToProgress) {94 Progress.Hide(this);95 attachedToProgress = false;96 }97 99 } 98 100 … … 133 135 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 134 136 progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name); 135 attachedToProgress = true;136 137 cancellationToken = new CancellationTokenSource(); 137 138 … … 145 146 .ToList(); 146 147 147 List<Tuple<string, double>> impacts = null; 148 await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedClassValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); }); 149 if (impacts == null) { return; } 148 var impacts = await Task.Run(() => CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedClassValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress)); 150 149 151 150 rawVariableImpacts.AddRange(impacts); 152 151 UpdateOrdering(); 152 } catch (OperationCanceledException) { 153 153 } finally { 154 if (attachedToProgress) { 155 Progress.Hide(this); 156 attachedToProgress = false; 157 } 154 Progress.Hide(this); 158 155 } 159 156 } … … 180 177 var clonedModel = (IClassificationModel)model.Clone(); 181 178 foreach (var variableName in originalVariableOrdering) { 182 if (cancellationToken.Token.IsCancellationRequested) { return null; }179 token.ThrowIfCancellationRequested(); 183 180 progress.ProgressValue = (double)++i / count; 184 181 progress.Message = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r17416 r17456 25 25 using System.Threading; 26 26 using System.Threading.Tasks; 27 using System.Windows.Forms; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Data; … … 40 41 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 42 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 private bool attachedToProgress = false;43 43 44 44 public new IRegressionSolution Content { … … 88 88 } 89 89 90 protected override void OnHidden(EventArgs e) { 91 base.OnHidden(e); 90 protected override void OnVisibleChanged(EventArgs e) { 91 base.OnVisibleChanged(e); 92 if (!this.Visible) { 93 cancellationToken.Cancel(); 94 } 95 } 96 97 protected override void OnClosed(FormClosedEventArgs e) { 98 base.OnClosed(e); 92 99 cancellationToken.Cancel(); 93 94 if (attachedToProgress) {95 Progress.Hide(this);96 attachedToProgress = false;97 }98 100 } 99 101 … … 132 134 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 133 135 var progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name); 134 attachedToProgress = true;135 136 cancellationToken = new CancellationTokenSource(); 136 137 … … 144 145 .ToList(); 145 146 146 List<Tuple<string, double>> impacts = null; 147 await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); }); 148 if (impacts == null) { return; } 147 var impacts = await Task.Run(() => CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress)); 149 148 150 149 rawVariableImpacts.AddRange(impacts); 151 150 UpdateOrdering(); 151 } catch (OperationCanceledException) { 152 152 } finally { 153 if (attachedToProgress) { 154 Progress.Hide(this); 155 attachedToProgress = false; 156 } 153 Progress.Hide(this); 157 154 } 158 155 } … … 179 176 180 177 foreach (var variableName in originalVariableOrdering) { 181 if (cancellationToken.Token.IsCancellationRequested) { return null; }178 token.ThrowIfCancellationRequested(); 182 179 progress.ProgressValue = (double)++i / count; 183 180 progress.Message = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4 (added) merged: 17422-17423
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionVariableImpactsCalculator.cs
r17180 r17456 26 26 using System.Collections.Generic; 27 27 using System.Linq; 28 using HEAL.Attic; 28 29 using HeuristicLab.Common; 29 30 using HeuristicLab.Core; 30 31 using HeuristicLab.Data; 31 32 using HeuristicLab.Parameters; 32 using HEAL.Attic;33 33 using HeuristicLab.Random; 34 34 … … 173 173 174 174 IList originalValues = null; 175 IList replacementValues = GetReplacementValues(modifiableDataset, variableName, model, rows, targetValues, out originalValues, replacementMethod, factorReplacementMethod);176 177 double newValue = CalculateQualityForReplacement(model, modifiableDataset, variableName, originalValues, rows, replacementValues, targetValues);175 IList replacementValues = GetReplacementValues(modifiableDataset, variableName, model, problemData.AllowedInputVariables, rows, targetValues, out originalValues, replacementMethod, factorReplacementMethod); 176 177 double newValue = CalculateQualityForReplacement(model, modifiableDataset, problemData.AllowedInputVariables, variableName, originalValues, rows, replacementValues, targetValues); 178 178 double impact = quality - newValue; 179 179 … … 184 184 string variableName, 185 185 IClassificationModel model, 186 IEnumerable<string> allowedInputVariables, 186 187 IEnumerable<int> rows, 187 188 IEnumerable<double> targetValues, … … 196 197 } else if (modifiableDataset.VariableHasType<string>(variableName)) { 197 198 originalValues = modifiableDataset.GetReadOnlyStringValues(variableName).ToList(); 198 replacementValues = GetReplacementValuesForString(model, modifiableDataset, variableName, rows, (List<string>)originalValues, targetValues, factorReplacementMethod);199 replacementValues = GetReplacementValuesForString(model, modifiableDataset, allowedInputVariables, variableName, rows, (List<string>)originalValues, targetValues, factorReplacementMethod); 199 200 } else { 200 201 throw new NotSupportedException("Variable not supported"); … … 254 255 private static IList GetReplacementValuesForString(IClassificationModel model, 255 256 ModifiableDataset modifiableDataset, 257 IEnumerable<string> allowedInputVariables, 256 258 string variableName, 257 259 IEnumerable<int> rows, … … 270 272 List<string> curReplacementValues = Enumerable.Repeat(repl, modifiableDataset.Rows).ToList(); 271 273 //fholzing: this result could be used later on (theoretically), but is neglected for better readability/method consistency 272 var newValue = CalculateQualityForReplacement(model, modifiableDataset, variableName, originalValues, rows, curReplacementValues, targetValues);274 var newValue = CalculateQualityForReplacement(model, modifiableDataset, allowedInputVariables, variableName, originalValues, rows, curReplacementValues, targetValues); 273 275 var curQuality = newValue; 274 276 … … 308 310 IClassificationModel model, 309 311 ModifiableDataset modifiableDataset, 312 IEnumerable<string> allowedInputVariables, 310 313 string variableName, 311 314 IList originalValues, … … 317 320 var discModel = model as IDiscriminantFunctionClassificationModel; 318 321 if (discModel != null) { 319 var problemData = new ClassificationProblemData(modifiableDataset, modifiableDataset.VariableNames, model.TargetVariable);322 var problemData = new ClassificationProblemData(modifiableDataset, allowedInputVariables, model.TargetVariable); 320 323 discModel.RecalculateModelParameters(problemData, rows); 321 324 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs
r17180 r17456 74 74 classValues = (double[])original.classValues.Clone(); 75 75 thresholds = (double[])original.thresholds.Clone(); 76 thresholdCalculator = (IDiscriminantFunctionThresholdCalculator)original.thresholdCalculator.Clone(); 76 77 } 77 78 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.ExternalEvaluation.GP/3.5/ExternalEvaluationExpressionGrammar.cs
r17180 r17456 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 using H EAL.Attic;26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 27 using HeuristicLab.Problems.DataAnalysis.Symbolic; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 28 29 29 namespace HeuristicLab.Problems.ExternalEvaluation.GP { 30 30 [StorableType("747A7784-EF15-4CEF-A621-79A9071A69F5")] 31 31 [Item("ExternalEvaluationExpressionGrammar", "Represents a grammar for functional expressions using all available functions.")] 32 public class ExternalEvaluationExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {32 public class ExternalEvaluationExpressionGrammar : DataAnalysisGrammar { 33 33 [Storable] 34 34 private HeuristicLab.Problems.DataAnalysis.Symbolic.Variable variableSymbol; … … 45 45 } 46 46 47 private void Initialize() { 47 private void Initialize() { 48 48 var add = new Addition(); 49 49 var sub = new Subtraction(); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.GrammaticalEvolution
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.GrammaticalEvolution (added) merged: 17413
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.GrammaticalEvolution/3.4/SymbolicRegression/GESymbolicExpressionGrammar.cs
r17180 r17456 25 25 using System.Collections.Generic; 26 26 using System.Linq; 27 using HEAL.Attic; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Core; 29 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HEAL.Attic;31 31 using HeuristicLab.Problems.DataAnalysis.Symbolic; 32 32 using HeuristicLab.Random; … … 35 35 [StorableType("73D43A23-02FF-4BD8-9834-55D8A90E0FCE")] 36 36 [Item("GESymbolicExpressionGrammar", "Represents a grammar for functional expressions for grammatical evolution.")] 37 public class GESymbolicExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {37 public class GESymbolicExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 38 38 [StorableConstructor] 39 39 protected GESymbolicExpressionGrammar(StorableConstructorFlag _) : base(_) { } -
branches/3040_VectorBasedGP/HeuristicLab.Scripting.Views/3.3/HeuristicLab.Scripting.Views-3.3.csproj
r16658 r17456 97 97 <Compile Include="CSharpScriptView.Designer.cs"> 98 98 <DependentUpon>CSharpScriptView.cs</DependentUpon> 99 </Compile> 100 <Compile Include="CompilerErrorDialog.cs"> 101 <SubType>Form</SubType> 102 </Compile> 103 <Compile Include="CompilerErrorDialog.Designer.cs"> 104 <DependentUpon>CompilerErrorDialog.cs</DependentUpon> 99 105 </Compile> 100 106 <Compile Include="ExecutableScriptView.cs"> -
branches/3040_VectorBasedGP/HeuristicLab.Scripting.Views/3.3/ScriptView.Designer.cs
r17180 r17456 184 184 this.errorListView.UseCompatibleStateImageBehavior = false; 185 185 this.errorListView.View = System.Windows.Forms.View.Details; 186 this.errorListView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.errorListView_MouseClick); 186 187 this.errorListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.errorListView_MouseDoubleClick); 187 188 // -
branches/3040_VectorBasedGP/HeuristicLab.Scripting.Views/3.3/ScriptView.cs
r17180 r17456 209 209 } 210 210 211 private void errorListView_MouseClick(object sender, MouseEventArgs e) { 212 if (e.Button != MouseButtons.Left) return; 213 214 var item = errorListView.SelectedItems[0]; 215 var message = (CompilerError)item.Tag; 216 217 codeEditor.ScrollToPosition(message.Line, message.Column); 218 codeEditor.Focus(); 219 } 220 211 221 private void errorListView_MouseDoubleClick(object sender, MouseEventArgs e) { 212 if (e.Button == MouseButtons.Left) { 213 var item = errorListView.SelectedItems[0]; 214 var message = (CompilerError)item.Tag; 215 codeEditor.ScrollToPosition(message.Line, message.Column); 216 codeEditor.Focus(); 217 } 222 if (e.Button != MouseButtons.Left) return; 223 224 var item = errorListView.SelectedItems[0]; 225 var message = (CompilerError)item.Tag; 226 227 using (var dialog = new CompilerErrorDialog(message)) { 228 dialog.ShowDialog(this); 229 }; 218 230 } 219 231 #endregion -
branches/3040_VectorBasedGP/HeuristicLab.Services.Hive
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Services.Hive (added) merged: 17376
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Services.Hive/3.3/HiveService.cs
r17180 r17456 665 665 bool oldIsAllowedToCalculate = slave.IsAllowedToCalculate; 666 666 Guid? oldParentResourceId = slave.ParentResourceId; 667 bool? oldIsDisposable = slave.IsDisposable; 667 668 slaveInfo.CopyToEntity(slave); 668 669 slave.IsAllowedToCalculate = oldIsAllowedToCalculate; 669 670 slave.ParentResourceId = oldParentResourceId; 671 slave.IsDisposable = oldIsDisposable; 670 672 slave.LastHeartbeat = DateTime.Now; 671 673 slave.SlaveState = DA.SlaveState.Idle; -
branches/3040_VectorBasedGP/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Tests (added) merged: 17428
- Property svn:mergeinfo changed
-
branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GaussianProcessRegressionSampleTest.cs
r17180 r17456 68 68 gpr.Problem = regProblem; 69 69 70 gpr.CovarianceFunction = new CovarianceSquaredExponentialIso();71 gpr.MeanFunction = new MeanConst();70 gpr.CovarianceFunction = gpr.CovarianceFunctionParameter.ValidValues.OfType<CovarianceSquaredExponentialIso>().First(); 71 gpr.MeanFunction = gpr.MeanFunctionParameter.ValidValues.OfType<MeanConst>().First(); 72 72 gpr.MinimizationIterations = 20; 73 73 gpr.Seed = 0;
Note: See TracChangeset
for help on using the changeset viewer.