Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/30/14 02:14:09 (10 years ago)
Author:
swagner
Message:

#2205: Worked on basic infrastructure for optimization networks

Location:
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/EventArgs.cs

    r11401 r11406  
    2424
    2525namespace HeuristicLab.Optimization.Networks {
    26   public class OutputInputPortEventArgs<T> : EventArgs where T : class, IItem {
    27     public T Result { get; set; }
     26  public class OutputInputPortEventArgs<TOut, TIn> : EventArgs
     27    where TOut : class, IItem
     28    where TIn : class, IItem {
     29    public TOut Value { get; private set; }
     30    public TIn Result { get; set; }
    2831
    29     public OutputInputPortEventArgs() { }
     32    public OutputInputPortEventArgs(TOut value) {
     33      Value = value;
     34    }
    3035  }
    3136}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11401 r11406  
    5050    <Compile Include="EventArgs.cs" />
    5151    <Compile Include="IInputOutputPort.cs" />
     52    <Compile Include="IAlgorithmNode.cs" />
    5253    <Compile Include="InputOutputPort.cs" />
    5354    <Compile Include="IOutputInputPort.cs" />
     55    <Compile Include="AlgorithmNode.cs" />
    5456    <Compile Include="OutputInputPort.cs" />
    5557    <Compile Include="OutputPort.cs" />
     
    9092      <Name>HeuristicLab.Core-3.3</Name>
    9193    </ProjectReference>
     94    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     95      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
     96      <Name>HeuristicLab.Optimization-3.3</Name>
     97    </ProjectReference>
    9298    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
    9399      <Project>{102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}</Project>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs

    r11401 r11406  
    2121
    2222using HeuristicLab.Core;
     23using System;
    2324
    2425namespace HeuristicLab.Optimization.Networks {
     
    3132    where TOut : class, IItem {
    3233    new IOutputInputPort<TIn, TOut> OutputInputPort { get; set; }
     34
     35    event EventHandler<OutputInputPortEventArgs<TIn, TOut>> ValueReceived;
    3336  }
    3437}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs

    r11401 r11406  
    3333    TIn SendValue(TOut value);
    3434
    35     event EventHandler<OutputInputPortEventArgs<TIn>> ValueSent;
     35    event EventHandler<OutputInputPortEventArgs<TOut, TIn>> ValueSent;
    3636  }
    3737}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs

    r11401 r11406  
    7373    }
    7474
     75    public event EventHandler<OutputInputPortEventArgs<TIn, TOut>> ValueReceived;
     76    protected TOut OnValueReceived(TIn value) {
     77      var args = new OutputInputPortEventArgs<TIn, TOut>(value);
     78      var handler = ValueReceived;
     79      if (handler != null) handler(this, args);
     80      return args.Result;
     81    }
     82
    7583    protected void RegisterOutputInputPortEvents() {
    7684      outputInputPort.ValueSent += OutputInputPort_ValueSent;
     
    7987      outputInputPort.ValueSent -= OutputInputPort_ValueSent;
    8088    }
    81     protected void OutputInputPort_ValueSent(object sender, OutputInputPortEventArgs<TOut> e) {
    82       Value = OutputInputPort.Value;
    83       //TODO: switch threads to decouple value propagation and resulting action
    84       //TODO: clone value?
    85       //TODO: add computed result to event args
     89    protected void OutputInputPort_ValueSent(object sender, OutputInputPortEventArgs<TIn, TOut> e) {
     90      var value = (TIn)e.Value.Clone();
     91      Value = value;
     92      e.Result = OnValueReceived(value);
     93      //DISCUSS: clone value?
     94      //DISCUSS: switch threads to decouple value propagation and resulting action -> should be done in Node?
    8695    }
    8796  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs

    r11401 r11406  
    7979    }
    8080    protected void OutputPort_ValueChanged(object sender, EventArgs e) {
    81       Value = OutputPort.Value;
    82       //TODO: switch threads to decouple value propagation and to make communication asynchronous
    83       //TODO: clone value?
    84       //TODO: clone value?
     81      Value = (T)OutputPort.Value.Clone();
     82      //DISCUSS: clone value?
     83      //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node?
    8584    }
    8685  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs

    r11401 r11406  
    4545    public TIn SendValue(TOut value) {
    4646      Value = value;
    47       return OnValueSent();
     47      return OnValueSent(value);
    4848    }
    4949    public object SendValue(object value) {
     
    5757    }
    5858
    59     public event EventHandler<OutputInputPortEventArgs<TIn>> ValueSent;
    60     protected virtual TIn OnValueSent() {
    61       var args = new OutputInputPortEventArgs<TIn>();
     59    public event EventHandler<OutputInputPortEventArgs<TOut, TIn>> ValueSent;
     60    protected virtual TIn OnValueSent(TOut value) {
     61      var args = new OutputInputPortEventArgs<TOut, TIn>(value);
    6262      var handler = ValueSent;
    6363      if (handler != null) handler(this, args);
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame

    r11401 r11406  
    3434//  [PluginDependency("HeuristicLab.Data", "3.3")]
    3535//  [PluginDependency("HeuristicLab.Parameters", "3.3")]
     36  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3637  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3738  public class HeuristicLabOptimizationNetworksPlugin : PluginBase {
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs

    r11401 r11406  
    3939      get { return value; }
    4040      protected set {
    41         if (value != this.value) {
    42           DeregisterValueEvents();
    43           this.value = value;
    44           RegisterValueEvents();
    45           OnValueChanged();
    46         }
     41        DeregisterValueEvents();
     42        this.value = value;
     43        RegisterValueEvents();
     44        OnValueChanged();
    4745      }
    4846    }
     
    7371    public event EventHandler ValueChanged;
    7472    protected virtual void OnValueChanged() {
    75       EventHandler handler = ValueChanged;
     73      var handler = ValueChanged;
    7674      if (handler != null) handler(this, EventArgs.Empty);
    7775      OnToStringChanged();
Note: See TracChangeset for help on using the changeset viewer.