Changeset 3275 for trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
- Timestamp:
- 04/06/10 03:37:29 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs
r3274 r3275 90 90 public abstract ResultCollection Results { get; } 91 91 92 [Storable] 93 private RunCollection runs; 94 public RunCollection Runs { 95 get { return runs; } 96 } 97 92 98 protected Algorithm() 93 99 : base() { 94 100 executionState = ExecutionState.Stopped; 95 101 executionTime = TimeSpan.Zero; 102 runs = new RunCollection(); 96 103 } 97 104 protected Algorithm(string name) … … 99 106 executionState = ExecutionState.Stopped; 100 107 executionTime = TimeSpan.Zero; 108 runs = new RunCollection(); 101 109 } 102 110 protected Algorithm(string name, ParameterCollection parameters) … … 104 112 executionState = ExecutionState.Stopped; 105 113 executionTime = TimeSpan.Zero; 114 runs = new RunCollection(); 106 115 } 107 116 protected Algorithm(string name, string description) … … 109 118 executionState = ExecutionState.Stopped; 110 119 executionTime = TimeSpan.Zero; 120 runs = new RunCollection(); 111 121 } 112 122 protected Algorithm(string name, string description, ParameterCollection parameters) … … 114 124 executionState = ExecutionState.Stopped; 115 125 executionTime = TimeSpan.Zero; 126 runs = new RunCollection(); 116 127 } 117 128 … … 121 132 clone.executionTime = executionTime; 122 133 clone.Problem = (IProblem)cloner.Clone(problem); 134 clone.runs = (RunCollection)cloner.Clone(runs); 123 135 return clone; 124 136 } 125 137 126 public void Prepare() { 127 Prepare(true); 128 } 129 public virtual void Prepare(bool clearResults) { 138 public virtual void Prepare() { 130 139 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 131 140 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 132 ExecutionTime = TimeSpan.Zero; 141 } 142 public void Prepare(bool clearRuns) { 143 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 144 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 145 if (clearRuns) runs.Clear(); 146 Prepare(); 133 147 } 134 148 public virtual void Start() { … … 172 186 public event EventHandler Prepared; 173 187 protected virtual void OnPrepared() { 188 ExecutionTime = TimeSpan.Zero; 174 189 ExecutionState = ExecutionState.Prepared; 175 190 EventHandler handler = Prepared; … … 190 205 public event EventHandler Stopped; 191 206 protected virtual void OnStopped() { 207 Run run = new Run("Run (" + ExecutionTime.ToString() + ")"); 208 CollectParameterValues(run.Parameters); 209 CollectResultValues(run.Results); 210 runs.Add(run); 192 211 ExecutionState = ExecutionState.Stopped; 193 212 EventHandler handler = Stopped;
Note: See TracChangeset
for help on using the changeset viewer.