- Timestamp:
- 02/01/17 18:25:28 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratedAlgorithmNode.cs
r14631 r14635 73 73 public OrchestratedAlgorithmNode(string name) 74 74 : base(name) { 75 var orchestrationPort = new MessagePort(OrchestrationPortName); 76 Ports.Add(orchestrationPort); 77 78 var evaluationPort = new MessagePort(EvaluationPortName); 79 Ports.Add(evaluationPort); 75 Ports.Add(CreateOrchestrationPort<IProblem>(OrchestrationPortName)); 76 Ports.Add(CreateEvaluationPort<IItem>(EvaluationPortName, "Solution", "Quality")); 80 77 81 78 RegisterEvents(); … … 93 90 private void RegisterEvents() { 94 91 OrchestrationPort.MessageReceived += OrchestrationPort_MessageReceived; 92 } 93 94 protected IMessagePort CreateOrchestrationPort<T>(string portName) where T : class, IProblem { 95 var orchestrationPort = new MessagePort(portName); 96 orchestrationPort.Parameters.Add(new PortParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage") { 97 Type = PortParameterType.Input 98 }); 99 orchestrationPort.Parameters.Add(new PortParameter<T>("Problem") { 100 Type = PortParameterType.Input 101 }); 102 orchestrationPort.Parameters.Add(new PortParameter<ResultCollection>("Results") { 103 Type = PortParameterType.Output 104 }); 105 return orchestrationPort; 106 } 107 108 protected IMessagePort CreateEvaluationPort<T>(string portName, string solutionName, string qualityName) where T : class, IItem { 109 var evaluationPort = new MessagePort(portName); 110 evaluationPort.Parameters.Add(new PortParameter<T>(solutionName) { 111 Type = PortParameterType.Output 112 }); 113 evaluationPort.Parameters.Add(new PortParameter<DoubleValue>(qualityName) { 114 Type = PortParameterType.Input | PortParameterType.Output 115 }); 116 return evaluationPort; 95 117 } 96 118 … … 106 128 case ExecutionState.Paused: 107 129 case ExecutionState.Stopped: 108 IMessageValue problemMsgVal;109 if ( e.Value.Values.TryGetValue("Problem", out problemMsgVal)) {110 var problem = (IProblem)problemMsgVal.Value.Clone();130 var problem = (IProblem)requestMessage["Problem"]; 131 if (problem != null) { 132 problem = (IProblem)problem.Clone(); 111 133 112 134 var heuristicOptimizationProblem = problem as IHeuristicOptimizationProblem; … … 140 162 } 141 163 } 142 143 Algorithm.Prepare(messageFlags.HasFlag(OrchestrationMessage.ClearRuns));144 164 } 165 166 167 Algorithm.Prepare(messageFlags.HasFlag(OrchestrationMessage.ClearRuns)); 145 168 break; 146 169 } … … 192 215 try { 193 216 Algorithm.Pause(); 194 } 195 catch (InvalidOperationException) { 217 } catch (InvalidOperationException) { 196 218 // ExecutionState might have changed since we accepted the message 197 219 } … … 207 229 try { 208 230 Algorithm.Stop(); 209 } 210 catch (InvalidOperationException) { 231 } catch (InvalidOperationException) { 211 232 // ExecutionState might have changed since we accepted the message 212 } 213 catch (NullReferenceException) { 233 } catch (NullReferenceException) { 214 234 // BasicAlgorithm might have stopped since we accepted the message 215 235 // CancellationTokenSource is null in this case
Note: See TracChangeset
for help on using the changeset viewer.