Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/31/17 16:54:03 (8 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • added variegation problem for minimization and maximization
  • refactored some classes
Location:
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3
Files:
2 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/HeuristicLab.Networks.IntegratedOptimization-3.3.csproj

    r14619 r14628  
    131131  <ItemGroup>
    132132    <Compile Include="IOrchestratorNode.cs" />
     133    <Compile Include="MaximizationVariegationProblem.cs" />
     134    <Compile Include="MinimizationVariegationProblem.cs" />
    133135    <Compile Include="OrchestratedAlgorithmNode.cs" />
    134136    <Compile Include="OrchestrationMessage.cs" />
    135137    <Compile Include="OrchestratorNode.cs" />
    136     <Compile Include="VariegationProblem.cs" />
    137138    <None Include="Plugin.cs.frame" />
    138139    <None Include="Properties\AssemblyInfo.cs.frame" />
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratedAlgorithmNode.cs

    r14624 r14628  
    6565    [StorableConstructor]
    6666    protected OrchestratedAlgorithmNode(bool deserializing) : base(deserializing) { }
    67     protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner)
    68       : base(original, cloner) {
     67    protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner) : base(original, cloner) {
    6968      EvalHook = cloner.Clone(original.EvalHook);
    7069      RegisterEvents();
    7170    }
    7271    public OrchestratedAlgorithmNode() : this("OrchestratedAlgorithmNode") { }
    73     public OrchestratedAlgorithmNode(string name)
    74       : base(name) {
     72    public OrchestratedAlgorithmNode(string name) : base(name) {
    7573      var orchestrationPort = new MessagePort(OrchestrationPortName);
    7674      Ports.Add(orchestrationPort);
     
    9795    #region Port Events
    9896    private void OrchestrationPort_MessageReceived(object sender, EventArgs<IMessage, CancellationToken> e) {
    99       var message = e.Value;
    100       var orchestrationMessage = ((EnumValue<OrchestrationMessage>)message["OrchestrationMessage"]).Value;
     97      var requestMessage = e.Value;
     98      var messageFlags = ((EnumValue<OrchestrationMessage>)requestMessage["OrchestrationMessage"]).Value;
    10199
    102100      #region Prepare
    103       if (orchestrationMessage.HasFlag(OrchestrationMessage.Prepare)) {
     101      if (messageFlags.HasFlag(OrchestrationMessage.Prepare)) {
    104102        switch (Algorithm.ExecutionState) {
    105103          case ExecutionState.Prepared:
     
    110108              var prob = (IHeuristicOptimizationProblem)problemMsgVal.Value.Clone();
    111109
    112               if (orchestrationMessage.HasFlag(OrchestrationMessage.SetEvalHook)) {
     110              if (messageFlags.HasFlag(OrchestrationMessage.SetEvalHook)) {
    113111                var instEval = prob.Evaluator as InstrumentedOperator;
    114112                if (instEval != null && EvalHook != null) instEval.AfterExecutionOperators.Add(EvalHook);
     
    140138              }
    141139
    142               Algorithm.Prepare(orchestrationMessage.HasFlag(OrchestrationMessage.ClearRuns));
     140              Algorithm.Prepare(messageFlags.HasFlag(OrchestrationMessage.ClearRuns));
    143141            }
    144142            break;
     
    148146
    149147      #region Start
    150       if (orchestrationMessage.HasFlag(OrchestrationMessage.Start)) {
     148      if (messageFlags.HasFlag(OrchestrationMessage.Start)) {
    151149        switch (Algorithm.ExecutionState) {
    152150          case ExecutionState.Prepared:
     
    175173
    176174            if (sendResultMessage) {
    177               message["Results"] = (ResultCollection)Algorithm.Results.Clone();
    178               var msg = OrchestrationPort.PrepareMessage();
    179               msg["Results"] = (ResultCollection)Algorithm.Results.Clone();
    180               OrchestrationPort.SendMessage(msg);
     175              requestMessage["Results"] = (ResultCollection)Algorithm.Results.Clone();
     176              var responseMessage = OrchestrationPort.PrepareMessage();
     177              responseMessage["Results"] = (ResultCollection)Algorithm.Results.Clone();
     178              OrchestrationPort.SendMessage(responseMessage);
    181179            } else sendResultMessage = true;
    182180            break;
     
    186184
    187185      #region Pause
    188       if (orchestrationMessage.HasFlag(OrchestrationMessage.Pause)) {
     186      if (messageFlags.HasFlag(OrchestrationMessage.Pause)) {
    189187        if (Algorithm.ExecutionState == ExecutionState.Started) {
    190188          sendResultMessage = false;
    191189          try {
    192190            Algorithm.Pause();
    193           }
    194           catch (InvalidOperationException) {
     191          } catch (InvalidOperationException) {
    195192            // ExecutionState might have changed since we accepted the message
    196193          }
     
    200197
    201198      #region Stop
    202       if (orchestrationMessage.HasFlag(OrchestrationMessage.Stop)) {
     199      if (messageFlags.HasFlag(OrchestrationMessage.Stop)) {
    203200        switch (Algorithm.ExecutionState) {
    204201          case ExecutionState.Started:
     
    206203            try {
    207204              Algorithm.Stop();
    208             }
    209             catch (InvalidOperationException) {
     205            } catch (InvalidOperationException) {
    210206              // ExecutionState might have changed since we accepted the message
    211             }
    212             catch (NullReferenceException) {
     207            } catch (NullReferenceException) {
    213208              // BasicAlgorithm might have stopped since we accepted the message
    214209              // CancellationTokenSource is null in this case
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratorNode.cs

    r14624 r14628  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Optimization;
    30 using HeuristicLab.Parameters;
    3130using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3231
     
    3534  [StorableClass]
    3635  public abstract class OrchestratorNode : Node, IOrchestratorNode {
    37     //TODO remove suffixes
    38     #region Constants
    39     protected const string OrchestrationMessageParameterName = "OrchestrationMessage";
    40     protected const string OrchestrationPortNameSuffix = "";
    41     protected const string EvaluationPortNameSuffix = "";
    42     #endregion
    43 
    4436    [Storable]
    4537    private ParameterCollection parameters;
     
    6355    [StorableConstructor]
    6456    protected OrchestratorNode(bool deserializing) : base(deserializing) { }
    65     protected OrchestratorNode(OrchestratorNode original, Cloner cloner)
    66       : base(original, cloner) {
     57    protected OrchestratorNode(OrchestratorNode original, Cloner cloner) : base(original, cloner) {
    6758      results = cloner.Clone(original.results);
    6859      parameters = cloner.Clone(original.parameters);
     
    7162    }
    7263
    73     protected OrchestratorNode()
    74       : base("OrchestratorNode") {
     64    protected OrchestratorNode() : base("OrchestratorNode") {
    7565      results = new ResultCollection();
    7666      parameters = new ParameterCollection();
    77       Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));
    7867      readOnlyParameters = null;
    7968    }
    80     protected OrchestratorNode(string name)
    81       : base(name) {
     69    protected OrchestratorNode(string name) : base(name) {
    8270      results = new ResultCollection();
    8371      parameters = new ParameterCollection();
    84       Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));
    8572      readOnlyParameters = null;
    8673    }
    87     protected OrchestratorNode(string name, string description)
    88       : base(name, description) {
     74    protected OrchestratorNode(string name, string description) : base(name, description) {
    8975      results = new ResultCollection();
    9076      parameters = new ParameterCollection();
    91       Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));
    9277      readOnlyParameters = null;
    9378    }
     
    10287    }
    10388
    104     protected IMessagePort CreateOrchestrationPort<T>(string solverName) where T : class, IProblem {
    105       var orchestrationPort = new MessagePort(solverName + OrchestrationPortNameSuffix);
     89    protected IMessagePort CreateOrchestrationPort<T>(string portName) where T : class, IProblem {
     90      var orchestrationPort = new MessagePort(portName);
    10691      orchestrationPort.Parameters.Add(new PortParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage") {
    10792        Type = PortParameterType.Output
     
    116101    }
    117102
    118     protected IMessagePort CreateEvaluationPort<T>(string solverName, string solutionName, string qualityName) where T : class, IItem {
    119       var evaluationPort = new MessagePort(solverName + EvaluationPortNameSuffix);
     103    protected IMessagePort CreateEvaluationPort<T>(string portName, string solutionName, string qualityName) where T : class, IItem {
     104      var evaluationPort = new MessagePort(portName);
    120105      evaluationPort.Parameters.Add(new PortParameter<T>(solutionName) {
    121106        Type = PortParameterType.Input
Note: See TracChangeset for help on using the changeset viewer.