Changeset 5300
- Timestamp:
- 01/15/11 02:34:08 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs
r5287 r5300 35 35 private void InitializeComponent() { 36 36 this.tabControl = new System.Windows.Forms.TabControl(); 37 this. algorithmTabPage = new System.Windows.Forms.TabPage();38 this. algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();39 this.open AlgorithmButton = new System.Windows.Forms.Button();40 this.new AlgorithmButton = new System.Windows.Forms.Button();37 this.optimizerTabPage = new System.Windows.Forms.TabPage(); 38 this.optimizerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 39 this.openOptimizerButton = new System.Windows.Forms.Button(); 40 this.newOptimizerButton = new System.Windows.Forms.Button(); 41 41 this.runsTabPage = new System.Windows.Forms.TabPage(); 42 42 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); … … 52 52 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 53 this.tabControl.SuspendLayout(); 54 this. algorithmTabPage.SuspendLayout();54 this.optimizerTabPage.SuspendLayout(); 55 55 this.runsTabPage.SuspendLayout(); 56 56 ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit(); … … 72 72 | System.Windows.Forms.AnchorStyles.Left) 73 73 | System.Windows.Forms.AnchorStyles.Right))); 74 this.tabControl.Controls.Add(this. algorithmTabPage);74 this.tabControl.Controls.Add(this.optimizerTabPage); 75 75 this.tabControl.Controls.Add(this.runsTabPage); 76 76 this.tabControl.Location = new System.Drawing.Point(0, 78); … … 80 80 this.tabControl.TabIndex = 6; 81 81 // 82 // algorithmTabPage83 // 84 this. algorithmTabPage.AllowDrop = true;85 this. algorithmTabPage.Controls.Add(this.algorithmViewHost);86 this. algorithmTabPage.Controls.Add(this.openAlgorithmButton);87 this. algorithmTabPage.Controls.Add(this.newAlgorithmButton);88 this. algorithmTabPage.Location = new System.Drawing.Point(4, 22);89 this. algorithmTabPage.Name = "algorithmTabPage";90 this. algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);91 this. algorithmTabPage.Size = new System.Drawing.Size(671, 348);92 this. algorithmTabPage.TabIndex = 1;93 this. algorithmTabPage.Text = "Algorithm";94 this. algorithmTabPage.UseVisualStyleBackColor = true;95 this. algorithmTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);96 this. algorithmTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragDrop);97 this. algorithmTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);98 // 99 // algorithmViewHost100 // 101 this. algorithmViewHost.Content = null;102 this. algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)82 // optimizerTabPage 83 // 84 this.optimizerTabPage.AllowDrop = true; 85 this.optimizerTabPage.Controls.Add(this.optimizerViewHost); 86 this.optimizerTabPage.Controls.Add(this.openOptimizerButton); 87 this.optimizerTabPage.Controls.Add(this.newOptimizerButton); 88 this.optimizerTabPage.Location = new System.Drawing.Point(4, 22); 89 this.optimizerTabPage.Name = "optimizerTabPage"; 90 this.optimizerTabPage.Padding = new System.Windows.Forms.Padding(3); 91 this.optimizerTabPage.Size = new System.Drawing.Size(671, 348); 92 this.optimizerTabPage.TabIndex = 1; 93 this.optimizerTabPage.Text = "Optimizer"; 94 this.optimizerTabPage.UseVisualStyleBackColor = true; 95 this.optimizerTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver); 96 this.optimizerTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragDrop); 97 this.optimizerTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver); 98 // 99 // optimizerViewHost 100 // 101 this.optimizerViewHost.Content = null; 102 this.optimizerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 103 103 | System.Windows.Forms.AnchorStyles.Left) 104 104 | System.Windows.Forms.AnchorStyles.Right))); 105 this. algorithmViewHost.Location = new System.Drawing.Point(6, 36);106 this. algorithmViewHost.Name = "algorithmViewHost";107 this. algorithmViewHost.Size = new System.Drawing.Size(659, 306);108 this. algorithmViewHost.TabIndex = 3;109 this. algorithmViewHost.ViewType = null;110 // 111 // open AlgorithmButton112 // 113 this.open AlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;114 this.open AlgorithmButton.Location = new System.Drawing.Point(36, 6);115 this.open AlgorithmButton.Name = "openAlgorithmButton";116 this.open AlgorithmButton.Size = new System.Drawing.Size(24, 24);117 this.open AlgorithmButton.TabIndex = 1;118 this.toolTip.SetToolTip(this.open AlgorithmButton, "Open Algorithm");119 this.open AlgorithmButton.UseVisualStyleBackColor = true;120 this.open AlgorithmButton.Click += new System.EventHandler(this.openAlgorithmButton_Click);121 // 122 // new AlgorithmButton123 // 124 this.new AlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;125 this.new AlgorithmButton.Location = new System.Drawing.Point(6, 6);126 this.new AlgorithmButton.Name = "newAlgorithmButton";127 this.new AlgorithmButton.Size = new System.Drawing.Size(24, 24);128 this.new AlgorithmButton.TabIndex = 0;129 this.toolTip.SetToolTip(this.new AlgorithmButton, "New Algorithm");130 this.new AlgorithmButton.UseVisualStyleBackColor = true;131 this.new AlgorithmButton.Click += new System.EventHandler(this.newAlgorithmButton_Click);105 this.optimizerViewHost.Location = new System.Drawing.Point(6, 36); 106 this.optimizerViewHost.Name = "optimizerViewHost"; 107 this.optimizerViewHost.Size = new System.Drawing.Size(659, 306); 108 this.optimizerViewHost.TabIndex = 3; 109 this.optimizerViewHost.ViewType = null; 110 // 111 // openOptimizerButton 112 // 113 this.openOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 114 this.openOptimizerButton.Location = new System.Drawing.Point(36, 6); 115 this.openOptimizerButton.Name = "openOptimizerButton"; 116 this.openOptimizerButton.Size = new System.Drawing.Size(24, 24); 117 this.openOptimizerButton.TabIndex = 1; 118 this.toolTip.SetToolTip(this.openOptimizerButton, "Open Optimizer"); 119 this.openOptimizerButton.UseVisualStyleBackColor = true; 120 this.openOptimizerButton.Click += new System.EventHandler(this.openOptimizerButton_Click); 121 // 122 // newOptimizerButton 123 // 124 this.newOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument; 125 this.newOptimizerButton.Location = new System.Drawing.Point(6, 6); 126 this.newOptimizerButton.Name = "newOptimizerButton"; 127 this.newOptimizerButton.Size = new System.Drawing.Size(24, 24); 128 this.newOptimizerButton.TabIndex = 0; 129 this.toolTip.SetToolTip(this.newOptimizerButton, "New Optimizer"); 130 this.newOptimizerButton.UseVisualStyleBackColor = true; 131 this.newOptimizerButton.Click += new System.EventHandler(this.newOptimizerButton_Click); 132 132 // 133 133 // runsTabPage … … 211 211 // 212 212 this.openFileDialog.DefaultExt = "hl"; 213 this.openFileDialog.FileName = " Algorithm";213 this.openFileDialog.FileName = "Optimizer"; 214 214 this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*"; 215 this.openFileDialog.Title = "Open Algorithm";215 this.openFileDialog.Title = "Open Optimizer"; 216 216 // 217 217 // repetitionsLabel … … 293 293 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 294 294 this.tabControl.ResumeLayout(false); 295 this. algorithmTabPage.ResumeLayout(false);295 this.optimizerTabPage.ResumeLayout(false); 296 296 this.runsTabPage.ResumeLayout(false); 297 297 ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit(); … … 303 303 304 304 private System.Windows.Forms.TabControl tabControl; 305 private System.Windows.Forms.TabPage algorithmTabPage;306 private HeuristicLab.MainForm.WindowsForms.ViewHost algorithmViewHost;307 private System.Windows.Forms.Button new AlgorithmButton;308 private System.Windows.Forms.Button open AlgorithmButton;305 private System.Windows.Forms.TabPage optimizerTabPage; 306 private HeuristicLab.MainForm.WindowsForms.ViewHost optimizerViewHost; 307 private System.Windows.Forms.Button newOptimizerButton; 308 private System.Windows.Forms.Button openOptimizerButton; 309 309 private System.Windows.Forms.Button startButton; 310 310 private System.Windows.Forms.Button stopButton; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r5237 r5300 35 35 [Content(typeof(BatchRun), true)] 36 36 public sealed partial class BatchRunView : NamedItemView { 37 private TypeSelectorDialog algorithmTypeSelectorDialog;37 private TypeSelectorDialog optimizerTypeSelectorDialog; 38 38 39 39 public new BatchRun Content { … … 51 51 protected override void Dispose(bool disposing) { 52 52 if (disposing) { 53 if ( algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();53 if (optimizerTypeSelectorDialog != null) optimizerTypeSelectorDialog.Dispose(); 54 54 if (components != null) components.Dispose(); 55 55 } … … 58 58 59 59 protected override void DeregisterContentEvents() { 60 Content. AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged);60 Content.OptimizerChanged -= new EventHandler(Content_OptimizerChanged); 61 61 Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 62 62 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 71 71 protected override void RegisterContentEvents() { 72 72 base.RegisterContentEvents(); 73 Content. AlgorithmChanged += new EventHandler(Content_AlgorithmChanged);73 Content.OptimizerChanged += new EventHandler(Content_OptimizerChanged); 74 74 Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 75 75 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); … … 86 86 if (Content == null) { 87 87 repetitionsNumericUpDown.Value = 1; 88 algorithmViewHost.Content = null;88 optimizerViewHost.Content = null; 89 89 runsView.Content = null; 90 90 executionTimeTextBox.Text = "-"; … … 92 92 Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started; 93 93 repetitionsNumericUpDown.Value = Content.Repetitions; 94 algorithmViewHost.Content = Content.Algorithm;94 optimizerViewHost.Content = Content.Optimizer; 95 95 runsView.Content = Content.Runs; 96 96 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); … … 100 100 base.SetEnabledStateOfControls(); 101 101 repetitionsNumericUpDown.Enabled = Content != null && !ReadOnly; 102 new AlgorithmButton.Enabled = Content != null && !ReadOnly;103 open AlgorithmButton.Enabled = Content != null && !ReadOnly;104 algorithmViewHost.Enabled = Content != null;102 newOptimizerButton.Enabled = Content != null && !ReadOnly; 103 openOptimizerButton.Enabled = Content != null && !ReadOnly; 104 optimizerViewHost.Enabled = Content != null; 105 105 runsView.Enabled = Content != null; 106 106 executionTimeTextBox.Enabled = Content != null; … … 164 164 ErrorHandling.ShowErrorDialog(this, e.Value); 165 165 } 166 private void Content_ AlgorithmChanged(object sender, EventArgs e) {167 if (InvokeRequired) 168 Invoke(new EventHandler(Content_ AlgorithmChanged), sender, e);169 else { 170 algorithmViewHost.Content = Content.Algorithm;166 private void Content_OptimizerChanged(object sender, EventArgs e) { 167 if (InvokeRequired) 168 Invoke(new EventHandler(Content_OptimizerChanged), sender, e); 169 else { 170 optimizerViewHost.Content = Content.Optimizer; 171 171 } 172 172 } … … 188 188 Content.Repetitions = (int)repetitionsNumericUpDown.Value; 189 189 } 190 private void new AlgorithmButton_Click(object sender, EventArgs e) {191 if ( algorithmTypeSelectorDialog == null) {192 algorithmTypeSelectorDialog = new TypeSelectorDialog();193 algorithmTypeSelectorDialog.Caption = "Select Algorithm";194 algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms";195 algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true);196 } 197 if ( algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {190 private void newOptimizerButton_Click(object sender, EventArgs e) { 191 if (optimizerTypeSelectorDialog == null) { 192 optimizerTypeSelectorDialog = new TypeSelectorDialog(); 193 optimizerTypeSelectorDialog.Caption = "Select Optimizer"; 194 optimizerTypeSelectorDialog.TypeSelector.Caption = "Available Optimizers"; 195 optimizerTypeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true); 196 } 197 if (optimizerTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 198 198 try { 199 Content. Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();199 Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 200 200 } 201 201 catch (Exception ex) { … … 204 204 } 205 205 } 206 private void open AlgorithmButton_Click(object sender, EventArgs e) {207 openFileDialog.Title = "Open Algorithm";206 private void openOptimizerButton_Click(object sender, EventArgs e) { 207 openFileDialog.Title = "Open Optimizer"; 208 208 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 209 new AlgorithmButton.Enabled = openAlgorithmButton.Enabled = false;210 algorithmViewHost.Enabled = false;209 newOptimizerButton.Enabled = openOptimizerButton.Enabled = false; 210 optimizerViewHost.Enabled = false; 211 211 212 212 ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) { 213 213 try { 214 214 if (error != null) throw error; 215 I Algorithm algorithm = content as IAlgorithm;216 if ( algorithm== null)217 MessageBox.Show(this, "The selected file does not contain an algorithm.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);215 IOptimizer optimizer = content as IOptimizer; 216 if (optimizer == null) 217 MessageBox.Show(this, "The selected file does not contain an optimizer.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error); 218 218 else 219 Content. Algorithm = algorithm;219 Content.Optimizer = optimizer; 220 220 } 221 221 catch (Exception ex) { … … 224 224 finally { 225 225 Invoke(new Action(delegate() { 226 algorithmViewHost.Enabled = true;227 new AlgorithmButton.Enabled = openAlgorithmButton.Enabled = true;226 optimizerViewHost.Enabled = true; 227 newOptimizerButton.Enabled = openOptimizerButton.Enabled = true; 228 228 })); 229 229 } … … 243 243 Content.Prepare(false); 244 244 } 245 private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) {245 private void optimizerTabPage_DragEnterOver(object sender, DragEventArgs e) { 246 246 e.Effect = DragDropEffects.None; 247 247 if (ReadOnly) 248 248 return; 249 249 Type type = e.Data.GetData("Type") as Type; 250 if ((type != null) && (typeof(I Algorithm).IsAssignableFrom(type))) {250 if ((type != null) && (typeof(IOptimizer).IsAssignableFrom(type))) { 251 251 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 252 252 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 256 256 } 257 257 } 258 private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) {258 private void optimizerTabPage_DragDrop(object sender, DragEventArgs e) { 259 259 if (e.Effect != DragDropEffects.None) { 260 I Algorithm algorithm = e.Data.GetData("Value") as IAlgorithm;261 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();262 Content. Algorithm = algorithm;260 IOptimizer optimizer = e.Data.GetData("Value") as IOptimizer; 261 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) optimizer = (IOptimizer)optimizer.Clone(); 262 Content.Optimizer = optimizer; 263 263 } 264 264 } -
trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs
r5287 r5300 31 31 namespace HeuristicLab.Optimization { 32 32 /// <summary> 33 /// A run in which an algorithmis executed a given number of times.33 /// A run in which an optimizer is executed a given number of times. 34 34 /// </summary> 35 [Item("Batch Run", "A run in which an algorithmis executed a given number of times.")]35 [Item("Batch Run", "A run in which an optimizer is executed a given number of times.")] 36 36 [Creatable("Testing & Analysis")] 37 37 [StorableClass] … … 66 66 public TimeSpan ExecutionTime { 67 67 get { 68 if (( Algorithm != null) && (Algorithm.ExecutionState != ExecutionState.Stopped))69 return executionTime + Algorithm.ExecutionTime;68 if ((Optimizer != null) && (Optimizer.ExecutionState != ExecutionState.Stopped)) 69 return executionTime + Optimizer.ExecutionTime; 70 70 else 71 71 return executionTime; … … 78 78 79 79 [Storable] 80 private I Algorithm algorithm;81 public I Algorithm Algorithm{82 get { return algorithm; }80 private IOptimizer optimizer; 81 public IOptimizer Optimizer { 82 get { return optimizer; } 83 83 set { 84 if ( algorithm!= value) {85 if ( algorithm!= null) {86 Deregister AlgorithmEvents();87 IEnumerable<IRun> runs = algorithm.Runs;88 algorithm = null; //necessary to avoid removing the runs from the old algorithm84 if (optimizer != value) { 85 if (optimizer != null) { 86 DeregisterOptimizerEvents(); 87 IEnumerable<IRun> runs = optimizer.Runs; 88 optimizer = null; //necessary to avoid removing the runs from the old optimizer 89 89 Runs.RemoveRange(runs); 90 90 } 91 algorithm= value;92 if ( algorithm!= null) {93 Register AlgorithmEvents();94 Runs.AddRange( algorithm.Runs);91 optimizer = value; 92 if (optimizer != null) { 93 RegisterOptimizerEvents(); 94 Runs.AddRange(optimizer.Runs); 95 95 } 96 On AlgorithmChanged();96 OnOptimizerChanged(); 97 97 Prepare(); 98 98 } 99 99 } 100 100 } 101 // BackwardsCompatibility3.3 102 #region Backwards compatible code (remove with 3.4) 103 [Storable] 104 private IAlgorithm algorithm { 105 get { return null; } 106 set { optimizer = value; } 107 } 108 #endregion 101 109 102 110 [Storable] … … 108 116 repetitions = value; 109 117 OnRepetitionsChanged(); 110 if (( Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Stopped))118 if ((Optimizer != null) && (Optimizer.ExecutionState == ExecutionState.Stopped)) 111 119 Prepare(); 112 120 } … … 176 184 executionState = original.executionState; 177 185 executionTime = original.executionTime; 178 algorithm = cloner.Clone(original.algorithm);186 optimizer = cloner.Clone(original.optimizer); 179 187 repetitions = original.repetitions; 180 188 repetitionsCounter = original.repetitionsCounter; … … 189 197 190 198 private void Initialize() { 191 if ( algorithm != null) RegisterAlgorithmEvents();199 if (optimizer != null) RegisterOptimizerEvents(); 192 200 if (runs != null) RegisterRunsEvents(); 193 201 } … … 199 207 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 200 208 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 201 if ( Algorithm!= null) {209 if (Optimizer != null) { 202 210 repetitionsCounter = 0; 203 211 if (clearRuns) runs.Clear(); 204 Algorithm.Prepare(clearRuns);212 Optimizer.Prepare(clearRuns); 205 213 } 206 214 } … … 208 216 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused)) 209 217 throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState)); 210 if ( Algorithm != null) Algorithm.Start();218 if (Optimizer != null) Optimizer.Start(); 211 219 } 212 220 public void Pause() { 213 221 if (ExecutionState != ExecutionState.Started) 214 222 throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState)); 215 if (( Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Started))216 Algorithm.Pause();223 if ((Optimizer != null) && (Optimizer.ExecutionState == ExecutionState.Started)) 224 Optimizer.Pause(); 217 225 } 218 226 public void Stop() { … … 220 228 throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState)); 221 229 stopPending = true; 222 if (( Algorithm!= null) &&223 (( Algorithm.ExecutionState == ExecutionState.Started) || (Algorithm.ExecutionState == ExecutionState.Paused)))224 Algorithm.Stop();230 if ((Optimizer != null) && 231 ((Optimizer.ExecutionState == ExecutionState.Started) || (Optimizer.ExecutionState == ExecutionState.Paused))) 232 Optimizer.Stop(); 225 233 } 226 234 … … 236 244 if (handler != null) handler(this, EventArgs.Empty); 237 245 } 238 public event EventHandler AlgorithmChanged;239 private void On AlgorithmChanged() {240 EventHandler handler = AlgorithmChanged;246 public event EventHandler OptimizerChanged; 247 private void OnOptimizerChanged() { 248 EventHandler handler = OptimizerChanged; 241 249 if (handler != null) handler(this, EventArgs.Empty); 242 250 } … … 276 284 } 277 285 278 private void Register AlgorithmEvents() {279 algorithm.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred);280 algorithm.ExecutionTimeChanged += new EventHandler(Algorithm_ExecutionTimeChanged);281 algorithm.Paused += new EventHandler(Algorithm_Paused);282 algorithm.Prepared += new EventHandler(Algorithm_Prepared);283 algorithm.Started += new EventHandler(Algorithm_Started);284 algorithm.Stopped += new EventHandler(Algorithm_Stopped);285 algorithm.Runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_CollectionReset);286 algorithm.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsAdded);287 algorithm.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsRemoved);288 } 289 private void Deregister AlgorithmEvents() {290 algorithm.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred);291 algorithm.ExecutionTimeChanged -= new EventHandler(Algorithm_ExecutionTimeChanged);292 algorithm.Paused -= new EventHandler(Algorithm_Paused);293 algorithm.Prepared -= new EventHandler(Algorithm_Prepared);294 algorithm.Started -= new EventHandler(Algorithm_Started);295 algorithm.Stopped -= new EventHandler(Algorithm_Stopped);296 algorithm.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_CollectionReset);297 algorithm.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsAdded);298 algorithm.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsRemoved);299 } 300 private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) {286 private void RegisterOptimizerEvents() { 287 optimizer.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Optimizer_ExceptionOccurred); 288 optimizer.ExecutionTimeChanged += new EventHandler(Optimizer_ExecutionTimeChanged); 289 optimizer.Paused += new EventHandler(Optimizer_Paused); 290 optimizer.Prepared += new EventHandler(Optimizer_Prepared); 291 optimizer.Started += new EventHandler(Optimizer_Started); 292 optimizer.Stopped += new EventHandler(Optimizer_Stopped); 293 optimizer.Runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_CollectionReset); 294 optimizer.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsAdded); 295 optimizer.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsRemoved); 296 } 297 private void DeregisterOptimizerEvents() { 298 optimizer.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Optimizer_ExceptionOccurred); 299 optimizer.ExecutionTimeChanged -= new EventHandler(Optimizer_ExecutionTimeChanged); 300 optimizer.Paused -= new EventHandler(Optimizer_Paused); 301 optimizer.Prepared -= new EventHandler(Optimizer_Prepared); 302 optimizer.Started -= new EventHandler(Optimizer_Started); 303 optimizer.Stopped -= new EventHandler(Optimizer_Stopped); 304 optimizer.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_CollectionReset); 305 optimizer.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsAdded); 306 optimizer.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsRemoved); 307 } 308 private void Optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) { 301 309 OnExceptionOccurred(e.Value); 302 310 } 303 private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) {311 private void Optimizer_ExecutionTimeChanged(object sender, EventArgs e) { 304 312 OnExecutionTimeChanged(); 305 313 } 306 private void Algorithm_Paused(object sender, EventArgs e) {314 private void Optimizer_Paused(object sender, EventArgs e) { 307 315 OnPaused(); 308 316 } 309 private void Algorithm_Prepared(object sender, EventArgs e) {317 private void Optimizer_Prepared(object sender, EventArgs e) { 310 318 if ((ExecutionState == ExecutionState.Paused) || (ExecutionState == ExecutionState.Stopped)) 311 319 OnPrepared(); 312 320 } 313 private void Algorithm_Started(object sender, EventArgs e) {321 private void Optimizer_Started(object sender, EventArgs e) { 314 322 stopPending = false; 315 323 if (ExecutionState != ExecutionState.Started) 316 324 OnStarted(); 317 325 } 318 private void Algorithm_Stopped(object sender, EventArgs e) {326 private void Optimizer_Stopped(object sender, EventArgs e) { 319 327 repetitionsCounter++; 320 328 321 329 if (!stopPending && (repetitionsCounter < repetitions)) { 322 Algorithm.Prepare();323 Algorithm.Start();330 Optimizer.Prepare(); 331 Optimizer.Start(); 324 332 } else { 325 333 OnStopped(); 326 334 } 327 335 } 328 private void Algorithm_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {336 private void Optimizer_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 329 337 Runs.RemoveRange(e.OldItems); 330 338 Runs.AddRange(e.Items); 331 339 } 332 private void Algorithm_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {340 private void Optimizer_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) { 333 341 Runs.AddRange(e.Items); 334 342 } 335 private void Algorithm_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {343 private void Optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 336 344 Runs.RemoveRange(e.Items); 337 345 } … … 355 363 if (executionTime != null) ExecutionTime -= executionTime.Value; 356 364 } 357 if ( Algorithm != null) Algorithm.Runs.RemoveRange(e.OldItems);365 if (Optimizer != null) Optimizer.Runs.RemoveRange(e.OldItems); 358 366 foreach (IRun run in e.Items) { 359 367 IItem item; … … 378 386 if (executionTime != null) ExecutionTime -= executionTime.Value; 379 387 } 380 if ( Algorithm != null) Algorithm.Runs.RemoveRange(e.Items);388 if (Optimizer != null) Optimizer.Runs.RemoveRange(e.Items); 381 389 } 382 390 #endregion -
trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs
r5287 r5300 30 30 namespace HeuristicLab.Optimization { 31 31 /// <summary> 32 /// An experiment which contains multiple batch runs of algorithms.32 /// An experiment which contains multiple algorithms, batch runs or other experiments. 33 33 /// </summary> 34 [Item("Experiment", "An experiment which contains multiple batch runs of algorithms.")]34 [Item("Experiment", "An experiment which contains multiple algorithms, batch runs or other experiments.")] 35 35 [Creatable("Testing & Analysis")] 36 36 [StorableClass] -
trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs
r4650 r5300 89 89 this.createBatchRunCheckBox.Size = new System.Drawing.Size(15, 14); 90 90 this.createBatchRunCheckBox.TabIndex = 1; 91 this.toolTip.SetToolTip(this.createBatchRunCheckBox, "Check to create a batch run for executing an algorithmmultiple times.");91 this.toolTip.SetToolTip(this.createBatchRunCheckBox, "Check to create a batch run for executing an optimizer multiple times."); 92 92 this.createBatchRunCheckBox.UseVisualStyleBackColor = true; 93 93 this.createBatchRunCheckBox.CheckedChanged += new System.EventHandler(this.createBatchRunCheckBox_CheckedChanged); -
trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
r4722 r5300 26 26 namespace HeuristicLab.Optimizer { 27 27 public partial class CreateExperimentDialog : Form { 28 private I Algorithm algorithm;29 public I Algorithm Algorithm{30 get { return algorithm; }28 private IOptimizer optimizer; 29 public IOptimizer Optimizer { 30 get { return optimizer; } 31 31 set { 32 algorithm= value;32 optimizer = value; 33 33 experiment = null; 34 okButton.Enabled = algorithm!= null;34 okButton.Enabled = optimizer != null; 35 35 } 36 36 } 37 37 38 38 private Experiment experiment; 39 39 public Experiment Experiment { … … 43 43 public CreateExperimentDialog() { 44 44 experiment = null; 45 algorithm= null;45 optimizer = null; 46 46 InitializeComponent(); 47 47 } 48 public CreateExperimentDialog(IAlgorithm algorithm) : this() { 49 Algorithm = algorithm; 48 public CreateExperimentDialog(IOptimizer optimizer) 49 : this() { 50 Optimizer = optimizer; 50 51 } 51 52 … … 58 59 } 59 60 private void okButton_Click(object sender, EventArgs e) { 60 experiment = new Experiment( Algorithm.Name);61 experiment = new Experiment(Optimizer.Name); 61 62 if (createBatchRunCheckBox.Checked) { 62 BatchRun batchRun = new BatchRun( Algorithm.Name);63 BatchRun batchRun = new BatchRun(Optimizer.Name); 63 64 batchRun.Repetitions = (int)repetitionsNumericUpDown.Value; 64 batchRun. Algorithm = (IAlgorithm)Algorithm.Clone();65 batchRun.Optimizer = (IOptimizer)Optimizer.Clone(); 65 66 Experiment.Optimizers.Add(batchRun); 66 67 } else { 67 Experiment.Optimizers.Add((I Algorithm)Algorithm.Clone());68 Experiment.Optimizers.Add((IOptimizer)Optimizer.Clone()); 68 69 } 69 70 Experiment.Prepare(true); -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CreateExperimentMenuItem.cs
r4650 r5300 38 38 } 39 39 public override string ToolTipText { 40 get { return "Create an experiment for the shown algorithm"; }40 get { return "Create an experiment for the shown optimizer"; } 41 41 } 42 42 … … 46 46 protected override void OnActiveViewChanged(object sender, EventArgs e) { 47 47 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 48 ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && (activeView.Content is I Algorithm) && !activeView.Locked;48 ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked; 49 49 } 50 50 51 51 public override void Execute() { 52 52 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 53 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is I Algorithm) && !activeView.Locked) {54 using (CreateExperimentDialog dialog = new CreateExperimentDialog((I Algorithm)activeView.Content)) {53 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) { 54 using (CreateExperimentDialog dialog = new CreateExperimentDialog((IOptimizer)activeView.Content)) { 55 55 if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment); 56 56 }
Note: See TracChangeset
for help on using the changeset viewer.