Changeset 3260 for trunk/sources/HeuristicLab.Optimization
- Timestamp:
- 04/03/10 06:04:49 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization/3.3
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs ¶
r3226 r3260 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 using HeuristicLab.Collections;25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; … … 120 120 } 121 121 122 public override void CollectParameterValues(IDictionary<string, IItem> values) { 123 base.CollectParameterValues(values); 124 Problem.CollectParameterValues(values); 125 } 126 public virtual void CollectResultValues(IDictionary<string, IItem> values) { 127 foreach (IResult result in Results) 128 values.Add(result.Name, result.Value != null ? (IItem)result.Value.Clone() : null); 129 } 130 122 131 #region Events 123 132 public event EventHandler ProblemChanged; -
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs ¶
r3246 r3260 22 22 using System; 23 23 using System.Drawing; 24 using HeuristicLab.Collections;25 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 74 73 75 74 [Storable] 76 private R esultCollection results;77 public R esultCollection Results {78 get { return r esults; }75 private RunCollection runs; 76 public RunCollection Runs { 77 get { return runs; } 79 78 } 80 79 … … 103 102 104 103 public bool Finished { 105 get { return ((Algorithm == null) || (Algorithm.Finished && (r esults.Count >= repetitions))); }104 get { return ((Algorithm == null) || (Algorithm.Finished && (runs.Count >= repetitions))); } 106 105 } 107 106 … … 111 110 : base() { 112 111 repetitions = 10; 113 r esults = new ResultCollection();112 runs = new RunCollection(); 114 113 executionTime = TimeSpan.Zero; 115 114 } 116 115 public BatchRun(string name) : base(name) { 117 116 repetitions = 10; 118 r esults = new ResultCollection();117 runs = new RunCollection(); 119 118 executionTime = TimeSpan.Zero; 120 119 } 121 120 public BatchRun(string name, string description) : base(name, description) { 122 121 repetitions = 10; 123 r esults = new ResultCollection();122 runs = new RunCollection(); 124 123 executionTime = TimeSpan.Zero; 125 124 } … … 129 128 clone.Algorithm = (IAlgorithm)cloner.Clone(algorithm); 130 129 clone.repetitions = repetitions; 131 clone.r esults = (ResultCollection)cloner.Clone(results);130 clone.runs = (RunCollection)cloner.Clone(runs); 132 131 clone.executionTime = executionTime; 133 132 clone.running = running; … … 137 136 138 137 public void Prepare() { 139 results.Clear(); 138 executionTime = TimeSpan.Zero; 139 runs.Clear(); 140 140 if (Algorithm != null) Algorithm.Prepare(); 141 141 OnPrepared(); … … 196 196 197 197 private void DeregisterAlgorithmEvents() { 198 algorithm.Prepared -= new EventHandler(Algorithm_Prepared);199 198 algorithm.RunningChanged -= new EventHandler(Algorithm_RunningChanged); 200 199 algorithm.ExceptionOccurred -= new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred); … … 202 201 203 202 private void RegisterAlgorithmEvents() { 204 algorithm.Prepared += new EventHandler(Algorithm_Prepared);205 203 algorithm.RunningChanged += new EventHandler(Algorithm_RunningChanged); 206 204 algorithm.ExceptionOccurred += new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred); 207 205 } 208 206 209 private void Algorithm_Prepared(object sender, EventArgs e) {210 results.Add(new Result("Run " + DateTime.Now.ToString(), Algorithm.Results));211 }212 207 private void Algorithm_RunningChanged(object sender, EventArgs e) { 213 208 if (Algorithm.Running) { … … 215 210 OnStarted(); 216 211 } else { 217 if (!canceled && (results.Count < repetitions)) {212 if (!canceled) { 218 213 ExecutionTime += Algorithm.ExecutionTime; 214 runs.Add(new Run("Run " + Algorithm.ExecutionTime.ToString(), Algorithm)); 219 215 Algorithm.Prepare(); 220 Algorithm.Start(); 216 if (runs.Count < repetitions) Algorithm.Start(); 217 else OnStopped(); 221 218 } else { 222 if (Algorithm.Finished) ExecutionTime += Algorithm.ExecutionTime;223 219 OnStopped(); 224 220 } -
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs ¶
r3226 r3260 216 216 Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred); 217 217 Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged); 218 Engine. Stopped += new EventHandler(Engine_Stopped);218 Engine.RunningChanged += new EventHandler(Engine_RunningChanged); 219 219 } 220 220 private void DeregisterEngineEvents() { 221 221 Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred); 222 222 Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged); 223 Engine. Stopped -= new EventHandler(Engine_Stopped);223 Engine.RunningChanged -= new EventHandler(Engine_RunningChanged); 224 224 } 225 225 … … 230 230 OnExecutionTimeChanged(); 231 231 } 232 private void Engine_ Stopped(object sender, EventArgs e) {233 OnStopped();232 private void Engine_RunningChanged(object sender, EventArgs e) { 233 if (!Engine.Running) OnStopped(); 234 234 } 235 235 } -
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj ¶
r3246 r3260 87 87 <Compile Include="Algorithm.cs" /> 88 88 <Compile Include="BatchRun.cs" /> 89 <Compile Include="RunCollection.cs" /> 90 <Compile Include="Run.cs" /> 89 91 <Compile Include="Interfaces\IMultiObjectiveSolutionsVisualizer.cs" /> 90 92 <Compile Include="Interfaces\IResult.cs" /> -
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs ¶
r3226 r3260 21 21 22 22 using System; 23 using HeuristicLab.Collections;23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; … … 41 41 void Stop(); 42 42 43 void CollectResultValues(IDictionary<string, IItem> values); 44 43 45 event EventHandler ProblemChanged; 44 46 event EventHandler ExecutionTimeChanged;
Note: See TracChangeset
for help on using the changeset viewer.