Changeset 2773


Ignore:
Timestamp:
02/10/10 03:39:02 (11 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on parameters and operators
Location:
trunk/sources
Files:
7 added
5 deleted
32 edited
6 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab 3.3.sln

    r2772 r2773  
    6868    {DC3D7072-7999-4719-B65D-3997744D5DC1} = {DC3D7072-7999-4719-B65D-3997744D5DC1}
    6969    {BF7D9494-A586-457B-8DF9-ED599F9E6A71} = {BF7D9494-A586-457B-8DF9-ED599F9E6A71}
     70    {F4539FB6-4708-40C9-BE64-0A1390AEA197} = {F4539FB6-4708-40C9-BE64-0A1390AEA197}
    7071    {958B43BC-CC5C-4FA2-8628-2B3B01D890B6} = {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}
    7172    {AB687BBE-1BFE-476B-906D-44237135431D} = {AB687BBE-1BFE-476B-906D-44237135431D}
  • trunk/sources/HeuristicLab.Core/3.3/Engine.cs

    r2757 r2773  
    9393    /// </summary>
    9494    [Storable]
    95     private Stack<IExecutionContext> executionStack;
     95    private Stack<IExecutionSequence> executionStack;
    9696    /// <summary>
    9797    /// Gets the current execution stack.
    9898    /// </summary>
    99     protected Stack<IExecutionContext> ExecutionStack {
     99    protected Stack<IExecutionSequence> ExecutionStack {
    100100      get { return executionStack; }
    101101    }
     
    135135    protected Engine() {
    136136      globalScope = new Scope("Global");
    137       executionStack = new Stack<IExecutionContext>();
     137      executionStack = new Stack<IExecutionSequence>();
    138138      OperatorGraph = new OperatorGraph();
    139139    }
     
    151151      clone.globalScope = (Scope)cloner.Clone(globalScope);
    152152      clone.executionTime = executionTime;
    153       IExecutionContext[] contexts = executionStack.ToArray();
     153      IExecutionSequence[] contexts = executionStack.ToArray();
    154154      for (int i = contexts.Length - 1; i >= 0; i--)
    155         clone.executionStack.Push((IExecutionContext)cloner.Clone(contexts[i]));
     155        clone.executionStack.Push((IExecutionSequence)cloner.Clone(contexts[i]));
    156156      clone.running = running;
    157157      clone.canceled = canceled;
  • trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs

    r2757 r2773  
    2626
    2727namespace HeuristicLab.Core {
    28   public class ExecutionContext : DeepCloneable, IExecutionContext {
     28  public class ExecutionContext : DeepCloneable, IExecutionSequence {
    2929    [Storable]
    3030    private ExecutionContext parent;
  • trunk/sources/HeuristicLab.Core/3.3/ExecutionContextCollection.cs

    r2757 r2773  
    2828
    2929namespace HeuristicLab.Core {
    30   public class ExecutionContextCollection : DeepCloneable, IList<IExecutionContext>, IExecutionContext {
     30  public class ExecutionContextCollection : DeepCloneable, IList<IExecutionSequence>, IExecutionSequence {
    3131    [Storable]
    32     private IList<IExecutionContext> contexts;
     32    private IList<IExecutionSequence> contexts;
    3333
    3434    [Storable]
     
    4040
    4141    public ExecutionContextCollection() {
    42       contexts = new List<IExecutionContext>();
     42      contexts = new List<IExecutionSequence>();
    4343      parallel = false;
    4444    }
    45     public ExecutionContextCollection(IEnumerable<IExecutionContext> collection) {
    46       contexts = new List<IExecutionContext>(collection.Where(e => e != null));
     45    public ExecutionContextCollection(IEnumerable<IExecutionSequence> collection) {
     46      contexts = new List<IExecutionSequence>(collection.Where(e => e != null));
    4747      parallel = false;
    4848    }
    49     public ExecutionContextCollection(params IExecutionContext[] list) {
    50       contexts = new List<IExecutionContext>(list.Where(e => e != null));
     49    public ExecutionContextCollection(params IExecutionSequence[] list) {
     50      contexts = new List<IExecutionSequence>(list.Where(e => e != null));
    5151      parallel = false;
    5252    }
     
    5757      clone.parallel = parallel;
    5858      for (int i = 0; i < contexts.Count; i++)
    59         clone.contexts.Add((IExecutionContext)cloner.Clone(contexts[i]));
     59        clone.contexts.Add((IExecutionSequence)cloner.Clone(contexts[i]));
    6060      return clone;
    6161    }
    6262
    6363    #region IList<IExecutionContext> Members
    64     public int IndexOf(IExecutionContext item) {
     64    public int IndexOf(IExecutionSequence item) {
    6565      return contexts.IndexOf(item);
    6666    }
    67     public void Insert(int index, IExecutionContext item) {
     67    public void Insert(int index, IExecutionSequence item) {
    6868      if (item != null) contexts.Insert(index, item);
    6969    }
     
    7171      contexts.RemoveAt(index);
    7272    }
    73     public IExecutionContext this[int index] {
     73    public IExecutionSequence this[int index] {
    7474      get { return contexts[index]; }
    7575      set { if (value != null) contexts[index] = value; }
     
    7878
    7979    #region ICollection<IExecutionContext> Members
    80     public void Add(IExecutionContext item) {
     80    public void Add(IExecutionSequence item) {
    8181      if (item != null) contexts.Add(item);
    8282    }
     
    8484      contexts.Clear();
    8585    }
    86     public bool Contains(IExecutionContext item) {
     86    public bool Contains(IExecutionSequence item) {
    8787      return contexts.Contains(item);
    8888    }
    89     public void CopyTo(IExecutionContext[] array, int arrayIndex) {
     89    public void CopyTo(IExecutionSequence[] array, int arrayIndex) {
    9090      contexts.CopyTo(array, arrayIndex);
    9191    }
     
    9696      get { return contexts.IsReadOnly; }
    9797    }
    98     public bool Remove(IExecutionContext item) {
     98    public bool Remove(IExecutionSequence item) {
    9999      return contexts.Remove(item);
    100100    }
     
    102102
    103103    #region IEnumerable<IExecutionContext> Members
    104     public IEnumerator<IExecutionContext> GetEnumerator() {
     104    public IEnumerator<IExecutionSequence> GetEnumerator() {
    105105      return contexts.GetEnumerator();
    106106    }
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r2757 r2773  
    104104    <Compile Include="ChangedEventArgs.cs" />
    105105    <None Include="HeuristicLabCorePlugin.cs.frame" />
    106     <Compile Include="Interfaces\IExecutionContext.cs" />
     106    <Compile Include="Interfaces\IExecutionSequence.cs" />
    107107    <Compile Include="Interfaces\IValueLookupParameter.cs" />
    108108    <Compile Include="Interfaces\IValueParameter.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IExecutionSequence.cs

    r2772 r2773  
    3030  /// Interface which represents an execution context.
    3131  /// </summary>
    32   public interface IExecutionContext : IDeepCloneable { }
     32  public interface IExecutionSequence : IDeepCloneable { }
    3333}
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IOperator.cs

    r2757 r2773  
    4444    /// <param name="scope">The scope where to execute the current instance.</param>
    4545    /// <returns>The next operation.</returns>
    46     IExecutionContext Execute(ExecutionContext context);
     46    IExecutionSequence Execute(ExecutionContext context);
    4747    /// <summary>
    4848    /// Aborts the current operator.
  • trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj

    r2756 r2773  
    5858    </Compile>
    5959    <None Include="HeuristicLabOperatorsViewsPlugin.cs.frame" />
    60     <Compile Include="MultipleSuccessorsOperatorView.cs">
     60    <Compile Include="MultipleCallsOperatorView.cs">
    6161      <SubType>UserControl</SubType>
    6262    </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>
    6571    </Compile>
    6672    <Compile Include="HeuristicLabOperatorsViewsPlugin.cs" />
  • trunk/sources/HeuristicLab.Operators.Views/3.3/MultipleCallsOperatorView.Designer.cs

    r2772 r2773  
    2121
    2222namespace HeuristicLab.Operators.Views {
    23   partial class MultipleSuccessorsOperatorView {
     23  partial class MultipleCallsOperatorView {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4646    private void InitializeComponent() {
    4747      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();
    5050      this.parametersTabPage = new System.Windows.Forms.TabPage();
    5151      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    5252      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5353      this.tabControl.SuspendLayout();
    54       this.successorsTabPage.SuspendLayout();
     54      this.operatorsTabPage.SuspendLayout();
    5555      this.parametersTabPage.SuspendLayout();
    5656      this.SuspendLayout();
     
    7373                  | System.Windows.Forms.AnchorStyles.Left)
    7474                  | System.Windows.Forms.AnchorStyles.Right)));
    75       this.tabControl.Controls.Add(this.successorsTabPage);
     75      this.tabControl.Controls.Add(this.operatorsTabPage);
    7676      this.tabControl.Controls.Add(this.parametersTabPage);
    7777      this.tabControl.Location = new System.Drawing.Point(0, 118);
     
    8181      this.tabControl.TabIndex = 4;
    8282      //
    83       // successorsTabPage
     83      // operatorsTabPage
    8484      //
    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;
    9393      //
    94       // successorsListView
     94      // operatorListView
    9595      //
    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)
    9797                  | System.Windows.Forms.AnchorStyles.Left)
    9898                  | 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;
    105105      //
    106106      // parametersTabPage
     
    127127      this.parameterCollectionView.TabIndex = 0;
    128128      //
    129       // MultipleSuccessorsOperatorView
     129      // MultipleCallsOperatorView
    130130      //
    131131      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    132132      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    133133      this.Controls.Add(this.tabControl);
    134       this.Name = "MultipleSuccessorsOperatorView";
     134      this.Name = "MultipleCallsOperatorView";
    135135      this.Size = new System.Drawing.Size(486, 482);
    136136      this.Controls.SetChildIndex(this.tabControl, 0);
     
    141141      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    142142      this.tabControl.ResumeLayout(false);
    143       this.successorsTabPage.ResumeLayout(false);
     143      this.operatorsTabPage.ResumeLayout(false);
    144144      this.parametersTabPage.ResumeLayout(false);
    145145      this.ResumeLayout(false);
     
    151151
    152152    protected System.Windows.Forms.TabControl tabControl;
    153     protected System.Windows.Forms.TabPage successorsTabPage;
     153    protected System.Windows.Forms.TabPage operatorsTabPage;
    154154    protected System.Windows.Forms.TabPage parametersTabPage;
    155155    private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
    156     private HeuristicLab.Core.Views.OperatorListView successorsListView;
     156    private HeuristicLab.Core.Views.OperatorListView operatorListView;
    157157  }
    158158}
  • trunk/sources/HeuristicLab.Operators.Views/3.3/MultipleCallsOperatorView.cs

    r2772 r2773  
    3535  /// The base class for visual representations of items.
    3636  /// </summary>
    37   [Content(typeof(MultipleSuccessorsOperator), true)]
    38   public partial class MultipleSuccessorsOperatorView : NamedItemView {
    39     public new MultipleSuccessorsOperator Content {
    40       get { return (MultipleSuccessorsOperator)base.Content; }
     37  [Content(typeof(MultipleCallsOperator), true)]
     38  public partial class MultipleCallsOperatorView : NamedItemView {
     39    public new MultipleCallsOperator Content {
     40      get { return (MultipleCallsOperator)base.Content; }
    4141      set { base.Content = value; }
    4242    }
     
    4545    /// Initializes a new instance of <see cref="ItemBaseView"/>.
    4646    /// </summary>
    47     public MultipleSuccessorsOperatorView() {
     47    public MultipleCallsOperatorView() {
    4848      InitializeComponent();
    4949    }
     
    5252    /// </summary>
    5353    /// <param name="item">The item that should be displayed.</param>
    54     public MultipleSuccessorsOperatorView(MultipleSuccessorsOperator content)
     54    public MultipleCallsOperatorView(MultipleCallsOperator content)
    5555      : this() {
    5656      Content = content;
     
    6060      base.OnContentChanged();
    6161      if (Content == null) {
    62         successorsListView.Content = null;
     62        operatorListView.Content = null;
    6363        parameterCollectionView.Content = null;
    6464        tabControl.Enabled = false;
    6565      } else {
    66         successorsListView.Content = Content.Successors;
     66        operatorListView.Content = Content.Operators;
    6767        parameterCollectionView.Content = ((IOperator)Content).Parameters;
    6868        tabControl.Enabled = true;
  • trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs

    r2757 r2773  
    6868    }
    6969
    70     public override IExecutionContext Apply() {
     70    public override IExecutionSequence Apply() {
    7171      ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
    7272      if (operatorGraph.InitialOperator != null)
  • trunk/sources/HeuristicLab.Operators/3.3/Comparator.cs

    r2757 r2773  
    6161    }
    6262
    63     public override IExecutionContext Apply() {
     63    public override IExecutionSequence Apply() {
    6464      IItem left = LeftSideParameter.ActualValue;
    6565      IItem right = RightSideParameter.ActualValue;
  • trunk/sources/HeuristicLab.Operators/3.3/ConditionalBranch.cs

    r2757 r2773  
    6262    }
    6363
    64     public override IExecutionContext Apply() {
     64    public override IExecutionSequence Apply() {
    6565      ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
    6666      if (ConditionParameter.ActualValue.Value) {
  • trunk/sources/HeuristicLab.Operators/3.3/DoubleCounter.cs

    r2757 r2773  
    3030namespace HeuristicLab.Operators {
    3131  /// <summary>
    32   /// Operator which increments a double variable.
     32  /// An operator which increments a double variable.
    3333  /// </summary>
    3434  [Item("DoubleCounter", "An operator which increments a double variable.")]
     
    5353    }
    5454
    55     public override IExecutionContext Apply() {
     55    public override IExecutionSequence Apply() {
    5656      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new DoubleData();
    5757      ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
  • trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r2757 r2773  
    8989    <Compile Include="ConditionalBranch.cs" />
    9090    <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" />
    9197    <Compile Include="ScopeCleaner.cs" />
     98    <Compile Include="SequentialSubScopesProcessor.cs" />
     99    <Compile Include="StochasticBranch.cs" />
    92100    <Compile Include="SubScopesRemover.cs" />
    93101    <Compile Include="SubScopesSorter.cs" />
    94102    <Compile Include="DoubleCounter.cs" />
    95     <Compile Include="ParallelProcessor.cs" />
    96103    <Compile Include="UniformParallelSubScopesProcessor.cs" />
    97104    <Compile Include="UniformSequentialSubScopesProcessor.cs" />
    98     <Compile Include="ValueCollector.cs" />
    99     <Compile Include="MultipleSuccessorsOperator.cs" />
    100     <Compile Include="Counter.cs" />
    101105    <Compile Include="EmptyOperator.cs">
    102106      <SubType>Code</SubType>
     
    105109    <Compile Include="Operator.cs" />
    106110    <Compile Include="Properties\AssemblyInfo.cs" />
    107     <Compile Include="SequentialProcessor.cs" />
    108111    <Compile Include="SingleSuccessorOperator.cs" />
    109112    <Compile Include="SubScopesCreater.cs" />
     113    <Compile Include="ValuesCollector.cs" />
    110114    <Compile Include="VariableInjector.cs">
    111115      <SubType>Code</SubType>
  • trunk/sources/HeuristicLab.Operators/3.3/IntCounter.cs

    r2772 r2773  
    3030namespace HeuristicLab.Operators {
    3131  /// <summary>
    32   /// Operator which increments an integer variable.
     32  /// An operator which increments an integer variable.
    3333  /// </summary>
    34   [Item("Counter", "An operator which increments an integer variable.")]
     34  [Item("IntCounter", "An operator which increments an integer variable.")]
    3535  [EmptyStorableClass]
    3636  [Creatable("Test")]
    37   public sealed class Counter : SingleSuccessorOperator {
     37  public sealed class IntCounter : SingleSuccessorOperator {
    3838    public LookupParameter<IntData> ValueParameter {
    3939      get { return (LookupParameter<IntData>)Parameters["Value"]; }
     
    4747    }
    4848
    49     public Counter()
     49    public IntCounter()
    5050      : base() {
    5151      Parameters.Add(new LookupParameter<IntData>("Value", "The value which should be incremented."));
     
    5353    }
    5454
    55     public override IExecutionContext Apply() {
     55    public override IExecutionSequence Apply() {
    5656      if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntData();
    5757      ValueParameter.ActualValue.Value += IncrementParameter.ActualValue.Value;
  • trunk/sources/HeuristicLab.Operators/3.3/Operator.cs

    r2757 r2773  
    130130
    131131    /// <inheritdoc/>
    132     public virtual IExecutionContext Execute(ExecutionContext context) {
     132    public virtual IExecutionSequence Execute(ExecutionContext context) {
    133133      try {
    134134        Canceled = false;
     
    136136        foreach (IParameter param in Parameters)
    137137          param.ExecutionContext = context;
    138         IExecutionContext next = Apply();
     138        IExecutionSequence next = Apply();
    139139        OnExecuted();
    140140        return next;
     
    156156    /// <param name="scope">The scope where to execute the operator</param>
    157157    /// <returns><c>null</c>.</returns>
    158     public abstract IExecutionContext Apply();
     158    public abstract IExecutionSequence Apply();
    159159
    160160    protected virtual void OnExecutionContextChanged() { }
  • trunk/sources/HeuristicLab.Operators/3.3/ParallelSubScopesProcessor.cs

    r1530 r2773  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Text;
     26using System.Xml;
     27using HeuristicLab.Collections;
    2528using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2731
    2832namespace HeuristicLab.Operators {
    2933  /// <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.
    3135  /// </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() {
    3641    }
    3742
    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      }
    4952      return next;
    5053    }
  • trunk/sources/HeuristicLab.Operators/3.3/Placeholder.cs

    r2772 r2773  
    2323using System.Collections.Generic;
    2424using System.Text;
     25using System.Xml;
    2526using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     27using HeuristicLab.Parameters;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
    2830namespace HeuristicLab.Operators {
    2931  /// <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.
    3233  /// </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"]; }
    3940    }
    4041
    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()
    4643      : 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."));
    4845    }
    4946
    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;
    6053    }
    6154  }
  • trunk/sources/HeuristicLab.Operators/3.3/ScopeCleaner.cs

    r2757 r2773  
    4747    }
    4848
    49     public override IExecutionContext Apply() {
     49    public override IExecutionSequence Apply() {
    5050      CurrentScope.Variables.Clear();
    5151      CurrentScope.SubScopes.Clear();
  • trunk/sources/HeuristicLab.Operators/3.3/SequentialSubScopesProcessor.cs

    r1530 r2773  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Text;
     26using System.Xml;
     27using HeuristicLab.Collections;
    2528using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2731
    2832namespace HeuristicLab.Operators {
    2933  /// <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.
    3135  /// </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() {
    3641    }
    3742
    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      }
    4851      return next;
    4952    }
  • trunk/sources/HeuristicLab.Operators/3.3/SingleSuccessorOperator.cs

    r2757 r2773  
    4949    }
    5050
    51     public override IExecutionContext Apply() {
     51    public override IExecutionSequence Apply() {
    5252      if (Successor != null)
    5353        return new ExecutionContext(ExecutionContext.Parent, Successor, ExecutionContext.Scope);
  • trunk/sources/HeuristicLab.Operators/3.3/StochasticBranch.cs

    r1530 r2773  
    2323using System.Collections.Generic;
    2424using System.Text;
     25using System.Xml;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     28using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2730
    2831namespace HeuristicLab.Operators {
    2932  /// <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.
    3134  /// </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; }
    3658    }
    3759
    38     /// <summary>
    39     /// Initializes a new instance of <see cref="StochasticBranch"/> with two variable infos
    40     /// (<c>Random</c> and <c>Probability</c>).
    41     /// </summary>
    4260    public StochasticBranch()
    4361      : 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."));
    4666    }
    4767
    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;
    6576    }
    6677  }
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesCreater.cs

    r2757 r2773  
    5252    }
    5353
    54     public override IExecutionContext Apply() {
     54    public override IExecutionSequence Apply() {
    5555      int n = NumberOfSubScopesParameter.ActualValue.Value;
    5656      for (int i = 0; i < n; i++)
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesRemover.cs

    r2757 r2773  
    5252    }
    5353
    54     public override IExecutionContext Apply() {
     54    public override IExecutionSequence Apply() {
    5555      IntData index = SubScopeIndexParameter.ActualValue;
    5656      if (index != null)
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesSorter.cs

    r2757 r2773  
    5959    }
    6060
    61     public override IExecutionContext Apply() {
     61    public override IExecutionSequence Apply() {
    6262      descending = DescendingParameter.ActualValue.Value;
    6363      actualName = LookupParameter<DoubleData>.TranslateName(ValueParameter.Name, ExecutionContext);
  • trunk/sources/HeuristicLab.Operators/3.3/UniformParallelSubScopesProcessor.cs

    r2757 r2773  
    3535  [Creatable("Test")]
    3636  [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 {
    4638    public UniformParallelSubScopesProcessor()
    4739      : base() {
     40      Parameters.Remove("Operator");
    4841      Parameters.Add(new OperatorParameter("Operator", "The operator which should be applied on all sub-scopes of the current scope in parallel."));
    4942    }
    5043
    51     public override IExecutionContext Apply() {
     44    public override IExecutionSequence Apply() {
    5245      ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
    5346      if (Operator != null) {
  • trunk/sources/HeuristicLab.Operators/3.3/UniformSequentialSubScopesProcessor.cs

    r2757 r2773  
    3535  [Creatable("Test")]
    3636  [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 {
    4638    public UniformSequentialSubScopesProcessor()
    4739      : base() {
     40      Parameters.Remove("Operator");
    4841      Parameters.Add(new OperatorParameter("Operator", "The operator which should be applied sequentially on all sub-scopes of the current scope."));
    4942    }
    5043
    51     public override IExecutionContext Apply() {
     44    public override IExecutionSequence Apply() {
    5245      ExecutionContextCollection next = new ExecutionContextCollection(base.Apply());
    5346      if (Operator != null) {
  • trunk/sources/HeuristicLab.Operators/3.3/ValuesCollector.cs

    r2772 r2773  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Collections;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Parameters;
     
    3233  /// An operator which collects the actual values of parameters.
    3334  /// </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.")]
    3636  [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]
    4140    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      }
    4448    }
    4549
    46     public ValueCollector()
     50    public ValuesCollector()
    4751      : base() {
    48       Parameters.Add(new ValueParameter<ParameterCollection>("CollectedValues", "The parameters whose actual values are collected.", new ParameterCollection()));
     52      CollectedValues = new ParameterCollection();
    4953    }
    5054
    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);
    5475    }
    5576  }
  • trunk/sources/HeuristicLab.Operators/3.3/VariableInjector.cs

    r2757 r2773  
    3737  [Creatable("Test")]
    3838  [EmptyStorableClass]
    39   public class VariableInjector : ValueCollector {
     39  public class VariableInjector : ValuesCollector {
    4040    protected ScopeParameter CurrentScopeParameter {
    4141      get { return (ScopeParameter)Parameters["CurrentScope"]; }
     
    5050    }
    5151
    52     public override IExecutionContext Apply() {
     52    public override IExecutionSequence Apply() {
    5353      IVariable var;
    5454      foreach (IParameter param in CollectedValues) {
  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r2757 r2773  
    7474    }
    7575
     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    }
    76107    private IVariable LookupVariable(string name) {
    77108      IScope scope = ExecutionContext.Scope;
     
    81112    }
    82113    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        }
    94130      }
    95131      return null;
     
    102138                        typeof(T).GetPrettyName())
    103139        );
    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      }
    108149    }
    109150
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r2757 r2773  
    3333  /// </summary>
    3434  [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 {
    4936    private T value;
    5037    [Storable]
     
    6148    }
    6249
    63     public new T ActualValue {
    64       get { return (T)GetActualValue(); }
    65       set { SetActualValue(value); }
    66     }
    67 
    6850    public ValueLookupParameter()
    69       : base("Anonymous", typeof(T)) {
    70       actualName = Name;
     51      : base() {
    7152    }
    7253    public ValueLookupParameter(string name)
    73       : base(name, typeof(T)) {
    74       actualName = Name;
     54      : base(name) {
    7555    }
    7656    public ValueLookupParameter(string name, T value)
    77       : base(name, typeof(T)) {
    78       actualName = Name;
     57      : base(name) {
    7958      Value = value;
    8059    }
    8160    public ValueLookupParameter(string name, string description)
    82       : base(name, description, typeof(T)) {
    83       actualName = Name;
     61      : base(name, description) {
    8462    }
    8563    public ValueLookupParameter(string name, string description, T value)
    86       : base(name, description, typeof(T)) {
    87       actualName = Name;
     64      : base(name, description) {
    8865      Value = value;
    8966    }
     
    9168    public override IDeepCloneable Clone(Cloner cloner) {
    9269      ValueLookupParameter<T> clone = (ValueLookupParameter<T>)base.Clone(cloner);
    93       clone.actualName = actualName;
    9470      clone.Value = (T)cloner.Clone(value);
    9571      return clone;
     
    10076    }
    10177
    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 stack
    142       IValueParameter<T> param = GetParameter(out name);
    143       if (param != null) return param.Value;
    144       else {  // try to get variable from scope
    145         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 stack
    167       string name;
    168       IValueParameter<T> param = GetParameter(out name);
    169       if (param != null) param.Value = val;
    170       else {  // try to get variable from scope
    171         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     }
    18378    public event EventHandler ValueChanged;
    18479    private void OnValueChanged() {
  • trunk/sources/HeuristicLab.Random/3.3

    • Property svn:ignore
      •  

        old new  
         1*.user
         2HeuristicLabRandomPlugin.cs
        13bin
        24obj
        3 *.user
  • trunk/sources/HeuristicLab.Random/3.3/HeuristicLab.Random-3.3.csproj

    r2524 r2773  
    8585  </ItemGroup>
    8686  <ItemGroup>
    87     <Compile Include="UniformRandomAdder.cs" />
    88     <Compile Include="NormalRandomAdder.cs" />
     87    <None Include="HeuristicLabRandomPlugin.cs.frame" />
     88    <Compile Include="RandomInitializer.cs" />
    8989    <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>
    9396    <Compile Include="Properties\AssemblyInfo.cs" />
    94     <Compile Include="RandomInjector.cs" />
    95     <Compile Include="UniformRandomizer.cs" />
    9697  </ItemGroup>
    9798  <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>
    98103    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    99104      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
     
    107112      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
    108113      <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>
    109118    </ProjectReference>
    110119    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     
    135144set Outdir=$(Outdir)
    136145
    137 call PreBuildEvent.cmd</PreBuildEvent>
     146call PreBuildEvent.cmd
     147SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\HeuristicLabRandomPlugin.cs.frame" "%25ProjectDir%25\HeuristicLabRandomPlugin.cs"</PreBuildEvent>
    138148  </PropertyGroup>
    139149</Project>
  • trunk/sources/HeuristicLab.Random/3.3/MersenneTwister.cs

    r2526 r2773  
    4343  /// A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator.
    4444  /// </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 {
    4647    private const int n = 624, m = 397;
    4748
     
    8485    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    8586    /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns>
    86     public override IItem Clone(ICloner cloner) {
     87    public override IDeepCloneable Clone(Cloner cloner) {
    8788      MersenneTwister clone = new MersenneTwister();
    8889      cloner.RegisterClonedObject(this, clone);
  • trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs

    r2526 r2773  
    2323using System.Collections.Generic;
    2424using System.Text;
    25 using HeuristicLab.Core;
    2625using System.Xml;
    2726using System.Globalization;
     27using HeuristicLab.Core;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
     
    3535  /// See "The Ziggurat Method for Generating Random Variables" (G. Marsaglia and W.W. Tsang 2000).
    3636  /// </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 {
    3939    [Storable]
    4040    private double mu;
     
    487487
    488488    /// <summary>
    489     /// TODO: The method is not implemented.
    490     /// </summary>
    491     /// <returns>TODO</returns>
     489    /// This method is not implemented.
     490    /// </summary>
    492491    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>
    501498    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>
    511505    public int Next(int minVal, int maxVal) {
    512       throw new Exception("The method or operation is not implemented.");
     506      throw new NotImplementedException();
    513507    }
    514508
     
    561555    /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param>
    562556    /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns>
    563     public override IItem Clone(ICloner cloner) {
     557    public override IDeepCloneable Clone(Cloner cloner) {
    564558      NormalDistributedRandom clone = new NormalDistributedRandom((IRandom)cloner.Clone(uniform), mu, sigma);
    565559      cloner.RegisterClonedObject(this, clone);
  • trunk/sources/HeuristicLab.Random/3.3/Properties/AssemblyInfo.frame

    r1688 r2773  
    2323using System.Runtime.CompilerServices;
    2424using System.Runtime.InteropServices;
    25 using HeuristicLab.PluginInfrastructure;
    2625
    2726// General Information about an assembly is controlled through the following
     
    3332[assembly: AssemblyCompany("")]
    3433[assembly: AssemblyProduct("HeuristicLab")]
    35 [assembly: AssemblyCopyright("(c) 2002-2008 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2010 HEAL")]
    3635[assembly: AssemblyTrademark("")]
    3736[assembly: AssemblyCulture("")]
     
    5453// You can specify all the values or you can default the Revision and Build Numbers
    5554// by using the '*' as shown below:
    56 [assembly: AssemblyVersion("3.3.0.$WCREV$")]
     55[assembly: AssemblyVersion("3.3.0.0")]
    5756[assembly: AssemblyFileVersion("3.3.0.$WCREV$")]
    58 [assembly: AssemblyBuildDate("$WCNOW$")]
  • trunk/sources/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs

    r2757 r2773  
    5757    protected override void ProcessNextOperator() {
    5858      currentOperator = null;
    59       IExecutionContext next = ExecutionStack.Pop();
     59      IExecutionSequence next = ExecutionStack.Pop();
    6060      ExecutionContextCollection coll = next as ExecutionContextCollection;
    6161      while (coll != null) {
Note: See TracChangeset for help on using the changeset viewer.