Changeset 2796 for trunk/sources/HeuristicLab.Core/3.3
- Timestamp:
- 02/15/10 05:26:02 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3
- Files:
-
- 3 added
- 8 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Engine.cs
r2793 r2796 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Text; 25 using System.Xml; 24 using System.Drawing; 26 25 using System.Threading; 27 using System.Drawing;26 using HeuristicLab.Common; 28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Common;30 28 31 29 namespace HeuristicLab.Core { … … 41 39 } 42 40 43 /// <summary>44 /// Field of the current instance that represent the operator graph.45 /// </summary>46 41 private OperatorGraph operatorGraph; 47 42 /// <summary> 48 /// Gets the current operator graph.43 /// Gets or sets the current operator graph. 49 44 /// </summary> 50 45 [Storable] … … 76 71 77 72 [Storable] 73 private IProblem problem; 74 /// <summary> 75 /// Gets or sets the current problem. 76 /// </summary> 77 public IProblem Problem { 78 get { return problem; } 79 set { 80 if (value == null) throw new ArgumentNullException(); 81 if (value != problem) { 82 problem = value; 83 OnProblemChanged(); 84 Prepare(); 85 } 86 } 87 } 88 89 [Storable] 78 90 private TimeSpan executionTime; 79 91 /// <summary> … … 134 146 protected Engine() { 135 147 globalScope = new Scope("Global"); 148 problem = null; 136 149 executionStack = new Stack<IExecutionSequence>(); 137 150 OperatorGraph = new OperatorGraph(); … … 149 162 clone.OperatorGraph = (OperatorGraph)cloner.Clone(operatorGraph); 150 163 clone.globalScope = (Scope)cloner.Clone(globalScope); 164 clone.problem = (IProblem)cloner.Clone(problem); 151 165 clone.executionTime = executionTime; 152 166 IExecutionSequence[] contexts = executionStack.ToArray(); … … 169 183 ExecutionTime = new TimeSpan(); 170 184 executionStack.Clear(); 171 if ( OperatorGraph.InitialOperator != null)172 executionStack.Push(new ExecutionContext(null, OperatorGraph.InitialOperator, GlobalScope ));185 if ((OperatorGraph.InitialOperator != null) && (Problem != null)) 186 executionStack.Push(new ExecutionContext(null, OperatorGraph.InitialOperator, GlobalScope, Problem)); 173 187 OnPrepared(); 174 188 } … … 228 242 } 229 243 244 /// <summary> 245 /// Occurs when the operator graph was changed. 246 /// </summary> 230 247 public event EventHandler OperatorGraphChanged; 248 /// <summary> 249 /// Fires a new <c>OperatorGraphChanged</c> event. 250 /// </summary> 231 251 protected virtual void OnOperatorGraphChanged() { 232 252 if (OperatorGraphChanged != null) 233 253 OperatorGraphChanged(this, EventArgs.Empty); 254 } 255 /// <summary> 256 /// Occurs when the problem was changed. 257 /// </summary> 258 public event EventHandler ProblemChanged; 259 /// <summary> 260 /// Fires a new <c>ProblemChanged</c> event. 261 /// </summary> 262 protected virtual void OnProblemChanged() { 263 if (ProblemChanged != null) 264 ProblemChanged(this, EventArgs.Empty); 234 265 } 235 266 /// <summary> -
trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs
r2790 r2796 45 45 } 46 46 47 [Storable] 48 private IProblem problem; 49 public IProblem Problem { 50 get { return problem; } 51 } 52 47 53 private ExecutionContext() { 48 54 parent = null; 49 55 op = null; 50 56 scope = null; 57 problem = null; 51 58 } 52 public ExecutionContext(ExecutionContext parent, IOperator op, IScope scope ) {53 if ((op == null) || (scope == null) ) throw new ArgumentNullException();59 public ExecutionContext(ExecutionContext parent, IOperator op, IScope scope, IProblem problem) { 60 if ((op == null) || (scope == null) || (problem == null)) throw new ArgumentNullException(); 54 61 this.parent = parent; 55 62 this.op = op; 56 63 this.scope = scope; 64 this.problem = problem; 57 65 } 58 66 … … 63 71 clone.op = (IOperator)cloner.Clone(op); 64 72 clone.scope = (IScope)cloner.Clone(scope); 73 clone.problem = (IProblem)cloner.Clone(problem); 65 74 return clone; 75 } 76 77 public ExecutionContext CreateContext(IOperator op) { 78 return new ExecutionContext(parent, op, scope, problem); 79 } 80 public ExecutionContext CreateContext(IOperator op, IScope scope) { 81 return new ExecutionContext(parent, op, scope, problem); 82 } 83 public ExecutionContext CreateChildContext(IOperator op) { 84 return new ExecutionContext(this, op, scope, problem); 85 } 86 public ExecutionContext CreateChildContext(IOperator op, IScope scope) { 87 return new ExecutionContext(this, op, scope, problem); 66 88 } 67 89 } -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2773 r2796 104 104 <Compile Include="ChangedEventArgs.cs" /> 105 105 <None Include="HeuristicLabCorePlugin.cs.frame" /> 106 <Compile Include="ValueParameterCollection.cs" /> 107 <Compile Include="Interfaces\IProblem.cs" /> 106 108 <Compile Include="Interfaces\IExecutionSequence.cs" /> 107 109 <Compile Include="Interfaces\IValueLookupParameter.cs" /> … … 115 117 <Compile Include="Item.cs" /> 116 118 <Compile Include="NamedItem.cs" /> 119 <Compile Include="Operator.cs" /> 120 <Compile Include="Problem.cs" /> 117 121 <Compile Include="OperatorGraph.cs" /> 118 122 <Compile Include="Interfaces\IParameter.cs" /> -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IEngine.cs
r2790 r2796 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 23 using HeuristicLab.Common; 26 24 … … 40 38 /// </summary> 41 39 IScope GlobalScope { get; } 40 /// <summary> 41 /// Gets the problem of the current instance. 42 /// </summary> 43 IProblem Problem { get; set; } 42 44 43 45 /// <summary> … … 72 74 void Stop(); 73 75 76 /// <summary> 77 /// Occurs when the operator graph was changed. 78 /// </summary> 74 79 event EventHandler OperatorGraphChanged; 80 /// <summary> 81 /// Occurs when the problem was changed. 82 /// </summary> 83 event EventHandler ProblemChanged; 75 84 /// <summary> 76 85 /// Occurs when the execution time was changed. -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/ILookupParameter.cs
r2790 r2796 26 26 27 27 namespace HeuristicLab.Core { 28 public interface ILookupParameter <T> : IParameter where T : class, IItem{28 public interface ILookupParameter : IParameter { 29 29 string ActualName { get; set; } 30 31 30 event EventHandler ActualNameChanged; 32 31 } 32 33 public interface ILookupParameter<T> : ILookupParameter where T : class, IItem { 34 new T ActualValue { get; set; } 35 } 33 36 } -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IValueLookupParameter.cs
r2790 r2796 26 26 27 27 namespace HeuristicLab.Core { 28 public interface IValueLookupParameter<T> : IValueParameter<T>, ILookupParameter<T> where T : class, IItem { } 28 public interface IValueLookupParameter : IValueParameter, ILookupParameter { } 29 30 public interface IValueLookupParameter<T> : IValueLookupParameter, IValueParameter<T>, ILookupParameter<T> where T : class, IItem { } 29 31 } -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IValueParameter.cs
r2790 r2796 26 26 27 27 namespace HeuristicLab.Core { 28 public interface IValueParameter<T> : IParameter where T : class, IItem { 29 T Value { get; set; } 30 28 public interface IValueParameter : IParameter { 29 IItem Value { get; set; } 31 30 event EventHandler ValueChanged; 32 31 } 32 33 public interface IValueParameter<T> : IValueParameter where T : class, IItem { 34 new T Value { get; set; } 35 } 33 36 } -
trunk/sources/HeuristicLab.Core/3.3/Operator.cs
r2795 r2796 23 23 using System.Drawing; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Core;26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 26 28 namespace HeuristicLab. Operators{27 namespace HeuristicLab.Core { 29 28 /// <summary> 30 29 /// The base class for all operators. -
trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs
r2793 r2796 34 34 /// </summary> 35 35 [Item("OperatorGraph", "Represents a graph of operators.")] 36 [Creatable(" Test")]36 [Creatable("Algorithms")] 37 37 public class OperatorGraph : Item { 38 38 private OperatorSet operators;
Note: See TracChangeset
for help on using the changeset viewer.