Changeset 17586
- Timestamp:
- 06/04/20 15:55:13 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 1 deleted
- 60 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
/trunk merged: 17574-17576,17579-17581,17583-17585
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.Slave merged: 17576
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
r17226 r17586 251 251 TaskData taskData = wcfService.GetTaskData(taskId); 252 252 if (taskData == null) throw new TaskDataNotFoundException(taskId); 253 task = wcfService.Update JobState(taskId, TaskState.Calculating, null);253 task = wcfService.UpdateTaskState(taskId, TaskState.Calculating, null); 254 254 if (task == null) throw new TaskNotFoundException(taskId); 255 255 taskManager.StartTaskAsync(task, taskData); … … 268 268 } 269 269 catch (OutOfCoresException) { 270 wcfService.Update JobState(taskId, TaskState.Waiting, "No more cores available");270 wcfService.UpdateTaskState(taskId, TaskState.Waiting, "No more cores available"); 271 271 throw; 272 272 } 273 273 catch (OutOfMemoryException) { 274 wcfService.Update JobState(taskId, TaskState.Waiting, "No more memory available");274 wcfService.UpdateTaskState(taskId, TaskState.Waiting, "No more memory available"); 275 275 throw; 276 276 } 277 277 catch (Exception e) { 278 278 SlaveStatusInfo.DecrementUsedCores(usedCores); 279 wcfService.Update JobState(taskId, TaskState.Failed, e.ToString());279 wcfService.UpdateTaskState(taskId, TaskState.Failed, e.ToString()); 280 280 throw; 281 281 } … … 391 391 wcfService.UpdateTaskData(task, taskData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString()); 392 392 } else { 393 wcfService.Update JobState(task.Id, TaskState.Failed, exception.ToString());393 wcfService.UpdateTaskState(task.Id, TaskState.Failed, exception.ToString()); 394 394 } 395 395 SlaveClientCom.Instance.LogMessage(exception.Message); … … 408 408 var slaveTask = e.Value; 409 409 var task = wcfService.GetTask(slaveTask.TaskId); 410 wcfService.Update JobState(task.Id, TaskState.Aborted, null);410 wcfService.UpdateTaskState(task.Id, TaskState.Aborted, null); 411 411 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 412 412 } -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/WcfService.cs
r17226 r17586 82 82 } 83 83 84 public Task Update JobState(Guid taskId, TaskState taskState, string exception) {84 public Task UpdateTaskState(Guid taskId, TaskState taskState, string exception) { 85 85 return CallHiveService(s => s.UpdateTaskState(taskId, taskState, ConfigManager.Instance.GetClientInfo().Id, null, exception)); 86 86 } -
branches/2521_ProblemRefactoring/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs
r17226 r17586 170 170 } 171 171 172 172 173 private void OnViewTypeChanged() { 173 if (viewType != null) {174 175 throw new InvalidOperationException(string.Format("View \"{0}\" cannot display content \"{1}\".",176 viewType, Content.GetType())); 177 178 179 180 181 182 183 184 } 174 if (viewType == null) return; 175 if (!ViewCanShowContent(viewType, Content)) 176 throw new InvalidOperationException(string.Format("View \"{0}\" cannot display content \"{1}\".", viewType, Content.GetType())); 177 178 IContentView view = MainFormManager.CreateView(viewType); 179 view.Locked = Locked; 180 view.ReadOnly = ReadOnly; 181 ActiveView = view; //necessary to allow the views to change the status of the viewhost 182 view.Content = Content; 183 184 UpdateActiveMenuItem(); 185 185 186 } 186 187 … … 188 189 activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged); 189 190 activeView.LockedChanged += new EventHandler(activeView_LockedChanged); 191 activeView.ReadOnlyChanged += new EventHandler(activeView_ReadOnlyChanged); 190 192 activeView.Changed += new EventHandler(activeView_Changed); 191 193 } … … 193 195 activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged); 194 196 activeView.LockedChanged -= new EventHandler(activeView_LockedChanged); 197 activeView.ReadOnlyChanged -= new EventHandler(activeView_ReadOnlyChanged); 195 198 activeView.Changed -= new EventHandler(activeView_Changed); 196 199 } … … 202 205 configurationLabel.Enabled = !activeView.Locked; 203 206 } 207 private void activeView_ReadOnlyChanged(object sender, EventArgs e) { 208 ReadOnly = activeView.ReadOnly; 209 } 210 204 211 private void activeView_Changed(object sender, EventArgs e) { 205 212 OnChanged(); … … 228 235 229 236 #region forwarding of view events 230 internal protectedoverride void OnShown(ViewShownEventArgs e) {237 protected internal override void OnShown(ViewShownEventArgs e) { 231 238 base.OnShown(e); 232 239 View view = ActiveView as View; … … 234 241 view.OnShown(e); 235 242 } 236 internal protectedoverride void OnHidden(EventArgs e) {243 protected internal override void OnHidden(EventArgs e) { 237 244 base.OnHidden(e); 238 245 View view = ActiveView as View; … … 240 247 view.OnHidden(e); 241 248 } 242 internal protectedoverride void OnClosing(FormClosingEventArgs e) {249 protected internal override void OnClosing(FormClosingEventArgs e) { 243 250 base.OnClosing(e); 244 251 View view = ActiveView as View; … … 246 253 view.OnClosing(e); 247 254 } 248 internal protectedoverride void OnClosed(FormClosedEventArgs e) {255 protected internal override void OnClosed(FormClosedEventArgs e) { 249 256 base.OnClosed(e); 250 257 View view = ActiveView as View; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs
r17226 r17586 23 23 24 24 namespace HeuristicLab.Optimization { 25 26 //TODO add non-generic for bwerths problem modifiers 27 public interface IProblemDefinition { 28 //IEncoding Encoding { get; } 29 } 30 25 31 [StorableType("747a3cea-b9ba-4322-a5c2-050cd7e16e2a")] 26 public interface IProblemDefinition<TEncoding, TEncodedSolution> 32 public interface IProblemDefinition<TEncoding, TEncodedSolution> : IProblemDefinition 27 33 where TEncoding : class, IEncoding<TEncodedSolution> 28 34 where TEncodedSolution : class, IEncodedSolution { 29 35 TEncoding Encoding { get; } 36 30 37 } 31 38 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionEvaluator.cs
r17226 r17586 1 using HEAL.Attic; 2 #region License Information 1 #region License Information 3 2 /* HeuristicLab 4 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 20 19 */ 21 20 #endregion 22 21 using HEAL.Attic; 23 22 24 23 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionModel.cs
r17226 r17586 1 using HEAL.Attic; 2 #region License Information 1 #region License Information 3 2 /* HeuristicLab 4 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 21 20 #endregion 22 21 22 using HEAL.Attic; 23 23 24 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 24 25 [StorableType("a411e2b5-f926-41a6-b55b-1aef862db2fb")] -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSolution.cs
r17226 r17586 22 22 23 23 24 24 25 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 25 26 [StorableType("dff1a450-e958-454f-bf8e-6b763fdcaff3")] -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r17226 r17586 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 21 21 22 22 using System.Linq; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 28 using HeuristicLab.Optimization; 28 using HEAL.Attic;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 47 47 private const string TestNaNEvaluationsResultName = "Test NaN Evaluations"; 48 48 49 private const string ModelBoundsResultName = "Model Bounds"; 50 49 51 public new ISymbolicRegressionModel Model { 50 52 get { return (ISymbolicRegressionModel)base.Model; } … … 95 97 private set { ((IntValue)EstimationLimitsResultCollection[TestNaNEvaluationsResultName].Value).Value = value; } 96 98 } 99 100 public IntervalCollection ModelBoundsCollection { 101 get { 102 if (!ContainsKey(ModelBoundsResultName)) return null; 103 return (IntervalCollection)this[ModelBoundsResultName].Value; 104 } 105 private set { 106 if (ContainsKey(ModelBoundsResultName)) { 107 this[ModelBoundsResultName].Value = value; 108 } else { 109 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", value)); 110 } 111 112 } 113 } 114 115 97 116 98 117 [StorableConstructor] … … 118 137 estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue())); 119 138 Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults)); 139 140 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 141 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 142 120 143 RecalculateResults(); 121 144 } … … 139 162 CalculateResults(); 140 163 } 164 165 if (!ContainsKey(ModelBoundsResultName)) { 166 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) { 167 Add(new Result(ModelBoundsResultName, "Results concerning the derivation of symbolic regression solution", new IntervalCollection())); 168 CalculateResults(); 169 } 170 } 141 171 } 142 172 … … 159 189 TrainingNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TrainingIndices).Count(double.IsNaN); 160 190 TestNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TestIndices).Count(double.IsNaN); 191 192 //Check if the tree contains unknown symbols for the interval calculation 193 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 194 ModelBoundsCollection = CalculateModelIntervals(this); 195 } 196 197 private static IntervalCollection CalculateModelIntervals(ISymbolicRegressionSolution solution) { 198 var intervalEvaluation = new IntervalCollection(); 199 var interpreter = new IntervalInterpreter(); 200 var problemData = solution.ProblemData; 201 var model = solution.Model; 202 var variableRanges = problemData.VariableRanges.GetReadonlyDictionary(); 203 204 intervalEvaluation.AddInterval($"Target {problemData.TargetVariable}", new Interval(variableRanges[problemData.TargetVariable].LowerBound, variableRanges[problemData.TargetVariable].UpperBound)); 205 intervalEvaluation.AddInterval("Model", interpreter.GetSymbolicExpressionTreeInterval(model.SymbolicExpressionTree, variableRanges)); 206 207 if (DerivativeCalculator.IsCompatible(model.SymbolicExpressionTree)) { 208 foreach (var inputVariable in model.VariablesUsedForPrediction.OrderBy(v => v, new NaturalStringComparer())) { 209 var derivedModel = DerivativeCalculator.Derive(model.SymbolicExpressionTree, inputVariable); 210 var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derivedModel, variableRanges); 211 212 intervalEvaluation.AddInterval(" ∂f/∂" + inputVariable, new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound)); 213 } 214 } 215 216 return intervalEvaluation; 161 217 } 162 218 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r17457 r17586 35 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 36 36 public abstract partial class InteractiveSymbolicDataAnalysisSolutionSimplifierView : AsynchronousContentView { 37 private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes; 38 private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes; 39 private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts; 37 private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 38 private readonly Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 39 private readonly Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>(); 40 private readonly Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>(); 40 41 41 42 private readonly ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator; … … 49 50 protected InteractiveSymbolicDataAnalysisSolutionSimplifierView(ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator) { 50 51 InitializeComponent(); 51 foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();52 changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();53 nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();54 52 this.Caption = "Interactive Solution Simplifier"; 55 53 this.impactCalculator = impactCalculator; … … 173 171 protected override void OnContentChanged() { 174 172 base.OnContentChanged(); 175 foldedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(); 173 foldedNodes.Clear(); 174 changedNodes.Clear(); 175 nodeIntervals.Clear(); 176 nodeImpacts.Clear(); 176 177 UpdateView(); 177 178 viewHost.Content = this.Content; … … 205 206 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 206 207 } 207 208 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 208 209 foreach (var pair in impactAndReplacementValues) { 210 nodeImpacts[pair.Key] = pair.Value.Item1; 211 } 212 213 if (IntervalInterpreter.IsCompatible(tree)) { 214 var regressionProblemData = Content.ProblemData as IRegressionProblemData; 215 if (regressionProblemData != null) { 216 var interpreter = new IntervalInterpreter(); 217 var variableRanges = regressionProblemData.VariableRanges.GetReadonlyDictionary(); 218 IDictionary<ISymbolicExpressionTreeNode, Interval> intervals; 219 interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals); 220 foreach (var kvp in intervals) { 221 nodeIntervals[kvp.Key] = kvp.Value; 222 } 223 } 224 } 209 225 } finally { 210 226 progress.Finish(); … … 303 319 } 304 320 } 305 if (visualTree != null) 321 if (visualTree != null) { 322 if (nodeIntervals.ContainsKey(treeNode)) 323 visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{nodeIntervals[treeNode].LowerBound:G5} ... {nodeIntervals[treeNode].UpperBound:G5}]"); 306 324 if (changedNodes.ContainsKey(treeNode)) { 307 325 visualTree.LineColor = Color.DodgerBlue; … … 309 327 visualTree.LineColor = Color.DarkOrange; 310 328 } 329 } 311 330 } 312 331 treeChart.RepaintNodes(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r17226 r17586 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Globalization; 24 25 using System.Linq; 25 26 using System.Text; 27 using HEAL.Attic; 26 28 using HeuristicLab.Common; 27 29 using HeuristicLab.Core; 28 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HEAL.Attic;30 31 31 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 32 /// <summary> 33 /// Formats mathematical expressions in infix form. E.g. x1 * (3.0 * x2 + x3) 34 /// </summary> 35 [StorableType("6FE2C83D-A594-4ABF-B101-5AEAEA6D3E3D")] 36 [Item("Infix Symbolic Expression Tree Formatter", "A string formatter that converts symbolic expression trees to infix expressions.")] 37 38 public sealed class InfixExpressionFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 39 40 41 [StorableConstructor] 42 private InfixExpressionFormatter(StorableConstructorFlag _) : base(_) { } 43 private InfixExpressionFormatter(InfixExpressionFormatter original, Cloner cloner) : base(original, cloner) { } 44 public InfixExpressionFormatter() 45 : base() { 46 Name = ItemName; 47 Description = ItemDescription; 48 } 49 public override IDeepCloneable Clone(Cloner cloner) { 50 return new InfixExpressionFormatter(this, cloner); 51 } 52 53 /// <summary> 54 /// Produces an infix expression for a given expression tree. 55 /// </summary> 56 /// <param name="symbolicExpressionTree">The tree representation of the expression.</param> 57 /// <param name="numberFormat">Number format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param> 58 /// <param name="formatString">The format string for numeric parameters (e.g. \"G4\" to limit to 4 digits, default is \"G\")</param> 59 /// <returns>Infix expression</returns> 60 public string Format(ISymbolicExpressionTree symbolicExpressionTree, NumberFormatInfo numberFormat, string formatString="G") { 61 // skip root and start symbols 62 StringBuilder strBuilder = new StringBuilder(); 63 FormatRecursively(symbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0), strBuilder, numberFormat, formatString); 64 return strBuilder.ToString(); 65 } 66 67 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 68 return Format(symbolicExpressionTree, NumberFormatInfo.InvariantInfo); 69 } 70 71 private static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, NumberFormatInfo numberFormat, string formatString) { 33 public static class BaseInfixExpressionFormatter { 34 public static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, 35 NumberFormatInfo numberFormat, string formatString, List<KeyValuePair<string, double>> constants = null) { 72 36 if (node.SubtreeCount > 1) { 73 37 var token = GetToken(node.Symbol); … … 77 41 token == "^") { 78 42 strBuilder.Append("("); 79 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString );43 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, constants); 80 44 81 45 foreach (var subtree in node.Subtrees.Skip(1)) { 82 46 strBuilder.Append(" ").Append(token).Append(" "); 83 FormatRecursively(subtree, strBuilder, numberFormat, formatString); 84 } 47 FormatRecursively(subtree, strBuilder, numberFormat, formatString, constants); 48 } 49 85 50 strBuilder.Append(")"); 86 51 } else { 87 52 // function with multiple arguments 88 53 strBuilder.Append(token).Append("("); 89 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString );54 FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, constants); 90 55 foreach (var subtree in node.Subtrees.Skip(1)) { 91 56 strBuilder.Append(", "); 92 FormatRecursively(subtree, strBuilder, numberFormat, formatString); 93 } 57 FormatRecursively(subtree, strBuilder, numberFormat, formatString, constants); 58 } 59 94 60 strBuilder.Append(")"); 95 61 } … … 98 64 if (token == "-" || token == "NOT") { 99 65 strBuilder.Append("(").Append(token).Append("("); 100 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString );66 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, constants); 101 67 strBuilder.Append("))"); 102 68 } else if (token == "/") { 103 69 strBuilder.Append("1/"); 104 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString );70 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, constants); 105 71 } else if (token == "+" || token == "*") { 106 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString );72 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, constants); 107 73 } else { 108 74 // function with only one argument 109 75 strBuilder.Append(token).Append("("); 110 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString );76 FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, constants); 111 77 strBuilder.Append(")"); 112 78 } … … 117 83 if (!varNode.Weight.IsAlmost(1.0)) { 118 84 strBuilder.Append("("); 119 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 85 if (constants != null) { 86 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Weight); 87 } else { 88 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 89 } 120 90 strBuilder.Append("*"); 121 91 } 92 122 93 strBuilder.Append("LAG("); 123 if (varNode.VariableName.Contains("'")) {94 if (varNode.VariableName.Contains("'")) 124 95 strBuilder.AppendFormat("\"{0}\"", varNode.VariableName); 125 } else {96 else 126 97 strBuilder.AppendFormat("'{0}'", varNode.VariableName); 127 } 98 128 99 strBuilder.Append(", ") 129 .AppendFormat(numberFormat, "{0}", varNode.Lag)130 .Append(")");100 .AppendFormat(numberFormat, "{0}", varNode.Lag) 101 .Append(")"); 131 102 } else if (node.Symbol is Variable) { 132 103 var varNode = node as VariableTreeNode; 133 104 if (!varNode.Weight.IsAlmost(1.0)) { 134 105 strBuilder.Append("("); 135 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 106 if (constants != null) { 107 string constantKey = $"c_{constants.Count}"; 108 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", constantKey); 109 constants.Add(new KeyValuePair<string, double>(constantKey, varNode.Weight)); 110 } else { 111 strBuilder.Append(varNode.Weight.ToString(formatString, numberFormat)); 112 } 113 136 114 strBuilder.Append("*"); 137 115 } 138 if (varNode.VariableName.Contains("'")) { 116 117 if (varNode.VariableName.Contains("'")) 139 118 strBuilder.AppendFormat("\"{0}\"", varNode.VariableName); 140 } else {119 else 141 120 strBuilder.AppendFormat("'{0}'", varNode.VariableName); 142 } 143 if (!varNode.Weight.IsAlmost(1.0)) { 144 strBuilder.Append(")"); 145 } 121 122 if (!varNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 146 123 } else if (node.Symbol is FactorVariable) { 147 124 var factorNode = node as FactorVariableTreeNode; 148 if (factorNode.VariableName.Contains("'")) {125 if (factorNode.VariableName.Contains("'")) 149 126 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableName); 150 } else {127 else 151 128 strBuilder.AppendFormat("'{0}'", factorNode.VariableName); 152 } 129 153 130 strBuilder.AppendFormat("[{0}]", 154 131 string.Join(", ", factorNode.Weights.Select(w => w.ToString(formatString, numberFormat)))); … … 157 134 if (!factorNode.Weight.IsAlmost(1.0)) { 158 135 strBuilder.Append("("); 159 strBuilder.Append(factorNode.Weight.ToString(formatString, numberFormat)); 136 if (constants != null) { 137 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", factorNode.Weight); 138 } else { 139 strBuilder.Append(factorNode.Weight.ToString(formatString, numberFormat)); 140 } 141 160 142 strBuilder.Append("*"); 161 143 } 162 if (factorNode.VariableName.Contains("'")) { 144 145 if (factorNode.VariableName.Contains("'")) 163 146 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableName); 164 } else {147 else 165 148 strBuilder.AppendFormat("'{0}'", factorNode.VariableName); 166 } 149 167 150 strBuilder.Append(" = "); 168 if (factorNode.VariableValue.Contains("'")) {151 if (factorNode.VariableValue.Contains("'")) 169 152 strBuilder.AppendFormat("\"{0}\"", factorNode.VariableValue); 170 } else {153 else 171 154 strBuilder.AppendFormat("'{0}'", factorNode.VariableValue); 172 } 173 174 if (!factorNode.Weight.IsAlmost(1.0)) { 175 strBuilder.Append(")"); 176 } 177 155 156 if (!factorNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 178 157 } else if (node.Symbol is Constant) { 179 158 var constNode = node as ConstantTreeNode; 180 if (constNode.Value >= 0.0) 181 strBuilder.Append(constNode.Value.ToString(formatString, numberFormat)); 182 else 183 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)).Append(")"); // (-1 159 if (constants != null) { 160 string constantKey = $"c_{constants.Count}"; 161 162 strBuilder.AppendFormat(CultureInfo.InvariantCulture, constantKey); 163 constants.Add(new KeyValuePair<string, double>(constantKey, constNode.Value)); 164 } else { 165 if (constNode.Value >= 0.0) 166 strBuilder.Append(constNode.Value.ToString(formatString, numberFormat)); 167 else 168 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)) 169 .Append(")"); // (-1 170 } 184 171 } 185 172 } … … 193 180 } 194 181 } 182 183 /// <summary> 184 /// Formats mathematical expressions in infix form. E.g. x1 * (3.0 * x2 + x3) 185 /// </summary> 186 [StorableType("6FE2C83D-A594-4ABF-B101-5AEAEA6D3E3D")] 187 [Item("Infix Symbolic Expression Tree Formatter", 188 "A string formatter that converts symbolic expression trees to infix expressions.")] 189 public sealed class InfixExpressionFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 190 [StorableConstructor] 191 private InfixExpressionFormatter(StorableConstructorFlag _) : base(_) { } 192 193 private InfixExpressionFormatter(InfixExpressionFormatter original, Cloner cloner) : base(original, cloner) { } 194 195 public InfixExpressionFormatter() 196 : base() { 197 Name = ItemName; 198 Description = ItemDescription; 199 } 200 201 public override IDeepCloneable Clone(Cloner cloner) { 202 return new InfixExpressionFormatter(this, cloner); 203 } 204 205 /// <summary> 206 /// Produces an infix expression for a given expression tree. 207 /// </summary> 208 /// <param name="symbolicExpressionTree">The tree representation of the expression.</param> 209 /// <param name="numberFormat">Number format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param> 210 /// <param name="formatString">The format string for numeric parameters (e.g. \"G4\" to limit to 4 digits, default is \"G\")</param> 211 /// <returns>Infix expression</returns> 212 public string Format(ISymbolicExpressionTree symbolicExpressionTree, NumberFormatInfo numberFormat, 213 string formatString = "G") { 214 // skip root and start symbols 215 StringBuilder strBuilder = new StringBuilder(); 216 BaseInfixExpressionFormatter.FormatRecursively(symbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0), 217 strBuilder, numberFormat, formatString); 218 return strBuilder.ToString(); 219 } 220 221 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 222 return Format(symbolicExpressionTree, NumberFormatInfo.InvariantInfo); 223 } 224 } 225 226 [StorableType("54D917E8-134E-4066-9A60-2737C12D81DC")] 227 [Item("Infix String Formater", "Formatter for symbolic expressions, which produces an infix expression " + 228 "as well as a list of all coefficient values")] 229 public sealed class InfixExpressionStringFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 230 [StorableConstructor] 231 private InfixExpressionStringFormatter(StorableConstructorFlag _) : base(_) { } 232 233 private InfixExpressionStringFormatter(InfixExpressionStringFormatter original, Cloner cloner) : base(original, cloner) { } 234 235 public InfixExpressionStringFormatter() : base() { 236 Name = ItemName; 237 Description = ItemDescription; 238 } 239 240 public override IDeepCloneable Clone(Cloner cloner) { 241 return new InfixExpressionStringFormatter(this, cloner); 242 } 243 244 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 245 StringBuilder strBuilder = new StringBuilder(); 246 var constants = new List<KeyValuePair<string, double>>(); 247 BaseInfixExpressionFormatter.FormatRecursively(symbolicExpressionTree.Root.GetSubtree(0).GetSubtree(0), 248 strBuilder, NumberFormatInfo.InvariantInfo, "G", constants); 249 strBuilder.Append($"{Environment.NewLine}{Environment.NewLine}"); 250 251 int maxDigits = GetDigits(constants.Count); 252 int padding = constants.Max(x => x.Value.ToString("F12", CultureInfo.InvariantCulture).Length); 253 foreach (var constant in constants) { 254 int digits = GetDigits(Int32.Parse(constant.Key.Substring(2))); 255 strBuilder.Append($"{constant.Key}{new String(' ', maxDigits - digits)} = " + 256 string.Format($"{{0,{padding}:F12}}", constant.Value, CultureInfo.InvariantCulture) + 257 Environment.NewLine); 258 } 259 260 return strBuilder.ToString(); 261 } 262 263 private int GetDigits(int x) { 264 if (x == 0) return 1; 265 return (int)Math.Floor(Math.Log10(x) + 1); 266 } 267 } 195 268 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs
r17226 r17586 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 29 using HEAL.Attic;30 30 using HeuristicLab.Parameters; 31 31 … … 80 80 } 81 81 82 public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, I Dictionary<string, Interval> variableRanges) {82 public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IReadOnlyDictionary<string, Interval> variableRanges) { 83 83 lock (syncRoot) { 84 84 EvaluatedSolutions++; … … 97 97 98 98 public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree, 99 I Dictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) {99 IReadOnlyDictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) { 100 100 lock (syncRoot) { 101 101 EvaluatedSolutions++; … … 124 124 125 125 126 private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, I Dictionary<string, Interval> variableRanges) {126 private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, IReadOnlyDictionary<string, Interval> variableRanges) { 127 127 if (variableRanges == null) 128 128 throw new ArgumentNullException("No variablew ranges are present!", nameof(variableRanges)); … … 234 234 break; 235 235 } 236 case OpCodes.Power: {237 result = Evaluate(instructions, ref instructionCounter, nodeIntervals);238 for (int i = 1; i < currentInstr.nArguments; i++) {239 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals);240 result = Interval.Power(result, argumentInterval);241 }242 break;243 }244 236 case OpCodes.Square: { 245 237 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); … … 247 239 break; 248 240 } 249 case OpCodes.Root: {250 result = Evaluate(instructions, ref instructionCounter, nodeIntervals);251 for (int i = 1; i < currentInstr.nArguments; i++) {252 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals);253 result = Interval.Root(result, argumentInterval);254 }255 break;256 }257 241 case OpCodes.SquareRoot: { 258 242 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 259 243 result = Interval.SquareRoot(argumentInterval); 244 break; 245 } 246 case OpCodes.Cube: { 247 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 248 result = Interval.Cube(argumentInterval); 249 break; 250 } 251 case OpCodes.CubeRoot: { 252 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 253 result = Interval.CubicRoot(argumentInterval); 254 break; 255 } 256 case OpCodes.Absolute: { 257 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 258 result = Interval.Absolute(argumentInterval); 259 break; 260 } 261 case OpCodes.AnalyticQuotient: { 262 result = Evaluate(instructions, ref instructionCounter, nodeIntervals); 263 for (var i = 1; i < currentInstr.nArguments; i++) { 264 var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals); 265 result = Interval.AnalyticalQuotient(result, argumentInterval); 266 } 267 260 268 break; 261 269 } … … 274 282 from n in tree.Root.GetSubtree(0).IterateNodesPrefix() 275 283 where 284 !(n.Symbol is Problems.DataAnalysis.Symbolic.Variable) && 285 !(n.Symbol is Constant) && 276 286 !(n.Symbol is StartSymbol) && 277 287 !(n.Symbol is Addition) && … … 284 294 !(n.Symbol is Logarithm) && 285 295 !(n.Symbol is Exponential) && 286 !(n.Symbol is Power) &&287 296 !(n.Symbol is Square) && 288 !(n.Symbol is Root) &&289 297 !(n.Symbol is SquareRoot) && 290 !(n.Symbol is Problems.DataAnalysis.Symbolic.Variable) && 291 !(n.Symbol is Constant) 298 !(n.Symbol is Cube) && 299 !(n.Symbol is CubeRoot) && 300 !(n.Symbol is Absolute) && 301 !(n.Symbol is AnalyticQuotient) 292 302 select n).Any(); 293 303 return !containsUnknownSyumbol; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
r17226 r17586 36 36 namespace HeuristicLab.Problems.DataAnalysis.Views { 37 37 public partial class PartialDependencePlot : UserControl, IPartialDependencePlot { 38 private ModifiableDataset sharedFixedVariables; // used for sync ronising variable values between charts38 private ModifiableDataset sharedFixedVariables; // used for synchronizing variable values between charts 39 39 private ModifiableDataset internalDataset; // holds the x values for each point drawn 40 40 … … 351 351 352 352 private void RecalculateTrainingLimits(bool initializeAxisRanges) { 353 trainingMin = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Where(x => !double.IsNaN(x)).Min()).Max(); 354 trainingMax = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Where(x => !double.IsNaN(x)).Max()).Min(); 353 //Set min and max to the interval ranges 354 trainingMin = solutions.Select(s => s.ProblemData.VariableRanges.GetInterval(freeVariable).LowerBound).Max(); 355 trainingMax = solutions.Select(s => s.ProblemData.VariableRanges.GetInterval(freeVariable).UpperBound).Min(); 355 356 356 357 if (initializeAxisRanges) { … … 438 439 chart.Palette = ChartColorPalette.None; 439 440 440 // Add confidence interval series before its cor esponding series for correct z index441 // Add confidence interval series before its corresponding series for correct z index 441 442 foreach (var solution in solutions) { 442 443 Series ciSeries; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r17520 r17586 222 222 <Compile Include="Interfaces\IDataPreprocessorStarter.cs" /> 223 223 <Compile Include="Interfaces\IPartialDependencePlot.cs" /> 224 <Compile Include="IntervalCollectionView.cs"> 225 <SubType>UserControl</SubType> 226 </Compile> 227 <Compile Include="IntervalCollectionView.Designer.cs"> 228 <DependentUpon>IntervalCollectionView.cs</DependentUpon> 229 </Compile> 224 230 <Compile Include="MenuItems\ChangeDataOfOptimizersMenuItem.cs" /> 225 231 <Compile Include="MenuItems\ShrinkDataAnalysisRunsMenuItem.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r17515 r17586 143 143 <Compile Include="Implementation\ConstantModel.cs" /> 144 144 <Compile Include="Implementation\DataAnalysisModel.cs" /> 145 <Compile Include="Implementation\Interval.cs" /> 145 <Compile Include="Implementation\Interval\Interval.cs" /> 146 <Compile Include="Implementation\Interval\IntervalCollection.cs" /> 146 147 <Compile Include="Implementation\Regression\ConfidenceBoundRegressionSolution.cs" /> 147 148 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r17226 r17586 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Parameters; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 34 34 public class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData, IStorableContent { 35 35 protected const string TargetVariableParameterName = "TargetVariable"; 36 protected const string VariableRangesParameterName = "VariableRanges"; 37 protected const string IntervalConstraintsParameterName = "IntervalConstraints"; 36 38 public string Filename { get; set; } 37 39 … … 91 93 problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly())); 92 94 problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>())); 95 problemData.Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, "", new IntervalCollection())); 93 96 emptyProblemData = problemData; 94 97 } … … 98 101 get { return (IConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 99 102 } 103 104 public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName]; 105 106 public IntervalCollection VariableRanges { 107 get => VariableRangesParameter.Value; 108 } 109 110 100 111 public string TargetVariable { 101 112 get { return TargetVariableParameter.Value.Value; } … … 125 136 [StorableHook(HookType.AfterDeserialization)] 126 137 private void AfterDeserialization() { 138 if (!Parameters.ContainsKey(VariableRangesParameterName)) { 139 var intervalCollection = CalculateDatasetIntervals(this.Dataset); 140 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection)); 141 } 127 142 RegisterParameterEvents(); 128 143 } … … 152 167 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 153 168 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First())); 169 var intervalCollection = CalculateDatasetIntervals(this.Dataset); 170 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection)); 154 171 RegisterParameterEvents(); 172 } 173 174 private static IntervalCollection CalculateDatasetIntervals(IDataset dataset) { 175 IntervalCollection intervalCollection = new IntervalCollection(); 176 foreach (var variable in dataset.DoubleVariables) {// intervals are only possible for double variables 177 var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable)); 178 intervalCollection.AddInterval(variable, variableInterval); 179 } 180 181 return intervalCollection; 155 182 } 156 183 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisModel.cs
r17226 r17586 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [StorableType("f85ccf7a-7df5-431e-bc4d-be6f3c4c2338")]28 27 /// <summary> 29 28 /// Interface for all data-analysis models (regression/classification/clustering). 30 29 /// <remarks>All methods and properties in in this interface must be implemented thread safely</remarks> 31 30 /// </summary> 31 [StorableType("f85ccf7a-7df5-431e-bc4d-be6f3c4c2338")] 32 32 public interface IDataAnalysisModel : INamedItem { 33 33 IEnumerable<string> VariablesUsedForPrediction { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblem.cs
r17520 r17586 35 35 [StorableType("c2f6fcdd-ab62-4423-be75-01aa694df411")] 36 36 public interface IDataAnalysisProblem<T> : IDataAnalysisProblem 37 where T : class, IDataAnalysisProblemData {37 where T : class, IDataAnalysisProblemData { 38 38 IValueParameter<T> ProblemDataParameter { get; } 39 39 new T ProblemData { get; set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDependencyCalculator.cs
r17226 r17586 22 22 using System; 23 23 using System.Collections.Generic; 24 using HEAL.Attic; 24 25 25 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [StorableType("3283B3FB-8467-4B99-9B6E-23BF3D1B8505")] 26 28 public interface IDependencyCalculator { 27 29 double Maximum { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IOnlineCalculator.cs
r17226 r17586 22 22 23 23 using System; 24 using HEAL.Attic; 25 24 26 namespace HeuristicLab.Problems.DataAnalysis { 25 27 [Flags] 28 [StorableType("8A28DDA1-4814-4B77-9457-0EE930BE9C73")] 26 29 public enum OnlineCalculatorError { 27 30 /// <summary> … … 38 41 InsufficientElementsAdded = 2 39 42 } 43 44 [StorableType("119C8242-3EE7-4C34-A7AC-68ABF76EB11B")] 40 45 public interface IOnlineCalculator { 41 46 OnlineCalculatorError ErrorState { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs
r17515 r17586 26 26 [StorableType("1ef22b8b-f3b4-494b-8cdd-f08e84e316e0")] 27 27 public interface IRegressionProblemData : ISupervisedDataAnalysisProblemData { 28 IntervalCollection VariableRanges { get;} 29 28 30 IEnumerable<double> TargetVariableValues { get; } 29 31 IEnumerable<double> TargetVariableTrainingValues { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/IOnlineTimeSeriesCalculator.cs
r17226 r17586 22 22 23 23 using System.Collections.Generic; 24 using HEAL.Attic; 24 25 25 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [StorableType("7461AC5D-9D9A-4DCD-B32F-602260E58FFC")] 26 28 public interface IOnlineTimeSeriesCalculator { 27 29 OnlineCalculatorError ErrorState { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Services.Hive merged: 17574-17575
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Services.Hive.DataAccess merged: 17574
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/HiveStatistics/DimJobDao.cs
r17226 r17586 44 44 } 45 45 46 public void UpdateExistingDimJobs() { 47 DataContext.ExecuteCommand(UpdateExistingDimJobsQuery); 48 } 49 46 50 #region Compiled queries 47 51 private static readonly Func<DataContext, Guid, DimJob> GetByIdQuery = … … 51 55 select dimJob).SingleOrDefault()); 52 56 #endregion 57 58 #region String queries 59 private const string UpdateExistingDimJobsQuery = @" 60 UPDATE u 61 SET 62 u.JobName = case when x.JobId is null then u.JobName else x.JobName end, 63 u.TotalTasks = x.TotalTasks, 64 u.CompletedTasks = x.CompletedTasks, 65 u.DateCompleted = 66 case when x.totaltasks = x.CompletedTasks 67 then (case when x.JobId is null and x.DateCompleted is null then GETDATE() else x.DateCompleted end) 68 else u.DateCompleted 69 end, 70 u.ProjectId = case when x.JobId is null then u.ProjectId else x.ProjectId end 71 FROM [statistics].dimjob u 72 JOIN ( 73 SELECT 74 dj.JobId as DimJobId, 75 j.JobId as JobId, 76 j.Name as JobName, 77 COUNT(*) as TotalTasks, 78 SUM( 79 CASE 80 WHEN TaskState in ('Finished', 'Aborted', 'Failed') then 1 81 ELSE 0 82 END) as CompletedTasks, 83 MAX(EndTime) as DateCompleted, 84 dp.ProjectId as ProjectId 85 from [statistics].DimJob dj 86 join [statistics].FactTask ft on dj.JobId = ft.JobId 87 left join Job j on j.JobId = dj.JobId 88 left join [statistics].DimProject dp on j.ProjectId = dp.ProjectId 89 where dj.DateCompleted is null and dp.DateExpired is null 90 group by dj.JobId, j.JobId, j.Name, dp.ProjectId 91 ) as x on u.JobId = x.DimJobId"; 92 #endregion 53 93 } 54 94 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs
r17226 r17586 37 37 } 38 38 39 public int DeleteByState(JobState state, int batchSize) { 40 return DataContext.ExecuteCommand(DeleteTopNByStateQueryString, batchSize, Enum.GetName(typeof(JobState), state)); 41 } 42 39 43 public IEnumerable<Job> GetByProjectId(Guid id) { 40 44 return GetByProjectIdQuery(DataContext, id); … … 43 47 public IEnumerable<Job> GetByProjectIds(IEnumerable<Guid> projectIds) { 44 48 string paramProjectIds = string.Join(",", projectIds.ToList().Select(x => string.Format("'{0}'", x))); 45 if (!string.IsNullOrWhiteSpace(paramProjectIds)) {49 if (!string.IsNullOrWhiteSpace(paramProjectIds)) { 46 50 string queryString = string.Format(GetByProjectIdsQueryString, paramProjectIds); 47 51 return DataContext.ExecuteQuery<Job>(queryString); … … 51 55 52 56 public IEnumerable<Job> GetByState(JobState state) { 53 return GetByStateQuery(DataContext, state );57 return GetByStateQuery(DataContext, state.ToString()); 54 58 } 55 59 56 60 public IEnumerable<Guid> GetJobIdsByState(JobState state) { 57 return GetJobIdsByStateQuery(DataContext, state );61 return GetJobIdsByStateQuery(DataContext, state.ToString()); 58 62 } 59 63 … … 74 78 where job.ProjectId == projectId 75 79 select job)); 76 private static readonly Func<DataContext, JobState, IEnumerable<Job>> GetByStateQuery =77 CompiledQuery.Compile((DataContext db, JobStatejobState) =>80 private static readonly Func<DataContext, string, IEnumerable<Job>> GetByStateQuery = 81 CompiledQuery.Compile((DataContext db, string jobState) => 78 82 (from job in db.GetTable<Job>() 79 where job.State == jobState83 where job.State.ToString() == jobState 80 84 select job)); 81 private static readonly Func<DataContext, JobState, IEnumerable<Guid>> GetJobIdsByStateQuery =82 CompiledQuery.Compile((DataContext db, JobStatejobState) =>85 private static readonly Func<DataContext, string, IEnumerable<Guid>> GetJobIdsByStateQuery = 86 CompiledQuery.Compile((DataContext db, string jobState) => 83 87 (from job in db.GetTable<Job>() 84 where job.State == jobState88 where job.State.ToString() == jobState 85 89 select job.JobId)); 86 90 private static readonly Func<DataContext, IEnumerable<Job>> GetJobsReadyForDeletionQuery = … … 101 105 WHERE JobState = {0} 102 106 "; 107 private const string DeleteTopNByStateQueryString = @" 108 DELETE TOP ({0}) 109 FROM [Job] 110 WHERE JobState = {1} 111 "; 103 112 private const string GetStatisticsPendingJobs = @" 104 113 SELECT DISTINCT j.* -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/StateLogDao.cs
r17226 r17586 40 40 } 41 41 42 public int DeleteObsolete(int batchSize) { 43 return DataContext.ExecuteCommand(DeleteObsoleteQueryString, batchSize); 44 } 45 42 46 #region Compiled queries 43 47 private static readonly Func<DataContext, Guid, StateLog> GetByIdQuery = … … 54 58 select stateLog).First(x => x.SlaveId != null)); 55 59 #endregion 60 61 #region String queries 62 private const string DeleteObsoleteQueryString = @" 63 delete top ({0}) s 64 from statelog s 65 join task t on t.taskid = s.taskid 66 join job j on j.jobid = t.jobid 67 where j.jobstate = 'deletionpending' 68 "; 69 #endregion 56 70 } 57 71 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs
r17226 r17586 50 50 //Because there is at the moment no case where this makes sense (there don't exist parent tasks which need to be calculated), 51 51 //we skip this step because it's wasted runtime 52 return DataContext.ExecuteQuery<TaskPriorityInfo>(GetWaitingTasksQueryString, 53 slave.ResourceId, 54 Enum.GetName(typeof(TaskState), TaskState.Waiting), 55 slave.FreeCores, 52 return DataContext.ExecuteQuery<TaskPriorityInfo>(GetWaitingTasksQueryString, 53 slave.ResourceId, 54 Enum.GetName(typeof(TaskState), TaskState.Waiting), 55 slave.FreeCores, 56 56 slave.FreeMemory).ToList(); 57 57 } … … 65 65 /// <returns></returns> 66 66 public IEnumerable<Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) { 67 var query = from t in Table68 where t.State == TaskState.Waiting69 && t.IsParentTask70 && t.Job.AssignedJobResources.All(x => resourceIds.ToList().Contains(x.ResourceId))71 && t.FinishWhenChildJobsFinished == finished72 && t.ChildJobs.Any()73 && t.ChildJobs.All(x =>74 x.State == TaskState.Finished75 || x.State == TaskState.Aborted76 || x.State == TaskState.Failed)67 var query = from t in Table 68 where t.State == TaskState.Waiting 69 && t.IsParentTask 70 && t.Job.AssignedJobResources.All(x => resourceIds.ToList().Contains(x.ResourceId)) 71 && t.FinishWhenChildJobsFinished == finished 72 && t.ChildJobs.Any() 73 && t.ChildJobs.All(x => 74 x.State == TaskState.Finished 75 || x.State == TaskState.Aborted 76 || x.State == TaskState.Failed) 77 77 orderby t.Priority descending 78 78 select t; … … 82 82 public void UpdateExecutionTime(Guid taskId, double executionTime) { 83 83 DataContext.ExecuteCommand(UpdateExecutionTimeQuery, executionTime, DateTime.Now, taskId); 84 } 85 86 public int DeleteObsolete(int batchSize) { 87 return DataContext.ExecuteCommand(DeleteObsoleteQueryString, batchSize); 84 88 } 85 89 … … 129 133 WHERE TaskId = {2} 130 134 "; 135 136 private const string DeleteObsoleteQueryString = @" 137 delete top ({0}) t1 138 from task t1 139 left join task t2 on t1.taskid = t2.parenttaskid 140 join job j on j.jobid = t1.jobid 141 where j.jobstate = 'deletionpending' and t2.taskid is null 142 "; 131 143 #endregion 132 144 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDataDao.cs
r17226 r17586 32 32 } 33 33 34 public int DeleteObsolete(int batchSize) { 35 return DataContext.ExecuteCommand(DeleteObsoleteQueryString, batchSize); 36 } 37 34 38 #region Compiled queries 35 39 private static readonly Func<DataContext, Guid, TaskData> GetByIdQuery = … … 39 43 select taskData).SingleOrDefault()); 40 44 #endregion 45 46 #region String queries 47 private const string DeleteObsoleteQueryString = @" 48 delete top ({0}) td 49 from taskdata td 50 join task t on t.taskid = td.taskid 51 join job j on j.jobid = t.jobid 52 where j.jobstate = 'deletionpending' 53 "; 54 #endregion 41 55 } 42 56 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Interfaces/IPersistenceManager.cs
r17226 r17586 64 64 #region Transaction management 65 65 void UseTransaction(Action call, bool repeatableRead = false, bool longRunning = false); 66 void UseTransactionAndSubmit(Action call, bool repeatableRead = false, bool longRunning = false); 66 67 T UseTransaction<T>(Func<T> call, bool repeatableRead = false, bool longRunning = false); 68 T UseTransactionAndSubmit<T>(Func<T> call, bool repeatableRead = false, bool longRunning = false); 67 69 #endregion 68 70 -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/Manager/PersistenceManager.cs
r17226 r17586 184 184 #region Transaction management 185 185 public void UseTransaction(Action call, bool repeatableRead = false, bool longRunning = false) { 186 UseTransaction<object>(() => { 187 call(); 188 return null; 189 }); 186 UseTransaction<object>(() => { call(); return null; }, repeatableRead, longRunning); 187 } 188 189 public void UseTransactionAndSubmit(Action call, bool repeatableRead = false, bool longRunning = false) { 190 UseTransaction(() => { call(); SubmitChanges(); }, repeatableRead, longRunning); 190 191 } 191 192 … … 211 212 } 212 213 214 public T UseTransactionAndSubmit<T>(Func<T> call, bool repeatableRead = false, bool longRunning = false) { 215 return UseTransaction(() => { var res = call(); SubmitChanges(); return res; }, repeatableRead, longRunning); 216 } 217 213 218 private static TransactionScope CreateTransaction(bool repeatableRead, bool longRunning) { 214 219 var options = new TransactionOptions { -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql
r16723 r17586 141 141 INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId]) 142 142 GO 143 144 145 146 -- OBSOLETE - DO NOT PERFORM (start)147 /****** Object: Trigger [dbo].[tr_JobDeleteCascade] Script Date: 04/19/2011 16:31:53 ******/148 SET ANSI_NULLS ON149 GO150 SET QUOTED_IDENTIFIER ON151 GO152 -- =============================================153 -- Author: cneumuel154 -- Create date: 19.04.2011155 -- Description: (1) Writes the execution times of deleted jobs into DeletedJobStats to ensure correct statistics156 -- (2) Deletes all associated jobs. This cannot be done with cascading delete,157 -- because the job table defines a INSTEAD OF DELETE trigger itself, which158 -- is not compatible with cascading deletes.159 -- =============================================160 CREATE TRIGGER [dbo].[tr_JobDeleteCascade] ON [dbo].[Job] INSTEAD OF DELETE AS161 BEGIN162 DELETE Task FROM deleted, Task WHERE deleted.JobId = Task.JobId163 DELETE Job FROM deleted, Job WHERE deleted.JobId = Job.JobId164 END165 GO166 167 -- =============================================168 -- Author: cneumuel169 -- Create date: 11.11.2010170 -- Description: Recursively deletes all child-jobs of a job when it is deleted. (Source: http://devio.wordpress.com/2008/05/23/recursive-delete-in-sql-server/)171 -- =============================================DeletedJobStatistics172 CREATE TRIGGER [dbo].[tr_TaskDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS173 BEGIN174 -- recursively delete jobs175 CREATE TABLE #Table(176 TaskId uniqueidentifier177 )178 INSERT INTO #Table (TaskId)179 SELECT TaskId FROM deleted180 181 DECLARE @c INT182 SET @c = 0183 184 WHILE @c <> (SELECT COUNT(TaskId) FROM #Table) BEGIN185 SELECT @c = COUNT(TaskId) FROM #Table186 187 INSERT INTO #Table (TaskId)188 SELECT Task.TaskId189 FROM Task190 LEFT OUTER JOIN #Table ON Task.TaskId = #Table.TaskId191 WHERE Task.ParentTaskId IN (SELECT TaskId FROM #Table)192 AND #Table.TaskId IS NULL193 END194 195 DELETE TaskData FROM TaskData INNER JOIN #Table ON TaskData.TaskId = #Table.TaskId196 DELETE Task FROM Task INNER JOIN #Table ON Task.TaskId = #Table.TaskId197 END198 GO199 -- OBSOLETE (end)200 -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.JanitorService
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Services.Hive.JanitorService merged: 17574
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive.JanitorService/3.3/JanitorService.cs
r17226 r17586 26 26 public partial class JanitorService : ServiceBase { 27 27 private HiveJanitor janitor; 28 private Thread janitorCleanupThread; 29 private Thread janitorGenerateStatisticsThread; 28 private Thread janitorThread; 30 29 31 30 public JanitorService() { … … 36 35 janitor = new HiveJanitor(); 37 36 38 janitorCleanupThread = new Thread(janitor.RunCleanup) { 39 IsBackground = true 40 }; 41 janitorGenerateStatisticsThread = new Thread(janitor.RunGenerateStatistics) { 37 janitorThread = new Thread(janitor.Run) { 42 38 IsBackground = true 43 39 }; 44 40 45 janitorCleanupThread.Start(); 46 janitorGenerateStatisticsThread.Start(); 41 janitorThread.Start(); 47 42 } 48 43 49 44 protected override void OnStop() { 50 45 janitor.StopJanitor(); 51 janitorCleanupThread.Join(); 52 janitorGenerateStatisticsThread.Join(); 46 janitorThread.Join(); 53 47 } 54 48 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj
r16723 r17586 173 173 <DesignTimeSharedInput>True</DesignTimeSharedInput> 174 174 </Compile> 175 <Compile Include="Scheduler\TaskScheduler.cs" /> 175 176 <Compile Include="ServiceContracts\IHiveService.cs" /> 176 177 <Compile Include="ServiceFaults\PluginAlreadyExistsFault.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs
r17226 r17586 28 28 public class HiveJanitor { 29 29 private bool stop; 30 private AutoResetEvent cleanupWaitHandle; 31 private AutoResetEvent generateStatisticsWaitHandle; 30 private AutoResetEvent runWaitHandle; 32 31 33 32 private IPersistenceManager PersistenceManager { … … 44 43 public HiveJanitor() { 45 44 stop = false; 46 cleanupWaitHandle = new AutoResetEvent(false); 47 generateStatisticsWaitHandle = new AutoResetEvent(false); 45 runWaitHandle = new AutoResetEvent(false); 48 46 } 49 47 50 48 public void StopJanitor() { 51 49 stop = true; 52 cleanupWaitHandle.Set(); 53 generateStatisticsWaitHandle.Set(); 50 runWaitHandle.Set(); 51 } 52 53 public void Run() { 54 while (!stop) { 55 RunCleanup(); 56 RunGenerateStatistics(); 57 runWaitHandle.WaitOne(Properties.Settings.Default.GenerateStatisticsInterval); 58 } 59 runWaitHandle.Close(); 54 60 } 55 61 56 62 public void RunCleanup() { 57 63 var pm = PersistenceManager; 58 while (!stop) { 59 try { 60 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup."); 61 bool cleanup = false; 64 try { 65 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup."); 66 bool cleanup = false; 62 67 63 64 65 66 67 68 69 70 71 72 68 var lifecycleDao = pm.LifecycleDao; 69 pm.UseTransaction(() => { 70 var lifecycle = lifecycleDao.GetLastLifecycle(); 71 if (lifecycle == null 72 || DateTime.Now - lifecycle.LastCleanup > Properties.Settings.Default.CleanupInterval) { 73 lifecycleDao.UpdateLifecycle(); 74 cleanup = true; 75 } 76 pm.SubmitChanges(); 77 }, true); 73 78 74 if (cleanup) { 75 EventManager.Cleanup(); 76 } 77 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: cleanup finished."); 79 if (cleanup) { 80 EventManager.Cleanup(); 78 81 } 79 catch (Exception e) { 80 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e.ToString())); 81 } 82 cleanupWaitHandle.WaitOne(Properties.Settings.Default.CleanupInterval); 82 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: cleanup finished."); 83 } catch (Exception e) { 84 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e.ToString())); 83 85 } 84 cleanupWaitHandle.Close();85 86 } 86 87 87 88 public void RunGenerateStatistics() { 88 while (!stop) { 89 try { 90 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting generate statistics."); 91 StatisticsGenerator.GenerateStatistics(); 92 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: generate statistics finished."); 93 } 94 catch (Exception e) { 95 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e)); 96 } 97 98 generateStatisticsWaitHandle.WaitOne(Properties.Settings.Default.GenerateStatisticsInterval); 89 try { 90 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting generate statistics."); 91 StatisticsGenerator.GenerateStatistics(); 92 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: generate statistics finished."); 93 } catch (Exception e) { 94 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e)); 99 95 } 100 101 generateStatisticsWaitHandle.Close();102 96 } 103 97 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/HiveService.cs
r17457 r17586 209 209 } 210 210 211 private bool IsAuthorizedForTask(DA.Task task, Guid? slaveId) { 212 var lastStateLog = task.StateLogs.OrderByDescending(x => x.DateTime).FirstOrDefault(x => x.State == DA.TaskState.Transferring); 213 return lastStateLog == null || slaveId == null || lastStateLog.SlaveId == slaveId; 214 } 215 211 216 public DT.Task UpdateTaskState(Guid taskId, DT.TaskState taskState, Guid? slaveId, Guid? userId, string exception) { 212 217 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave); … … 217 222 return pm.UseTransaction(() => { 218 223 var task = taskDao.GetById(taskId); 219 UpdateTaskState(pm, task, taskState, slaveId, userId, exception); 220 pm.SubmitChanges(); 224 if (IsAuthorizedForTask(task, slaveId)) { 225 UpdateTaskState(pm, task, taskState, slaveId, userId, exception); 226 pm.SubmitChanges(); 227 } 221 228 return task.ToDto(); 222 229 }); -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs
r17226 r17586 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Data.Linq;25 24 using System.Linq; 26 25 using HeuristicLab.Services.Access.DataAccess; … … 36 35 37 36 public void GenerateStatistics() { 38 using (var pm = new PersistenceManager()) { 39 40 pm.UseTransaction(() => { 41 UpdateDimProjectTable(pm); 42 pm.SubmitChanges(); 37 Console.WriteLine("started generate statistics"); 38 39 using (var pm = new PersistenceManager(true)) { 40 var sw = new System.Diagnostics.Stopwatch(); 41 42 sw.Start(); 43 pm.UseTransactionAndSubmit(() => { UpdateDimProjectTable(pm); }); 44 sw.Stop(); 45 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateDimProjectTable: {sw.Elapsed}"); 46 Console.WriteLine($"UpdateDimProjectTable: {sw.Elapsed}"); 47 sw.Reset(); 48 49 pm.UseTransactionAndSubmit(() => { 50 sw.Start(); 51 UpdateDimUserTable(pm); 52 sw.Stop(); 53 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateDimUserTable: {sw.Elapsed}"); 54 Console.WriteLine($"UpdateDimUserTable: {sw.Elapsed}"); 55 sw.Reset(); 56 57 sw.Start(); 58 UpdateDimJobTable(pm); 59 sw.Stop(); 60 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateDimJobTable: {sw.Elapsed}"); 61 Console.WriteLine($"UpdateDimJobTable: {sw.Elapsed}"); 62 sw.Reset(); 63 64 sw.Start(); 65 UpdateDimClientsTable(pm); 66 sw.Stop(); 67 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateDimClientsTable: {sw.Elapsed}"); 68 Console.WriteLine($"UpdateDimClientsTable: {sw.Elapsed}"); 69 sw.Reset(); 43 70 }); 44 71 45 pm.UseTransaction(() => { 46 UpdateDimUserTable(pm); 47 48 UpdateDimJobTable(pm); 49 UpdateDimClientsTable(pm); 50 pm.SubmitChanges(); 51 }); 52 53 DimTime time = null; 54 pm.UseTransaction(() => { 55 time = UpdateDimTimeTable(pm); 56 pm.SubmitChanges(); 57 }); 58 59 if (time != null) { 60 pm.UseTransaction(() => { 61 UpdateFactClientInfoTable(time, pm); 62 pm.SubmitChanges(); 63 UpdateFactProjectInfoTable(time, pm); 64 pm.SubmitChanges(); 65 }); 66 67 pm.UseTransaction(() => { 68 try { 69 UpdateFactTaskTable(pm); 70 UpdateExistingDimJobs(pm); 71 FlagJobsForDeletion(pm); 72 pm.SubmitChanges(); 73 } 74 catch (DuplicateKeyException e) { 75 var logger = LogFactory.GetLogger(typeof(HiveStatisticsGenerator).Namespace); 76 logger.Log(string.Format( 77 @"Propable change from summertime to wintertime, resulting in overlapping times. 78 On wintertime to summertime change, slave timeouts and a fact gap will occur. 79 Exception Details: {0}", e)); 80 } 81 }); 82 } 72 pm.UseTransactionAndSubmit(() => { 73 sw.Start(); 74 var time = UpdateDimTimeTable(pm); 75 sw.Stop(); 76 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateDimTimeTable: {sw.Elapsed}"); 77 Console.WriteLine($"UpdateDimTimeTable: {sw.Elapsed}"); 78 sw.Reset(); 79 80 sw.Start(); 81 UpdateFactClientInfoTable(time, pm); 82 sw.Stop(); 83 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateFactClientInfoTable: {sw.Elapsed}"); 84 Console.WriteLine($"UpdateFactClientInfoTable: {sw.Elapsed}"); 85 sw.Reset(); 86 87 sw.Start(); 88 UpdateFactProjectInfoTable(time, pm); 89 sw.Stop(); 90 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateFactProjectInfoTable: {sw.Elapsed}"); 91 Console.WriteLine($"UpdateFactProjectInfoTable: {sw.Elapsed}"); 92 sw.Reset(); 93 94 95 sw.Start(); 96 UpdateFactTaskTable(pm); 97 sw.Stop(); 98 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateFactTaskTable: {sw.Elapsed}"); 99 Console.WriteLine($"UpdateFactTaskTable: {sw.Elapsed}"); 100 sw.Reset(); 101 102 sw.Start(); 103 UpdateExistingDimJobs(pm); 104 sw.Stop(); 105 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"UpdateExistingDimJobs: {sw.Elapsed}"); 106 Console.WriteLine($"UpdateExistingDimJobs: {sw.Elapsed}"); 107 sw.Reset(); 108 109 sw.Start(); 110 FlagJobsForDeletion(pm); 111 sw.Stop(); 112 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"FlagJobsForDeletion: {sw.Elapsed}"); 113 Console.WriteLine($"FlagJobsForDeletion: {sw.Elapsed}"); 114 sw.Reset(); 115 }, longRunning: true); 83 116 } 84 117 } … … 207 240 208 241 private void UpdateExistingDimJobs(PersistenceManager pm) { 209 var dimProjectDao = pm.DimProjectDao;210 var jobDao = pm.JobDao;211 242 var dimJobDao = pm.DimJobDao; 212 var factTaskDao = pm.FactTaskDao; 213 foreach (var dimJob in dimJobDao.GetNotCompletedJobs()) { 214 var taskStates = factTaskDao.GetByJobId(dimJob.JobId) 215 .GroupBy(x => x.TaskState) 216 .Select(x => new { 217 State = x.Key, 218 Count = x.Count() 219 }).ToList(); 220 int totalTasks = 0, completedTasks = 0; 221 foreach (var state in taskStates) { 222 totalTasks += state.Count; 223 if (CompletedStates.Contains(state.State)) { 224 completedTasks += state.Count; 225 } 226 } 227 var job = jobDao.GetById(dimJob.JobId); 228 if (totalTasks == completedTasks) { 229 var completeDate = factTaskDao.GetLastCompletedTaskFromJob(dimJob.JobId); 230 if (completeDate == null) { 231 if (job == null) { 232 completeDate = DateTime.Now; 233 } 234 } 235 dimJob.DateCompleted = completeDate; 236 } 237 if(job != null) { 238 dimJob.JobName = job.Name; 239 dimJob.ProjectId = dimProjectDao.GetLastValidIdByProjectId(job.ProjectId); 240 } 241 242 dimJob.TotalTasks = totalTasks; 243 dimJob.CompletedTasks = completedTasks; 244 } 243 dimJobDao.UpdateExistingDimJobs(); 245 244 } 246 245 … … 248 247 var jobDao = pm.JobDao; 249 248 var jobs = jobDao.GetJobsReadyForDeletion(); 250 foreach (var job in jobs) {249 foreach (var job in jobs) { 251 250 job.State = JobState.DeletionPending; 252 251 } … … 257 256 var resourceDao = pm.ResourceDao; 258 257 259 var resources = resourceDao.GetAll().ToList(); 260 var dimClients = dimClientDao.GetAllOnlineClients().ToList(); 258 var resources = resourceDao.GetAll().ToList(); // all live now 259 var dimClients = dimClientDao.GetAllOnlineClients().ToList(); // all in statistics which are online (i.e. not expired) 261 260 262 261 var onlineClients = dimClients.Where(x => resources.Select(y => y.ResourceId).Contains(x.ResourceId)); … … 265 264 266 265 // set expiration time of removed resources 267 foreach (var r in removedResources) {266 foreach (var r in removedResources) { 268 267 r.DateExpired = DateTime.Now; 269 268 } … … 281 280 // expire client if its parent has changed and create a new entry 282 281 // otherwise perform "normal" update 283 foreach (var dimc in onlineClients) {282 foreach (var dimc in onlineClients) { 284 283 var r = resources.Where(x => x.ResourceId == dimc.ResourceId).SingleOrDefault(); 285 if (r != null) {286 if (dimc.ParentResourceId == null ? r.ParentResourceId != null : dimc.ParentResourceId != r.ParentResourceId) {284 if (r != null) { 285 if (dimc.ParentResourceId == null ? r.ParentResourceId != null : dimc.ParentResourceId != r.ParentResourceId) { 287 286 var now = DateTime.Now; 288 287 dimc.DateExpired = now; … … 416 415 let uStats = projectUsageStats.Where(x => x.ProjectId == dimp.ProjectId).SingleOrDefault() 417 416 select new FactProjectInfo { 418 419 420 421 422 423 424 417 ProjectId = dimp.Id, 418 DimTime = newTime, 419 NumTotalCores = aStats != null ? aStats.Cores : 0, 420 TotalMemory = aStats != null ? aStats.Memory : 0, 421 NumUsedCores = uStats != null ? uStats.Cores : 0, 422 UsedMemory = uStats != null ? uStats.Memory : 0 423 } 425 424 ); 426 425 } … … 431 430 var dimClientDao = pm.DimClientDao; 432 431 433 var factTaskIds = factTaskDao.GetAll().Select(x => x.TaskId); 434 var notFinishedFactTasks = factTaskDao.GetNotFinishedTasks(); 435 //var notFinishedFactTasks = factTaskDao.GetNotFinishedTasks().Select(x => new { 436 // x.TaskId, 437 // x.LastClientId 438 //}); 439 440 // query several properties for all new and not finished tasks 441 // in order to use them later either... 442 // (1) to update the fact task entry of not finished tasks 443 // (2) to insert a new fact task entry for new tasks 432 var preselectedNewAndNotFinishedTasks = 433 (from task in taskDao.GetAll() 434 from factTask in factTaskDao.GetAll().Where(f => task.TaskId == f.TaskId).DefaultIfEmpty() 435 let stateLogs = task.StateLogs.OrderByDescending(x => x.DateTime).ToList() 436 let lastSlaveId = stateLogs.First(x => x.SlaveId != null) 437 where !task.IsParentTask && (factTask.TaskId == null || factTask.EndTime == null) 438 select new { Task = task, StateLogs = stateLogs, LastSlaveId = lastSlaveId }).ToList(); 439 440 Console.WriteLine("preselectedNewAndNotFinishedTasks.Count = {0}", preselectedNewAndNotFinishedTasks.Count); 441 442 // jkarder: maybe we can split this query into multiple ones to retrieve state logs and the last slave 443 444 var clients = dimClientDao.GetAllOnlineClients().ToList(); 445 Console.WriteLine("clients.Count = {0}", clients.Count); 446 var notFinishedFactTasks = factTaskDao.GetNotFinishedTasks().ToList(); 447 Console.WriteLine("notFinishedFactTasks.Count = {0}", notFinishedFactTasks.Count); 448 444 449 var newAndNotFinishedTasks = 445 (from task in taskDao.GetAllChildTasks() 446 let stateLogs = task.StateLogs.OrderByDescending(x => x.DateTime) 447 let lastSlaveId = stateLogs.First(x => x.SlaveId != null).SlaveId 448 where (!factTaskIds.Contains(task.TaskId) 449 || notFinishedFactTasks.Select(x => x.TaskId).Contains(task.TaskId)) 450 (from x in preselectedNewAndNotFinishedTasks 451 let task = x.Task 452 let stateLogs = x.StateLogs // jkarder: if multiple join results in multiple rows, statelogs of all equal tasks must be the same ... 453 let lastSlaveId = x.LastSlaveId 450 454 join lastFactTask in notFinishedFactTasks on task.TaskId equals lastFactTask.TaskId into lastFactPerTask 451 455 from lastFact in lastFactPerTask.DefaultIfEmpty() 452 join client in dimClientDao.GetAllOnlineClients() on lastSlaveId equals client.ResourceId into clientsPerSlaveId 453 from client in clientsPerSlaveId.DefaultIfEmpty() 456 // jkarder: 457 // we can still fix this another way, if we only select that one row from dimclients that fits the given statelog/lastslave entry 458 // dimclient has multiple entires for one and the same client, because we track changes in resource group hierarchies 459 // -> left join from task/statelog to dimclient results in multiple rows because multiple rows in dimclient with the same resource id exist 460 // -> further down the road we call singleordefault to single out tasks to get the data for the update 461 // -> dimclient should only contain one valid row for a given time span that fits to the lastslaveid.datetime 462 // -> client.datecreated <= lastslaveid.datetime <= client.dateexpired 463 // it's aweful ... 464 from client in clients.Where(c => lastSlaveId != null && lastSlaveId.SlaveId == c.ResourceId && c.DateCreated <= lastSlaveId.DateTime && (c.DateExpired == null || lastSlaveId.DateTime <= c.DateExpired)).DefaultIfEmpty() 465 // jkarder: 466 //join client in clients on lastSlaveId.SlaveId equals client.ResourceId into clientsPerSlaveId 467 //from client in clientsPerSlaveId.DefaultIfEmpty() 454 468 select new { 455 469 TaskId = task.TaskId, … … 459 473 MemoryRequired = task.MemoryNeeded, 460 474 State = task.State, 461 StateLogs = stateLogs.OrderBy(x => x.DateTime) ,475 StateLogs = stateLogs.OrderBy(x => x.DateTime).ToList(), 462 476 LastClientId = client != null 463 464 477 ? client.Id : lastFact != null 478 ? lastFact.LastClientId : (Guid?)null, 465 479 NotFinishedTask = notFinishedFactTasks.Any(y => y.TaskId == task.TaskId) 466 480 }).ToList(); 481 482 Console.WriteLine("newAndNotFinishedTasks.Count = {0}", newAndNotFinishedTasks.Count); 483 467 484 468 485 // (1) update data of already existing facts 469 486 // i.e. for all in newAndNotFinishedTasks where NotFinishedTask = true 470 487 foreach (var notFinishedFactTask in notFinishedFactTasks) { 471 var nfftUpdate = newAndNotFinishedTasks.Where(x => x.TaskId == notFinishedFactTask.TaskId).SingleOrDefault(); 472 if(nfftUpdate != null) { 488 // jkarder: firstordefault should work too, because statelogs of multiple task rows that result from the earlier join have to be the same 489 var nfftUpdate = newAndNotFinishedTasks.Where(x => x.TaskId == notFinishedFactTask.TaskId).FirstOrDefault(); 490 if (nfftUpdate != null) { 473 491 var taskData = CalculateFactTaskData(nfftUpdate.StateLogs); 474 492 … … 487 505 notFinishedFactTask.Exception = taskData.Exception; 488 506 notFinishedFactTask.InitialWaitingTime = taskData.InitialWaitingTime; 507 } else { 508 //Console.WriteLine("could not update task {0}", notFinishedFactTask.TaskId); 489 509 } 490 510 } 511 512 Console.WriteLine("nfft update complete"); 491 513 492 514 // (2) insert facts for new tasks 493 515 // i.e. for all in newAndNotFinishedTasks where NotFinishedTask = false 494 factTaskDao.Save( 495 from x in newAndNotFinishedTasks 496 where !x.NotFinishedTask 497 let taskData = CalculateFactTaskData(x.StateLogs) 498 select new FactTask { 499 TaskId = x.TaskId, 500 JobId = x.JobId, 501 StartTime = taskData.StartTime, 502 EndTime = taskData.EndTime, 503 LastClientId = x.LastClientId, 504 Priority = x.Priority, 505 CoresRequired = x.CoresRequired, 506 MemoryRequired = x.MemoryRequired, 507 NumCalculationRuns = taskData.CalculationRuns, 508 NumRetries = taskData.Retries, 509 WaitingTime = taskData.WaitingTime, 510 CalculatingTime = taskData.CalculatingTime, 511 TransferTime = taskData.TransferTime, 512 TaskState = x.State, 513 Exception = taskData.Exception, 514 InitialWaitingTime = taskData.InitialWaitingTime 515 }); 516 517 518 ////update data of already existing facts 519 //foreach (var notFinishedTask in factTaskDao.GetNotFinishedTasks()) { 520 // var ntc = newTasks.Where(x => x.TaskId == notFinishedTask.TaskId); 521 // if (ntc.Any()) { 522 // var x = ntc.Single(); 523 // var taskData = CalculateFactTaskData(x.StateLogs); 524 525 // notFinishedTask.StartTime = taskData.StartTime; 526 // notFinishedTask.EndTime = taskData.EndTime; 527 // notFinishedTask.LastClientId = x.LastClientId; 528 // notFinishedTask.Priority = x.Priority; 529 // notFinishedTask.CoresRequired = x.CoresRequired; 530 // notFinishedTask.MemoryRequired = x.MemoryRequired; 531 // notFinishedTask.NumCalculationRuns = taskData.CalculationRuns; 532 // notFinishedTask.NumRetries = taskData.Retries; 533 // notFinishedTask.WaitingTime = taskData.WaitingTime; 534 // notFinishedTask.CalculatingTime = taskData.CalculatingTime; 535 // notFinishedTask.TransferTime = taskData.TransferTime; 536 // notFinishedTask.TaskState = x.State; 537 // notFinishedTask.Exception = taskData.Exception; 538 // notFinishedTask.InitialWaitingTime = taskData.InitialWaitingTime; 539 // } 540 //} 516 var newFactTasks = (from x in newAndNotFinishedTasks 517 where !x.NotFinishedTask 518 let taskData = CalculateFactTaskData(x.StateLogs) 519 select new FactTask { 520 TaskId = x.TaskId, 521 JobId = x.JobId, 522 StartTime = taskData.StartTime, 523 EndTime = taskData.EndTime, 524 LastClientId = x.LastClientId, 525 Priority = x.Priority, 526 CoresRequired = x.CoresRequired, 527 MemoryRequired = x.MemoryRequired, 528 NumCalculationRuns = taskData.CalculationRuns, 529 NumRetries = taskData.Retries, 530 WaitingTime = taskData.WaitingTime, 531 CalculatingTime = taskData.CalculatingTime, 532 TransferTime = taskData.TransferTime, 533 TaskState = x.State, 534 Exception = taskData.Exception, 535 InitialWaitingTime = taskData.InitialWaitingTime 536 }).ToList(); 537 Console.WriteLine("newFactTasks.Count = {0}", newFactTasks.Count); 538 factTaskDao.Save(newFactTasks); 539 Console.WriteLine("save of new fact tasks completed"); 541 540 } 542 541 … … 551 550 return user != null ? user.UserName : UnknownUserName; 552 551 } 553 } 554 catch (Exception) { 552 } catch (Exception) { 555 553 return UnknownUserName; 556 554 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Interfaces/ITaskScheduler.cs
r17226 r17586 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using HeuristicLab.Services.Hive.Data Transfer;24 using HeuristicLab.Services.Hive.DataAccess; 24 25 25 26 namespace HeuristicLab.Services.Hive { 26 27 public interface ITaskScheduler { 27 IEnumerable< TaskInfoForScheduler> Schedule(IEnumerable<TaskInfoForScheduler> tasks, int count = 1);28 IEnumerable<Guid> Schedule(Slave slave, int count = 1); 28 29 } 29 30 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs
r17226 r17586 28 28 public class EventManager : IEventManager { 29 29 private const string SlaveTimeout = "Slave timed out."; 30 private static readonly TaskState[] CompletedStates = { TaskState.Finished, TaskState.Aborted, TaskState.Failed }; 31 30 32 private IPersistenceManager PersistenceManager { 31 33 get { return ServiceLocator.Instance.PersistenceManager; } … … 33 35 34 36 public void Cleanup() { 37 Console.WriteLine("started cleanup"); 35 38 var pm = PersistenceManager; 36 39 37 pm.UseTransaction(() => { 38 FinishJobDeletion(pm); 39 pm.SubmitChanges(); 40 }); 40 // preemptiv delete obsolete entities 41 // speeds up job deletion 42 BatchDelete((p, s) => p.StateLogDao.DeleteObsolete(s), 100, 100, true, pm, "DeleteObsoleteStateLogs"); 43 BatchDelete((p, s) => p.TaskDataDao.DeleteObsolete(s), 100, 20, true, pm, "DeleteObsoleteTaskData"); 44 BatchDelete((p, s) => p.TaskDao.DeleteObsolete(s), 100, 20, false, pm, "DeleteObsoleteTasks"); 45 BatchDelete((p, s) => p.JobDao.DeleteByState(JobState.DeletionPending, s), 100, 20, true, pm, "DeleteObsoleteJobs"); 41 46 42 pm.UseTransaction(() => { 43 SetTimeoutSlavesOffline(pm); 44 SetTimeoutTasksWaiting(pm); 45 DeleteObsoleteSlaves(pm); 46 pm.SubmitChanges(); 47 }); 47 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: SetTimeoutSlavesOffline"); 48 Console.WriteLine("5"); 49 pm.UseTransactionAndSubmit(() => { SetTimeoutSlavesOffline(pm); }); 50 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: SetTimeoutTasksWaiting"); 51 Console.WriteLine("6"); 52 pm.UseTransactionAndSubmit(() => { SetTimeoutTasksWaiting(pm); }); 53 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: DeleteObsoleteSlaves"); 54 Console.WriteLine("7"); 55 pm.UseTransactionAndSubmit(() => { DeleteObsoleteSlaves(pm); }); 56 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: AbortObsoleteTasks"); 57 Console.WriteLine("8"); 58 pm.UseTransactionAndSubmit(() => { AbortObsoleteTasks(pm); }); 59 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: FinishParentTasks"); 60 Console.WriteLine("9"); 61 pm.UseTransactionAndSubmit(() => { FinishParentTasks(pm); }); 62 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: DONE"); 63 Console.WriteLine("10"); 64 } 48 65 49 pm.UseTransaction(() => { 50 FinishParentTasks(pm); 51 pm.SubmitChanges(); 52 }); 66 private void BatchDelete( 67 Func<IPersistenceManager, int, int> deletionFunc, 68 int batchSize, 69 int maxCalls, 70 bool limitIsBatchSize, 71 IPersistenceManager pm, 72 string logMessage 73 ) { 74 int totalDeleted = 0; 75 while (maxCalls > 0) { 76 maxCalls--; 77 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"HiveJanitor: {logMessage}"); 78 Console.WriteLine($"HiveJanitor: {logMessage}"); 79 var deleted = pm.UseTransactionAndSubmit(() => { return deletionFunc(pm, batchSize); }); 80 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"HiveJanitor: {logMessage} DONE (deleted {deleted}, {maxCalls} calls left)"); 81 Console.WriteLine($"HiveJanitor: {logMessage} DONE (deleted {deleted}, {maxCalls} calls left)"); 82 totalDeleted += deleted; 83 if (limitIsBatchSize && deleted < batchSize || deleted <= 0) return; 84 } 85 LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log($"HiveJanitor: Possible rows left to delete (total deleted: {totalDeleted})."); 86 Console.WriteLine($"HiveJanitor: Possible rows left to delete (total deleted: {totalDeleted})."); 53 87 } 54 88 … … 136 170 } 137 171 } 172 173 /// <summary> 174 /// Aborts tasks whose jobs have already been marked for deletion 175 /// </summary> 176 /// <param name="pm"></param> 177 private void AbortObsoleteTasks(IPersistenceManager pm) { 178 var jobDao = pm.JobDao; 179 var taskDao = pm.TaskDao; 180 181 var obsoleteTasks = (from jobId in jobDao.GetJobIdsByState(JobState.StatisticsPending) 182 join task in taskDao.GetAll() on jobId equals task.JobId 183 where !CompletedStates.Contains(task.State) && task.Command == null 184 select task).ToList(); 185 186 foreach (var t in obsoleteTasks) { 187 t.State = TaskState.Aborted; 188 } 189 } 138 190 } 139 191 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r17226 r17586 83 83 mutexAquired = mutex.WaitOne(Properties.Settings.Default.SchedulingPatience); 84 84 if (mutexAquired) { 85 var waitingTasks = pm.UseTransaction(() => taskDao.GetWaitingTasks(slave) 86 .Select(x => new TaskInfoForScheduler { 87 TaskId = x.TaskId, 88 JobId = x.JobId, 89 Priority = x.Priority 90 }) 91 .ToList() 92 ); 93 var availableTasks = TaskScheduler.Schedule(waitingTasks).ToArray(); 94 if (availableTasks.Any()) { 95 var task = availableTasks.First(); 96 AssignTask(pm, slave, task.TaskId); 97 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateTask, task.TaskId)); 85 var scheduledTaskIds = TaskScheduler.Schedule(slave, 1).ToArray(); 86 foreach (var id in scheduledTaskIds) { 87 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateTask, id)); 98 88 } 99 89 } else { 100 LogFactory.GetLogger(this.GetType().Namespace).Log( "HeartbeatManager: The mutex used for scheduling could not be aquired.");90 LogFactory.GetLogger(this.GetType().Namespace).Log($"HeartbeatManager: The mutex used for scheduling could not be aquired. (HB from Slave {slave.ResourceId})"); 101 91 } 102 } 103 catch (AbandonedMutexException) { 104 LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling has been abandoned."); 105 } 106 catch (Exception ex) { 107 LogFactory.GetLogger(this.GetType().Namespace).Log(string.Format("HeartbeatManager threw an exception in ProcessHeartbeat: {0}", ex)); 108 } 109 finally { 92 } catch (AbandonedMutexException) { 93 LogFactory.GetLogger(this.GetType().Namespace).Log($"HeartbeatManager: The mutex used for scheduling has been abandoned. (HB from Slave {slave.ResourceId})"); 94 } catch (Exception ex) { 95 LogFactory.GetLogger(this.GetType().Namespace).Log($"HeartbeatManager threw an exception in ProcessHeartbeat (HB from Slave {slave.ResourceId}): {ex}"); 96 } finally { 110 97 if (mutexAquired) mutex.ReleaseMutex(); 111 98 } … … 113 100 } 114 101 return actions; 115 }116 117 private void AssignTask(IPersistenceManager pm, DA.Slave slave, Guid taskId) {118 const DA.TaskState transferring = DA.TaskState.Transferring;119 DateTime now = DateTime.Now;120 var taskDao = pm.TaskDao;121 var stateLogDao = pm.StateLogDao;122 pm.UseTransaction(() => {123 var task = taskDao.GetById(taskId);124 stateLogDao.Save(new DA.StateLog {125 State = transferring,126 DateTime = now,127 TaskId = taskId,128 SlaveId = slave.ResourceId,129 UserId = null,130 Exception = null131 });132 task.State = transferring;133 task.LastHeartbeat = now;134 pm.SubmitChanges();135 });136 102 } 137 103 … … 154 120 var taskInfos = pm.UseTransaction(() => 155 121 (from task in taskDao.GetAll() 156 157 let lastStateLog = task.StateLogs.OrderByDescending(x => x.DateTime).FirstOrDefault()158 159 160 161 162 163 SlaveId = lastStateLog != null ? lastStateLog.SlaveId : default(Guid)164 122 where taskIds.Contains(task.TaskId) 123 let lastStateLog = task.StateLogs.OrderByDescending(x => x.DateTime).FirstOrDefault(x => x.State == DA.TaskState.Transferring) 124 select new { 125 TaskId = task.TaskId, 126 JobId = task.JobId, 127 State = task.State, 128 Command = task.Command, 129 SlaveId = lastStateLog != null ? lastStateLog.SlaveId : Guid.Empty 130 }).ToList() 165 131 ); 166 132 -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/MessageContainer.cs
r17226 r17586 24 24 using HEAL.Attic; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;27 26 28 27 namespace HeuristicLab.Services.Hive { … … 31 30 /// the actual message itself and the TaskId, refered by the message 32 31 /// </summary> 33 [Storable Class]32 [StorableType("67DEE81F-81FA-4B47-B043-93DBC2028DB5")] 34 33 [Serializable] 35 34 [DataContract] 36 35 public class MessageContainer : IDeepCloneable { 37 36 [StorableType("A907BDB0-99E3-4EE2-BA31-72FFD29F7B19")] 38 37 public enum MessageType { 39 38 // *** commands from hive server *** … … 62 61 63 62 [StorableConstructor] 64 protected MessageContainer( bool deserializing) { }63 protected MessageContainer(StorableConstructorFlag _) { } 65 64 protected MessageContainer() { } 66 65 public MessageContainer(MessageType message) { -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Properties/Settings.Designer.cs
r12961 r17586 1 1 //------------------------------------------------------------------------------ 2 2 // <auto-generated> 3 // Dieser Code wurde von einem Tool generiert.4 // Laufzeitversion:4.0.30319.420003 // This code was generated by a tool. 4 // Runtime Version:4.0.30319.42000 5 5 // 6 // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn7 // der Code erneut generiert wird.6 // Changes to this file may cause incorrect behavior and will be lost if 7 // the code is regenerated. 8 8 // </auto-generated> 9 9 //------------------------------------------------------------------------------ … … 13 13 14 14 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "1 4.0.0.0")]15 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] 16 16 public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 17 … … 80 80 [global::System.Configuration.ApplicationScopedSettingAttribute()] 81 81 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 82 [global::System.Configuration.DefaultSettingValueAttribute("00:0 0:20")]82 [global::System.Configuration.DefaultSettingValueAttribute("00:01:10")] 83 83 public global::System.TimeSpan SchedulingPatience { 84 84 get { -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Properties/Settings.settings
r12961 r17586 22 22 </Setting> 23 23 <Setting Name="SchedulingPatience" Type="System.TimeSpan" Scope="Application"> 24 <Value Profile="(Default)">00:0 0:20</Value>24 <Value Profile="(Default)">00:01:10</Value> 25 25 </Setting> 26 26 <Setting Name="ProfileServicePerformance" Type="System.Boolean" Scope="Application"> -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/Scheduler/RoundRobinTaskScheduler.cs
r17226 r17586 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Services.Hive.DataAccess.Interfaces;26 25 using DA = HeuristicLab.Services.Hive.DataAccess; 27 26 28 27 namespace HeuristicLab.Services.Hive { 29 public class RoundRobinTaskScheduler : ITaskScheduler { 30 private IPersistenceManager PersistenceManager { 31 get { return ServiceLocator.Instance.PersistenceManager; } 28 public class RoundRobinTaskScheduler : TaskScheduler { 29 private class TaskPriorityResult { 30 public Guid TaskId { get; set; } 31 public Guid OwnerUserId { get; set; } 32 32 } 33 33 34 p ublic IEnumerable<TaskInfoForScheduler> Schedule(IEnumerable<TaskInfoForScheduler> tasks, int count = 1) {35 if (!tasks.Any()) return Enumerable.Empty<TaskInfoForScheduler>();34 protected override IReadOnlyList<Guid> ScheduleInternal(DA.Slave slave, int count) { 35 var pm = PersistenceManager; 36 36 37 var pm = PersistenceManager; 38 var userPriorityDao = pm.UserPriorityDao; 39 var jobDao = pm.JobDao; 37 var result = pm.DataContext.ExecuteQuery<TaskPriorityResult>( 38 GetHighestPriorityWaitingTasksQuery, slave.ResourceId, count, slave.FreeCores, slave.FreeMemory).ToList(); 40 39 41 var userPriorities = pm.UseTransaction(() => userPriorityDao.GetAll() 42 .OrderBy(x => x.DateEnqueued) 43 .ToArray() 44 ); 40 foreach (var row in result) { 41 pm.DataContext.ExecuteCommand("UPDATE UserPriority SET DateEnqueued = SYSDATETIME() WHERE UserId = {0}", row.OwnerUserId); 42 } 45 43 46 var userIds = userPriorities.Select(x => x.UserId).ToList(); 47 var jobs = pm.UseTransaction(() => { 48 return jobDao.GetAll() 49 .Where(x => userIds.Contains(x.OwnerUserId)) 50 .Select(x => new { 51 Id = x.JobId, 52 DateCreated = x.DateCreated, 53 OwnerUserId = x.OwnerUserId 54 }) 55 .ToList(); 56 }); 57 58 var taskJobRelations = tasks.Join(jobs, 59 task => task.JobId, 60 job => job.Id, 61 (task, job) => new { Task = task, JobInfo = job }) 62 .OrderByDescending(x => x.Task.Priority) 63 .ToList(); 64 65 var scheduledTasks = new List<TaskInfoForScheduler>(); 66 int priorityIndex = 0; 67 68 if (count == 0 || count > taskJobRelations.Count) count = taskJobRelations.Count; 69 70 for (int i = 0; i < count; i++) { 71 var defaultEntry = taskJobRelations.First(); // search first task which is not included yet 72 var priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray(); // search for tasks with desired user priority 73 while (!priorityEntries.Any() && priorityIndex < userPriorities.Length - 1) { 74 priorityIndex++; 75 priorityEntries = taskJobRelations.Where(x => x.JobInfo.OwnerUserId == userPriorities[priorityIndex].UserId).ToArray(); 76 } 77 if (priorityEntries.Any()) { // tasks with desired user priority found 78 var priorityEntry = priorityEntries.OrderByDescending(x => x.Task.Priority).ThenBy(x => x.JobInfo.DateCreated).First(); 79 if (defaultEntry.Task.Priority <= priorityEntry.Task.Priority) { 80 taskJobRelations.Remove(priorityEntry); 81 scheduledTasks.Add(priorityEntry.Task); 82 UpdateUserPriority(pm, userPriorities[priorityIndex]); 83 priorityIndex++; 84 } else { // there are other tasks with higher priorities 85 taskJobRelations.Remove(defaultEntry); 86 scheduledTasks.Add(defaultEntry.Task); 87 } 88 } else { 89 taskJobRelations.Remove(defaultEntry); 90 scheduledTasks.Add(defaultEntry.Task); 91 } 92 if (priorityIndex >= (userPriorities.Length - 1)) priorityIndex = 0; 93 } 94 return scheduledTasks; 95 44 return result.Select(x => x.TaskId).ToArray(); 96 45 } 97 46 98 private void UpdateUserPriority(IPersistenceManager pm, DA.UserPriority up) { 99 pm.UseTransaction(() => { 100 up.DateEnqueued = DateTime.Now; 101 pm.SubmitChanges(); 102 }); 103 } 47 #region Query Strings 48 private string GetHighestPriorityWaitingTasksQuery = @" 49 WITH rbranch AS( 50 SELECT ResourceId, ParentResourceId 51 FROM [Resource] 52 WHERE ResourceId = {0} 53 UNION ALL 54 SELECT r.ResourceId, r.ParentResourceId 55 FROM [Resource] r 56 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId 57 ) 58 SELECT TOP ({1}) t.TaskId, j.OwnerUserId 59 FROM Task t 60 JOIN Job j on t.JobId = j.JobId 61 JOIN AssignedJobResource ajr on j.JobId = ajr.JobId 62 JOIN rbranch on ajr.ResourceId = rbranch.ResourceId 63 JOIN UserPriority u on j.OwnerUserId = u.UserId 64 WHERE NOT (t.IsParentTask = 1 AND t.FinishWhenChildJobsFinished = 1) 65 AND t.TaskState = 'Waiting' 66 AND t.CoresNeeded <= {2} 67 AND t.MemoryNeeded <= {3} 68 AND j.JobState = 'Online' 69 ORDER BY t.Priority DESC, u.DateEnqueued ASC, j.DateCreated ASC"; 70 #endregion 104 71 } 105 72 } -
branches/2521_ProblemRefactoring/HeuristicLab.Services.Hive/3.3/app.config
r16692 r17586 28 28 </setting> 29 29 <setting name="SchedulingPatience" serializeAs="String"> 30 <value>00:0 0:20</value>30 <value>00:01:10</value> 31 31 </setting> 32 32 <setting name="ProfileServicePerformance" serializeAs="String"> -
branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Tests merged: 17584
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalTest.cs
r17457 r17586 1 1 using System; 2 using System.Collections.Generic; 2 3 using Microsoft.VisualStudio.TestTools.UnitTesting; 3 4 … … 141 142 [TestProperty("Time", "short")] 142 143 public void SquarerootIntervalTest() { 143 Assert.AreEqual<Interval>(new Interval( 1, 2), Interval.SquareRoot(new Interval(1, 4)));144 Assert.AreEqual<Interval>(new Interval(-2, 2), Interval.SquareRoot(new Interval(1, 4))); 144 145 Assert.AreEqual<Interval>(new Interval(double.NaN, double.NaN), Interval.SquareRoot(new Interval(-4, -1))); 145 146 } … … 192 193 193 194 //Second interval goes over zero 194 Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound), Interval.AnalyticalQuotient(aPos, bZero)); 195 Assert.AreEqual(new Interval(aZero.LowerBound, aZero.UpperBound), Interval.AnalyticalQuotient(aZero, bZero)); 196 Assert.AreEqual(new Interval(aNeg.LowerBound, aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bZero)); 197 //Second interval is positive 198 Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aPos, bPos)); 199 Assert.AreEqual(new Interval(aZero.LowerBound/Math.Sqrt(5), aZero.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aZero, bPos)); 200 Assert.AreEqual(new Interval(aNeg.LowerBound/Math.Sqrt(5), aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bPos)); 201 //Second interval is negative 202 Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aPos, bNeg)); 203 Assert.AreEqual(new Interval(aZero.LowerBound/Math.Sqrt(5), aZero.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aZero, bNeg)); 204 Assert.AreEqual(new Interval(aNeg.LowerBound/Math.Sqrt(5), aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bNeg)); 195 //Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound), Interval.AnalyticalQuotient(aPos, bZero)); 196 //Assert.AreEqual(new Interval(aZero.LowerBound, aZero.UpperBound), Interval.AnalyticalQuotient(aZero, bZero)); 197 //Assert.AreEqual(new Interval(aNeg.LowerBound, aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bZero)); 198 ////Second interval is positive 199 //Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aPos, bPos)); 200 //Assert.AreEqual(new Interval(aZero.LowerBound/Math.Sqrt(5), aZero.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aZero, bPos)); 201 //Assert.AreEqual(new Interval(aNeg.LowerBound/Math.Sqrt(5), aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bPos)); 202 ////Second interval is negative 203 //Assert.AreEqual(new Interval(aPos.LowerBound/Math.Sqrt(17), aPos.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aPos, bNeg)); 204 //Assert.AreEqual(new Interval(aZero.LowerBound/Math.Sqrt(5), aZero.UpperBound/Math.Sqrt(5)), Interval.AnalyticalQuotient(aZero, bNeg)); 205 //Assert.AreEqual(new Interval(aNeg.LowerBound/Math.Sqrt(5), aNeg.UpperBound/Math.Sqrt(17)), Interval.AnalyticalQuotient(aNeg, bNeg)); 206 Assert.AreEqual(new Interval(double.NegativeInfinity, double.PositiveInfinity), Interval.AnalyticalQuotient(aPos, bZero)); 207 Assert.AreEqual(new Interval(double.NegativeInfinity, double.PositiveInfinity), Interval.AnalyticalQuotient(aPos, bPos)); 208 Assert.AreEqual(new Interval(double.NegativeInfinity, double.PositiveInfinity), Interval.AnalyticalQuotient(aZero, bNeg)); 205 209 } 206 210 … … 247 251 Assert.AreEqual(0, zeroInterval.LowerBound); 248 252 Assert.AreEqual(0, zeroInterval.UpperBound); 249 250 } 253 } 254 255 [TestMethod] 256 [TestCategory("Problems.DataAnalysis")] 257 [TestProperty("Time", "short")] 258 public void ContaintsTest() { 259 var negativeInterval = new Interval(-10, -5); 260 var positiveInterval = new Interval(5, 10); 261 var overZeroInterval = new Interval(-5, 5); 262 263 //Tests for negative intervals 264 Assert.AreEqual(true, negativeInterval.Contains(new Interval(-9, -7))); 265 Assert.AreEqual(false, negativeInterval.Contains(new Interval(-11, -3))); 266 Assert.AreEqual(false, negativeInterval.Contains(positiveInterval)); 267 Assert.AreEqual(false, negativeInterval.Contains(overZeroInterval)); 268 Assert.AreEqual(true, negativeInterval.Contains(-8)); 269 Assert.AreEqual(false, negativeInterval.Contains(-12)); 270 Assert.AreEqual(false, negativeInterval.Contains(0)); 271 //Testes for positive intervals 272 Assert.AreEqual(true, positiveInterval.Contains(new Interval(6, 10))); 273 Assert.AreEqual(false, positiveInterval.Contains(new Interval(6, 12))); 274 Assert.AreEqual(false, positiveInterval.Contains(negativeInterval)); 275 Assert.AreEqual(false, positiveInterval.Contains(overZeroInterval)); 276 Assert.AreEqual(true, positiveInterval.Contains(7)); 277 Assert.AreEqual(false, positiveInterval.Contains(11)); 278 Assert.AreEqual(false, positiveInterval.Contains(0)); 279 //Tests for over zero intervals 280 Assert.AreEqual(true, overZeroInterval.Contains(new Interval(-3, 3))); 281 Assert.AreEqual(true, overZeroInterval.Contains(new Interval(-4, -1))); 282 Assert.AreEqual(true, overZeroInterval.Contains(new Interval(1, 5))); 283 Assert.AreEqual(false, overZeroInterval.Contains(new Interval(-6, 0))); 284 Assert.AreEqual(false, overZeroInterval.Contains(new Interval(0, 6))); 285 Assert.AreEqual(false, overZeroInterval.Contains(new Interval(-7, 7))); 286 Assert.AreEqual(true, overZeroInterval.Contains(-3)); 287 Assert.AreEqual(true, overZeroInterval.Contains(0)); 288 Assert.AreEqual(true, overZeroInterval.Contains(3)); 289 Assert.AreEqual(false, overZeroInterval.Contains(12)); 290 Assert.AreEqual(false, overZeroInterval.Contains(-7)); 291 } 292 293 [TestMethod] 294 [TestCategory("Problems.DataAnalysis")] 295 [TestProperty("Time", "short")] 296 public void GetIntervalTest() { 297 var values = new List<double>() { -2.5, -9, 2, 7, 0 ,12, 12.4, 12.4, 9.29, 1002, -29.9}; 298 var valuesNan = new List<double>() { double.NaN, 2, 4, 19, -2, -12.2}; 299 var valuesInf = new List<double>() {double.NegativeInfinity, double.PositiveInfinity, 12, 2, -2, -12.2}; 300 301 var valuesInterval = new Interval(-29.9, 1002); 302 var valuesNanInterval = new Interval(double.NaN, double.NaN); 303 var valuesInfInterval = new Interval(double.NegativeInfinity, double.PositiveInfinity); 304 305 306 Assert.AreEqual(valuesInterval, Interval.GetInterval(values)); 307 Assert.AreEqual(valuesNanInterval, Interval.GetInterval(valuesNan)); 308 Assert.AreEqual(valuesInfInterval, Interval.GetInterval(valuesInf)); 309 } 310 311 [TestMethod] 312 [TestCategory("Problems.DataAnalysis")] 313 [TestProperty("Time", "short")] 314 public void EqualsTest() { 315 var interval1 = new Interval(0, 12); 316 var interval2 = new Interval(-12, 8); 317 var interval3 = new Interval(double.NegativeInfinity, 0); 318 319 Assert.AreEqual(true, interval1.Equals(new Interval(0, 12))); 320 Assert.AreEqual(false, interval1.Equals(interval2)); 321 Assert.AreEqual(true, interval3 == new Interval(double.NegativeInfinity, 0)); 322 Assert.AreEqual(true, interval1 != interval2); 323 Assert.AreEqual(false, interval2 == interval3); 324 Assert.AreEqual(false, interval1 != new Interval(0, 12)); 325 } 326 //[TestMethod] 327 //[TestCategory("Problems.DataAnalysis")] 328 //[TestProperty("Time", "short")] 329 //public void RootTest() { 330 // var posInterval = new Interval(3, 5); 331 // var negInterval = new Interval(-6, -2); 332 // var posIntervalConst = new Interval(5, 5); 333 // var negIntervalConst = new Interval(-3, -3); 334 // var zeroIntervalConst = new Interval(0, 0); 335 // var zeroPosInterval = new Interval(0, 2); 336 // var zeroNegInterval = new Interval(-2, 0); 337 338 // var posRoot = new Interval(4, 4); 339 // var negRoot = new Interval(-4, -4); 340 // var zeroRoot = new Interval(0, 0); 341 // var oneRoot = new Interval(1, 1); 342 343 // Assert.AreEqual(Interval.Root(posInterval, posRoot), new Interval(Math.Pow(3, (1.0/4)), Math.Pow(5, (1.0/4)))); 344 // Assert.AreEqual(Interval.Root(posInterval, negRoot), new Interval(Math.Pow(5, -(1.0/4)), Math.Pow(3, -(1.0/4)))); 345 // Assert.AreEqual(Interval.Root(posInterval, zeroRoot), new Interval(double.NaN, double.NaN)); 346 // Assert.AreEqual(Interval.Root(posInterval, oneRoot), new Interval(3, 5)); 347 348 // Assert.AreEqual(Interval.Root(negInterval, posRoot), new Interval(Math.Pow(-6, (1.0 / 4)), Math.Pow(-2, (1.0 / 4)))); 349 // Assert.AreEqual(Interval.Root(negInterval, negRoot), new Interval(Math.Pow(-2, -(1.0 / 4)), Math.Pow(-6, -(1.0 / 4)))); 350 // Assert.AreEqual(Interval.Root(negInterval, zeroRoot), new Interval(double.NaN, double.NaN)); 351 // Assert.AreEqual(Interval.Root(negInterval, oneRoot), new Interval(-6, -2)); 352 353 // Assert.AreEqual(Interval.Root(posIntervalConst, posRoot), new Interval(Math.Pow(5, (1.0 / 4)), Math.Pow(5, (1.0 / 4)))); 354 // Assert.AreEqual(Interval.Root(posIntervalConst, negRoot), new Interval(Math.Pow(5, -(1.0 / 4)), Math.Pow(5, -(1.0 / 4)))); 355 // Assert.AreEqual(Interval.Root(posIntervalConst, zeroRoot), new Interval(double.NaN, double.NaN)); 356 // Assert.AreEqual(Interval.Root(posIntervalConst, oneRoot), new Interval(5, 5)); 357 358 // Assert.AreEqual(Interval.Root(negIntervalConst, posRoot), new Interval(Math.Pow(-3, (1.0 / 4)), Math.Pow(-3, (1.0 / 4)))); 359 // Assert.AreEqual(Interval.Root(negIntervalConst, negRoot), new Interval(Math.Pow(-3, -(1.0 / 4)), Math.Pow(-3, -(1.0 / 4)))); 360 // Assert.AreEqual(Interval.Root(negIntervalConst, zeroRoot), new Interval(double.NaN, double.NaN)); 361 // Assert.AreEqual(Interval.Root(negIntervalConst, oneRoot), new Interval(-3, -3)); 362 363 // Assert.AreEqual(Interval.Root(zeroIntervalConst, posRoot), new Interval(0, 0)); 364 // //Compley Infinity https://www.wolframalpha.com/input/?i=root%28-4%2C+0%29 365 // Assert.AreEqual(Interval.Root(zeroIntervalConst, negRoot), new Interval(double.PositiveInfinity, double.PositiveInfinity)); 366 // Assert.AreEqual(Interval.Root(zeroIntervalConst, zeroRoot), new Interval(0, 0)); 367 // Assert.AreEqual(Interval.Root(zeroIntervalConst, oneRoot), new Interval(0, 0)); 368 369 // Assert.AreEqual(Interval.Root(zeroPosInterval, posRoot), new Interval(0, Math.Pow(2, (1.0 / 4)))); 370 // //Check for complex infinity 371 // Assert.AreEqual(Interval.Root(zeroPosInterval, negRoot), new Interval(Math.Pow(2, -(1.0 / 4)), double.PositiveInfinity)); 372 // Assert.AreEqual(Interval.Root(zeroPosInterval, zeroRoot), new Interval(0, 0)); 373 // Assert.AreEqual(Interval.Root(zeroPosInterval, oneRoot), new Interval(0, 2)); 374 375 // Assert.AreEqual(Interval.Root(zeroNegInterval, posRoot), new Interval(Math.Pow(-2, (1.0 / 4)),0)); 376 // //Check for complex infinity 377 // Assert.AreEqual(Interval.Root(zeroNegInterval, negRoot), new Interval(Math.Pow(-2, -(1.0 / 4)), double.PositiveInfinity)); 378 // Assert.AreEqual(Interval.Root(zeroNegInterval, zeroRoot), new Interval(double.NaN, double.NaN)); 379 // Assert.AreEqual(Interval.Root(zeroNegInterval, oneRoot), new Interval(-2, 0)); 380 //} 251 381 } 252 382 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/IntervalInterpreterTest.cs
r16801 r17586 40 40 Interval result; 41 41 if (variableRanges == null) 42 result = interpreter.GetSymbolicExpressionTreeInterval(tree, problemData.Dataset, problemData.AllIndices);42 result = interpreter.GetSymbolicExpressionTreeInterval(tree, problemData.Dataset, rows:problemData.AllIndices); 43 43 else 44 44 result = interpreter.GetSymbolicExpressionTreeInterval(tree, variableRanges); … … 163 163 } 164 164 165 [TestMethod]166 [TestCategory("Problems.DataAnalysis.Symbolic")]167 [TestProperty("Time", "short")]168 public void TestIntervalInterpreterExpRoot() {169 EvaluateTest("exp(root(x1*x2, 2))", new Interval(Math.Exp(Math.Sqrt(6)), Math.Exp(Math.Sqrt(48))));170 EvaluateTest("exp(root(x1*x2, 2))", new Interval(Math.Exp(Math.Sqrt(4)), Math.Exp(Math.Sqrt(60))), variableRanges);171 }172 173 [TestMethod]174 [TestCategory("Problems.DataAnalysis.Symbolic")]175 [TestProperty("Time", "short")]176 public void TestIntervalInterpreterPower() {177 EvaluateTest("pow(x1, 2)", new Interval(Math.Pow(3, 1), Math.Pow(8, 3)));178 }179 165 } 180 166 } -
branches/2521_ProblemRefactoring/Installers/HiveJanitorServiceInstaller.nsi
r17226 r17586 46 46 SetOutPath $INSTDIR 47 47 48 File "${JANITORBUILDPATH}\GeoIP.dat" 48 File "${JANITORBUILDPATH}\Google.Protobuf.dll" 49 File "${JANITORBUILDPATH}\HEAL.Attic.dll" 50 ;File "${JANITORBUILDPATH}\GeoIP.dat" 49 51 File "${JANITORBUILDPATH}\HeuristicLab.Common-3.3.dll" 50 File "${JANITORBUILDPATH}\HeuristicLab.Persistence-3.3.dll"52 ;File "${JANITORBUILDPATH}\HeuristicLab.Persistence-3.3.dll" 51 53 File "${JANITORBUILDPATH}\HeuristicLab.PluginInfrastructure-3.3.dll" 52 54 File "${JANITORBUILDPATH}\HeuristicLab.Services.Access.dll" … … 56 58 File "${JANITORBUILDPATH}\HeuristicLab.Services.Hive.JanitorService-3.3.exe.config" 57 59 File "${JANITORBUILDPATH}\HeuristicLab.Services.Hive-3.3.dll" 58 File "${JANITORBUILDPATH}\HeuristicLab.Tracing-3.3.dll"60 ;File "${JANITORBUILDPATH}\HeuristicLab.Tracing-3.3.dll" 59 61 60 62 WriteRegStr HKLM SOFTWARE\HeuristicLabHiveJanitorService "Install_Dir" "$INSTDIR" … … 76 78 nsExec::ExecToLog '"$INSTDIR\HeuristicLab.Services.Hive.JanitorService-3.3.exe" --uninstall' 77 79 78 Delete "$INSTDIR\GeoIP.dat" 80 Delete "$INSTDIR\Google.Protobuf.dll" 81 Delete "$INSTDIR\HEAL.Attic.dll" 82 ;Delete "$INSTDIR\GeoIP.dat" 79 83 Delete "$INSTDIR\HeuristicLab.Common-3.3.dll" 80 Delete "$INSTDIR\HeuristicLab.Persistence-3.3.dll"84 ;Delete "$INSTDIR\HeuristicLab.Persistence-3.3.dll" 81 85 Delete "$INSTDIR\HeuristicLab.PluginInfrastructure-3.3.dll" 82 86 Delete "$INSTDIR\HeuristicLab.Services.Access.dll" 87 Delete "$INSTDIR\HeuristicLab.Services.Access.DataAccess.dll" 83 88 Delete "$INSTDIR\HeuristicLab.Services.Hive.DataAccess-3.3.dll" 84 89 Delete "$INSTDIR\HeuristicLab.Services.Hive.JanitorService-3.3.exe" 85 90 Delete "$INSTDIR\HeuristicLab.Services.Hive.JanitorService-3.3.exe.config" 86 91 Delete "$INSTDIR\HeuristicLab.Services.Hive-3.3.dll" 87 Delete "$INSTDIR\HeuristicLab.Tracing-3.3.dll"92 ;Delete "$INSTDIR\HeuristicLab.Tracing-3.3.dll" 88 93 Delete "$INSTDIR\uninstall.exe" 89 94 -
branches/2521_ProblemRefactoring/Installers/HiveSlaveInstaller.nsi
r17226 r17586 46 46 SetOutPath $INSTDIR 47 47 48 File "${SLAVEBUILDPATH}\Google.Protobuf.dll" 49 File "${SLAVEBUILDPATH}\HEAL.Attic.dll" 50 File "${SLAVEBUILDPATH}\HeuristicLab.Clients.Common-3.3.dll" 48 51 File "${SLAVEBUILDPATH}\HeuristicLab.Clients.Hive.Slave.WindowsService.exe" 49 File "${SLAVEBUILDPATH}\HeuristicLab.Clients.Common-3.3.dll"50 52 File "${SLAVEBUILDPATH}\HeuristicLab.Clients.Hive.Slave.WindowsService.exe.config" 51 53 File "${SLAVEBUILDPATH}\HeuristicLab.Clients.Hive.SlaveCore-3.3.dll" … … 82 84 83 85 nsExec::ExecToLog '"$INSTDIR\HeuristicLab.Clients.Hive.Slave.WindowsService.exe" --uninstall' 84 85 Delete $INSTDIR\HeuristicLab.Clients.Hive.Slave.WindowsService.exe86 Delete $INSTDIR\HeuristicLab.Clients.Common-3.3.dll87 Delete $INSTDIR\HeuristicLab.Clients.Hive.Slave.WindowsService.exe.config88 Delete $INSTDIR\HeuristicLab.Clients.Hive.SlaveCore-3.3.dll89 Delete $INSTDIR\HeuristicLab.Clients.Hive-3.3.dll90 Delete $INSTDIR\HeuristicLab.Collections-3.3.dll91 Delete $INSTDIR\HeuristicLab.Common.Resources-3.3.dll92 Delete $INSTDIR\HeuristicLab.Common-3.3.dll93 Delete $INSTDIR\HeuristicLab.Core-3.3.dll94 Delete $INSTDIR\HeuristicLab.Data-3.3.dll95 Delete $INSTDIR\HeuristicLab.Hive-3.3.dll96 Delete $INSTDIR\HeuristicLab.MainForm-3.3.dll97 Delete $INSTDIR\HeuristicLab.Optimization-3.3.dll98 Delete $INSTDIR\HeuristicLab.Parameters-3.3.dll99 Delete $INSTDIR\HeuristicLab.Persistence-3.3.dll100 Delete $INSTDIR\HeuristicLab.PluginInfrastructure-3.3.dll101 Delete $INSTDIR\HeuristicLab.Tracing-3.3.dll102 Delete $INSTDIR\uninstall.exe103 86 104 RMDir "$INSTDIR"87 RMDir /r "$INSTDIR" 105 88 SectionEnd 106 89
Note: See TracChangeset
for help on using the changeset viewer.