- Timestamp:
- 04/20/20 17:31:31 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
r17513 r17517 95 95 } 96 96 97 public abstract ResultCollection Results { get; } 97 [Storable] 98 private readonly ResultCollection results = new ResultCollection(); 99 public ResultCollection Results { 100 get { return results; } 101 } 98 102 99 103 [Storable] … … 185 189 storeAlgorithmInEachRun = original.storeAlgorithmInEachRun; 186 190 runsCounter = original.runsCounter; 191 results = cloner.Clone(original.Results); 187 192 runs = cloner.Clone(original.runs); 188 193 Initialize(); … … 197 202 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 198 203 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 204 results.Clear(); 199 205 } 200 206 public void Prepare(bool clearRuns) { … … 286 292 public event EventHandler Started; 287 293 protected virtual void OnStarted() { 294 foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>()) 295 param.ResultCollection = results; 288 296 ExecutionState = ExecutionState.Started; 289 297 EventHandler handler = Started; … … 292 300 public event EventHandler Paused; 293 301 protected virtual void OnPaused() { 302 foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>()) 303 param.ResultCollection = null; 294 304 ExecutionState = ExecutionState.Paused; 295 305 EventHandler handler = Paused; … … 311 321 } 312 322 } finally { 323 foreach (var param in Parameters.Concat(Problem.Parameters).OfType<IResultParameter>()) 324 param.ResultCollection = null; 313 325 ExecutionState = ExecutionState.Stopped; 314 326 EventHandler handler = Stopped; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs
r17226 r17517 22 22 using System; 23 23 using System.Threading; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HEAL.Attic;27 27 28 28 namespace HeuristicLab.Optimization { … … 42 42 [Storable] 43 43 private bool initialized; 44 [Storable]45 private readonly ResultCollection results;46 public override ResultCollection Results {47 get { return results; }48 }49 44 50 45 private CancellationTokenSource cancellationTokenSource; … … 58 53 protected BasicAlgorithm(BasicAlgorithm original, Cloner cloner) 59 54 : base(original, cloner) { 60 results = cloner.Clone(original.Results);61 55 initialized = original.initialized; 62 56 } 63 57 protected BasicAlgorithm() 64 58 : base() { 65 results = new ResultCollection();66 59 } 67 60 … … 69 62 if (Problem == null) return; 70 63 base.Prepare(); 71 results.Clear();72 64 initialized = false; 73 65 OnPrepared(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs
r17513 r17517 76 76 } 77 77 78 public override ResultCollection Results {79 get {80 return (ResultCollection)globalScope.Variables["Results"].Value;81 }82 }83 84 78 protected EngineAlgorithm() 85 79 : base() { 86 80 globalScope = new Scope("Global Scope"); 87 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));81 globalScope.Variables.Add(new Variable("Results", Results)); 88 82 operatorGraph = new OperatorGraph(); 89 83 Initialize(); … … 92 86 : base(name) { 93 87 globalScope = new Scope("Global Scope"); 94 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));88 globalScope.Variables.Add(new Variable("Results", Results)); 95 89 operatorGraph = new OperatorGraph(); 96 90 Initialize(); … … 99 93 : base(name, parameters) { 100 94 globalScope = new Scope("Global Scope"); 101 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));95 globalScope.Variables.Add(new Variable("Results", Results)); 102 96 operatorGraph = new OperatorGraph(); 103 97 Initialize(); … … 106 100 : base(name, description) { 107 101 globalScope = new Scope("Global Scope"); 108 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));102 globalScope.Variables.Add(new Variable("Results", Results)); 109 103 operatorGraph = new OperatorGraph(); 110 104 Initialize(); … … 113 107 : base(name, description, parameters) { 114 108 globalScope = new Scope("Global Scope"); 115 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));109 globalScope.Variables.Add(new Variable("Results", Results)); 116 110 operatorGraph = new OperatorGraph(); 117 111 Initialize(); … … 160 154 base.Prepare(); 161 155 globalScope.Clear(); 162 globalScope.Variables.Add(new Variable("Results", new ResultCollection()));156 globalScope.Variables.Add(new Variable("Results", Results)); 163 157 164 158 if ((engine != null) && (operatorGraph.InitialOperator != null)) {
Note: See TracChangeset
for help on using the changeset viewer.