Changeset 17333
- Timestamp:
- 10/17/19 10:01:44 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 1 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
/trunk merged: 17242,17255,17267-17268,17272-17274,17276,17278,17301-17302,17305-17306,17316,17329
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis merged: 17242,17272,17278
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 merged: 17242,17272,17278
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesModelSurrogate.cs
r17226 r17333 24 24 using System.Collections.Generic; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 using HEAL.Attic;29 29 using HeuristicLab.Problems.DataAnalysis; 30 30 … … 38 38 // don't store the actual model! 39 39 // the actual model is only recalculated when necessary 40 private IGradientBoostedTreesModel fullModel; 40 41 private readonly Lazy<IGradientBoostedTreesModel> actualModel; 41 42 private IGradientBoostedTreesModel ActualModel { … … 48 49 private readonly uint seed; 49 50 [Storable] 50 private ILossFunction lossFunction;51 private readonly ILossFunction lossFunction; 51 52 [Storable] 52 private double r;53 private readonly double r; 53 54 [Storable] 54 private double m;55 private readonly double m; 55 56 [Storable] 56 private double nu;57 private readonly double nu; 57 58 [Storable] 58 private int iterations;59 private readonly int iterations; 59 60 [Storable] 60 private int maxSize;61 private readonly int maxSize; 61 62 62 63 … … 69 70 [StorableConstructor] 70 71 private GradientBoostedTreesModelSurrogate(StorableConstructorFlag _) : base(_) { 71 actualModel = new Lazy<IGradientBoostedTreesModel>(() => RecalculateModel());72 actualModel = CreateLazyInitFunc(); 72 73 } 73 74 74 75 private GradientBoostedTreesModelSurrogate(GradientBoostedTreesModelSurrogate original, Cloner cloner) 75 76 : base(original, cloner) { 76 IGradientBoostedTreesModel clonedModel = null; 77 if (original.actualModel.IsValueCreated) clonedModel = cloner.Clone(original.ActualModel); 78 actualModel = new Lazy<IGradientBoostedTreesModel>(CreateLazyInitFunc(clonedModel)); // only capture clonedModel in the closure 79 77 // clone data which is necessary to rebuild the model 80 78 this.trainingProblemData = cloner.Clone(original.trainingProblemData); 81 79 this.lossFunction = cloner.Clone(original.lossFunction); … … 86 84 this.m = original.m; 87 85 this.nu = original.nu; 86 87 // clone full model if it has already been created 88 if (original.fullModel != null) this.fullModel = cloner.Clone(original.fullModel); 89 actualModel = CreateLazyInitFunc(); 88 90 } 89 91 90 private Func<IGradientBoostedTreesModel> CreateLazyInitFunc(IGradientBoostedTreesModel clonedModel) { 91 return () => { 92 return clonedModel ?? RecalculateModel(); 93 }; 92 private Lazy<IGradientBoostedTreesModel> CreateLazyInitFunc() { 93 return new Lazy<IGradientBoostedTreesModel>(() => { 94 if (fullModel == null) fullModel = RecalculateModel(); 95 return fullModel; 96 }); 94 97 } 95 98 … … 107 110 this.nu = nu; 108 111 109 actualModel = new Lazy<IGradientBoostedTreesModel>(() => RecalculateModel());112 actualModel = CreateLazyInitFunc(); 110 113 } 111 114 112 // wrap an actual model in a surrog rate115 // wrap an actual model in a surrogate 113 116 public GradientBoostedTreesModelSurrogate(IGradientBoostedTreesModel model, IRegressionProblemData trainingProblemData, uint seed, 114 117 ILossFunction lossFunction, int iterations, int maxSize, double r, double m, double nu) 115 118 : this(trainingProblemData, seed, lossFunction, iterations, maxSize, r, m, nu) { 116 actualModel = new Lazy<IGradientBoostedTreesModel>(() => model);119 fullModel = model; 117 120 } 118 121 … … 135 138 136 139 public IEnumerable<IRegressionModel> Models { 137 get { 138 return ActualModel.Models; 139 } 140 get { return ActualModel.Models; } 140 141 } 141 142 142 143 public IEnumerable<double> Weights { 143 get { 144 return ActualModel.Weights; 145 } 144 get { return ActualModel.Weights; } 146 145 } 147 146 } -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestModelSurrogate.cs
r17226 r17333 35 35 #region parameters for recalculation of the model 36 36 [Storable] 37 private int seed;37 private readonly int seed; 38 38 [Storable] 39 private IDataAnalysisProblemData originalTrainingData;39 private readonly IDataAnalysisProblemData originalTrainingData; 40 40 [Storable] 41 private double[] classValues;41 private readonly double[] classValues; 42 42 [Storable] 43 private int nTrees;43 private readonly int nTrees; 44 44 [Storable] 45 private double r;45 private readonly double r; 46 46 [Storable] 47 private double m;47 private readonly double m; 48 48 #endregion 49 49 50 50 51 // don't store the actual model! 51 52 // the actual model is only recalculated when necessary 53 private IRandomForestModel fullModel = null; 52 54 private readonly Lazy<IRandomForestModel> actualModel; 55 53 56 private IRandomForestModel ActualModel { 54 57 get { return actualModel.Value; } … … 74 77 this.m = m; 75 78 76 actualModel = new Lazy<IRandomForestModel>(() => RecalculateModel());79 actualModel = CreateLazyInitFunc(); 77 80 } 78 81 79 // wrap an actual model in a surrog rate82 // wrap an actual model in a surrogate 80 83 public RandomForestModelSurrogate(IRandomForestModel model, string targetVariable, IDataAnalysisProblemData originalTrainingData, 81 int seed, int nTrees, double r, double m, double[] classValues = null) : this(targetVariable, originalTrainingData, seed, nTrees, r, m, classValues) { 82 actualModel = new Lazy<IRandomForestModel>(() => model); 84 int seed, int nTrees, double r, double m, double[] classValues = null) 85 : this(targetVariable, originalTrainingData, seed, nTrees, r, m, classValues) { 86 fullModel = model; 83 87 } 84 88 85 89 [StorableConstructor] 86 90 private RandomForestModelSurrogate(StorableConstructorFlag _) : base(_) { 87 actualModel = new Lazy<IRandomForestModel>(() => RecalculateModel());91 actualModel = CreateLazyInitFunc(); 88 92 } 89 93 90 94 private RandomForestModelSurrogate(RandomForestModelSurrogate original, Cloner cloner) : base(original, cloner) { 91 IRandomForestModel clonedModel = null;92 if (original.actualModel.IsValueCreated) clonedModel = cloner.Clone(original.ActualModel);93 actualModel = new Lazy<IRandomForestModel>(CreateLazyInitFunc(clonedModel)); // only capture clonedModel in the closure94 95 95 // clone data which is necessary to rebuild the model 96 96 this.originalTrainingData = cloner.Clone(original.originalTrainingData); … … 100 100 this.r = original.r; 101 101 this.m = original.m; 102 }103 102 104 private Func<IRandomForestModel> CreateLazyInitFunc(IRandomForestModel clonedModel) { 105 return () => { 106 return clonedModel ?? RecalculateModel(); 107 }; 103 // clone full model if it has already been created 104 if (original.fullModel != null) this.fullModel = cloner.Clone(original.fullModel); 105 actualModel = CreateLazyInitFunc(); 108 106 } 109 107 110 108 public override IDeepCloneable Clone(Cloner cloner) { 111 109 return new RandomForestModelSurrogate(this, cloner); 110 } 111 112 private Lazy<IRandomForestModel> CreateLazyInitFunc() { 113 return new Lazy<IRandomForestModel>(() => { 114 if (fullModel == null) fullModel = RecalculateModel(); 115 return fullModel; 116 }); 112 117 } 113 118 -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.Administrator merged: 17268,17273-17274
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs
r16723 r17333 39 39 this.endLabel = new System.Windows.Forms.Label(); 40 40 this.indefiniteCheckBox = new System.Windows.Forms.CheckBox(); 41 this.createdTextBox = new System.Windows.Forms.TextBox(); 41 this.createdTextBox = new System.Windows.Forms.TextBox(); 42 42 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 43 this.refreshButton = new System.Windows.Forms.Button(); 43 44 this.SuspendLayout(); 44 45 // … … 68 69 this.nameLabel.Name = "nameLabel"; 69 70 this.nameLabel.Size = new System.Drawing.Size(38, 13); 70 this.nameLabel.TabIndex = 0;71 this.nameLabel.TabIndex = 2; 71 72 this.nameLabel.Text = "Name:"; 72 73 // … … 78 79 this.nameTextBox.Name = "nameTextBox"; 79 80 this.nameTextBox.Size = new System.Drawing.Size(464, 20); 80 this.nameTextBox.TabIndex = 2;81 this.nameTextBox.TabIndex = 3; 81 82 this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged); 82 83 this.nameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.nameTextBox_Validating); … … 88 89 this.descriptionLabel.Name = "descriptionLabel"; 89 90 this.descriptionLabel.Size = new System.Drawing.Size(63, 13); 90 this.descriptionLabel.TabIndex = 0;91 this.descriptionLabel.TabIndex = 4; 91 92 this.descriptionLabel.Text = "Description:"; 92 93 // … … 99 100 this.descriptionTextBox.Name = "descriptionTextBox"; 100 101 this.descriptionTextBox.Size = new System.Drawing.Size(464, 98); 101 this.descriptionTextBox.TabIndex = 3;102 this.descriptionTextBox.TabIndex = 5; 102 103 this.descriptionTextBox.TextChanged += new System.EventHandler(this.descriptionTextBox_TextChanged); 103 104 // 104 // ownerLabel105 //106 this.ownerLabel.AutoSize = true;107 this.ownerLabel.Location = new System.Drawing.Point(3, 167);108 this.ownerLabel.Name = "ownerLabel";109 this.ownerLabel.Size = new System.Drawing.Size(41, 13);110 this.ownerLabel.TabIndex = 0;111 this.ownerLabel.Text = "Owner:";112 //113 105 // ownerComboBox 114 106 // 115 //this.ownerComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)116 // | System.Windows.Forms.AnchorStyles.Right)));117 107 this.ownerComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 118 108 this.ownerComboBox.FormattingEnabled = true; … … 120 110 this.ownerComboBox.Name = "ownerComboBox"; 121 111 this.ownerComboBox.Size = new System.Drawing.Size(200, 21); 122 this.ownerComboBox.TabIndex = 4;112 this.ownerComboBox.TabIndex = 7; 123 113 this.ownerComboBox.SelectedIndexChanged += new System.EventHandler(this.ownerComboBox_SelectedIndexChanged); 114 // 115 // ownerLabel 116 // 117 this.ownerLabel.AutoSize = true; 118 this.ownerLabel.Location = new System.Drawing.Point(3, 167); 119 this.ownerLabel.Name = "ownerLabel"; 120 this.ownerLabel.Size = new System.Drawing.Size(41, 13); 121 this.ownerLabel.TabIndex = 6; 122 this.ownerLabel.Text = "Owner:"; 124 123 // 125 124 // createdLabel … … 129 128 this.createdLabel.Name = "createdLabel"; 130 129 this.createdLabel.Size = new System.Drawing.Size(47, 13); 131 this.createdLabel.TabIndex = 8;130 this.createdLabel.TabIndex = 9; 132 131 this.createdLabel.Text = "Created:"; 133 132 // … … 135 134 // 136 135 this.startDateTimePicker.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 137 this.startDateTimePicker.Enabled = false;138 136 this.startDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 139 137 this.startDateTimePicker.Location = new System.Drawing.Point(72, 216); 140 138 this.startDateTimePicker.Name = "startDateTimePicker"; 141 139 this.startDateTimePicker.Size = new System.Drawing.Size(200, 20); 142 this.startDateTimePicker.TabIndex = 9;143 this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged); 140 this.startDateTimePicker.TabIndex = 12; 141 this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged); 144 142 // 145 143 // startLabel … … 149 147 this.startLabel.Name = "startLabel"; 150 148 this.startLabel.Size = new System.Drawing.Size(32, 13); 151 this.startLabel.TabIndex = 1 0;149 this.startLabel.TabIndex = 11; 152 150 this.startLabel.Text = "Start:"; 153 151 // … … 155 153 // 156 154 this.endDateTimePicker.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 157 this.endDateTimePicker.Enabled = false;158 155 this.endDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 159 156 this.endDateTimePicker.Location = new System.Drawing.Point(72, 243); 160 157 this.endDateTimePicker.Name = "endDateTimePicker"; 161 158 this.endDateTimePicker.Size = new System.Drawing.Size(200, 20); 162 this.endDateTimePicker.TabIndex = 1 1;159 this.endDateTimePicker.TabIndex = 14; 163 160 this.endDateTimePicker.ValueChanged += new System.EventHandler(this.endDateTimePicker_ValueChanged); 164 161 // … … 169 166 this.endLabel.Name = "endLabel"; 170 167 this.endLabel.Size = new System.Drawing.Size(29, 13); 171 this.endLabel.TabIndex = 1 0;168 this.endLabel.TabIndex = 13; 172 169 this.endLabel.Text = "End:"; 173 170 // … … 178 175 this.indefiniteCheckBox.Name = "indefiniteCheckBox"; 179 176 this.indefiniteCheckBox.Size = new System.Drawing.Size(69, 17); 180 this.indefiniteCheckBox.TabIndex = 1 3;177 this.indefiniteCheckBox.TabIndex = 15; 181 178 this.indefiniteCheckBox.Text = "Indefinite"; 182 179 this.indefiniteCheckBox.UseVisualStyleBackColor = true; … … 189 186 this.createdTextBox.ReadOnly = true; 190 187 this.createdTextBox.Size = new System.Drawing.Size(200, 20); 191 this.createdTextBox.TabIndex = 14; 188 this.createdTextBox.TabIndex = 10; 189 // 190 // refreshButton 191 // 192 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 193 this.refreshButton.Location = new System.Drawing.Point(278, 162); 194 this.refreshButton.Name = "refreshButton"; 195 this.refreshButton.Size = new System.Drawing.Size(24, 24); 196 this.refreshButton.TabIndex = 8; 197 this.refreshButton.UseVisualStyleBackColor = true; 198 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 192 199 // 193 200 // ProjectView … … 195 202 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 196 203 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 204 this.Controls.Add(this.refreshButton); 197 205 this.Controls.Add(this.createdTextBox); 198 206 this.Controls.Add(this.indefiniteCheckBox); … … 213 221 this.Size = new System.Drawing.Size(539, 271); 214 222 this.Load += new System.EventHandler(this.ProjectView_Load); 215 this.Disposed += new System.EventHandler(this.ProjectView_Disposed);216 223 this.ResumeLayout(false); 217 224 this.PerformLayout(); … … 235 242 private System.Windows.Forms.Label endLabel; 236 243 private System.Windows.Forms.CheckBox indefiniteCheckBox; 237 private System.Windows.Forms.TextBox createdTextBox; 244 private System.Windows.Forms.TextBox createdTextBox; 238 245 private System.Windows.Forms.ToolTip toolTip; 246 private System.Windows.Forms.Button refreshButton; 239 247 } 240 248 } -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r17226 r17333 28 28 using HeuristicLab.Core.Views; 29 29 using HeuristicLab.MainForm; 30 using Tpl = System.Threading.Tasks; 30 31 31 32 namespace HeuristicLab.Clients.Hive.Administrator.Views { … … 33 34 [Content(typeof(Project), IsDefaultView = true)] 34 35 public partial class ProjectView : ItemView { 35 private readonly object locker = new object();36 37 36 public new Project Content { 38 37 get { return (Project)base.Content; } … … 58 57 } 59 58 60 protected void RegisterControlEvents() {61 nameTextBox.TextChanged += nameTextBox_TextChanged;62 nameTextBox.Validating += nameTextBox_Validating;63 descriptionTextBox.TextChanged += descriptionTextBox_TextChanged;64 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;65 startDateTimePicker.ValueChanged += startDateTimePicker_ValueChanged;66 endDateTimePicker.ValueChanged += endDateTimePicker_ValueChanged;67 indefiniteCheckBox.CheckedChanged += indefiniteCheckBox_CheckedChanged;68 }69 70 protected void DeregisterControlEvents() {71 nameTextBox.TextChanged -= nameTextBox_TextChanged;72 nameTextBox.Validating -= nameTextBox_Validating;73 descriptionTextBox.TextChanged -= descriptionTextBox_TextChanged;74 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged;75 startDateTimePicker.ValueChanged -= startDateTimePicker_ValueChanged;76 endDateTimePicker.ValueChanged -= endDateTimePicker_ValueChanged;77 indefiniteCheckBox.CheckedChanged -= indefiniteCheckBox_CheckedChanged;78 }79 80 59 protected override void OnContentChanged() { 81 60 base.OnContentChanged(); 82 DeregisterControlEvents(); 61 UpdateView(); 62 } 63 64 private void UpdateView() { 83 65 if (Content == null) { 84 66 idTextBox.Clear(); … … 94 76 nameTextBox.Text = Content.Name; 95 77 descriptionTextBox.Text = Content.Description; 96 97 if (AccessClient.Instance.UsersAndGroups != null) { 98 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 99 if (!Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 100 var projectOwnerId = Content.OwnerUserId; 101 ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList(); 102 ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == projectOwnerId); 103 } 104 78 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups?.OfType<LightweightUser>().SingleOrDefault(x => x.Id == Content.OwnerUserId); 105 79 createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss"); 106 80 startDateTimePicker.Value = Content.StartDate; 107 81 endDateTimePicker.Value = Content.EndDate.GetValueOrDefault(Content.StartDate); 108 82 indefiniteCheckBox.Checked = !Content.EndDate.HasValue; 109 if (!indefiniteCheckBox.Checked) endDateTimePicker.Value = Content.EndDate.Value; 110 else endDateTimePicker.Value = Content.StartDate; 111 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 112 } 113 SetEnabledStateOfControls(); 114 RegisterControlEvents(); 115 } 116 117 protected override void SetEnabledStateOfControls() { 118 base.SetEnabledStateOfControls(); 119 bool enabled = Content != null && !Locked && !ReadOnly; 120 nameTextBox.Enabled = enabled; 121 descriptionTextBox.Enabled = enabled; 122 ownerComboBox.Enabled = enabled; 123 createdTextBox.Enabled = enabled; 124 startDateTimePicker.Enabled = enabled; 125 endDateTimePicker.Enabled = enabled && Content.EndDate.HasValue; 126 indefiniteCheckBox.Enabled = enabled; 127 128 if (Content != null) { 129 //var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 130 var parentProject = HiveAdminClient.Instance.Projects.FirstOrDefault(x => x.Id == Content.ParentProjectId); 131 if ((!IsAdmin() && (parentProject == null || parentProject.EndDate.HasValue)) 132 || (IsAdmin() && parentProject != null && parentProject.EndDate.HasValue)) { 133 indefiniteCheckBox.Enabled = false; 134 } 135 136 if (Content.Id != Guid.Empty && !IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) { 137 ownerComboBox.Enabled = false; 138 startDateTimePicker.Enabled = false; 139 endDateTimePicker.Enabled = false; 140 indefiniteCheckBox.Enabled = false; 141 } 142 } 143 } 144 #endregion 145 146 #region Event Handlers 147 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 148 if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)Content_PropertyChanged, sender, e); 149 else OnContentChanged(); 150 } 151 152 private void AccessClient_Instance_Refreshing(object sender, EventArgs e) { 153 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e); 154 else { 155 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate); 156 SetEnabledStateOfControls(); 157 } 158 } 159 160 private void AccessClient_Instance_Refreshed(object sender, EventArgs e) { 161 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e); 162 else { 163 Progress.Hide(this); 164 SetEnabledStateOfControls(); 165 } 166 } 167 168 private async void ProjectView_Load(object sender, EventArgs e) { 169 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 170 action: () => UpdateUsers(), 171 finallyCallback: () => { 172 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 173 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 174 if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 175 var projectOwnerId = Content != null ? Content.OwnerUserId : (Guid?)null; 176 ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList(); 177 ownerComboBox.SelectedItem = projectOwnerId.HasValue ? users.FirstOrDefault(x => x.Id == projectOwnerId) : null; 178 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 179 }); 180 } 181 182 private void ProjectView_Disposed(object sender, EventArgs e) { 183 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed; 184 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing; 185 } 186 187 private void nameTextBox_Validating(object sender, CancelEventArgs e) { 188 if (string.IsNullOrEmpty(nameTextBox.Text)) { 189 MessageBox.Show( 190 "Project must have a name.", 191 "HeuristicLab Hive Administrator", 192 MessageBoxButtons.OK, 193 MessageBoxIcon.Error); 194 e.Cancel = true; 195 } 196 } 197 198 private void nameTextBox_TextChanged(object sender, EventArgs e) { 199 if (Content != null && Content.Name != nameTextBox.Text) { 200 DeregisterContentEvents(); 201 Content.Name = nameTextBox.Text; 202 RegisterContentEvents(); 203 } 204 } 205 206 private void descriptionTextBox_TextChanged(object sender, EventArgs e) { 207 if (Content != null && Content.Description != descriptionTextBox.Text) { 208 DeregisterContentEvents(); 209 Content.Description = descriptionTextBox.Text; 210 RegisterContentEvents(); 211 } 212 } 213 214 private void ownerComboBox_SelectedIndexChanged(object sender, EventArgs e) { 215 var selectedItem = (LightweightUser)ownerComboBox.SelectedItem; 216 var selectedOwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty; 217 if (Content != null && Content.OwnerUserId != selectedOwnerUserId) { 218 DeregisterContentEvents(); 219 Content.OwnerUserId = selectedOwnerUserId; 220 RegisterContentEvents(); 221 } 222 } 223 224 private void startDateTimePicker_ValueChanged(object sender, EventArgs e) { 225 if (Content == null) return; 226 startDateTimePicker.ValueChanged -= startDateTimePicker_ValueChanged; 227 228 if (!IsAdmin()) { 229 var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 230 if (parentProject != null) { 231 if (startDateTimePicker.Value < parentProject.StartDate) 232 startDateTimePicker.Value = parentProject.StartDate; 233 } else { 234 startDateTimePicker.Value = Content.StartDate; 235 } 236 } 237 238 if (!Content.EndDate.HasValue || startDateTimePicker.Value > Content.EndDate) 239 endDateTimePicker.Value = startDateTimePicker.Value; 240 if (Content.StartDate != startDateTimePicker.Value) { 241 DeregisterContentEvents(); 242 Content.StartDate = startDateTimePicker.Value; 243 RegisterContentEvents(); 244 } 245 246 startDateTimePicker.ValueChanged += startDateTimePicker_ValueChanged; 247 } 248 249 private void endDateTimePicker_ValueChanged(object sender, EventArgs e) { 250 if (Content == null) return; 251 endDateTimePicker.ValueChanged -= endDateTimePicker_ValueChanged; 252 253 if (!IsAdmin()) { 254 var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 255 if (parentProject != null) { 256 if (parentProject.EndDate.HasValue && endDateTimePicker.Value > parentProject.EndDate.Value) { 257 endDateTimePicker.Value = parentProject.EndDate.Value; 258 } 259 } else if (Content.EndDate.HasValue) { 260 endDateTimePicker.Value = Content.EndDate.Value; 261 } 262 } 263 264 if (endDateTimePicker.Value < startDateTimePicker.Value) 265 endDateTimePicker.Value = startDateTimePicker.Value; 266 if (Content.EndDate != endDateTimePicker.Value) { 267 DeregisterContentEvents(); 268 Content.EndDate = endDateTimePicker.Value; 269 RegisterContentEvents(); 270 } 271 272 endDateTimePicker.ValueChanged += endDateTimePicker_ValueChanged; 273 } 274 275 private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) { 276 if (Content == null) return; 277 278 var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : endDateTimePicker.Value; 279 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 280 if (Content.EndDate != newEndDate) { 281 DeregisterContentEvents(); 282 Content.EndDate = newEndDate; 283 RegisterContentEvents(); 284 } 285 } 286 #endregion 287 288 #region Helpers 83 } 84 } 85 86 private async Tpl.Task UpdateUsersAsync() { 87 await Tpl.Task.Run(() => UpdateUsers()); 88 } 89 289 90 private void UpdateUsers() { 91 // deregister handler to avoid change of content's owner when data source is updated 92 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 290 93 try { 291 AccessClient.Instance.Refresh(); 94 ownerComboBox.DataSource = null; 95 SecurityExceptionUtil.TryAndReportSecurityExceptions(AccessClient.Instance.Refresh); 96 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().OrderBy(x => x.UserName).ToList(); 292 97 } catch (AnonymousUserException) { 293 98 ShowHiveInformationDialog(); 294 } 295 } 296 297 private bool IsAdmin() { 298 return HiveRoles.CheckAdminUserPermissions(); 99 } finally { 100 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 101 } 299 102 } 300 103 … … 307 110 } 308 111 } 112 113 protected override void SetEnabledStateOfControls() { 114 base.SetEnabledStateOfControls(); 115 116 bool enabled = Content != null && !Locked && !ReadOnly; 117 118 nameTextBox.Enabled = enabled; 119 descriptionTextBox.Enabled = enabled; 120 ownerComboBox.Enabled = enabled; 121 refreshButton.Enabled = enabled; 122 createdTextBox.Enabled = enabled; 123 startDateTimePicker.Enabled = enabled; 124 endDateTimePicker.Enabled = enabled && Content.EndDate.HasValue && Content.EndDate > Content.StartDate; 125 indefiniteCheckBox.Enabled = enabled; 126 127 if (Content == null) return; 128 129 var parentProject = HiveAdminClient.Instance.Projects.SingleOrDefault(x => x.Id == Content.ParentProjectId); 130 if (parentProject != null && parentProject.EndDate.HasValue) 131 indefiniteCheckBox.Enabled = false; 132 133 if (Content.Id == Guid.Empty) return; // newly created project 134 if (HiveRoles.CheckAdminUserPermissions()) return; // admins can edit any project 135 if (HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) return; // owner can edit project 136 137 // project was already created and user is neither admin nor owner 138 ownerComboBox.Enabled = false; 139 startDateTimePicker.Enabled = false; 140 endDateTimePicker.Enabled = false; 141 indefiniteCheckBox.Enabled = false; 142 } 143 #endregion 144 145 #region Event Handlers 146 private void ProjectView_Load(object sender, EventArgs e) { 147 Locked = true; 148 try { 149 UpdateUsers(); 150 UpdateView(); 151 } finally { 152 Locked = false; 153 } 154 } 155 156 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 157 UpdateView(); 158 } 159 160 private void nameTextBox_TextChanged(object sender, EventArgs e) { 161 if (Content == null || Content.Name == nameTextBox.Text) return; 162 Content.Name = nameTextBox.Text; 163 } 164 165 private void nameTextBox_Validating(object sender, CancelEventArgs e) { 166 if (!string.IsNullOrEmpty(nameTextBox.Text)) return; 167 168 MessageBox.Show("Project must have a name.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 169 e.Cancel = true; 170 } 171 172 private void descriptionTextBox_TextChanged(object sender, EventArgs e) { 173 if (Content == null || Content.Description == descriptionTextBox.Text) return; 174 Content.Description = descriptionTextBox.Text; 175 } 176 177 private void ownerComboBox_SelectedIndexChanged(object sender, EventArgs e) { 178 if (Content == null) return; 179 180 var selectedItem = (LightweightUser)ownerComboBox.SelectedItem; 181 var selectedOwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty; 182 if (Content.OwnerUserId == selectedOwnerUserId) return; 183 184 Content.OwnerUserId = selectedOwnerUserId; 185 } 186 187 private async void refreshButton_Click(object sender, EventArgs e) { 188 Locked = true; 189 try { 190 await UpdateUsersAsync(); 191 UpdateView(); 192 } finally { 193 Locked = false; 194 } 195 } 196 197 private void startDateTimePicker_ValueChanged(object sender, EventArgs e) { 198 if (Content == null || Content.StartDate == startDateTimePicker.Value) return; 199 200 string errorMessage = string.Empty; 201 202 var parentProject = HiveAdminClient.Instance.Projects.SingleOrDefault(x => x.Id == Content.ParentProjectId); 203 if (parentProject != null) { 204 if (startDateTimePicker.Value < parentProject.StartDate) { 205 errorMessage = "Project cannot start before its parent project has started."; 206 } else if (startDateTimePicker.Value > parentProject.EndDate) { 207 errorMessage = "Project cannot start after its parent project has ended."; 208 } 209 } 210 211 if (startDateTimePicker.Value > endDateTimePicker.Value) { 212 errorMessage = "Project cannot start after it ends."; 213 } 214 215 if (!string.IsNullOrEmpty(errorMessage)) { 216 MessageBox.Show(errorMessage, "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 217 startDateTimePicker.Value = Content.StartDate; 218 } 219 220 Content.StartDate = startDateTimePicker.Value; 221 } 222 223 private void endDateTimePicker_ValueChanged(object sender, EventArgs e) { 224 if (Content == null || Content.EndDate == endDateTimePicker.Value || Content.StartDate == endDateTimePicker.Value) return; 225 226 string errorMessage = string.Empty; 227 228 var parentProject = HiveAdminClient.Instance.Projects.SingleOrDefault(x => x.Id == Content.ParentProjectId); 229 if (parentProject != null) { 230 if (endDateTimePicker.Value > parentProject.EndDate) { 231 errorMessage = "Project cannot end after its parent project has ended."; 232 } else if (endDateTimePicker.Value < parentProject.StartDate) { 233 errorMessage = "Project cannot end before its parent project has started."; 234 } 235 } 236 237 if (endDateTimePicker.Value < startDateTimePicker.Value) { 238 errorMessage = "Project cannot end after it starts."; 239 } 240 241 if (!string.IsNullOrEmpty(errorMessage)) { 242 MessageBox.Show(errorMessage, "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 243 endDateTimePicker.Value = Content.EndDate.GetValueOrDefault(Content.StartDate); 244 } 245 246 Content.EndDate = endDateTimePicker.Value; 247 } 248 249 private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) { 250 if (Content == null) return; 251 252 var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : endDateTimePicker.Value; 253 254 if (Content.EndDate == newEndDate) return; 255 Content.EndDate = newEndDate; 256 257 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 258 } 259 260 private void AccessClient_Instance_Refreshing(object sender, EventArgs e) { 261 if (InvokeRequired) { 262 Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e); 263 return; 264 } 265 266 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate); 267 SetEnabledStateOfControls(); 268 } 269 270 private void AccessClient_Instance_Refreshed(object sender, EventArgs e) { 271 if (InvokeRequired) { 272 Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e); 273 return; 274 } 275 276 Progress.Hide(this); 277 SetEnabledStateOfControls(); 278 } 309 279 #endregion 310 280 } -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.JobManager
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.JobManager merged: 17267
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs
r17226 r17333 144 144 if (Content != null && Content.Jobs != null) { 145 145 // clear hive client only if it is not displayed by any other content view (i.e. job manager) 146 var contentViews = MainFormManager.MainForm.Views.OfType<IContentView>(); 147 if (contentViews.All(x => x.Content != Content || x == this)) 146 var contentViews = MainFormManager.MainForm.Views.OfType<IContentView>() 147 .Where(v => v.Content == Content && v != this); 148 if (!contentViews.Any()) 148 149 Content.ClearHiveClient(); 149 150 -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.Slave merged: 17316
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs
r17226 r17333 25 25 using System.Linq; 26 26 using System.Management; 27 using System.Net.NetworkInformation;28 27 using HeuristicLab.Clients.Hive.SlaveCore.Properties; 29 28 … … 133 132 try { 134 133 prog = jobManager.GetExecutionTimes(); 135 } 136 catch (Exception ex) { 134 } catch (Exception ex) { 137 135 SlaveClientCom.Instance.LogMessage(string.Format("Exception was thrown while trying to get execution times: {0}", ex.Message)); 138 136 } … … 140 138 } 141 139 140 /// <summary> 141 /// Returns the unique machine id of the slave 142 /// </summary> 143 /// <returns><see cref="Guid"/></returns> 142 144 public static Guid GetUniqueMachineId() { 143 Guid id;144 try {145 id = GetUniqueMachineIdFromMac();146 }147 catch {148 // fallback if something goes wrong...149 id = new Guid(Environment.MachineName.GetHashCode(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);150 } 151 return id;145 // Due to the fact that repeated calculation of the machine ID can lead to a client registering at 146 // the Hive server multiple times with different IDs it's better to set the unique machine id only 147 // once, at first startup, and store it in core settings. 148 if (Settings.Default.MachineId == Guid.Empty) { 149 Settings.Default.MachineId = Guid.NewGuid(); 150 Settings.Default.Save(); 151 } 152 153 return Settings.Default.MachineId; 152 154 } 153 155 … … 170 172 } 171 173 172 /// <summary>173 /// Generate a guid based on mac address of the first found nic (yes, mac addresses are not unique...)174 /// and the machine name.175 /// Format:176 ///177 /// D1 D2 D3 Res. D4178 /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+179 /// |n a m e|0 0|0 0|0 0 mac address|180 /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+181 ///182 /// The mac address is saved in the last 48 bits of the Data 4 segment183 /// of the guid (first 2 bytes of Data 4 are reserved).184 /// D1 contains the hash of the machinename.185 /// </summary>186 private static Guid GetUniqueMachineIdFromMac() {187 //try to get a real network interface, not a virtual one188 NetworkInterface validNic = NetworkInterface.GetAllNetworkInterfaces()189 .FirstOrDefault(x =>190 !x.Name.Contains(vmwareNameString) &&191 !x.Name.Contains(virtualboxNameString) &&192 (x.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||193 x.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet));194 195 if (validNic == default(NetworkInterface)) {196 validNic = NetworkInterface.GetAllNetworkInterfaces().First();197 }198 199 byte[] addr = validNic.GetPhysicalAddress().GetAddressBytes();200 if (addr.Length < macLength || addr.Length > macLongLength) {201 throw new ArgumentException(string.Format("Error generating slave UID: MAC address has to have a length between {0} and {1} bytes. Actual MAC address is: {2}",202 macLength, macLongLength, addr));203 }204 205 if (addr.Length < macLongLength) {206 byte[] b = new byte[8];207 Array.Copy(addr, 0, b, 2, addr.Length);208 addr = b;209 }210 211 // also get machine name and save it to the first 4 bytes212 Guid guid = new Guid(Environment.MachineName.GetHashCode(), 0, 0, addr);213 return guid;214 }215 216 174 private static long? GetWMIValue(string clazz, string property) { 217 175 ManagementClass mgtClass = new ManagementClass(clazz); … … 223 181 try { 224 182 return long.Parse(prop.Value.ToString()); 225 } 226 catch { 183 } catch { 227 184 return null; 228 185 } … … 241 198 try { 242 199 mb = (int)(memCounter.NextValue() / 1024 / 1024); 243 } 244 catch { } 200 } catch { } 245 201 return mb; 246 202 } … … 251 207 try { 252 208 return cpuCounter.NextValue(); 253 } 254 catch { } 209 } catch { } 255 210 return cpuVal; 256 211 } -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/Properties/Settings.Designer.cs
r12960 r17333 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.2.0.0")] 16 16 public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 17 … … 323 323 } 324 324 } 325 326 [global::System.Configuration.UserScopedSettingAttribute()] 327 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 328 [global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")] 329 public global::System.Guid MachineId { 330 get { 331 return ((global::System.Guid)(this["MachineId"])); 332 } 333 set { 334 this["MachineId"] = value; 335 } 336 } 325 337 } 326 338 } -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/Properties/Settings.settings
r12960 r17333 78 78 <Value Profile="(Default)">00:05:00</Value> 79 79 </Setting> 80 <Setting Name="MachineId" Type="System.Guid" Scope="User"> 81 <Value Profile="(Default)">00000000-0000-0000-0000-000000000000</Value> 82 </Setting> 80 83 </Settings> 81 84 </SettingsFile> -
branches/2521_ProblemRefactoring/HeuristicLab.Clients.Hive.Slave/3.3/app.config
r16723 r17333 84 84 <setting name="CheckpointCheckInterval" serializeAs="String"> 85 85 <value>00:05:00</value> 86 </setting> 87 <setting name="MachineId" serializeAs="String"> 88 <value>00000000-0000-0000-0000-000000000000</value> 86 89 </setting> 87 90 </HeuristicLab.Clients.Hive.SlaveCore.Properties.Settings> -
branches/2521_ProblemRefactoring/HeuristicLab.Data
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data merged: 17255
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Data/3.3
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data/3.3 merged: 17255
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Data/3.3/Interfaces/ITextValue.cs
r17226 r17333 20 20 #endregion 21 21 22 using System; 23 using HeuristicLab.Common; 22 using HEAL.Attic; 24 23 25 24 namespace HeuristicLab.Data { 26 public interface ITextValue : IStringConvertibleValue {27 }25 [StorableType("6fe7970b-66de-4dcf-aa2b-c1aa9d7da29f")] 26 public interface ITextValue : IStringConvertibleValue { } 28 27 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 17301,17305
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views merged: 17276
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.Designer.cs
r17226 r17333 192 192 this.Name = "ClassificationSolutionVariableImpactsView"; 193 193 this.Size = new System.Drawing.Size(712, 365); 194 this.VisibleChanged += new System.EventHandler(this.ClassificationSolutionVariableImpactsView_VisibleChanged);195 194 this.ResumeLayout(false); 196 195 this.PerformLayout(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r17226 r17333 40 40 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 private bool attachedToProgress = false; 42 43 43 44 public new IClassificationSolution Content { … … 86 87 } 87 88 } 88 private void ClassificationSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 89 protected override void OnHidden(EventArgs e) { 90 base.OnHidden(e); 89 91 cancellationToken.Cancel(); 92 93 if (attachedToProgress) { 94 Progress.Hide(this); 95 attachedToProgress = false; 96 } 90 97 } 91 98 … … 126 133 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 127 134 progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name); 135 attachedToProgress = true; 128 136 cancellationToken = new CancellationTokenSource(); 129 137 … … 144 152 UpdateOrdering(); 145 153 } finally { 146 Progress.Hide(this); 154 if (attachedToProgress) { 155 Progress.Hide(this); 156 attachedToProgress = false; 157 } 147 158 } 148 159 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r17226 r17333 192 192 this.Name = "RegressionSolutionVariableImpactsView"; 193 193 this.Size = new System.Drawing.Size(712, 365); 194 this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged);195 194 this.ResumeLayout(false); 196 195 this.PerformLayout(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r17226 r17333 40 40 private CancellationTokenSource cancellationToken = new CancellationTokenSource(); 41 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 42 private bool attachedToProgress = false; 42 43 43 44 public new IRegressionSolution Content { … … 86 87 } 87 88 } 88 private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 89 90 protected override void OnHidden(EventArgs e) { 91 base.OnHidden(e); 89 92 cancellationToken.Cancel(); 93 94 if (attachedToProgress) { 95 Progress.Hide(this); 96 attachedToProgress = false; 97 } 90 98 } 91 99 … … 124 132 variableImpactsArrayView.Caption = Content.Name + " Variable Impacts"; 125 133 var progress = Progress.Show(this, "Calculating variable impacts for " + Content.Name); 134 attachedToProgress = true; 126 135 cancellationToken = new CancellationTokenSource(); 127 136 … … 141 150 rawVariableImpacts.AddRange(impacts); 142 151 UpdateOrdering(); 143 } 144 finally { 145 Progress.Hide(this); 152 } finally { 153 if (attachedToProgress) { 154 Progress.Hide(this); 155 attachedToProgress = false; 156 } 146 157 } 147 158 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4 merged: 17301,17305
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs
r17226 r17333 226 226 227 227 public static Interval CubicRoot(Interval a) { 228 if (a.LowerBound < 0) return new Interval(double.NaN, double.NaN); 229 return new Interval(Math.Pow(a.LowerBound, 1.0/3), Math.Pow(a.UpperBound, 1.0/3)); 228 var lower = (a.LowerBound < 0) ? -Math.Pow(-a.LowerBound, 1d / 3d) : Math.Pow(a.LowerBound, 1d / 3d); 229 var upper = (a.UpperBound < 0) ? -Math.Pow(-a.UpperBound, 1d / 3d) : Math.Pow(a.UpperBound, 1d / 3d); 230 231 return new Interval(lower, upper); 232 } 233 234 public static Interval Absolute(Interval a) { 235 var absLower = Math.Abs(a.LowerBound); 236 var absUpper = Math.Abs(a.UpperBound); 237 return new Interval(Math.Min(absLower, absUpper), Math.Max(absLower, absUpper)); 230 238 } 231 239 #endregion -
branches/2521_ProblemRefactoring/HeuristicLab.Scripting/3.3/Script.cs
r17226 r17333 40 40 public abstract class Script : NamedItem, IProgrammableItem { 41 41 #region Fields & Properties 42 public static readonly HashSet<string> ExcludedAssemblyFileNames = new HashSet<string> { "IKVM.OpenJDK.ClassLibrary.dll" }; 42 43 public static new Image StaticItemImage { 43 44 get { return VSImageLibrary.Script; } … … 124 125 public virtual IEnumerable<Assembly> GetAssemblies() { 125 126 var assemblies = AppDomain.CurrentDomain.GetAssemblies() 126 .Where(a => !a.IsDynamic && File.Exists(a.Location)) 127 .Where(a => !a.IsDynamic && File.Exists(a.Location) 128 && !ExcludedAssemblyFileNames.Contains(Path.GetFileName(a.Location))) 127 129 .GroupBy(x => Regex.Replace(Path.GetFileName(x.Location), @"-[\d.]+\.dll$", "")) 128 130 .Select(x => x.OrderByDescending(y => y.GetName().Version).First()) -
branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Tests merged: 17302,17306
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalTest.cs
r16723 r17333 159 159 public void TestIntervalCbrtOperator() { 160 160 Assert.AreEqual<Interval>(new Interval(1, 2), Interval.CubicRoot(new Interval(1, 8))); 161 Assert.AreEqual<Interval>(new Interval(double.NaN, double.NaN), Interval.CubicRoot(new Interval(-8, -1))); 161 Assert.AreEqual<Interval>(new Interval(-2, -2), Interval.CubicRoot(new Interval(-8, -8))); 162 Assert.AreEqual<Interval>(new Interval(-2, 2), Interval.CubicRoot(new Interval(-8, 8))); 163 Assert.AreEqual(new Interval(2, 2), Interval.CubicRoot(new Interval(8, 8))); 164 Assert.AreEqual(new Interval(-Math.Pow(6, 1.0 / 3), 2), Interval.CubicRoot(new Interval(-6, 8))); 165 Assert.AreEqual(new Interval(2, 2), Interval.CubicRoot(new Interval(8, 8))); 166 Assert.AreEqual(new Interval(-2, 0), Interval.CubicRoot(new Interval(-8, 0))); 167 } 168 169 [TestMethod] 170 [TestCategory("Problems.DataAnalysis")] 171 [TestProperty("Time", "short")] 172 public void TestIntervalAbsoluteOperator() { 173 Assert.AreEqual(new Interval(2, 2), Interval.Absolute(new Interval(-2, -2))); 174 Assert.AreEqual(new Interval(5, 5), Interval.Absolute(new Interval(5, 5))); 175 Assert.AreEqual(new Interval(2, 8), Interval.Absolute(new Interval(2, 8))); 176 Assert.AreEqual(new Interval(5, 14), Interval.Absolute(new Interval(-14, -5))); 177 Assert.AreEqual(new Interval(2, 7), Interval.Absolute(new Interval(-2, 7))); 178 Assert.AreEqual(new Interval(2, 22), Interval.Absolute(new Interval(-22, -2))); 179 Assert.AreEqual(new Interval(6, 22), Interval.Absolute(new Interval(-22, 6))); 180 Assert.AreEqual(new Interval(0, 0), Interval.Absolute(new Interval(0, 0))); 181 Assert.AreEqual(new Interval(0, 2), Interval.Absolute(new Interval(-2, 0))); 182 Assert.AreEqual(new Interval(0, 2), Interval.Absolute(new Interval(0, 2))); 162 183 } 163 184 }
Note: See TracChangeset
for help on using the changeset viewer.