Changeset 3274
- Timestamp:
- 04/06/10 01:57:29 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 added
- 3 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r3265 r3274 179 179 } 180 180 181 public override void Prepare( ) {182 if (Problem != null) base.Prepare( );181 public override void Prepare(bool clearResults) { 182 if (Problem != null) base.Prepare(clearResults); 183 183 } 184 184 -
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r3265 r3274 154 154 } 155 155 156 public override void Prepare( ) {156 public override void Prepare(bool clearResults) { 157 157 if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null) 158 base.Prepare( );158 base.Prepare(clearResults); 159 159 } 160 160 -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r3265 r3274 182 182 } 183 183 184 public override void Prepare( ) {184 public override void Prepare(bool clearResults) { 185 185 if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null) 186 base.Prepare( );186 base.Prepare(clearResults); 187 187 } 188 188 -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs
r3265 r3274 176 176 } 177 177 178 public override void Prepare( ) {178 public override void Prepare(bool clearResults) { 179 179 if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null && 180 180 TabuMoveEvaluator != null && TabuMoveMaker != null) 181 base.Prepare( );181 base.Prepare(clearResults); 182 182 } 183 183 -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorListView.cs
r2924 r3274 1 using System.Windows.Forms; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System.Windows.Forms; 2 23 using HeuristicLab.Collections; 3 24 using HeuristicLab.MainForm; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r3265 r3274 237 237 } 238 238 protected virtual void resetButton_Click(object sender, EventArgs e) { 239 Content.Prepare(); 239 if (Content.Results.Count > 0) { 240 if (MessageBox.Show(this, "Clear all results of this run?", "Clear All Results?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) 241 Content.Prepare(true); 242 else 243 Content.Prepare(false); 244 } else { 245 Content.Prepare(); 246 } 240 247 } 241 248 #endregion -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r3265 r3274 227 227 private void resetButton_Click(object sender, EventArgs e) { 228 228 if (Content.Runs.Count > 0) { 229 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button 1) == DialogResult.Yes)229 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 230 230 Content.Prepare(true); 231 231 else -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.Designer.cs
r3267 r3274 46 46 private void InitializeComponent() { 47 47 this.tabControl = new System.Windows.Forms.TabControl(); 48 this.batchRunsTabPage = new System.Windows.Forms.TabPage(); 49 this.resultsTabPage = new System.Windows.Forms.TabPage(); 50 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); 48 this.optimizersTabPage = new System.Windows.Forms.TabPage(); 51 49 this.startButton = new System.Windows.Forms.Button(); 52 50 this.stopButton = new System.Windows.Forms.Button(); … … 55 53 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 56 54 this.pauseButton = new System.Windows.Forms.Button(); 57 this. batchRunListView = new HeuristicLab.Optimization.Views.BatchRunListView();55 this.optimizerListView = new HeuristicLab.Optimization.Views.OptimizerListView(); 58 56 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 59 57 this.tabControl.SuspendLayout(); 60 this.batchRunsTabPage.SuspendLayout(); 61 this.resultsTabPage.SuspendLayout(); 58 this.optimizersTabPage.SuspendLayout(); 62 59 this.SuspendLayout(); 63 60 // … … 77 74 | System.Windows.Forms.AnchorStyles.Left) 78 75 | System.Windows.Forms.AnchorStyles.Right))); 79 this.tabControl.Controls.Add(this.batchRunsTabPage); 80 this.tabControl.Controls.Add(this.resultsTabPage); 76 this.tabControl.Controls.Add(this.optimizersTabPage); 81 77 this.tabControl.Location = new System.Drawing.Point(0, 52); 82 78 this.tabControl.Name = "tabControl"; … … 85 81 this.tabControl.TabIndex = 4; 86 82 // 87 // batchRunsTabPage 88 // 89 this.batchRunsTabPage.Controls.Add(this.batchRunListView); 90 this.batchRunsTabPage.Location = new System.Drawing.Point(4, 22); 91 this.batchRunsTabPage.Name = "batchRunsTabPage"; 92 this.batchRunsTabPage.Padding = new System.Windows.Forms.Padding(3); 93 this.batchRunsTabPage.Size = new System.Drawing.Size(671, 374); 94 this.batchRunsTabPage.TabIndex = 1; 95 this.batchRunsTabPage.Text = "Batch Runs"; 96 this.batchRunsTabPage.UseVisualStyleBackColor = true; 97 // 98 // resultsTabPage 99 // 100 this.resultsTabPage.Controls.Add(this.runsView); 101 this.resultsTabPage.Location = new System.Drawing.Point(4, 22); 102 this.resultsTabPage.Name = "resultsTabPage"; 103 this.resultsTabPage.Padding = new System.Windows.Forms.Padding(3); 104 this.resultsTabPage.Size = new System.Drawing.Size(671, 374); 105 this.resultsTabPage.TabIndex = 2; 106 this.resultsTabPage.Text = "Results"; 107 this.resultsTabPage.UseVisualStyleBackColor = true; 108 // 109 // runsView 110 // 111 this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 112 | System.Windows.Forms.AnchorStyles.Left) 113 | System.Windows.Forms.AnchorStyles.Right))); 114 this.runsView.Caption = "RunCollection"; 115 this.runsView.Content = null; 116 this.runsView.Location = new System.Drawing.Point(6, 6); 117 this.runsView.Name = "runsView"; 118 this.runsView.Size = new System.Drawing.Size(659, 362); 119 this.runsView.TabIndex = 0; 83 // optimizersTabPage 84 // 85 this.optimizersTabPage.Controls.Add(this.optimizerListView); 86 this.optimizersTabPage.Location = new System.Drawing.Point(4, 22); 87 this.optimizersTabPage.Name = "optimizersTabPage"; 88 this.optimizersTabPage.Padding = new System.Windows.Forms.Padding(3); 89 this.optimizersTabPage.Size = new System.Drawing.Size(671, 374); 90 this.optimizersTabPage.TabIndex = 1; 91 this.optimizersTabPage.Text = "Optimizers"; 92 this.optimizersTabPage.UseVisualStyleBackColor = true; 120 93 // 121 94 // startButton … … 186 159 this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click); 187 160 // 188 // batchRunListView189 // 190 this. batchRunListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)161 // optimizerListView 162 // 163 this.optimizerListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 191 164 | System.Windows.Forms.AnchorStyles.Left) 192 165 | System.Windows.Forms.AnchorStyles.Right))); 193 this. batchRunListView.Caption = "BatchRunList";194 this. batchRunListView.Content = null;195 this. batchRunListView.Location = new System.Drawing.Point(6, 6);196 this. batchRunListView.Name = "batchRunListView";197 this. batchRunListView.Size = new System.Drawing.Size(659, 362);198 this. batchRunListView.TabIndex = 0;166 this.optimizerListView.Caption = "OptimizerList"; 167 this.optimizerListView.Content = null; 168 this.optimizerListView.Location = new System.Drawing.Point(6, 6); 169 this.optimizerListView.Name = "optimizerListView"; 170 this.optimizerListView.Size = new System.Drawing.Size(659, 362); 171 this.optimizerListView.TabIndex = 0; 199 172 // 200 173 // ExperimentView … … 224 197 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 225 198 this.tabControl.ResumeLayout(false); 226 this.batchRunsTabPage.ResumeLayout(false); 227 this.resultsTabPage.ResumeLayout(false); 199 this.optimizersTabPage.ResumeLayout(false); 228 200 this.ResumeLayout(false); 229 201 this.PerformLayout(); … … 233 205 234 206 private System.Windows.Forms.TabControl tabControl; 235 private System.Windows.Forms.TabPage batchRunsTabPage;207 private System.Windows.Forms.TabPage optimizersTabPage; 236 208 private System.Windows.Forms.Button startButton; 237 209 private System.Windows.Forms.Button stopButton; … … 239 211 private System.Windows.Forms.Label executionTimeLabel; 240 212 private System.Windows.Forms.TextBox executionTimeTextBox; 241 private System.Windows.Forms.TabPage resultsTabPage;242 private RunCollectionView runsView;243 213 private System.Windows.Forms.Button pauseButton; 244 private BatchRunListView batchRunListView;214 private OptimizerListView optimizerListView; 245 215 246 216 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs
r3267 r3274 70 70 base.OnContentChanged(); 71 71 if (Content == null) { 72 batchRunListView.Content = null; 73 runsView.Content = null; 72 optimizerListView.Content = null; 74 73 tabControl.Enabled = false; 75 74 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false; … … 77 76 executionTimeTextBox.Enabled = false; 78 77 } else { 79 batchRunListView.Content = Content.BatchRuns; 80 runsView.Content = Content.Runs; 78 optimizerListView.Content = Content.Optimizers; 81 79 tabControl.Enabled = true; 82 80 EnableDisableButtons(); … … 127 125 } 128 126 private void resetButton_Click(object sender, EventArgs e) { 129 if (Content.Runs.Count > 0) { 130 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) 131 Content.Prepare(true); 132 else 133 Content.Prepare(false); 134 } else { 135 Content.Prepare(); 136 } 127 if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) 128 Content.Prepare(true); 129 else 130 Content.Prepare(false); 137 131 } 138 132 #endregion -
trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r3267 r3274 98 98 <DependentUpon>BatchRunView.cs</DependentUpon> 99 99 </Compile> 100 <Compile Include=" BatchRunListView.cs">101 <SubType>UserControl</SubType> 102 </Compile> 103 <Compile Include=" BatchRunListView.Designer.cs">104 <DependentUpon> BatchRunListView.cs</DependentUpon>100 <Compile Include="OptimizerListView.cs"> 101 <SubType>UserControl</SubType> 102 </Compile> 103 <Compile Include="OptimizerListView.Designer.cs"> 104 <DependentUpon>OptimizerListView.cs</DependentUpon> 105 105 </Compile> 106 106 <Compile Include="ExperimentView.cs"> -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultCollectionView.cs
r3226 r3274 21 21 22 22 using HeuristicLab.Collections; 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Core.Views; 24 25 using HeuristicLab.MainForm; … … 50 51 protected override IResult CreateItem() { 51 52 IResult item = new Result(); 52 item.Name = GetUniqueName(item.Name); 53 if (Content.ContainsKey(item.Name)) 54 item = new Result(GetUniqueName(item.Name), typeof(IItem)); 53 55 return item; 54 56 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3260 r3274 20 20 #endregion 21 21 22 using HeuristicLab.Collections; 22 23 using HeuristicLab.Core.Views; 23 24 using HeuristicLab.MainForm; … … 26 27 [View("RunCollection View")] 27 28 [Content(typeof(RunCollection), true)] 29 [Content(typeof(IObservableCollection<Run>), false)] 28 30 public partial class RunCollectionView : ItemCollectionView<Run> { 29 31 /// <summary> … … 41 43 /// <remarks>Calls <see cref="VariablesScopeView()"/>.</remarks> 42 44 /// <param name="scope">The scope whose variables should be represented visually.</param> 43 public RunCollectionView( RunCollectioncontent)45 public RunCollectionView(IObservableCollection<Run> content) 44 46 : this() { 45 47 Content = content; … … 47 49 48 50 protected override Run CreateItem() { 49 return n ull;51 return new Run(); 50 52 } 51 53 } -
trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
r3262 r3274 124 124 } 125 125 126 public virtual void Prepare() { 126 public void Prepare() { 127 Prepare(true); 128 } 129 public virtual void Prepare(bool clearResults) { 127 130 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 128 131 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); -
trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs
r3265 r3274 33 33 [Creatable("Testing & Analysis")] 34 34 [StorableClass] 35 public sealed class BatchRun : NamedItem, I Executable{35 public sealed class BatchRun : NamedItem, IOptimizer { 36 36 public override Image ItemImage { 37 37 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event; } … … 147 147 Prepare(true); 148 148 } 149 public void Prepare(bool clearR uns) {149 public void Prepare(bool clearResults) { 150 150 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 151 151 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 152 152 if (Algorithm != null) { 153 if (clearR uns) {153 if (clearResults) { 154 154 ExecutionTime = TimeSpan.Zero; 155 155 runs.Clear(); -
trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs
r3262 r3274 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Collections;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; … … 158 157 } 159 158 160 public override void Prepare() { 161 base.Prepare(); 159 public override void Prepare(bool clearResults) { 160 base.Prepare(clearResults); 161 162 ResultCollection results = Results; 162 163 globalScope.Clear(); 163 globalScope.Variables.Add(new Variable("Results", new ResultCollection())); 164 if (clearResults) 165 globalScope.Variables.Add(new Variable("Results", new ResultCollection())); 166 else 167 globalScope.Variables.Add(new Variable("Results", results)); 164 168 165 169 if (engine != null) { -
trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs
r3267 r3274 35 35 [Creatable("Testing & Analysis")] 36 36 [StorableClass] 37 public sealed class Experiment : NamedItem, I Executable{37 public sealed class Experiment : NamedItem, IOptimizer { 38 38 public override Image ItemImage { 39 39 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event; } … … 62 62 } 63 63 64 private BatchRunList batchRuns;64 private OptimizerList optimizers; 65 65 [Storable] 66 public BatchRunList BatchRuns {67 get { return batchRuns; }66 public OptimizerList Optimizers { 67 get { return optimizers; } 68 68 private set { 69 if ( batchRuns != value) {70 if ( batchRuns != null) DeregisterBatchRunsEvents();71 batchRuns = value;72 if ( batchRuns != null) RegisterBatchRunsEvents();73 foreach ( BatchRun batchRun in batchRuns)74 Register BatchRunEvents(batchRun);69 if (optimizers != value) { 70 if (optimizers != null) DeregisterOptimizersEvents(); 71 optimizers = value; 72 if (optimizers != null) RegisterOptimizersEvents(); 73 foreach (IOptimizer optimizer in optimizers) 74 RegisterOptimizerEvents(optimizer); 75 75 } 76 76 } 77 }78 79 [Storable]80 private RunCollection runs;81 public RunCollection Runs {82 get { return runs; }83 77 } 84 78 … … 89 83 executionState = ExecutionState.Stopped; 90 84 executionTime = TimeSpan.Zero; 91 BatchRuns = new BatchRunList(); 92 runs = new RunCollection(); 85 Optimizers = new OptimizerList(); 93 86 stopPending = false; 94 87 } … … 96 89 executionState = ExecutionState.Stopped; 97 90 executionTime = TimeSpan.Zero; 98 BatchRuns = new BatchRunList(); 99 runs = new RunCollection(); 91 Optimizers = new OptimizerList(); 100 92 stopPending = false; 101 93 } … … 103 95 executionState = ExecutionState.Stopped; 104 96 executionTime = TimeSpan.Zero; 105 BatchRuns = new BatchRunList(); 106 runs = new RunCollection(); 97 Optimizers = new OptimizerList(); 107 98 stopPending = false; 108 99 } … … 112 103 clone.executionState = executionState; 113 104 clone.executionTime = executionTime; 114 clone.BatchRuns = (BatchRunList)cloner.Clone(batchRuns); 115 clone.runs = (RunCollection)cloner.Clone(runs); 105 clone.Optimizers = (OptimizerList)cloner.Clone(optimizers); 116 106 clone.stopPending = stopPending; 117 107 return clone; … … 121 111 Prepare(true); 122 112 } 123 public void Prepare(bool clearR uns) {113 public void Prepare(bool clearResults) { 124 114 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 125 115 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 126 if (BatchRuns.Count > 0) { 127 if (clearRuns) { 128 ExecutionTime = TimeSpan.Zero; 129 runs.Clear(); 130 } 131 foreach (BatchRun batchRun in BatchRuns.Where(x => x.ExecutionState != ExecutionState.Started)) 132 batchRun.Prepare(clearRuns); 116 if (Optimizers.Count > 0) { 117 foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState != ExecutionState.Started)) 118 optimizer.Prepare(clearResults); 133 119 } 134 120 } … … 137 123 throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState)); 138 124 stopPending = false; 139 if ( BatchRuns.Count > 0) {140 BatchRun batchRun = BatchRuns.FirstOrDefault(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused));141 if ( batchRun != null) batchRun.Start();125 if (Optimizers.Count > 0) { 126 IOptimizer optimizer = Optimizers.FirstOrDefault(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)); 127 if (optimizer != null) optimizer.Start(); 142 128 } 143 129 } … … 145 131 if (ExecutionState != ExecutionState.Started) 146 132 throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState)); 147 if ( BatchRuns.Count > 0) {148 foreach ( BatchRun batchRun in BatchRuns.Where(x => x.ExecutionState == ExecutionState.Started))149 batchRun.Pause();133 if (Optimizers.Count > 0) { 134 foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState == ExecutionState.Started)) 135 optimizer.Pause(); 150 136 } 151 137 } … … 154 140 throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState)); 155 141 stopPending = true; 156 if ( BatchRuns.Count > 0) {157 foreach ( BatchRun batchRun in BatchRuns.Where(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused)))158 batchRun.Stop();142 if (Optimizers.Count > 0) { 143 foreach (IOptimizer optimizer in Optimizers.Where(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused))) 144 optimizer.Stop(); 159 145 } 160 146 } … … 201 187 } 202 188 203 private void RegisterBatchRunsEvents() { 204 BatchRuns.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_CollectionReset); 205 BatchRuns.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsAdded); 206 BatchRuns.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsRemoved); 207 BatchRuns.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsReplaced); 208 } 209 private void DeregisterBatchRunsEvents() { 210 BatchRuns.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_CollectionReset); 211 BatchRuns.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsAdded); 212 BatchRuns.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsRemoved); 213 BatchRuns.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<BatchRun>>(BatchRuns_ItemsReplaced); 214 } 215 private void BatchRuns_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<BatchRun>> e) { 216 foreach (IndexedItem<BatchRun> item in e.OldItems) { 217 DeregisterBatchRunEvents(item.Value); 218 } 219 foreach (IndexedItem<BatchRun> item in e.Items) { 220 RegisterBatchRunEvents(item.Value); 221 } 222 } 223 private void BatchRuns_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<BatchRun>> e) { 224 foreach (IndexedItem<BatchRun> item in e.Items) { 225 RegisterBatchRunEvents(item.Value); 226 } 227 } 228 private void BatchRuns_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<BatchRun>> e) { 229 foreach (IndexedItem<BatchRun> item in e.Items) { 230 DeregisterBatchRunEvents(item.Value); 231 } 232 } 233 private void BatchRuns_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<BatchRun>> e) { 234 foreach (IndexedItem<BatchRun> item in e.OldItems) { 235 DeregisterBatchRunEvents(item.Value); 236 } 237 foreach (IndexedItem<BatchRun> item in e.Items) { 238 RegisterBatchRunEvents(item.Value); 239 } 240 } 241 242 private void RegisterBatchRunEvents(BatchRun batchRun) { 243 batchRun.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(batchRun_ExceptionOccurred); 244 batchRun.Paused += new EventHandler(batchRun_Paused); 245 batchRun.Prepared += new EventHandler(batchRun_Prepared); 246 batchRun.Started += new EventHandler(batchRun_Started); 247 batchRun.Stopped += new EventHandler(batchRun_Stopped); 248 } 249 private void DeregisterBatchRunEvents(BatchRun batchRun) { 250 batchRun.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(batchRun_ExceptionOccurred); 251 batchRun.Paused -= new EventHandler(batchRun_Paused); 252 batchRun.Prepared -= new EventHandler(batchRun_Prepared); 253 batchRun.Started -= new EventHandler(batchRun_Started); 254 batchRun.Stopped -= new EventHandler(batchRun_Stopped); 255 } 256 private void batchRun_ExceptionOccurred(object sender, EventArgs<Exception> e) { 189 private void RegisterOptimizersEvents() { 190 Optimizers.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset); 191 Optimizers.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded); 192 Optimizers.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved); 193 Optimizers.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced); 194 } 195 private void DeregisterOptimizersEvents() { 196 Optimizers.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_CollectionReset); 197 Optimizers.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded); 198 Optimizers.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsRemoved); 199 Optimizers.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsReplaced); 200 } 201 private void Optimizers_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 202 foreach (IndexedItem<IOptimizer> item in e.OldItems) { 203 DeregisterOptimizerEvents(item.Value); 204 } 205 foreach (IndexedItem<IOptimizer> item in e.Items) { 206 RegisterOptimizerEvents(item.Value); 207 } 208 } 209 private void Optimizers_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 210 foreach (IndexedItem<IOptimizer> item in e.Items) { 211 RegisterOptimizerEvents(item.Value); 212 } 213 } 214 private void Optimizers_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 215 foreach (IndexedItem<IOptimizer> item in e.Items) { 216 DeregisterOptimizerEvents(item.Value); 217 } 218 } 219 private void Optimizers_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) { 220 foreach (IndexedItem<IOptimizer> item in e.OldItems) { 221 DeregisterOptimizerEvents(item.Value); 222 } 223 foreach (IndexedItem<IOptimizer> item in e.Items) { 224 RegisterOptimizerEvents(item.Value); 225 } 226 } 227 228 private void RegisterOptimizerEvents(IOptimizer optimizer) { 229 optimizer.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(optimizer_ExceptionOccurred); 230 optimizer.ExecutionTimeChanged += new EventHandler(optimizer_ExecutionTimeChanged); 231 optimizer.Paused += new EventHandler(optimizer_Paused); 232 optimizer.Prepared += new EventHandler(optimizer_Prepared); 233 optimizer.Started += new EventHandler(optimizer_Started); 234 optimizer.Stopped += new EventHandler(optimizer_Stopped); 235 } 236 237 private void DeregisterOptimizerEvents(IOptimizer optimizer) { 238 optimizer.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(optimizer_ExceptionOccurred); 239 optimizer.ExecutionTimeChanged -= new EventHandler(optimizer_ExecutionTimeChanged); 240 optimizer.Paused -= new EventHandler(optimizer_Paused); 241 optimizer.Prepared -= new EventHandler(optimizer_Prepared); 242 optimizer.Started -= new EventHandler(optimizer_Started); 243 optimizer.Stopped -= new EventHandler(optimizer_Stopped); 244 } 245 private void optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) { 257 246 OnExceptionOccurred(e.Value); 258 247 } 259 private void batchRun_Paused(object sender, EventArgs e) { 260 if (BatchRuns.All(x => x.ExecutionState != ExecutionState.Started)) 248 private void optimizer_ExecutionTimeChanged(object sender, EventArgs e) { 249 ExecutionTime = Optimizers.Aggregate(TimeSpan.Zero, (t, o) => t + o.ExecutionTime); 250 } 251 private void optimizer_Paused(object sender, EventArgs e) { 252 if (Optimizers.All(x => x.ExecutionState != ExecutionState.Started)) 261 253 OnPaused(); 262 254 } 263 void batchRun_Prepared(object sender, EventArgs e) {255 private void optimizer_Prepared(object sender, EventArgs e) { 264 256 if (ExecutionState == ExecutionState.Stopped) 265 257 OnPrepared(); 266 258 } 267 private void batchRun_Started(object sender, EventArgs e) {259 private void optimizer_Started(object sender, EventArgs e) { 268 260 if (ExecutionState != ExecutionState.Started) 269 261 OnStarted(); 270 262 } 271 private void batchRun_Stopped(object sender, EventArgs e) {263 private void optimizer_Stopped(object sender, EventArgs e) { 272 264 bool stop = stopPending; 273 BatchRun batchRun = (BatchRun)sender; 274 ExecutionTime += batchRun.ExecutionTime; 275 runs.AddRange(batchRun.Runs); 276 277 if (BatchRuns.All(x => (x.ExecutionState != ExecutionState.Started) && (x.ExecutionState != ExecutionState.Paused))) { 265 266 if (Optimizers.All(x => (x.ExecutionState != ExecutionState.Started) && (x.ExecutionState != ExecutionState.Paused))) { 278 267 stopPending = false; 279 268 OnStopped(); … … 281 270 282 271 if (!stop) { 283 BatchRun next = BatchRuns.FirstOrDefault(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused));272 IOptimizer next = Optimizers.FirstOrDefault(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)); 284 273 if (next != null) 285 274 next.Start(); -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r3267 r3274 87 87 <Compile Include="Algorithm.cs" /> 88 88 <Compile Include="BatchRun.cs" /> 89 <Compile Include=" BatchRunList.cs" />89 <Compile Include="OptimizerList.cs" /> 90 90 <Compile Include="Experiment.cs" /> 91 <Compile Include="Interfaces\IOptimizer.cs" /> 91 92 <Compile Include="RunCollection.cs" /> 92 93 <Compile Include="Run.cs" /> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs
r3262 r3274 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common;25 24 using HeuristicLab.Core; 26 25 … … 29 28 /// Interface to represent an algorithm. 30 29 /// </summary> 31 public interface IAlgorithm : IParameterizedNamedItem, I Executable{30 public interface IAlgorithm : IParameterizedNamedItem, IOptimizer { 32 31 Type ProblemType { get; } 33 32 IProblem Problem { get; set; } -
trunk/sources/HeuristicLab.Optimization/3.3/ResultCollection.cs
r3226 r3274 28 28 [StorableClass] 29 29 [Item("ResultCollection", "Represents a collection of results.")] 30 public sealedclass ResultCollection : NamedItemCollection<IResult> {30 public class ResultCollection : NamedItemCollection<IResult> { 31 31 public ResultCollection() : base() { } 32 32 public ResultCollection(int capacity) : base(capacity) { } -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r3260 r3274 28 28 [StorableClass] 29 29 [Item("RunCollection", "Represents a collection of runs.")] 30 public sealedclass RunCollection : ItemCollection<Run> {30 public class RunCollection : ItemCollection<Run> { 31 31 public RunCollection() : base() { } 32 32 public RunCollection(int capacity) : base(capacity) { }
Note: See TracChangeset
for help on using the changeset viewer.