Changeset 2773
- Timestamp:
- 02/10/10 03:39:02 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 added
- 5 deleted
- 32 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r2772 r2773 68 68 {DC3D7072-7999-4719-B65D-3997744D5DC1} = {DC3D7072-7999-4719-B65D-3997744D5DC1} 69 69 {BF7D9494-A586-457B-8DF9-ED599F9E6A71} = {BF7D9494-A586-457B-8DF9-ED599F9E6A71} 70 {F4539FB6-4708-40C9-BE64-0A1390AEA197} = {F4539FB6-4708-40C9-BE64-0A1390AEA197} 70 71 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6} = {958B43BC-CC5C-4FA2-8628-2B3B01D890B6} 71 72 {AB687BBE-1BFE-476B-906D-44237135431D} = {AB687BBE-1BFE-476B-906D-44237135431D} -
trunk/sources/HeuristicLab.Core/3.3/Engine.cs
r2757 r2773 93 93 /// </summary> 94 94 [Storable] 95 private Stack<IExecution Context> executionStack;95 private Stack<IExecutionSequence> executionStack; 96 96 /// <summary> 97 97 /// Gets the current execution stack. 98 98 /// </summary> 99 protected Stack<IExecution Context> ExecutionStack {99 protected Stack<IExecutionSequence> ExecutionStack { 100 100 get { return executionStack; } 101 101 } … … 135 135 protected Engine() { 136 136 globalScope = new Scope("Global"); 137 executionStack = new Stack<IExecution Context>();137 executionStack = new Stack<IExecutionSequence>(); 138 138 OperatorGraph = new OperatorGraph(); 139 139 } … … 151 151 clone.globalScope = (Scope)cloner.Clone(globalScope); 152 152 clone.executionTime = executionTime; 153 IExecution Context[] contexts = executionStack.ToArray();153 IExecutionSequence[] contexts = executionStack.ToArray(); 154 154 for (int i = contexts.Length - 1; i >= 0; i--) 155 clone.executionStack.Push((IExecution Context)cloner.Clone(contexts[i]));155 clone.executionStack.Push((IExecutionSequence)cloner.Clone(contexts[i])); 156 156 clone.running = running; 157 157 clone.canceled = canceled; -
trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs
r2757 r2773 26 26 27 27 namespace HeuristicLab.Core { 28 public class ExecutionContext : DeepCloneable, IExecution Context{28 public class ExecutionContext : DeepCloneable, IExecutionSequence { 29 29 [Storable] 30 30 private ExecutionContext parent; -
trunk/sources/HeuristicLab.Core/3.3/ExecutionContextCollection.cs
r2757 r2773 28 28 29 29 namespace HeuristicLab.Core { 30 public class ExecutionContextCollection : DeepCloneable, IList<IExecution Context>, IExecutionContext{30 public class ExecutionContextCollection : DeepCloneable, IList<IExecutionSequence>, IExecutionSequence { 31 31 [Storable] 32 private IList<IExecution Context> contexts;32 private IList<IExecutionSequence> contexts; 33 33 34 34 [Storable] … … 40 40 41 41 public ExecutionContextCollection() { 42 contexts = new List<IExecution Context>();42 contexts = new List<IExecutionSequence>(); 43 43 parallel = false; 44 44 } 45 public ExecutionContextCollection(IEnumerable<IExecution Context> collection) {46 contexts = new List<IExecution Context>(collection.Where(e => e != null));45 public ExecutionContextCollection(IEnumerable<IExecutionSequence> collection) { 46 contexts = new List<IExecutionSequence>(collection.Where(e => e != null)); 47 47 parallel = false; 48 48 } 49 public ExecutionContextCollection(params IExecution Context[] list) {50 contexts = new List<IExecution Context>(list.Where(e => e != null));49 public ExecutionContextCollection(params IExecutionSequence[] list) { 50 contexts = new List<IExecutionSequence>(list.Where(e => e != null)); 51 51 parallel = false; 52 52 } … … 57 57 clone.parallel = parallel; 58 58 for (int i = 0; i < contexts.Count; i++) 59 clone.contexts.Add((IExecution Context)cloner.Clone(contexts[i]));59 clone.contexts.Add((IExecutionSequence)cloner.Clone(contexts[i])); 60 60 return clone; 61 61 } 62 62 63 63 #region IList<IExecutionContext> Members 64 public int IndexOf(IExecution Contextitem) {64 public int IndexOf(IExecutionSequence item) { 65 65 return contexts.IndexOf(item); 66 66 } 67 public void Insert(int index, IExecution Contextitem) {67 public void Insert(int index, IExecutionSequence item) { 68 68 if (item != null) contexts.Insert(index, item); 69 69 } … … 71 71 contexts.RemoveAt(index); 72 72 } 73 public IExecution Contextthis[int index] {73 public IExecutionSequence this[int index] { 74 74 get { return contexts[index]; } 75 75 set { if (value != null) contexts[index] = value; } … … 78 78 79 79 #region ICollection<IExecutionContext> Members 80 public void Add(IExecution Contextitem) {80 public void Add(IExecutionSequence item) { 81 81 if (item != null) contexts.Add(item); 82 82 } … … 84 84 contexts.Clear(); 85 85 } 86 public bool Contains(IExecution Contextitem) {86 public bool Contains(IExecutionSequence item) { 87 87 return contexts.Contains(item); 88 88 } 89 public void CopyTo(IExecution Context[] array, int arrayIndex) {89 public void CopyTo(IExecutionSequence[] array, int arrayIndex) { 90 90 contexts.CopyTo(array, arrayIndex); 91 91 } … … 96 96 get { return contexts.IsReadOnly; } 97 97 } 98 public bool Remove(IExecution Contextitem) {98 public bool Remove(IExecutionSequence item) { 99 99 return contexts.Remove(item); 100 100 } … … 102 102 103 103 #region IEnumerable<IExecutionContext> Members 104 public IEnumerator<IExecution Context> GetEnumerator() {104 public IEnumerator<IExecutionSequence> GetEnumerator() { 105 105 return contexts.GetEnumerator(); 106 106 } -
trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2757 r2773 104 104 <Compile Include="ChangedEventArgs.cs" /> 105 105 <None Include="HeuristicLabCorePlugin.cs.frame" /> 106 <Compile Include="Interfaces\IExecution Context.cs" />106 <Compile Include="Interfaces\IExecutionSequence.cs" /> 107 107 <Compile Include="Interfaces\IValueLookupParameter.cs" /> 108 108 <Compile Include="Interfaces\IValueParameter.cs" /> -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IExecutionSequence.cs
r2772 r2773 30 30 /// Interface which represents an execution context. 31 31 /// </summary> 32 public interface IExecution Context: IDeepCloneable { }32 public interface IExecutionSequence : IDeepCloneable { } 33 33 } -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperator.cs
r2757 r2773 44 44 /// <param name="scope">The scope where to execute the current instance.</param> 45 45 /// <returns>The next operation.</returns> 46 IExecution ContextExecute(ExecutionContext context);46 IExecutionSequence Execute(ExecutionContext context); 47 47 /// <summary> 48 48 /// Aborts the current operator. -
trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj
r2756 r2773 58 58 </Compile> 59 59 <None Include="HeuristicLabOperatorsViewsPlugin.cs.frame" /> 60 <Compile Include="Multiple SuccessorsOperatorView.cs">60 <Compile Include="MultipleCallsOperatorView.cs"> 61 61 <SubType>UserControl</SubType> 62 62 </Compile> 63 <Compile Include="MultipleSuccessorsOperatorView.Designer.cs"> 64 <DependentUpon>MultipleSuccessorsOperatorView.cs</DependentUpon> 63 <Compile Include="MultipleCallsOperatorView.Designer.cs"> 64 <DependentUpon>MultipleCallsOperatorView.cs</DependentUpon> 65 </Compile> 66 <Compile Include="ValuesCollectorView.cs"> 67 <SubType>UserControl</SubType> 68 </Compile> 69 <Compile Include="ValuesCollectorView.Designer.cs"> 70 <DependentUpon>ValuesCollectorView.cs</DependentUpon> 65 71 </Compile> 66 72 <Compile Include="HeuristicLabOperatorsViewsPlugin.cs" /> -
trunk/sources/HeuristicLab.Operators.Views/3.3/MultipleCallsOperatorView.Designer.cs
r2772 r2773 21 21 22 22 namespace HeuristicLab.Operators.Views { 23 partial class Multiple SuccessorsOperatorView {23 partial class MultipleCallsOperatorView { 24 24 /// <summary> 25 25 /// Required designer variable. … … 46 46 private void InitializeComponent() { 47 47 this.tabControl = new System.Windows.Forms.TabControl(); 48 this. successorsTabPage = new System.Windows.Forms.TabPage();49 this. successorsListView = new HeuristicLab.Core.Views.OperatorListView();48 this.operatorsTabPage = new System.Windows.Forms.TabPage(); 49 this.operatorListView = new HeuristicLab.Core.Views.OperatorListView(); 50 50 this.parametersTabPage = new System.Windows.Forms.TabPage(); 51 51 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 52 52 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 53 this.tabControl.SuspendLayout(); 54 this. successorsTabPage.SuspendLayout();54 this.operatorsTabPage.SuspendLayout(); 55 55 this.parametersTabPage.SuspendLayout(); 56 56 this.SuspendLayout(); … … 73 73 | System.Windows.Forms.AnchorStyles.Left) 74 74 | System.Windows.Forms.AnchorStyles.Right))); 75 this.tabControl.Controls.Add(this. successorsTabPage);75 this.tabControl.Controls.Add(this.operatorsTabPage); 76 76 this.tabControl.Controls.Add(this.parametersTabPage); 77 77 this.tabControl.Location = new System.Drawing.Point(0, 118); … … 81 81 this.tabControl.TabIndex = 4; 82 82 // 83 // successorsTabPage83 // operatorsTabPage 84 84 // 85 this. successorsTabPage.Controls.Add(this.successorsListView);86 this. successorsTabPage.Location = new System.Drawing.Point(4, 22);87 this. successorsTabPage.Name = "successorsTabPage";88 this. successorsTabPage.Padding = new System.Windows.Forms.Padding(3);89 this. successorsTabPage.Size = new System.Drawing.Size(478, 338);90 this. successorsTabPage.TabIndex = 0;91 this. successorsTabPage.Text = "Successors";92 this. successorsTabPage.UseVisualStyleBackColor = true;85 this.operatorsTabPage.Controls.Add(this.operatorListView); 86 this.operatorsTabPage.Location = new System.Drawing.Point(4, 22); 87 this.operatorsTabPage.Name = "operatorsTabPage"; 88 this.operatorsTabPage.Padding = new System.Windows.Forms.Padding(3); 89 this.operatorsTabPage.Size = new System.Drawing.Size(478, 338); 90 this.operatorsTabPage.TabIndex = 0; 91 this.operatorsTabPage.Text = "Operators"; 92 this.operatorsTabPage.UseVisualStyleBackColor = true; 93 93 // 94 // successorsListView94 // operatorListView 95 95 // 96 this. successorsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)96 this.operatorListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 97 97 | System.Windows.Forms.AnchorStyles.Left) 98 98 | System.Windows.Forms.AnchorStyles.Right))); 99 this. successorsListView.Caption = "Operator List";100 this. successorsListView.Content = null;101 this. successorsListView.Location = new System.Drawing.Point(6, 6);102 this. successorsListView.Name = "successorsListView";103 this. successorsListView.Size = new System.Drawing.Size(466, 326);104 this. successorsListView.TabIndex = 0;99 this.operatorListView.Caption = "Operator List"; 100 this.operatorListView.Content = null; 101 this.operatorListView.Location = new System.Drawing.Point(6, 6); 102 this.operatorListView.Name = "operatorListView"; 103 this.operatorListView.Size = new System.Drawing.Size(466, 326); 104 this.operatorListView.TabIndex = 0; 105 105 // 106 106 // parametersTabPage … … 127 127 this.parameterCollectionView.TabIndex = 0; 128 128 // 129 // Multiple SuccessorsOperatorView129 // MultipleCallsOperatorView 130 130 // 131 131 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 132 132 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 133 133 this.Controls.Add(this.tabControl); 134 this.Name = "Multiple SuccessorsOperatorView";134 this.Name = "MultipleCallsOperatorView"; 135 135 this.Size = new System.Drawing.Size(486, 482); 136 136 this.Controls.SetChildIndex(this.tabControl, 0); … … 141 141 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 142 142 this.tabControl.ResumeLayout(false); 143 this. successorsTabPage.ResumeLayout(false);143 this.operatorsTabPage.ResumeLayout(false); 144 144 this.parametersTabPage.ResumeLayout(false); 145 145 this.ResumeLayout(false); … … 151 151 152 152 protected System.Windows.Forms.TabControl tabControl; 153 protected System.Windows.Forms.TabPage successorsTabPage;153 protected System.Windows.Forms.TabPage operatorsTabPage; 154 154 protected System.Windows.Forms.TabPage parametersTabPage; 155 155 private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView; 156 private HeuristicLab.Core.Views.OperatorListView successorsListView;156 private HeuristicLab.Core.Views.OperatorListView operatorListView; 157 157 } 158 158 } -
trunk/sources/HeuristicLab.Operators.Views/3.3/MultipleCallsOperatorView.cs
r2772 r2773 35 35 /// The base class for visual representations of items. 36 36 /// </summary> 37 [Content(typeof(Multiple SuccessorsOperator), true)]38 public partial class Multiple SuccessorsOperatorView : NamedItemView {39 public new Multiple SuccessorsOperator Content {40 get { return (Multiple SuccessorsOperator)base.Content; }37 [Content(typeof(MultipleCallsOperator), true)] 38 public partial class MultipleCallsOperatorView : NamedItemView { 39 public new MultipleCallsOperator Content { 40 get { return (MultipleCallsOperator)base.Content; } 41 41 set { base.Content = value; } 42 42 } … … 45 45 /// Initializes a new instance of <see cref="ItemBaseView"/>. 46 46 /// </summary> 47 public Multiple SuccessorsOperatorView() {47 public MultipleCallsOperatorView() { 48 48 InitializeComponent(); 49 49 } … … 52 52 /// </summary> 53 53 /// <param name="item">The item that should be displayed.</param> 54 public Multiple SuccessorsOperatorView(MultipleSuccessorsOperator content)54 public MultipleCallsOperatorView(MultipleCallsOperator content) 55 55 : this() { 56 56 Content = content; … … 60 60 base.OnContentChanged(); 61 61 if (Content == null) { 62 successorsListView.Content = null;62 operatorListView.Content = null; 63 63 parameterCollectionView.Content = null; 64 64 tabControl.Enabled = false; 65 65 } else { 66 successorsListView.Content = Content.Successors;66 operatorListView.Content = Content.Operators; 67 67 parameterCollectionView.Content = ((IOperator)Content).Parameters; 68 68 tabControl.Enabled = true; -
trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs
r2757 r2773 68 68 } 69 69 70 public override IExecution ContextApply() {70 public override IExecutionSequence Apply() { 71 71 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 72 72 if (operatorGraph.InitialOperator != null) -
trunk/sources/HeuristicLab.Operators/3.3/Comparator.cs
r2757 r2773 61 61 } 62 62 63 public override IExecution ContextApply() {63 public override IExecutionSequence Apply() { 64 64 IItem left = LeftSideParameter.ActualValue; 65 65 IItem right = RightSideParameter.ActualValue; -
trunk/sources/HeuristicLab.Operators/3.3/ConditionalBranch.cs
r2757 r2773 62 62 } 63 63 64 public override IExecution ContextApply() {64 public override IExecutionSequence Apply() { 65 65 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 66 66 if (ConditionParameter.ActualValue.Value) { -
trunk/sources/HeuristicLab.Operators/3.3/DoubleCounter.cs
r2757 r2773 30 30 namespace HeuristicLab.Operators { 31 31 /// <summary> 32 /// Operator which increments a double variable.32 /// An operator which increments a double variable. 33 33 /// </summary> 34 34 [Item("DoubleCounter", "An operator which increments a double variable.")] … … 53 53 } 54 54 55 public override IExecution ContextApply() {55 public override IExecutionSequence Apply() { 56 56 if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new DoubleData(); 57 57 ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value; -
trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r2757 r2773 89 89 <Compile Include="ConditionalBranch.cs" /> 90 90 <Compile Include="Comparator.cs" /> 91 <Compile Include="Assigner.cs" /> 92 <Compile Include="MultipleCallsOperator.cs" /> 93 <Compile Include="ParallelSubScopesProcessor.cs" /> 94 <Compile Include="Placeholder.cs" /> 95 <Compile Include="SingleCallOperator.cs" /> 96 <Compile Include="IntCounter.cs" /> 91 97 <Compile Include="ScopeCleaner.cs" /> 98 <Compile Include="SequentialSubScopesProcessor.cs" /> 99 <Compile Include="StochasticBranch.cs" /> 92 100 <Compile Include="SubScopesRemover.cs" /> 93 101 <Compile Include="SubScopesSorter.cs" /> 94 102 <Compile Include="DoubleCounter.cs" /> 95 <Compile Include="ParallelProcessor.cs" />96 103 <Compile Include="UniformParallelSubScopesProcessor.cs" /> 97 104 <Compile Include="UniformSequentialSubScopesProcessor.cs" /> 98 <Compile Include="ValueCollector.cs" />99 <Compile Include="MultipleSuccessorsOperator.cs" />100 <Compile Include="Counter.cs" />101 105 <Compile Include="EmptyOperator.cs"> 102 106 <SubType>Code</SubType> … … 105 109 <Compile Include="Operator.cs" /> 106 110 <Compile Include="Properties\AssemblyInfo.cs" /> 107 <Compile Include="SequentialProcessor.cs" />108 111 <Compile Include="SingleSuccessorOperator.cs" /> 109 112 <Compile Include="SubScopesCreater.cs" /> 113 <Compile Include="ValuesCollector.cs" /> 110 114 <Compile Include="VariableInjector.cs"> 111 115 <SubType>Code</SubType> -
trunk/sources/HeuristicLab.Operators/3.3/IntCounter.cs
r2772 r2773 30 30 namespace HeuristicLab.Operators { 31 31 /// <summary> 32 /// Operator which increments an integer variable.32 /// An operator which increments an integer variable. 33 33 /// </summary> 34 [Item(" Counter", "An operator which increments an integer variable.")]34 [Item("IntCounter", "An operator which increments an integer variable.")] 35 35 [EmptyStorableClass] 36 36 [Creatable("Test")] 37 public sealed class Counter : SingleSuccessorOperator {37 public sealed class IntCounter : SingleSuccessorOperator { 38 38 public LookupParameter<IntData> ValueParameter { 39 39 get { return (LookupParameter<IntData>)Parameters["Value"]; } … … 47 47 } 48 48 49 public Counter()49 public IntCounter() 50 50 : base() { 51 51 Parameters.Add(new LookupParameter<IntData>("Value", "The value which should be incremented.")); … … 53 53 } 54 54 55 public override IExecution ContextApply() {55 public override IExecutionSequence Apply() { 56 56 if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntData(); 57 57 ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value; -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r2757 r2773 130 130 131 131 /// <inheritdoc/> 132 public virtual IExecution ContextExecute(ExecutionContext context) {132 public virtual IExecutionSequence Execute(ExecutionContext context) { 133 133 try { 134 134 Canceled = false; … … 136 136 foreach (IParameter param in Parameters) 137 137 param.ExecutionContext = context; 138 IExecution Contextnext = Apply();138 IExecutionSequence next = Apply(); 139 139 OnExecuted(); 140 140 return next; … … 156 156 /// <param name="scope">The scope where to execute the operator</param> 157 157 /// <returns><c>null</c>.</returns> 158 public abstract IExecution ContextApply();158 public abstract IExecutionSequence Apply(); 159 159 160 160 protected virtual void OnExecutionContextChanged() { } -
trunk/sources/HeuristicLab.Operators/3.3/ParallelSubScopesProcessor.cs
r1530 r2773 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Text; 26 using System.Xml; 27 using HeuristicLab.Collections; 25 28 using HeuristicLab.Core; 26 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 31 28 32 namespace HeuristicLab.Operators { 29 33 /// <summary> 30 /// Performs <c>n</c> operators on <c>n</c> subscopes, operations can be executed in parallel.34 /// An operator which contains multiple operators of which each is applied in parallel on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on. 31 35 /// </summary> 32 public class ParallelSubScopesProcessor : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 36 [Item("ParallelSubScopesProcessor", "An operator which contains multiple operators of which each is applied in parallel on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on.")] 37 [Creatable("Test")] 38 public sealed class ParallelSubScopesProcessor : MultipleCallsOperator { 39 public ParallelSubScopesProcessor() 40 : base() { 36 41 } 37 42 38 /// <summary> 39 /// Applies <c>n</c> operators on all the <c>n</c> sub scopes of the given <paramref name="scope"/>. 40 /// </summary> 41 /// <param name="scope">The scope on whose sub scopes the operators are applied.</param> 42 /// <returns>A new <see cref="CompositeOperation"/> with the <c>i</c>th operator applied 43 /// on the <c>i</c>th sub scope, the <c>ExecuteInParallel</c> flag set to <c>true</c>.</returns> 44 public override IOperation Apply(IScope scope) { 45 CompositeOperation next = new CompositeOperation(); 46 next.ExecuteInParallel = true; 47 for (int i = 0; i < scope.SubScopes.Count; i++) 48 next.AddOperation(new AtomicOperation(SubOperators[i], scope.SubScopes[i])); 43 public override IExecutionSequence Apply() { 44 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 45 if (Operators.Count > 0) { 46 ExecutionContextCollection inner = new ExecutionContextCollection(); 47 inner.Parallel = true; 48 for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++) 49 inner.Add(new ExecutionContext(ExecutionContext.Parent, Operators[i], ExecutionContext.Scope.SubScopes[i])); 50 next.Insert(0, inner); 51 } 49 52 return next; 50 53 } -
trunk/sources/HeuristicLab.Operators/3.3/Placeholder.cs
r2772 r2773 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.Xml; 25 26 using HeuristicLab.Core; 26 using HeuristicLab.Data; 27 using HeuristicLab.Parameters; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 28 30 namespace HeuristicLab.Operators { 29 31 /// <summary> 30 /// Retrieves an operator from a specified scope and returns a successor operation with this operation 31 /// and scope. 32 /// An operator which acts as a placeholder for another operator retrieved from the scope or a parent execution context. 32 33 /// </summary> 33 public class OperatorExtractor : OperatorBase {34 /// <inheritdoc select="summary"/>35 public override string Description {36 get { return @"An operator extractor retrievs an operator from the scope it is applied on and returns a successor operation containing this operator and the current scope. Lookup for the operator is done recursively.37 38 Operator extractors can be used to get those operators again that have been injected by combined operators."; }34 [Item("Placeholder", "An operator which acts as a placeholder for another operator retrieved from the scope or a parent execution context.")] 35 [Creatable("Test")] 36 [EmptyStorableClass] 37 public sealed class Placeholder : SingleSuccessorOperator { 38 public LookupParameter<IOperator> OperatorParameter { 39 get { return (LookupParameter<IOperator>)Parameters["Operator"]; } 39 40 } 40 41 41 /// <summary> 42 /// Initializes a new instance of <see cref="OperatorExtractor"/> with 43 /// one variable info (<c>Operator</c>). 44 /// </summary> 45 public OperatorExtractor() 42 public Placeholder() 46 43 : base() { 47 AddVariableInfo(new VariableInfo("Operator", "Extracted operator", typeof(IOperator), VariableKind.In));44 Parameters.Add(new LookupParameter<IOperator>("Operator", "The operator which is retrieved from the scope or a parent execution context and applied on the current scope.")); 48 45 } 49 46 50 /// <summary> 51 /// Gets an operator from the specified <paramref name="scope"/> and returns an 52 /// <see cref="AtomicOperation"/> containing this operator and scope. 53 /// </summary> 54 /// <param name="scope">The scope where to apply the operator on.</param> 55 /// <returns>A new <see cref="AtomicOperation"/> containing the operator and the given 56 /// <paramref name="scope"/>.</returns> 57 public override IOperation Apply(IScope scope) { 58 IOperator op = GetVariableValue<IOperator>("Operator", scope, true, true); 59 return new AtomicOperation(op, scope); 47 public override IExecutionSequence Apply() { 48 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 49 IOperator op = OperatorParameter.ActualValue; 50 if (op != null) 51 next.Insert(0, new ExecutionContext(ExecutionContext.Parent, op, ExecutionContext.Scope)); 52 return next; 60 53 } 61 54 } -
trunk/sources/HeuristicLab.Operators/3.3/ScopeCleaner.cs
r2757 r2773 47 47 } 48 48 49 public override IExecution ContextApply() {49 public override IExecutionSequence Apply() { 50 50 CurrentScope.Variables.Clear(); 51 51 CurrentScope.SubScopes.Clear(); -
trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs
r1530 r2773 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Text; 26 using System.Xml; 27 using HeuristicLab.Collections; 25 28 using HeuristicLab.Core; 26 using HeuristicLab.Data; 29 using HeuristicLab.Parameters; 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 31 28 32 namespace HeuristicLab.Operators { 29 33 /// <summary> 30 /// Performs <c>n</c> operators on <c>n</c> subscopes, operations must be executed sequentially.34 /// An operator which contains multiple operators of which each is applied sequentially on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on. 31 35 /// </summary> 32 public class SequentialSubScopesProcessor : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 36 [Item("SequentialSubScopesProcessor", "An operator which contains multiple operators of which each is applied sequentially on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on.")] 37 [Creatable("Test")] 38 public sealed class SequentialSubScopesProcessor : MultipleCallsOperator { 39 public SequentialSubScopesProcessor() 40 : base() { 36 41 } 37 42 38 /// <summary> 39 /// Applies <c>n</c> operators on all the <c>n</c> sub scopes of the given <paramref name="scope"/>. 40 /// </summary> 41 /// <param name="scope">The scope on whose sub scopes the operators are applied.</param> 42 /// <returns>A new <see cref="CompositeOperation"/> with the <c>i</c>th operator applied 43 /// on the <c>i</c>th sub scope.</returns> 44 public override IOperation Apply(IScope scope) { 45 CompositeOperation next = new CompositeOperation(); 46 for (int i = 0; i < scope.SubScopes.Count; i++) 47 next.AddOperation(new AtomicOperation(SubOperators[i], scope.SubScopes[i])); 43 public override IExecutionSequence Apply() { 44 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 45 if (Operators.Count > 0) { 46 ExecutionContextCollection inner = new ExecutionContextCollection(); 47 for (int i = 0; (i < ExecutionContext.Scope.SubScopes.Count) && (i < Operators.Count); i++) 48 inner.Add(new ExecutionContext(ExecutionContext.Parent, Operators[i], ExecutionContext.Scope.SubScopes[i])); 49 next.Insert(0, inner); 50 } 48 51 return next; 49 52 } -
trunk/sources/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs
r2757 r2773 49 49 } 50 50 51 public override IExecution ContextApply() {51 public override IExecutionSequence Apply() { 52 52 if (Successor != null) 53 53 return new ExecutionContext(ExecutionContext.Parent, Successor, ExecutionContext.Scope); -
trunk/sources/HeuristicLab.Operators/3.3/StochasticBranch.cs
r1530 r2773 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.Xml; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Data; 28 using HeuristicLab.Parameters; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 30 28 31 namespace HeuristicLab.Operators { 29 32 /// <summary> 30 /// Branch of (one or) two operators that have different probabilities to get executed.33 /// A branch of two operators which are executed with a specified probability. 31 34 /// </summary> 32 public class StochasticBranch : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 35 [Item("StochasticBranch", "A branch of two operators which are executed with a specified probability.")] 36 [Creatable("Test")] 37 [EmptyStorableClass] 38 public class StochasticBranch : SingleSuccessorOperator { 39 public LookupParameter<IRandom> RandomParameter { 40 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 41 } 42 public ValueLookupParameter<DoubleData> ProbabilityParameter { 43 get { return (ValueLookupParameter<DoubleData>)Parameters["Probability"]; } 44 } 45 protected OperatorParameter FirstBranchParameter { 46 get { return (OperatorParameter)Parameters["FirstBranch"]; } 47 } 48 protected OperatorParameter SecondBranchParameter { 49 get { return (OperatorParameter)Parameters["SecondBranch"]; } 50 } 51 public IOperator FirstBranch { 52 get { return FirstBranchParameter.Value; } 53 set { FirstBranchParameter.Value = value; } 54 } 55 public IOperator SecondBranch { 56 get { return SecondBranchParameter.Value; } 57 set { SecondBranchParameter.Value = value; } 36 58 } 37 59 38 /// <summary>39 /// Initializes a new instance of <see cref="StochasticBranch"/> with two variable infos40 /// (<c>Random</c> and <c>Probability</c>).41 /// </summary>42 60 public StochasticBranch() 43 61 : base() { 44 AddVariableInfo(new VariableInfo("Random", "Pseudo random number generator", typeof(IRandom), VariableKind.In)); 45 AddVariableInfo(new VariableInfo("Probability", "Probability to choose first branch", typeof(DoubleData), VariableKind.In)); 62 Parameters.Add(new LookupParameter<IRandom>("Random", "A pseudo random number generator.")); 63 Parameters.Add(new ValueLookupParameter<DoubleData>("Probability", "The probability to execute the first branch.")); 64 Parameters.Add(new OperatorParameter("FirstBranch", "The operator which is executed with the given probability.")); 65 Parameters.Add(new OperatorParameter("SecondBranch", "The operator which is executed if the first branch is not executed.")); 46 66 } 47 67 48 /// <summary> 49 /// Applies the operator of branch one with a specific probability on the given 50 /// <paramref name="scope"/>, or - if existent - with another probability operator of branch two. 51 /// </summary> 52 /// <param name="scope">The scope to apply the operators on.</param> 53 /// <returns>A new <see cref="AtomicOperation"/> with either operator 1 or operator 2 applied 54 /// to the given <paramref name="scope"/> or <c>null</c>.</returns> 55 public override IOperation Apply(IScope scope) { 56 IRandom random = GetVariableValue<IRandom>("Random", scope, true); 57 DoubleData probability = GetVariableValue<DoubleData>("Probability", scope, true); 58 59 bool result = random.NextDouble() < probability.Data; 60 if ((result) && (SubOperators.Count > 0) && (SubOperators[0] != null)) 61 return new AtomicOperation(SubOperators[0], scope); 62 else if ((!result) && (SubOperators.Count > 1) && (SubOperators[1] != null)) 63 return new AtomicOperation(SubOperators[1], scope); 64 return null; 68 public override IExecutionSequence Apply() { 69 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 70 if (RandomParameter.ActualValue.NextDouble() < ProbabilityParameter.ActualValue.Value) { 71 if (FirstBranch != null) next.Insert(0, new ExecutionContext(ExecutionContext.Parent, FirstBranch, ExecutionContext.Scope)); 72 } else { 73 if (SecondBranch != null) next.Insert(0, new ExecutionContext(ExecutionContext.Parent, SecondBranch, ExecutionContext.Scope)); 74 } 75 return next; 65 76 } 66 77 } -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesCreater.cs
r2757 r2773 52 52 } 53 53 54 public override IExecution ContextApply() {54 public override IExecutionSequence Apply() { 55 55 int n = NumberOfSubScopesParameter.ActualValue.Value; 56 56 for (int i = 0; i < n; i++) -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs
r2757 r2773 52 52 } 53 53 54 public override IExecution ContextApply() {54 public override IExecutionSequence Apply() { 55 55 IntData index = SubScopeIndexParameter.ActualValue; 56 56 if (index != null) -
trunk/sources/HeuristicLab.Operators/3.3/SubScopesSorter.cs
r2757 r2773 59 59 } 60 60 61 public override IExecution ContextApply() {61 public override IExecutionSequence Apply() { 62 62 descending = DescendingParameter.ActualValue.Value; 63 63 actualName = LookupParameter<DoubleData>.TranslateName(ValueParameter.Name, ExecutionContext); -
trunk/sources/HeuristicLab.Operators/3.3/UniformParallelSubScopesProcessor.cs
r2757 r2773 35 35 [Creatable("Test")] 36 36 [EmptyStorableClass] 37 public sealed class UniformParallelSubScopesProcessor : SingleSuccessorOperator { 38 private OperatorParameter OperatorParameter { 39 get { return (OperatorParameter)Parameters["Operator"]; } 40 } 41 public IOperator Operator { 42 get { return OperatorParameter.Value; } 43 set { OperatorParameter.Value = value; } 44 } 45 37 public sealed class UniformParallelSubScopesProcessor : SingleCallOperator { 46 38 public UniformParallelSubScopesProcessor() 47 39 : base() { 40 Parameters.Remove("Operator"); 48 41 Parameters.Add(new OperatorParameter("Operator", "The operator which should be applied on all sub-scopes of the current scope in parallel.")); 49 42 } 50 43 51 public override IExecution ContextApply() {44 public override IExecutionSequence Apply() { 52 45 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 53 46 if (Operator != null) { -
trunk/sources/HeuristicLab.Operators/3.3/UniformSequentialSubScopesProcessor.cs
r2757 r2773 35 35 [Creatable("Test")] 36 36 [EmptyStorableClass] 37 public sealed class UniformSequentialSubScopesProcessor : SingleSuccessorOperator { 38 private OperatorParameter OperatorParameter { 39 get { return (OperatorParameter)Parameters["Operator"]; } 40 } 41 public IOperator Operator { 42 get { return OperatorParameter.Value; } 43 set { OperatorParameter.Value = value; } 44 } 45 37 public sealed class UniformSequentialSubScopesProcessor : SingleCallOperator { 46 38 public UniformSequentialSubScopesProcessor() 47 39 : base() { 40 Parameters.Remove("Operator"); 48 41 Parameters.Add(new OperatorParameter("Operator", "The operator which should be applied sequentially on all sub-scopes of the current scope.")); 49 42 } 50 43 51 public override IExecution ContextApply() {44 public override IExecutionSequence Apply() { 52 45 ExecutionContextCollection next = new ExecutionContextCollection(base.Apply()); 53 46 if (Operator != null) { -
trunk/sources/HeuristicLab.Operators/3.3/ValuesCollector.cs
r2772 r2773 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Parameters; … … 32 33 /// An operator which collects the actual values of parameters. 33 34 /// </summary> 34 [Item("ValueCollector", "An operator which collects the actual values of parameters.")] 35 [EmptyStorableClass] 35 [Item("ValuesCollector", "An operator which collects the actual values of parameters.")] 36 36 [Creatable("Test")] 37 public abstract class ValueCollector : SingleSuccessorOperator, IOperator { 38 protected ValueParameter<ParameterCollection> CollectedValuesParameter { 39 get { return (ValueParameter<ParameterCollection>)Parameters["CollectedValues"]; } 40 } 37 public abstract class ValuesCollector : SingleSuccessorOperator, IOperator { 38 private ParameterCollection collectedValues; 39 [Storable] 41 40 public ParameterCollection CollectedValues { 42 get { return CollectedValuesParameter.Value; } 43 set { CollectedValuesParameter.Value = value; } 41 get { return collectedValues; } 42 private set { 43 collectedValues = value; 44 collectedValues.ItemsAdded += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsAdded); 45 collectedValues.ItemsRemoved += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_ItemsRemoved); 46 collectedValues.CollectionReset += new CollectionItemsChangedEventHandler<IParameter>(collectedValues_CollectionReset); 47 } 44 48 } 45 49 46 public Value Collector()50 public ValuesCollector() 47 51 : base() { 48 Parameters.Add(new ValueParameter<ParameterCollection>("CollectedValues", "The parameters whose actual values are collected.", new ParameterCollection()));52 CollectedValues = new ParameterCollection(); 49 53 } 50 54 51 protected override void OnExecutionContextChanged() { 52 foreach (IParameter param in CollectedValues) 53 param.ExecutionContext = ExecutionContext; 55 public override IDeepCloneable Clone(Cloner cloner) { 56 ValuesCollector clone = (ValuesCollector)base.Clone(cloner); 57 clone.CollectedValues = (ParameterCollection)cloner.Clone(collectedValues); 58 return clone; 59 } 60 61 private void collectedValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 62 Parameters.AddRange(e.Items); 63 } 64 private void collectedValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 65 Parameters.RemoveRange(e.Items); 66 } 67 #region NOTE 68 // NOTE: The ItemsReplaced event has not to be handled here as it is only fired when the name (i.e. key) of a parameter 69 // changes. As the same parameter is also contained in the Parameters collection of the operator, the Parameters collection 70 // will react on this name change on its own. 71 #endregion 72 private void collectedValues_CollectionReset(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 73 Parameters.RemoveRange(e.OldItems); 74 Parameters.AddRange(e.Items); 54 75 } 55 76 } -
trunk/sources/HeuristicLab.Operators/3.3/VariableInjector.cs
r2757 r2773 37 37 [Creatable("Test")] 38 38 [EmptyStorableClass] 39 public class VariableInjector : Value Collector {39 public class VariableInjector : ValuesCollector { 40 40 protected ScopeParameter CurrentScopeParameter { 41 41 get { return (ScopeParameter)Parameters["CurrentScope"]; } … … 50 50 } 51 51 52 public override IExecution ContextApply() {52 public override IExecutionSequence Apply() { 53 53 IVariable var; 54 54 foreach (IParameter param in CollectedValues) { -
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r2757 r2773 74 74 } 75 75 76 private IValueParameter<T> GetParameter(out string name) { 77 IValueParameter<T> valueParam = this as IValueParameter<T>; 78 ILookupParameter<T> lookupParam = this as ILookupParameter<T>; 79 ExecutionContext current = ExecutionContext; 80 81 name = Name; 82 while ((valueParam != null) && (lookupParam != null)) { 83 if ((valueParam != null) && (valueParam.Value != null)) return valueParam; 84 if (lookupParam != null) name = lookupParam.ActualName; 85 86 current = current.Parent; 87 while ((current != null) && !current.Operator.Parameters.ContainsKey(name)) 88 current = current.Parent; 89 90 if (current != null) { 91 valueParam = current.Operator.Parameters[name] as IValueParameter<T>; 92 lookupParam = current.Operator.Parameters[name] as ILookupParameter<T>; 93 if ((valueParam == null) && (lookupParam == null)) 94 throw new InvalidOperationException( 95 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 96 name, 97 typeof(IValueParameter<T>).GetPrettyName(), 98 typeof(ILookupParameter<T>).GetPrettyName()) 99 ); 100 } else { 101 valueParam = null; 102 lookupParam = null; 103 } 104 } 105 return null; 106 } 76 107 private IVariable LookupVariable(string name) { 77 108 IScope scope = ExecutionContext.Scope; … … 81 112 } 82 113 protected override IItem GetActualValue() { 83 string name = TranslateName(Name, ExecutionContext); 84 IVariable var = LookupVariable(name); 85 if (var != null) { 86 T value = var.Value as T; 87 if (value == null) 88 throw new InvalidOperationException( 89 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 90 name, 91 typeof(T).GetPrettyName()) 92 ); 93 return value; 114 string name; 115 // try to get local value from context stack 116 IValueParameter<T> param = GetParameter(out name); 117 if (param != null) return param.Value; 118 else { // try to get variable from scope 119 IVariable var = LookupVariable(name); 120 if (var != null) { 121 T value = var.Value as T; 122 if (value == null) 123 throw new InvalidOperationException( 124 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 125 name, 126 typeof(T).GetPrettyName()) 127 ); 128 return value; 129 } 94 130 } 95 131 return null; … … 102 138 typeof(T).GetPrettyName()) 103 139 ); 104 string name = TranslateName(Name, ExecutionContext); 105 IVariable var = LookupVariable(name); 106 if (var != null) var.Value = val; 107 else ExecutionContext.Scope.Variables.Add(new Variable(name, val)); 140 // try to get local value from context stack 141 string name; 142 IValueParameter<T> param = GetParameter(out name); 143 if (param != null) param.Value = val; 144 else { // try to get variable from scope 145 IVariable var = LookupVariable(name); 146 if (var != null) var.Value = val; 147 else ExecutionContext.Scope.Variables.Add(new Variable(name, value)); 148 } 108 149 } 109 150 -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r2757 r2773 33 33 /// </summary> 34 34 [Item("ValueLookupParameter<T>", "A parameter whose value is either defined it the parameter itself or is retrieved from or written to a scope.")] 35 public class ValueLookupParameter<T> : Parameter, IValueLookupParameter<T> where T : class, IItem { 36 [Storable] 37 private string actualName; 38 public string ActualName { 39 get { return actualName; } 40 set { 41 if (value == null) throw new ArgumentNullException(); 42 if (!actualName.Equals(value)) { 43 actualName = value; 44 OnActualNameChanged(); 45 } 46 } 47 } 48 35 public class ValueLookupParameter<T> : LookupParameter<T>, IValueLookupParameter<T> where T : class, IItem { 49 36 private T value; 50 37 [Storable] … … 61 48 } 62 49 63 public new T ActualValue {64 get { return (T)GetActualValue(); }65 set { SetActualValue(value); }66 }67 68 50 public ValueLookupParameter() 69 : base("Anonymous", typeof(T)) { 70 actualName = Name; 51 : base() { 71 52 } 72 53 public ValueLookupParameter(string name) 73 : base(name, typeof(T)) { 74 actualName = Name; 54 : base(name) { 75 55 } 76 56 public ValueLookupParameter(string name, T value) 77 : base(name, typeof(T)) { 78 actualName = Name; 57 : base(name) { 79 58 Value = value; 80 59 } 81 60 public ValueLookupParameter(string name, string description) 82 : base(name, description, typeof(T)) { 83 actualName = Name; 61 : base(name, description) { 84 62 } 85 63 public ValueLookupParameter(string name, string description, T value) 86 : base(name, description, typeof(T)) { 87 actualName = Name; 64 : base(name, description) { 88 65 Value = value; 89 66 } … … 91 68 public override IDeepCloneable Clone(Cloner cloner) { 92 69 ValueLookupParameter<T> clone = (ValueLookupParameter<T>)base.Clone(cloner); 93 clone.actualName = actualName;94 70 clone.Value = (T)cloner.Clone(value); 95 71 return clone; … … 100 76 } 101 77 102 private IValueParameter<T> GetParameter(out string name) {103 IValueParameter<T> valueParam = this;104 ILookupParameter<T> lookupParam = this;105 ExecutionContext current = ExecutionContext;106 107 name = Name;108 while ((valueParam != null) && (lookupParam != null)) {109 if ((valueParam != null) && (valueParam.Value != null)) return valueParam;110 if (lookupParam != null) name = lookupParam.ActualName;111 112 current = current.Parent;113 while ((current != null) && !current.Operator.Parameters.ContainsKey(name))114 current = current.Parent;115 116 if (current != null) {117 valueParam = current.Operator.Parameters[name] as IValueParameter<T>;118 lookupParam = current.Operator.Parameters[name] as ILookupParameter<T>;119 if ((valueParam == null) && (lookupParam == null))120 throw new InvalidOperationException(121 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".",122 name,123 typeof(IValueParameter<T>).GetPrettyName(),124 typeof(ILookupParameter<T>).GetPrettyName())125 );126 } else {127 valueParam = null;128 lookupParam = null;129 }130 }131 return null;132 }133 private IVariable LookupVariable(string name) {134 IScope scope = ExecutionContext.Scope;135 while ((scope != null) && !scope.Variables.ContainsKey(name))136 scope = scope.Parent;137 return scope != null ? scope.Variables[actualName] : null;138 }139 protected override IItem GetActualValue() {140 string name;141 // try to get local value from context stack142 IValueParameter<T> param = GetParameter(out name);143 if (param != null) return param.Value;144 else { // try to get variable from scope145 IVariable var = LookupVariable(name);146 if (var != null) {147 T value = var.Value as T;148 if (value == null)149 throw new InvalidOperationException(150 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".",151 name,152 typeof(T).GetPrettyName())153 );154 return value;155 }156 }157 return null;158 }159 protected override void SetActualValue(IItem value) {160 T val = value as T;161 if (val == null)162 throw new InvalidOperationException(163 string.Format("Type mismatch. Value is not a \"{0}\".",164 typeof(T).GetPrettyName())165 );166 // try to get local value from context stack167 string name;168 IValueParameter<T> param = GetParameter(out name);169 if (param != null) param.Value = val;170 else { // try to get variable from scope171 IVariable var = LookupVariable(name);172 if (var != null) var.Value = val;173 else ExecutionContext.Scope.Variables.Add(new Variable(name, value));174 }175 }176 177 public event EventHandler ActualNameChanged;178 private void OnActualNameChanged() {179 if (ActualNameChanged != null)180 ActualNameChanged(this, new EventArgs());181 OnChanged();182 }183 78 public event EventHandler ValueChanged; 184 79 private void OnValueChanged() { -
trunk/sources/HeuristicLab.Random/3.3
- Property svn:ignore
-
old new 1 *.user 2 HeuristicLabRandomPlugin.cs 1 3 bin 2 4 obj 3 *.user
-
- Property svn:ignore
-
trunk/sources/HeuristicLab.Random/3.3/HeuristicLab.Random-3.3.csproj
r2524 r2773 85 85 </ItemGroup> 86 86 <ItemGroup> 87 < Compile Include="UniformRandomAdder.cs" />88 <Compile Include=" NormalRandomAdder.cs" />87 <None Include="HeuristicLabRandomPlugin.cs.frame" /> 88 <Compile Include="RandomInitializer.cs" /> 89 89 <Compile Include="HeuristicLabRandomPlugin.cs" /> 90 <Compile Include="MersenneTwister.cs" /> 91 <Compile Include="NormalDistributedRandom.cs" /> 92 <Compile Include="NormalRandomizer.cs" /> 90 <Compile Include="MersenneTwister.cs"> 91 <SubType>Code</SubType> 92 </Compile> 93 <Compile Include="NormalDistributedRandom.cs"> 94 <SubType>Code</SubType> 95 </Compile> 93 96 <Compile Include="Properties\AssemblyInfo.cs" /> 94 <Compile Include="RandomInjector.cs" />95 <Compile Include="UniformRandomizer.cs" />96 97 </ItemGroup> 97 98 <ItemGroup> 99 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 100 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 101 <Name>HeuristicLab.Collections-3.3</Name> 102 </ProjectReference> 98 103 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 99 104 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> … … 107 112 <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project> 108 113 <Name>HeuristicLab.Operators-3.3</Name> 114 </ProjectReference> 115 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 116 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 117 <Name>HeuristicLab.Parameters-3.3</Name> 109 118 </ProjectReference> 110 119 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> … … 135 144 set Outdir=$(Outdir) 136 145 137 call PreBuildEvent.cmd</PreBuildEvent> 146 call PreBuildEvent.cmd 147 SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabRandomPlugin.cs.frame" "%25ProjectDir%25\HeuristicLabRandomPlugin.cs"</PreBuildEvent> 138 148 </PropertyGroup> 139 149 </Project> -
trunk/sources/HeuristicLab.Random/3.3/MersenneTwister.cs
r2526 r2773 43 43 /// A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator. 44 44 /// </summary> 45 public class MersenneTwister : ItemBase, IRandom { 45 [Item("MersenneTwister", "A high-quality pseudo random number generator which creates uniformly distributed random numbers.")] 46 public class MersenneTwister : Item, IRandom { 46 47 private const int n = 624, m = 397; 47 48 … … 84 85 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 85 86 /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns> 86 public override I Item Clone(ICloner cloner) {87 public override IDeepCloneable Clone(Cloner cloner) { 87 88 MersenneTwister clone = new MersenneTwister(); 88 89 cloner.RegisterClonedObject(this, clone); -
trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs
r2526 r2773 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using HeuristicLab.Core;26 25 using System.Xml; 27 26 using System.Globalization; 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 … … 35 35 /// See "The Ziggurat Method for Generating Random Variables" (G. Marsaglia and W.W. Tsang 2000). 36 36 /// </summary> 37 public class NormalDistributedRandom : ItemBase, IRandom {38 37 [Item("NormalDistributedRandom", "A pseudo random number generator which uses the Ziggurat method to create normally distributed random numbers.")] 38 public class NormalDistributedRandom : Item, IRandom { 39 39 [Storable] 40 40 private double mu; … … 487 487 488 488 /// <summary> 489 /// TODO: The method is not implemented. 490 /// </summary> 491 /// <returns>TODO</returns> 489 /// This method is not implemented. 490 /// </summary> 492 491 public int Next() { 493 throw new Exception("The method or operation is not implemented."); 494 } 495 496 /// <summary> 497 /// TODO: The method is not implemented. 498 /// </summary> 499 /// <param name="maxVal">TODO</param> 500 /// <returns>TODO</returns> 492 throw new NotImplementedException(); 493 } 494 495 /// <summary> 496 /// This method is not implemented. 497 /// </summary> 501 498 public int Next(int maxVal) { 502 throw new Exception("The method or operation is not implemented."); 503 } 504 505 /// <summary> 506 /// TODO: The method is not implemented. 507 /// </summary> 508 /// <param name="minVal">TODO</param> 509 /// <param name="maxVal">TODO</param> 510 /// <returns>TODO</returns> 499 throw new NotImplementedException(); 500 } 501 502 /// <summary> 503 /// This method is not implemented. 504 /// </summary> 511 505 public int Next(int minVal, int maxVal) { 512 throw new Exception("The method or operation is not implemented.");506 throw new NotImplementedException(); 513 507 } 514 508 … … 561 555 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 562 556 /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns> 563 public override I Item Clone(ICloner cloner) {557 public override IDeepCloneable Clone(Cloner cloner) { 564 558 NormalDistributedRandom clone = new NormalDistributedRandom((IRandom)cloner.Clone(uniform), mu, sigma); 565 559 cloner.RegisterClonedObject(this, clone); -
trunk/sources/HeuristicLab.Random/3.3/Properties/AssemblyInfo.frame
r1688 r2773 23 23 using System.Runtime.CompilerServices; 24 24 using System.Runtime.InteropServices; 25 using HeuristicLab.PluginInfrastructure;26 25 27 26 // General Information about an assembly is controlled through the following … … 33 32 [assembly: AssemblyCompany("")] 34 33 [assembly: AssemblyProduct("HeuristicLab")] 35 [assembly: AssemblyCopyright("(c) 2002-20 08HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2010 HEAL")] 36 35 [assembly: AssemblyTrademark("")] 37 36 [assembly: AssemblyCulture("")] … … 54 53 // You can specify all the values or you can default the Revision and Build Numbers 55 54 // by using the '*' as shown below: 56 [assembly: AssemblyVersion("3.3.0. $WCREV$")]55 [assembly: AssemblyVersion("3.3.0.0")] 57 56 [assembly: AssemblyFileVersion("3.3.0.$WCREV$")] 58 [assembly: AssemblyBuildDate("$WCNOW$")] -
trunk/sources/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs
r2757 r2773 57 57 protected override void ProcessNextOperator() { 58 58 currentOperator = null; 59 IExecution Contextnext = ExecutionStack.Pop();59 IExecutionSequence next = ExecutionStack.Pop(); 60 60 ExecutionContextCollection coll = next as ExecutionContextCollection; 61 61 while (coll != null) {
Note: See TracChangeset
for help on using the changeset viewer.