Changeset 3716 for trunk/sources
- Timestamp:
- 05/08/10 04:28:19 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r3694 r3716 217 217 } 218 218 protected virtual void resetButton_Click(object sender, EventArgs e) { 219 if (Content.Runs.Count > 0) { 220 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 221 Content.Prepare(true); 222 else 223 Content.Prepare(false); 224 } else { 225 Content.Prepare(); 226 } 219 Content.Prepare(false); 227 220 } 228 221 protected virtual void problemPanel_DragEnterOver(object sender, DragEventArgs e) { -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r3709 r3716 198 198 } 199 199 private void resetButton_Click(object sender, EventArgs e) { 200 if (Content.Runs.Count > 0) { 201 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 202 Content.Prepare(true); 203 else 204 Content.Prepare(false); 205 } else { 206 Content.Prepare(); 207 } 200 Content.Prepare(false); 208 201 } 209 202 private void algorithmPanel_DragEnterOver(object sender, DragEventArgs e) { -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs
r3566 r3716 125 125 } 126 126 private void resetButton_Click(object sender, EventArgs e) { 127 if (Content.Runs.Count > 0) { 128 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 129 Content.Prepare(true); 130 else 131 Content.Prepare(false); 132 } else { 133 Content.Prepare(); 134 } 127 Content.Prepare(false); 135 128 } 136 129 #endregion -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs
r3614 r3716 54 54 private void InitializeComponent() { 55 55 this.components = new System.ComponentModel.Container(); 56 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RunCollectionView));57 56 this.splitContainer = new System.Windows.Forms.SplitContainer(); 58 57 this.toolStrip = new System.Windows.Forms.ToolStrip(); … … 70 69 this.constraintPage = new System.Windows.Forms.TabPage(); 71 70 this.runCollectionConstraintCollectionView = new HeuristicLab.Core.Views.RunCollectionConstraintCollectionView(); 71 this.clearButton = new System.Windows.Forms.Button(); 72 72 this.splitContainer.Panel1.SuspendLayout(); 73 73 this.splitContainer.Panel2.SuspendLayout(); … … 90 90 // splitContainer.Panel1 91 91 // 92 this.splitContainer.Panel1.Controls.Add(this.clearButton); 92 93 this.splitContainer.Panel1.Controls.Add(this.toolStrip); 93 94 this.splitContainer.Panel1.Controls.Add(this.itemsListView); … … 113 114 this.toolStrip.Location = new System.Drawing.Point(30, 3); 114 115 this.toolStrip.Name = "toolStrip"; 115 this.toolStrip.Size = new System.Drawing.Size( 217, 24);116 this.toolStrip.Size = new System.Drawing.Size(166, 24); 116 117 this.toolStrip.TabIndex = 1; 117 118 this.toolStrip.Text = "toolStrip1"; … … 141 142 this.itemsListView.Size = new System.Drawing.Size(244, 295); 142 143 this.itemsListView.SmallImageList = this.imageList; 143 this.itemsListView.TabIndex = 1;144 this.itemsListView.TabIndex = 3; 144 145 this.itemsListView.UseCompatibleStateImageBehavior = false; 145 146 this.itemsListView.View = System.Windows.Forms.View.Details; … … 218 219 this.tabControl.SelectedIndex = 0; 219 220 this.tabControl.Size = new System.Drawing.Size(532, 383); 220 this.tabControl.TabIndex = 1;221 this.tabControl.TabIndex = 0; 221 222 // 222 223 // runPage … … 252 253 this.runCollectionConstraintCollectionView.Size = new System.Drawing.Size(518, 351); 253 254 this.runCollectionConstraintCollectionView.TabIndex = 0; 255 // 256 // clearButton 257 // 258 this.clearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 259 this.clearButton.Enabled = false; 260 this.clearButton.Location = new System.Drawing.Point(199, 3); 261 this.clearButton.Name = "clearButton"; 262 this.clearButton.Size = new System.Drawing.Size(48, 24); 263 this.clearButton.TabIndex = 2; 264 this.clearButton.Text = "&Clear"; 265 this.toolTip.SetToolTip(this.clearButton, "Remove All Runs"); 266 this.clearButton.UseVisualStyleBackColor = true; 267 this.clearButton.Click += new System.EventHandler(this.clearButton_Click); 254 268 // 255 269 // RunCollectionView … … 286 300 protected ToolStrip toolStrip; 287 301 protected ToolStripDropDownButton analyzeRunsToolStripDropDownButton; 288 private TabControl tabControl; 289 private TabPage runPage; 290 private TabPage constraintPage; 291 private HeuristicLab.Core.Views.RunCollectionConstraintCollectionView runCollectionConstraintCollectionView; 302 protected TabControl tabControl; 303 protected TabPage runPage; 304 protected TabPage constraintPage; 305 protected HeuristicLab.Core.Views.RunCollectionConstraintCollectionView runCollectionConstraintCollectionView; 306 protected Button clearButton; 292 307 } 293 308 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3709 r3716 131 131 viewHost.Enabled = false; 132 132 removeButton.Enabled = false; 133 clearButton.Enabled = false; 133 134 } else { 134 135 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; … … 137 138 detailsGroupBox.Enabled = true; 138 139 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly && !ReadOnly; 140 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 139 141 viewHost.Enabled = true; 140 142 } … … 268 270 } 269 271 } 272 protected virtual void clearButton_Click(object sender, EventArgs e) { 273 Content.Clear(); 274 } 270 275 #endregion 271 276 … … 279 284 AddListViewItem(CreateListViewItem(item)); 280 285 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 286 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 281 287 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 282 288 } … … 294 300 } 295 301 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 302 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 296 303 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 297 304 } … … 312 319 AddListViewItem(CreateListViewItem(item)); 313 320 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 321 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; 314 322 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 315 323 } … … 357 365 } 358 366 #endregion 367 359 368 } 360 369 } -
trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
r3694 r3716 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 97 98 public RunCollection Runs { 98 99 get { return runs; } 100 protected set { 101 if (value == null) throw new ArgumentNullException(); 102 if (runs != value) { 103 if (runs != null) DeregisterRunsEvents(); 104 runs = value; 105 if (runs != null) RegisterRunsEvents(); 106 } 107 } 99 108 } 100 109 … … 104 113 executionTime = TimeSpan.Zero; 105 114 runsCounter = 0; 106 runs = new RunCollection();115 Runs = new RunCollection(); 107 116 } 108 117 protected Algorithm(string name) … … 111 120 executionTime = TimeSpan.Zero; 112 121 runsCounter = 0; 113 runs = new RunCollection();122 Runs = new RunCollection(); 114 123 } 115 124 protected Algorithm(string name, ParameterCollection parameters) … … 118 127 executionTime = TimeSpan.Zero; 119 128 runsCounter = 0; 120 runs = new RunCollection();129 Runs = new RunCollection(); 121 130 } 122 131 protected Algorithm(string name, string description) … … 125 134 executionTime = TimeSpan.Zero; 126 135 runsCounter = 0; 127 runs = new RunCollection();136 Runs = new RunCollection(); 128 137 } 129 138 protected Algorithm(string name, string description, ParameterCollection parameters) … … 132 141 executionTime = TimeSpan.Zero; 133 142 runsCounter = 0; 134 runs = new RunCollection();143 Runs = new RunCollection(); 135 144 } 136 145 [StorableConstructor] … … 140 149 private void Initialize() { 141 150 if (problem != null) RegisterProblemEvents(); 151 if (runs != null) RegisterRunsEvents(); 142 152 } 143 153 … … 176 186 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 177 187 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 178 if (clearRuns) { 179 runsCounter = 0; 180 runs.Clear(); 181 } 188 if (clearRuns) runs.Clear(); 182 189 Prepare(); 183 190 } … … 264 271 problem.OperatorsChanged += new EventHandler(Problem_OperatorsChanged); 265 272 } 266 267 273 protected virtual void Problem_SolutionCreatorChanged(object sender, EventArgs e) { } 268 274 protected virtual void Problem_EvaluatorChanged(object sender, EventArgs e) { } 269 275 protected virtual void Problem_OperatorsChanged(object sender, EventArgs e) { } 276 277 protected virtual void DeregisterRunsEvents() { 278 runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 279 } 280 protected virtual void RegisterRunsEvents() { 281 runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 282 } 283 protected virtual void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 284 runsCounter = runs.Count; 285 } 270 286 #endregion 271 287 } -
trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs
r3372 r3716 22 22 using System; 23 23 using System.Drawing; 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Collections;28 29 29 30 namespace HeuristicLab.Optimization { … … 83 84 if (algorithm != null) RegisterAlgorithmEvents(); 84 85 OnAlgorithmChanged(); 85 Prepare( true);86 Prepare(); 86 87 } 87 88 } … … 96 97 repetitions = value; 97 98 OnRepetitionsChanged(); 98 if (( runs.Count < repetitions) && (Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Stopped))99 if ((Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Stopped)) 99 100 Prepare(); 100 101 } 101 102 } 102 103 } 104 [Storable] 105 private int repetitionsCounter; 103 106 104 107 [Storable] … … 106 109 public RunCollection Runs { 107 110 get { return runs; } 111 private set { 112 if (value == null) throw new ArgumentNullException(); 113 if (runs != value) { 114 if (runs != null) DeregisterRunsEvents(); 115 runs = value; 116 if (runs != null) RegisterRunsEvents(); 117 } 118 } 108 119 } 109 120 … … 117 128 executionTime = TimeSpan.Zero; 118 129 repetitions = 10; 119 runs = new RunCollection(); 130 repetitionsCounter = 0; 131 Runs = new RunCollection(); 120 132 stopPending = false; 121 133 } … … 126 138 executionTime = TimeSpan.Zero; 127 139 repetitions = 10; 128 runs = new RunCollection(); 140 repetitionsCounter = 0; 141 Runs = new RunCollection(); 129 142 stopPending = false; 130 143 } … … 134 147 executionTime = TimeSpan.Zero; 135 148 repetitions = 10; 136 runs = new RunCollection(); 149 repetitionsCounter = 0; 150 Runs = new RunCollection(); 137 151 stopPending = false; 138 152 } … … 146 160 private void Initialize() { 147 161 if (algorithm != null) RegisterAlgorithmEvents(); 162 if (runs != null) RegisterRunsEvents(); 148 163 } 149 164 … … 155 170 clone.algorithm = (IAlgorithm)cloner.Clone(algorithm); 156 171 clone.repetitions = repetitions; 172 clone.repetitionsCounter = repetitionsCounter; 157 173 clone.runs = (RunCollection)cloner.Clone(runs); 158 174 clone.stopPending = stopPending; … … 168 184 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 169 185 if (Algorithm != null) { 170 if (clearRuns) { 171 ExecutionTime = TimeSpan.Zero; 172 runs.Clear(); 173 } 186 repetitionsCounter = 0; 187 if (clearRuns) runs.Clear(); 174 188 Algorithm.Prepare(clearRuns); 175 189 } … … 183 197 if (ExecutionState != ExecutionState.Started) 184 198 throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState)); 185 if (Algorithm != null) Algorithm.Pause(); 199 if ((Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Started)) 200 Algorithm.Pause(); 186 201 } 187 202 public void Stop() { … … 189 204 throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState)); 190 205 stopPending = true; 191 if (Algorithm != null) Algorithm.Stop(); 206 if ((Algorithm != null) && 207 ((Algorithm.ExecutionState == ExecutionState.Started) || (Algorithm.ExecutionState == ExecutionState.Paused))) 208 Algorithm.Stop(); 192 209 } 193 210 … … 285 302 private void Algorithm_Stopped(object sender, EventArgs e) { 286 303 ExecutionTime += Algorithm.ExecutionTime; 287 288 if (!stopPending && (runs.Count < repetitions)) { 304 repetitionsCounter++; 305 306 if (!stopPending && (repetitionsCounter < repetitions)) { 289 307 Algorithm.Prepare(); 290 308 Algorithm.Start(); … … 303 321 Runs.RemoveRange(e.Items); 304 322 } 323 324 private void RegisterRunsEvents() { 325 runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 326 runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Runs_ItemsRemoved); 327 } 328 private void DeregisterRunsEvents() { 329 runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 330 runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Runs_ItemsRemoved); 331 } 332 private void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 333 foreach (IRun run in e.OldItems) { 334 IItem item; 335 run.Results.TryGetValue("Execution Time", out item); 336 TimeSpanValue executionTime = item as TimeSpanValue; 337 if (executionTime != null) ExecutionTime -= executionTime.Value; 338 } 339 if (Algorithm != null) Algorithm.Runs.RemoveRange(e.OldItems); 340 foreach (IRun run in e.Items) { 341 IItem item; 342 run.Results.TryGetValue("Execution Time", out item); 343 TimeSpanValue executionTime = item as TimeSpanValue; 344 if (executionTime != null) ExecutionTime += executionTime.Value; 345 } 346 } 347 private void Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 348 foreach (IRun run in e.Items) { 349 IItem item; 350 run.Results.TryGetValue("Execution Time", out item); 351 TimeSpanValue executionTime = item as TimeSpanValue; 352 if (executionTime != null) ExecutionTime -= executionTime.Value; 353 } 354 if (Algorithm != null) Algorithm.Runs.RemoveRange(e.Items); 355 } 305 356 #endregion 306 357 } -
trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs
r3372 r3716 79 79 public RunCollection Runs { 80 80 get { return runs; } 81 private set { 82 if (value == null) throw new ArgumentNullException(); 83 if (runs != value) { 84 if (runs != null) DeregisterRunsEvents(); 85 runs = value; 86 if (runs != null) RegisterRunsEvents(); 87 } 88 } 81 89 } 82 90 … … 90 98 executionTime = TimeSpan.Zero; 91 99 optimizers = new OptimizerList(); 92 runs = new RunCollection();100 Runs = new RunCollection(); 93 101 stopPending = false; 94 102 Initialize(); … … 100 108 executionTime = TimeSpan.Zero; 101 109 optimizers = new OptimizerList(); 102 runs = new RunCollection();110 Runs = new RunCollection(); 103 111 stopPending = false; 104 112 Initialize(); … … 109 117 executionTime = TimeSpan.Zero; 110 118 optimizers = new OptimizerList(); 111 runs = new RunCollection();119 Runs = new RunCollection(); 112 120 stopPending = false; 113 121 Initialize(); … … 124 132 foreach (IOptimizer optimizer in optimizers) 125 133 RegisterOptimizerEvents(optimizer); 134 if (runs != null) RegisterRunsEvents(); 126 135 } 127 136 … … 236 245 foreach (IndexedItem<IOptimizer> item in e.Items) { 237 246 RegisterOptimizerEvents(item.Value); 247 item.Value.Prepare(); 238 248 } 239 249 } … … 241 251 foreach (IndexedItem<IOptimizer> item in e.Items) { 242 252 RegisterOptimizerEvents(item.Value); 253 item.Value.Prepare(); 243 254 } 244 255 } … … 254 265 foreach (IndexedItem<IOptimizer> item in e.Items) { 255 266 RegisterOptimizerEvents(item.Value); 267 item.Value.Prepare(); 256 268 } 257 269 } … … 317 329 Runs.RemoveRange(e.Items); 318 330 } 331 332 private void RegisterRunsEvents() { 333 runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 334 runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Runs_ItemsRemoved); 335 } 336 private void DeregisterRunsEvents() { 337 runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset); 338 runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Runs_ItemsRemoved); 339 } 340 private void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 341 foreach (IOptimizer optimizer in Optimizers) 342 optimizer.Runs.RemoveRange(e.OldItems); 343 } 344 private void Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) { 345 foreach (IOptimizer optimizer in Optimizers) 346 optimizer.Runs.RemoveRange(e.Items); 347 } 319 348 #endregion 320 349 } -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r3632 r3716 30 30 31 31 namespace HeuristicLab.Optimization { 32 [Item("Run Collection", "Represents a collection of runs.")] 33 [Creatable("Testing & Analysis")] 32 34 [StorableClass] 33 [Item("RunCollection", "Represents a collection of runs.")]34 35 public class RunCollection : ItemCollection<IRun>, IStringConvertibleMatrix { 35 36 public RunCollection() : base() { Initialize(); }
Note: See TracChangeset
for help on using the changeset viewer.