Changeset 14624
- Timestamp:
- 01/31/17 13:58:50 (8 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratedAlgorithmNode.cs
r14611 r14624 65 65 [StorableConstructor] 66 66 protected OrchestratedAlgorithmNode(bool deserializing) : base(deserializing) { } 67 protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner) : base(original, cloner) { 67 protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner) 68 : base(original, cloner) { 68 69 EvalHook = cloner.Clone(original.EvalHook); 69 70 RegisterEvents(); 70 71 } 71 72 public OrchestratedAlgorithmNode() : this("OrchestratedAlgorithmNode") { } 72 public OrchestratedAlgorithmNode(string name) : base(name) { 73 public OrchestratedAlgorithmNode(string name) 74 : base(name) { 73 75 var orchestrationPort = new MessagePort(OrchestrationPortName); 74 76 Ports.Add(orchestrationPort); … … 95 97 #region Port Events 96 98 private void OrchestrationPort_MessageReceived(object sender, EventArgs<IMessage, CancellationToken> e) { 97 var message = ((EnumValue<OrchestrationMessage>)e.Value["OrchestrationMessage"]).Value; 99 var message = e.Value; 100 var orchestrationMessage = ((EnumValue<OrchestrationMessage>)message["OrchestrationMessage"]).Value; 98 101 99 102 #region Prepare 100 if ( message.HasFlag(OrchestrationMessage.Prepare)) {103 if (orchestrationMessage.HasFlag(OrchestrationMessage.Prepare)) { 101 104 switch (Algorithm.ExecutionState) { 102 105 case ExecutionState.Prepared: … … 107 110 var prob = (IHeuristicOptimizationProblem)problemMsgVal.Value.Clone(); 108 111 109 if ( message.HasFlag(OrchestrationMessage.SetEvalHook)) {112 if (orchestrationMessage.HasFlag(OrchestrationMessage.SetEvalHook)) { 110 113 var instEval = prob.Evaluator as InstrumentedOperator; 111 114 if (instEval != null && EvalHook != null) instEval.AfterExecutionOperators.Add(EvalHook); … … 137 140 } 138 141 139 Algorithm.Prepare( message.HasFlag(OrchestrationMessage.ClearRuns));142 Algorithm.Prepare(orchestrationMessage.HasFlag(OrchestrationMessage.ClearRuns)); 140 143 } 141 144 break; … … 145 148 146 149 #region Start 147 if ( message.HasFlag(OrchestrationMessage.Start)) {150 if (orchestrationMessage.HasFlag(OrchestrationMessage.Start)) { 148 151 switch (Algorithm.ExecutionState) { 149 152 case ExecutionState.Prepared: … … 172 175 173 176 if (sendResultMessage) { 177 message["Results"] = (ResultCollection)Algorithm.Results.Clone(); 174 178 var msg = OrchestrationPort.PrepareMessage(); 175 179 msg["Results"] = (ResultCollection)Algorithm.Results.Clone(); … … 182 186 183 187 #region Pause 184 if ( message.HasFlag(OrchestrationMessage.Pause)) {188 if (orchestrationMessage.HasFlag(OrchestrationMessage.Pause)) { 185 189 if (Algorithm.ExecutionState == ExecutionState.Started) { 186 190 sendResultMessage = false; 187 191 try { 188 192 Algorithm.Pause(); 189 } catch (InvalidOperationException) { 193 } 194 catch (InvalidOperationException) { 190 195 // ExecutionState might have changed since we accepted the message 191 196 } … … 195 200 196 201 #region Stop 197 if ( message.HasFlag(OrchestrationMessage.Stop)) {202 if (orchestrationMessage.HasFlag(OrchestrationMessage.Stop)) { 198 203 switch (Algorithm.ExecutionState) { 199 204 case ExecutionState.Started: … … 201 206 try { 202 207 Algorithm.Stop(); 203 } catch (InvalidOperationException) { 208 } 209 catch (InvalidOperationException) { 204 210 // ExecutionState might have changed since we accepted the message 205 } catch (NullReferenceException) { 211 } 212 catch (NullReferenceException) { 206 213 // BasicAlgorithm might have stopped since we accepted the message 207 214 // CancellationTokenSource is null in this case -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratorNode.cs
r14616 r14624 35 35 [StorableClass] 36 36 public abstract class OrchestratorNode : Node, IOrchestratorNode { 37 //TODO remove suffixes 37 38 #region Constants 38 39 protected const string OrchestrationMessageParameterName = "OrchestrationMessage"; 39 protected const string OrchestrationPortNameSuffix = " OrchestrationPort";40 protected const string EvaluationPortNameSuffix = " EvaluationPort";40 protected const string OrchestrationPortNameSuffix = ""; 41 protected const string EvaluationPortNameSuffix = ""; 41 42 #endregion 42 43 … … 62 63 [StorableConstructor] 63 64 protected OrchestratorNode(bool deserializing) : base(deserializing) { } 64 protected OrchestratorNode(OrchestratorNode original, Cloner cloner) : base(original, cloner) { 65 protected OrchestratorNode(OrchestratorNode original, Cloner cloner) 66 : base(original, cloner) { 65 67 results = cloner.Clone(original.results); 66 68 parameters = cloner.Clone(original.parameters); … … 69 71 } 70 72 71 protected OrchestratorNode() : base("OrchestratorNode") { 73 protected OrchestratorNode() 74 : base("OrchestratorNode") { 72 75 results = new ResultCollection(); 73 76 parameters = new ParameterCollection(); … … 75 78 readOnlyParameters = null; 76 79 } 77 protected OrchestratorNode(string name) : base(name) { 80 protected OrchestratorNode(string name) 81 : base(name) { 78 82 results = new ResultCollection(); 79 83 parameters = new ParameterCollection(); … … 81 85 readOnlyParameters = null; 82 86 } 83 protected OrchestratorNode(string name, string description) : base(name, description) { 87 protected OrchestratorNode(string name, string description) 88 : base(name, description) { 84 89 results = new ResultCollection(); 85 90 parameters = new ParameterCollection();
Note: See TracChangeset
for help on using the changeset viewer.