Changeset 16173 for addons/HeuristicLab.MetaOptimization
- Timestamp:
- 09/21/18 16:00:50 (6 years ago)
- Location:
- addons/HeuristicLab.MetaOptimization
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HeuristicLab.HiveEngine.Views-3.3.csproj
r15741 r16173 125 125 <Private>False</Private> 126 126 </Reference> 127 <Reference Include="HeuristicLab.Common.Resources-3.3"> 128 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath> 129 <Private>False</Private> 130 </Reference> 127 131 <Reference Include="HeuristicLab.Core-3.3"> 128 132 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath> … … 173 177 </ProjectReference> 174 178 </ItemGroup> 175 <ItemGroup>176 <EmbeddedResource Include="HiveEngineView.resx">177 <DependentUpon>HiveEngineView.cs</DependentUpon>178 </EmbeddedResource>179 </ItemGroup>180 179 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 181 180 <PropertyGroup> -
addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.Designer.cs
r12930 r16173 25 25 /// </summary> 26 26 private void InitializeComponent() { 27 this. resourceIdsLabel = new System.Windows.Forms.Label();28 this. resourceIdsTextBox = new System.Windows.Forms.TextBox();27 this.projectLabel = new System.Windows.Forms.Label(); 28 this.projectNameTextBox = new System.Windows.Forms.TextBox(); 29 29 this.priorityLabel = new System.Windows.Forms.Label(); 30 this.priorityTextBox = new System.Windows.Forms.TextBox();31 30 this.label1 = new System.Windows.Forms.Label(); 32 31 this.executionTimeOnHiveTextBox = new System.Windows.Forms.TextBox(); … … 38 37 this.executionTimeLabel = new System.Windows.Forms.Label(); 39 38 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 39 this.priorityComboBox = new System.Windows.Forms.ComboBox(); 40 this.searchButton = new System.Windows.Forms.Button(); 40 41 this.tabControl.SuspendLayout(); 41 42 this.jobsTabPage.SuspendLayout(); … … 43 44 this.SuspendLayout(); 44 45 // 45 // resourceIdsLabel 46 // 47 this.resourceIdsLabel.AutoSize = true; 48 this.resourceIdsLabel.Location = new System.Drawing.Point(113, 55); 49 this.resourceIdsLabel.Name = "resourceIdsLabel"; 50 this.resourceIdsLabel.Size = new System.Drawing.Size(70, 13); 51 this.resourceIdsLabel.TabIndex = 3; 52 this.resourceIdsLabel.Text = "ResourceIds:"; 53 // 54 // resourceIdsTextBox 55 // 56 this.resourceIdsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 57 | System.Windows.Forms.AnchorStyles.Left) 58 | System.Windows.Forms.AnchorStyles.Right))); 59 this.resourceIdsTextBox.Location = new System.Drawing.Point(189, 52); 60 this.resourceIdsTextBox.Name = "resourceIdsTextBox"; 61 this.resourceIdsTextBox.Size = new System.Drawing.Size(517, 20); 62 this.resourceIdsTextBox.TabIndex = 4; 63 this.resourceIdsTextBox.Text = "HEAL"; 64 this.resourceIdsTextBox.Validated += new System.EventHandler(this.resourceIdsTextBox_Validated); 46 // projectLabel 47 // 48 this.projectLabel.AutoSize = true; 49 this.projectLabel.Location = new System.Drawing.Point(3, 55); 50 this.projectLabel.Name = "projectLabel"; 51 this.projectLabel.Size = new System.Drawing.Size(43, 13); 52 this.projectLabel.TabIndex = 3; 53 this.projectLabel.Text = "Project:"; 54 // 55 // projectNameTextBox 56 // 57 this.projectNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 58 | System.Windows.Forms.AnchorStyles.Left) 59 | System.Windows.Forms.AnchorStyles.Right))); 60 this.projectNameTextBox.Location = new System.Drawing.Point(162, 52); 61 this.projectNameTextBox.Name = "projectNameTextBox"; 62 this.projectNameTextBox.ReadOnly = true; 63 this.projectNameTextBox.Size = new System.Drawing.Size(544, 20); 64 this.projectNameTextBox.TabIndex = 4; 65 65 // 66 66 // priorityLabel 67 67 // 68 68 this.priorityLabel.AutoSize = true; 69 this.priorityLabel.Location = new System.Drawing.Point(3, 55);69 this.priorityLabel.Location = new System.Drawing.Point(3, 81); 70 70 this.priorityLabel.Name = "priorityLabel"; 71 71 this.priorityLabel.Size = new System.Drawing.Size(41, 13); 72 72 this.priorityLabel.TabIndex = 5; 73 73 this.priorityLabel.Text = "Priority:"; 74 //75 // priorityTextBox76 //77 this.priorityTextBox.Location = new System.Drawing.Point(50, 52);78 this.priorityTextBox.Name = "priorityTextBox";79 this.priorityTextBox.Size = new System.Drawing.Size(57, 20);80 this.priorityTextBox.TabIndex = 6;81 this.priorityTextBox.Text = "0";82 this.priorityTextBox.Validated += new System.EventHandler(this.priorityTextBox_Validated);83 74 // 84 75 // label1 … … 96 87 | System.Windows.Forms.AnchorStyles.Left) 97 88 | System.Windows.Forms.AnchorStyles.Right))); 98 this.executionTimeOnHiveTextBox.Location = new System.Drawing.Point(1 29, 26);89 this.executionTimeOnHiveTextBox.Location = new System.Drawing.Point(132, 26); 99 90 this.executionTimeOnHiveTextBox.Name = "executionTimeOnHiveTextBox"; 100 91 this.executionTimeOnHiveTextBox.ReadOnly = true; 101 this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(57 7, 20);92 this.executionTimeOnHiveTextBox.Size = new System.Drawing.Size(574, 20); 102 93 this.executionTimeOnHiveTextBox.TabIndex = 8; 103 94 // … … 109 100 this.tabControl.Controls.Add(this.jobsTabPage); 110 101 this.tabControl.Controls.Add(this.logTabPage); 111 this.tabControl.Location = new System.Drawing.Point(3, 78);102 this.tabControl.Location = new System.Drawing.Point(3, 105); 112 103 this.tabControl.Name = "tabControl"; 113 104 this.tabControl.SelectedIndex = 0; 114 this.tabControl.Size = new System.Drawing.Size(700, 4 60);105 this.tabControl.Size = new System.Drawing.Size(700, 433); 115 106 this.tabControl.TabIndex = 9; 116 107 // … … 121 112 this.jobsTabPage.Name = "jobsTabPage"; 122 113 this.jobsTabPage.Padding = new System.Windows.Forms.Padding(3); 123 this.jobsTabPage.Size = new System.Drawing.Size(692, 4 34);114 this.jobsTabPage.Size = new System.Drawing.Size(692, 407); 124 115 this.jobsTabPage.TabIndex = 0; 125 116 this.jobsTabPage.Text = "Jobs"; … … 135 126 this.hiveExperimentListView.ReadOnly = false; 136 127 this.hiveExperimentListView.ShowDetails = true; 137 this.hiveExperimentListView.Size = new System.Drawing.Size(686, 4 28);128 this.hiveExperimentListView.Size = new System.Drawing.Size(686, 401); 138 129 this.hiveExperimentListView.TabIndex = 0; 139 130 // … … 144 135 this.logTabPage.Name = "logTabPage"; 145 136 this.logTabPage.Padding = new System.Windows.Forms.Padding(3); 146 this.logTabPage.Size = new System.Drawing.Size(692, 4 34);137 this.logTabPage.Size = new System.Drawing.Size(692, 410); 147 138 this.logTabPage.TabIndex = 1; 148 139 this.logTabPage.Text = "Log"; … … 157 148 this.logView.Name = "logView"; 158 149 this.logView.ReadOnly = false; 159 this.logView.Size = new System.Drawing.Size(686, 4 28);150 this.logView.Size = new System.Drawing.Size(686, 404); 160 151 this.logView.TabIndex = 0; 161 152 // … … 163 154 // 164 155 this.executionTimeLabel.AutoSize = true; 165 this.executionTimeLabel.Location = new System.Drawing.Point( 4, 6);156 this.executionTimeLabel.Location = new System.Drawing.Point(3, 6); 166 157 this.executionTimeLabel.Name = "executionTimeLabel"; 167 158 this.executionTimeLabel.Size = new System.Drawing.Size(83, 13); … … 174 165 | System.Windows.Forms.AnchorStyles.Left) 175 166 | System.Windows.Forms.AnchorStyles.Right))); 176 this.executionTimeTextBox.Location = new System.Drawing.Point(1 29, 3);167 this.executionTimeTextBox.Location = new System.Drawing.Point(132, 3); 177 168 this.executionTimeTextBox.Name = "executionTimeTextBox"; 178 169 this.executionTimeTextBox.ReadOnly = true; 179 this.executionTimeTextBox.Size = new System.Drawing.Size(57 7, 20);170 this.executionTimeTextBox.Size = new System.Drawing.Size(574, 20); 180 171 this.executionTimeTextBox.TabIndex = 11; 172 // 173 // priorityComboBox 174 // 175 this.priorityComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 176 | System.Windows.Forms.AnchorStyles.Right))); 177 this.priorityComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 178 this.priorityComboBox.FormattingEnabled = true; 179 this.priorityComboBox.Items.AddRange(new object[] { 180 "Low", 181 "Normal", 182 "Urgent", 183 "Critical"}); 184 this.priorityComboBox.Location = new System.Drawing.Point(132, 78); 185 this.priorityComboBox.Name = "priorityComboBox"; 186 this.priorityComboBox.Size = new System.Drawing.Size(574, 21); 187 this.priorityComboBox.TabIndex = 44; 188 this.priorityComboBox.SelectedIndexChanged += new System.EventHandler(this.priorityComboBox_SelectedIndexChanged); 189 // 190 // searchButton 191 // 192 this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom; 193 this.searchButton.Location = new System.Drawing.Point(132, 49); 194 this.searchButton.Name = "searchButton"; 195 this.searchButton.Size = new System.Drawing.Size(24, 24); 196 this.searchButton.TabIndex = 45; 197 this.searchButton.UseVisualStyleBackColor = true; 198 this.searchButton.Click += new System.EventHandler(this.searchButton_Click); 181 199 // 182 200 // HiveEngineView … … 184 202 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 185 203 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 204 this.Controls.Add(this.searchButton); 205 this.Controls.Add(this.priorityComboBox); 186 206 this.Controls.Add(this.executionTimeTextBox); 187 207 this.Controls.Add(this.executionTimeLabel); … … 189 209 this.Controls.Add(this.label1); 190 210 this.Controls.Add(this.executionTimeOnHiveTextBox); 191 this.Controls.Add(this.priorityTextBox);192 211 this.Controls.Add(this.priorityLabel); 193 this.Controls.Add(this. resourceIdsLabel);194 this.Controls.Add(this. resourceIdsTextBox);212 this.Controls.Add(this.projectLabel); 213 this.Controls.Add(this.projectNameTextBox); 195 214 this.Name = "HiveEngineView"; 196 215 this.Size = new System.Drawing.Size(706, 541); … … 205 224 #endregion 206 225 207 private System.Windows.Forms.Label resourceIdsLabel;208 private System.Windows.Forms.TextBox resourceIdsTextBox;226 private System.Windows.Forms.Label projectLabel; 227 private System.Windows.Forms.TextBox projectNameTextBox; 209 228 private System.Windows.Forms.Label priorityLabel; 210 private System.Windows.Forms.TextBox priorityTextBox;211 229 private System.Windows.Forms.Label label1; 212 230 private System.Windows.Forms.TextBox executionTimeOnHiveTextBox; … … 218 236 private HeuristicLab.Core.Views.LogView logView; 219 237 private RefreshableHiveJobListView hiveExperimentListView; 238 protected System.Windows.Forms.ComboBox priorityComboBox; 239 private System.Windows.Forms.Button searchButton; 220 240 } 221 241 } -
addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs
r12930 r16173 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Windows.Forms; 26 using HeuristicLab.Clients.Hive; 27 using HeuristicLab.Clients.Hive.JobManager.Views; 23 28 using HeuristicLab.Core.Views; 24 29 using HeuristicLab.MainForm; … … 28 33 [Content(typeof(HiveEngine), IsDefaultView = true)] 29 34 public sealed partial class HiveEngineView : ItemView { 35 private readonly HiveResourceSelectorDialog hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Guid.Empty, Guid.Empty); 36 30 37 public new HiveEngine Content { 31 38 get { return (HiveEngine)base.Content; } … … 70 77 base.OnContentChanged(); 71 78 if (Content == null) { 72 resourceIdsTextBox.Text = string.Empty;73 priority TextBox.Text = string.Empty;79 projectNameTextBox.Text = string.Empty; 80 priorityComboBox.SelectedIndex = 1; 74 81 executionTimeOnHiveTextBox.Text = string.Empty; 75 82 hiveExperimentListView.Content = null; 76 83 logView.Content = null; 77 84 } else { 78 resourceIdsTextBox.Text = Content.ResourceNames; 79 priorityTextBox.Text = Content.Priority.ToString(); 85 if (Content.ProjectId != null && Content.ProjectId != Guid.Empty) { 86 var project = HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(Content.ProjectId)); 87 if (project != null) projectNameTextBox.Text = project.Name; 88 } else { 89 projectNameTextBox.Text = string.Empty; 90 } 91 92 if (Content.Priority >= 0 && Content.Priority < priorityComboBox.Items.Count) { 93 priorityComboBox.SelectedIndex = Content.Priority; 94 } else { 95 priorityComboBox.SelectedIndex = 1; 96 } 97 80 98 executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); 81 99 hiveExperimentListView.Content = Content.Jobs; … … 86 104 protected override void SetEnabledStateOfControls() { 87 105 base.SetEnabledStateOfControls(); 88 // Enable or disable controls based on whether the content is null or the view is set readonly 89 if (Content != null) { 90 resourceIdsTextBox.ReadOnly = this.ReadOnly; 91 priorityTextBox.ReadOnly = this.ReadOnly; 92 } else { 93 resourceIdsTextBox.ReadOnly = false; 94 priorityTextBox.ReadOnly = false; 106 107 searchButton.Enabled = Content != null && !ReadOnly && !Locked; 108 projectNameTextBox.Enabled = Content != null && !ReadOnly && !Locked; 109 priorityComboBox.Enabled = Content != null && !ReadOnly && !Locked; 110 } 111 112 private void searchButton_Click(object sender, EventArgs e) { 113 hiveResourceSelectorDialog.SelectedProjectId = Content != null ? Content.ProjectId : Guid.Empty; 114 hiveResourceSelectorDialog.SelectedResourceIds = Content != null ? Content.ResourceIds : new List<Guid>(); 115 116 var result = hiveResourceSelectorDialog.ShowDialog(this); 117 if (result == DialogResult.OK) { 118 var selectedProject = hiveResourceSelectorDialog.SelectedProject; 119 if (selectedProject != null) { 120 projectNameTextBox.Text = selectedProject.Name; 121 Content.ProjectId = selectedProject.Id; 122 Content.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); 123 } else { 124 projectNameTextBox.Text = string.Empty; 125 Content.ProjectId = Guid.Empty; 126 Content.ResourceIds = new List<Guid>(); 127 } 95 128 } 96 129 } 97 130 98 #region Event Handlers (child controls) 99 private void resourceIdsTextBox_Validated(object sender, EventArgs e) { 100 Content.ResourceNames = resourceIdsTextBox.Text; 131 private void priorityComboBox_SelectedIndexChanged(object sender, EventArgs e) { 132 if (Content != null && Content.Priority != priorityComboBox.SelectedIndex) { 133 Content.Priority = priorityComboBox.SelectedIndex; 134 } 101 135 } 102 103 private void priorityTextBox_Validated(object sender, EventArgs e) {104 Content.Priority = int.Parse(priorityTextBox.Text);105 }106 #endregion107 136 } 108 137 } -
addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
r14913 r16173 45 45 46 46 [Storable] 47 public string ResourceNames { get; set; } 47 public Guid ProjectId { get; set; } 48 49 [Storable] 50 public IEnumerable<Guid> ResourceIds { get; set; } 48 51 49 52 [Storable] … … 94 97 #region constructors and cloning 95 98 public HiveEngine() { 96 this.ResourceNames = "HEAL"; 99 this.ProjectId = Guid.Empty; 100 this.ResourceIds = new List<Guid>(); 97 101 this.Priority = 0; 98 102 this.log = new ThreadSafeLog(); … … 103 107 protected HiveEngine(HiveEngine original, Cloner cloner) 104 108 : base(original, cloner) { 105 this.ResourceNames = original.ResourceNames; 109 this.ProjectId = original.ProjectId; 110 this.ResourceIds = original.ResourceIds.ToList(); 106 111 this.currentOperator = cloner.Clone(original.currentOperator); 107 112 this.priority = original.priority; … … 145 150 firstRun = false; 146 151 } 152 153 if (ProjectId == Guid.Empty) 154 throw new ArgumentException("Cannot run HiveEngine. No project has been specified."); 155 156 if (!ResourceIds.Any()) 157 throw new ArgumentException("Cannot run HiveEngine. No resources have been specified."); 147 158 148 159 while (executionStack.Count > 0) { … … 175 186 } 176 187 } 177 } 178 catch { 188 } catch { 179 189 executionStack.Push(coll); throw; 180 190 } … … 187 197 try { 188 198 next = operation.Operator.Execute((IExecutionContext)operation, cancellationToken); 189 } 190 catch (Exception ex) { 199 } catch (Exception ex) { 191 200 executionStack.Push(operation); 192 201 if (ex is OperationCanceledException) throw ex; … … 217 226 } 218 227 return FindRandomParameter(ec.Parent); 219 } 220 catch { return null; } 228 } catch { return null; } 221 229 } 222 230 … … 256 264 random.Reset(random.Next()); 257 265 } 266 258 267 HiveClient.StartJob((e) => { log.LogException(e); }, refreshableJob, cancellationToken); 259 268 260 269 // do polling until experiment is finished and all jobs are downloaded 261 270 while (!refreshableJob.IsFinished()) { 271 if (!refreshableJob.RefreshAutomatically && refreshableJob.Id != Guid.Empty) 272 refreshableJob.RefreshAutomatically = true; 273 262 274 Thread.Sleep(2000); 275 263 276 this.ExecutionTimeOnHive = TimeSpan.FromMilliseconds(jobs.Sum(x => x.ExecutionTime.TotalMilliseconds)); 264 277 cancellationToken.ThrowIfCancellationRequested(); 265 278 } 279 266 280 log.LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableJob.ToString(), refreshableJob.ExecutionTime)); 267 281 … … 277 291 scopes[j++] = scope; 278 292 } 293 279 294 return scopes; 280 } 281 catch (OperationCanceledException e) { 295 } catch (OperationCanceledException e) { 282 296 throw e; 283 } 284 catch (Exception e) { 297 } catch (Exception e) { 285 298 log.LogException(e); 286 299 throw e; 287 } 288 finally { 300 } finally { 289 301 DisposeJob(refreshableJob); 290 302 } … … 293 305 private RefreshableJob CreateJob() { 294 306 lock (locker) { 295 var hiveExperiment = new Job(); 296 hiveExperiment.Name = "HiveEngine Run " + jobs.Count; 297 hiveExperiment.DateCreated = DateTime.Now; 298 hiveExperiment.ResourceNames = this.ResourceNames; 299 var refreshableHiveExperiment = new RefreshableJob(hiveExperiment); 300 refreshableHiveExperiment.IsDownloadable = false; // download happens automatically so disable button 307 var hiveExperiment = new Job { 308 Name = "HiveEngine Run " + jobs.Count, 309 DateCreated = DateTime.Now, 310 ProjectId = ProjectId, 311 ResourceIds = ResourceIds.ToList(), 312 }; 313 314 var refreshableHiveExperiment = new RefreshableJob(hiveExperiment) { 315 RefreshAutomatically = false, 316 IsDownloadable = false // download happens automatically later on so disable button 317 }; 318 301 319 jobs.Add(refreshableHiveExperiment); 320 302 321 return refreshableHiveExperiment; 303 322 } … … 319 338 private void DeleteHiveExperiment(Guid jobId) { 320 339 HiveClient.TryAndRepeat(() => { 321 HiveServiceLocator.Instance.CallHiveService(s => s. DeleteJob(jobId));340 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(jobId, JobState.StatisticsPending)); 322 341 }, 5, string.Format("Could not delete jobs")); 323 }324 325 private List<Guid> GetResourceIds() {326 return HiveServiceLocator.Instance.CallHiveService(service => {327 var resourceNames = ResourceNames.Split(';');328 var resourceIds = new List<Guid>();329 foreach (var resourceName in resourceNames) {330 Guid resourceId = service.GetResourceId(resourceName);331 if (resourceId == Guid.Empty) {332 throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName));333 }334 resourceIds.Add(resourceId);335 }336 return resourceIds;337 });338 342 } 339 343 }
Note: See TracChangeset
for help on using the changeset viewer.