- Timestamp:
- 01/30/17 10:28:58 (8 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs
r14610 r14616 134 134 135 135 #region Configure Ports 136 AddOrchestrationPort<VariegationProblem>(MetaSolverName);137 AddEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality");138 AddOrchestrationPort<VehicleRoutingProblem>(VrpSolverName);139 AddEvaluationPort<Permutation>(VrpSolverName, "TSPTour", "TSPTourLength");140 AddOrchestrationPort<FacilityLocationProblem>(FlpSolverName);141 AddEvaluationPort<BinaryVector>(FlpSolverName, "KnapsackSolution", "Quality");136 Ports.Add(CreateOrchestrationPort<VariegationProblem>(MetaSolverName)); 137 Ports.Add(CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality")); 138 Ports.Add(CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName)); 139 Ports.Add(CreateEvaluationPort<Permutation>(VrpSolverName, "TSPTour", "TSPTourLength")); 140 Ports.Add(CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName)); 141 Ports.Add(CreateEvaluationPort<BinaryVector>(FlpSolverName, "KnapsackSolution", "Quality")); 142 142 143 143 RegisterEvents(); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork.cs
r14613 r14616 31 31 [Item("TtpNetwork", "An abstract base class for TTP optimization networks.")] 32 32 [StorableClass] 33 public abstract class TtpNetwork : Network, IOptimizer { 33 public abstract class TtpNetwork : Network { 34 #region Constants 35 protected const string OrchestratorNodeName = "Orchestrator"; 36 protected const string MetaSolverNodeName = "MetaSolver"; 37 protected const string TspSolverNodeName = "TspSolver"; 38 protected const string KspSolverNodeName = "KspSolver"; 39 #endregion 40 34 41 #region Nodes 35 public TtpOrchestratorNode1 Orchestrator { 36 get { return (TtpOrchestratorNode1)Nodes["Orchestrator"]; } 42 public TtpOrchestratorNode Orchestrator { 43 get { return (TtpOrchestratorNode)Nodes[OrchestratorNodeName]; } 44 protected set { 45 if (Nodes.ContainsKey(OrchestratorNodeName)) 46 throw new InvalidOperationException("Orchestrator already set."); 47 Nodes.Add(value); 48 } 37 49 } 38 50 39 51 public OrchestratedAlgorithmNode MetaSolver { 40 get { return (OrchestratedAlgorithmNode)Nodes["MetaSolver"]; } 52 get { return (OrchestratedAlgorithmNode)Nodes[MetaSolverNodeName]; } 53 protected set { 54 if (Nodes.ContainsKey(MetaSolverNodeName)) 55 throw new InvalidOperationException("MetaSolver already set."); 56 Nodes.Add(value); 57 RegisterEvents(); 58 } 41 59 } 42 60 43 61 public OrchestratedAlgorithmNode TspSolver { 44 get { return (OrchestratedAlgorithmNode)Nodes["TspSolver"]; } 62 get { return (OrchestratedAlgorithmNode)Nodes[TspSolverNodeName]; } 63 protected set { 64 if (Nodes.ContainsKey(TspSolverNodeName)) 65 throw new InvalidOperationException("TspSolver already set."); 66 Nodes.Add(value); 67 } 45 68 } 46 69 47 70 public OrchestratedAlgorithmNode KspSolver { 48 get { return (OrchestratedAlgorithmNode)Nodes["KspSolver"]; } 71 get { return (OrchestratedAlgorithmNode)Nodes[KspSolverNodeName]; } 72 protected set { 73 if (Nodes.ContainsKey(KspSolverNodeName)) 74 throw new InvalidOperationException("KspSolver already set."); 75 Nodes.Add(value); 76 } 49 77 } 50 78 #endregion … … 56 84 } 57 85 protected TtpNetwork() : this("TtpNetwork") { } 58 protected TtpNetwork(string name) : base(name) { 59 Nodes.Add(new TtpOrchestratorNode1("Orchestrator")); 60 Nodes.Add(new OrchestratedAlgorithmNode("MetaSolver")); 61 Nodes.Add(new OrchestratedAlgorithmNode("TspSolver")); 62 Nodes.Add(new OrchestratedAlgorithmNode("KspSolver")); 63 64 RegisterEvents(); 65 } 86 protected TtpNetwork(string name) : base(name) { } 66 87 67 88 [StorableHook(HookType.AfterDeserialization)] … … 70 91 } 71 92 72 pr otected virtualvoid RegisterEvents() {93 private void RegisterEvents() { 73 94 MetaSolver.AlgorithmChanged += MetaSolver_AlgorithmChanged; 74 95 RegisterAlgorithmEvents(); 75 96 } 76 97 77 protected virtual void RegisterAlgorithmEvents() { 98 private void MetaSolver_AlgorithmChanged(object sender, EventArgs e) { 99 RegisterAlgorithmEvents(); 100 } 101 102 private void RegisterAlgorithmEvents() { 78 103 var algorithm = MetaSolver.Algorithm; 79 104 if (algorithm == null) return; … … 86 111 algorithm.Stopped += OnStopped; 87 112 algorithm.ExceptionOccurred += OnExceptionOccurred; 88 }89 90 protected virtual void MetaSolver_AlgorithmChanged(object sender, EventArgs e) {91 RegisterAlgorithmEvents();92 113 } 93 114 … … 103 124 public void Pause() { Orchestrator.Pause(); } 104 125 public void Stop() { Orchestrator.Stop(); } 105 #endregion106 107 private void OnExecutionStateChanged(object sender, EventArgs e) { OnExecutionStateChanged(); }108 private void OnExecutionTimeChanged(object sender, EventArgs e) { OnExecutionTimeChanged(); }109 private void OnPrepared(object sender, EventArgs e) { OnPrepared(); }110 private void OnStarted(object sender, EventArgs e) { OnStarted(); }111 private void OnPaused(object sender, EventArgs e) { OnPaused(); }112 private void OnStopped(object sender, EventArgs e) { OnStopped(); }113 private void OnExceptionOccurred(object sender, EventArgs<Exception> e) { OnExceptionOccurred(e.Value); }114 126 115 127 public event EventHandler ExecutionStateChanged; … … 154 166 if (handler != null) handler(this, new EventArgs<Exception>(exception)); 155 167 } 168 #endregion 169 170 protected void OnExecutionStateChanged(object sender, EventArgs e) { OnExecutionStateChanged(); } 171 protected void OnExecutionTimeChanged(object sender, EventArgs e) { OnExecutionTimeChanged(); } 172 protected void OnPrepared(object sender, EventArgs e) { OnPrepared(); } 173 protected void OnStarted(object sender, EventArgs e) { OnStarted(); } 174 protected void OnPaused(object sender, EventArgs e) { OnPaused(); } 175 protected void OnStopped(object sender, EventArgs e) { OnStopped(); } 176 protected void OnExceptionOccurred(object sender, EventArgs<Exception> e) { OnExceptionOccurred(e.Value); } 156 177 } 157 178 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs
r14610 r14616 38 38 public TtpNetwork1() : this("TtpNetwork1") { } 39 39 public TtpNetwork1(string name) : base(name) { 40 Orchestrator = new TtpOrchestratorNode1(OrchestratorNodeName); 41 MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName); 42 TspSolver = new OrchestratedAlgorithmNode(TspSolverNodeName); 43 KspSolver = new OrchestratedAlgorithmNode(KspSolverNodeName); 44 40 45 var cmaes = new CMAEvolutionStrategy(); 41 46 cmaes.Problem = new VariegationProblem(); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs
r14610 r14616 38 38 public TtpNetwork2() : this("TtpNetwork2") { } 39 39 public TtpNetwork2(string name) : base(name) { 40 Orchestrator = new TtpOrchestratorNode2(OrchestratorNodeName); 41 MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName); 42 TspSolver = new OrchestratedAlgorithmNode(TspSolverNodeName); 43 KspSolver = new OrchestratedAlgorithmNode(KspSolverNodeName); 44 40 45 var cmaes = new CMAEvolutionStrategy(); 41 46 cmaes.Problem = new VariegationProblem(); … … 45 50 46 51 var ls = new LocalSearch(); 47 ls.Problem = Orchestrator. KspParameter.Value;52 ls.Problem = Orchestrator.TspParameter.Value; 48 53 ls.MaximumIterations.Value = 100; 49 54 ls.SampleSize.Value = 2000; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs
r14610 r14616 38 38 public TtpNetwork3() : this("TtpNetwork3") { } 39 39 public TtpNetwork3(string name) : base(name) { 40 Orchestrator = new TtpOrchestratorNode2(OrchestratorNodeName); 41 MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName); 42 TspSolver = new OrchestratedAlgorithmNode(TspSolverNodeName); 43 KspSolver = new OrchestratedAlgorithmNode(KspSolverNodeName); 44 40 45 var cmaes = new CMAEvolutionStrategy(); 41 46 cmaes.Problem = new VariegationProblem(); … … 45 50 46 51 var ls = new LocalSearch(); 47 ls.Problem = Orchestrator. KspParameter.Value;52 ls.Problem = Orchestrator.TspParameter.Value; 48 53 ls.MaximumIterations.Value = 100; 49 54 ls.SampleSize.Value = 2000; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode.cs
r14610 r14616 27 27 using HeuristicLab.Core.Networks; 28 28 using HeuristicLab.Data; 29 using HeuristicLab.Encodings.BinaryVectorEncoding;30 using HeuristicLab.Encodings.PermutationEncoding;31 29 using HeuristicLab.Encodings.RealVectorEncoding; 32 30 using HeuristicLab.Operators; … … 41 39 public abstract class TtpOrchestratorNode : OrchestratorNode { 42 40 #region Constants 43 pr ivateconst string InstanceParameterName = "Instance";44 pr ivateconst string TspParameterName = "TSP";45 pr ivateconst string KspParameterName = "KSP";46 pr ivateconst string AvailabilityParameterName = "Availability";47 pr ivateconst string MinSpeedParameterName = "MinSpeed";48 pr ivateconst string MaxSpeedParameterName = "MaxSpeed";49 pr ivateconst string RentingRatioParameterName = "RentingRatio";50 pr ivateconst string MetaSolverName = "MetaSolver";51 pr ivateconst string TspSolverName = "TspSolver";52 pr ivateconst string KspSolverName = "KspSolver";41 protected const string InstanceParameterName = "Instance"; 42 protected const string TspParameterName = "TSP"; 43 protected const string KspParameterName = "KSP"; 44 protected const string AvailabilityParameterName = "Availability"; 45 protected const string MinSpeedParameterName = "MinSpeed"; 46 protected const string MaxSpeedParameterName = "MaxSpeed"; 47 protected const string RentingRatioParameterName = "RentingRatio"; 48 protected const string MetaSolverName = "MetaSolver"; 49 protected const string TspSolverName = "TspSolver"; 50 protected const string KspSolverName = "KspSolver"; 53 51 #endregion 54 52 … … 100 98 public IMessagePort MetaSolverOrchestrationPort { 101 99 get { return (IMessagePort)Ports[MetaSolverName + OrchestrationPortNameSuffix]; } 100 protected set { 101 string portName = MetaSolverName + OrchestrationPortNameSuffix; 102 if (Ports.ContainsKey(portName)) 103 throw new InvalidOperationException(portName + " already set."); 104 Ports.Add(value); 105 value.ConnectedPortChanged += MetaSolverOrchestrationPort_ConnectedPortChanged; 106 } 102 107 } 103 108 104 109 public IMessagePort MetaSolverEvaluationPort { 105 110 get { return (IMessagePort)Ports[MetaSolverName + EvaluationPortNameSuffix]; } 111 protected set { 112 string portName = MetaSolverName + EvaluationPortNameSuffix; 113 if (Ports.ContainsKey(portName)) 114 throw new InvalidOperationException(portName + " already set."); 115 Ports.Add(value); 116 } 106 117 } 107 118 108 119 public IMessagePort TspSolverOrchestrationPort { 109 120 get { return (IMessagePort)Ports[TspSolverName + OrchestrationPortNameSuffix]; } 121 protected set { 122 string portName = TspSolverName + OrchestrationPortNameSuffix; 123 if (Ports.ContainsKey(portName)) 124 throw new InvalidOperationException(portName + " already set."); 125 Ports.Add(value); 126 value.ConnectedPortChanged += TspSolverOrchestrationPort_ConnectedPortChanged; 127 } 110 128 } 111 129 112 130 public IMessagePort TspSolverEvaluationPort { 113 131 get { return (IMessagePort)Ports[TspSolverName + EvaluationPortNameSuffix]; } 132 protected set { 133 string portName = TspSolverName + EvaluationPortNameSuffix; 134 if (Ports.ContainsKey(portName)) 135 throw new InvalidOperationException(portName + " already set."); 136 Ports.Add(value); 137 } 114 138 } 115 139 116 140 public IMessagePort KspSolverOrchestrationPort { 117 141 get { return (IMessagePort)Ports[KspSolverName + OrchestrationPortNameSuffix]; } 142 protected set { 143 string portName = KspSolverName + OrchestrationPortNameSuffix; 144 if (Ports.ContainsKey(portName)) 145 throw new InvalidOperationException(portName + " already set."); 146 Ports.Add(value); 147 value.ConnectedPortChanged += KspSolverOrchestrationPort_ConnectedPortChanged; 148 } 118 149 } 119 150 120 151 public IMessagePort KspSolverEvaluationPort { 121 152 get { return (IMessagePort)Ports[KspSolverName + EvaluationPortNameSuffix]; } 153 protected set { 154 string portName = KspSolverName + EvaluationPortNameSuffix; 155 if (Ports.ContainsKey(portName)) 156 throw new InvalidOperationException(portName + " already set."); 157 Ports.Add(value); 158 } 122 159 } 123 160 #endregion … … 139 176 protected TtpOrchestratorNode() : this("TtpOrchestratorNode") { } 140 177 protected TtpOrchestratorNode(string name) : base(name) { 141 #region Configure Parameters142 178 Parameters.Add(new FixedValueParameter<TextFileValue>(InstanceParameterName)); 143 179 Parameters.Add(new ValueParameter<TravelingSalesmanProblem>(TspParameterName, new TravelingSalesmanProblem())); … … 147 183 Parameters.Add(new ValueParameter<DoubleValue>(MaxSpeedParameterName, new DoubleValue(1.0))); 148 184 Parameters.Add(new ValueParameter<DoubleValue>(RentingRatioParameterName, new DoubleValue(0.5))); 149 #endregion 150 151 #region Configure Ports 152 AddOrchestrationPort<VariegationProblem>(MetaSolverName); 153 AddEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"); 154 AddOrchestrationPort<TourProfitProblem>(TspSolverName); 155 AddEvaluationPort<Permutation>(TspSolverName, "TSPTour", "TSPTourLength"); 156 AddOrchestrationPort<BinaryKnapsackProblem>(KspSolverName); 157 AddEvaluationPort<BinaryVector>(KspSolverName, "KnapsackSolution", "Quality"); 158 159 RegisterEvents(); 160 #endregion 185 186 InstanceParameter.Value.ToStringChanged += InstanceParameter_Value_ToStringChanged; 161 187 } 162 188 … … 166 192 } 167 193 168 pr otected virtualvoid RegisterEvents() {194 private void RegisterEvents() { 169 195 InstanceParameter.Value.ToStringChanged += InstanceParameter_Value_ToStringChanged; 170 196 MetaSolverOrchestrationPort.ConnectedPortChanged += MetaSolverOrchestrationPort_ConnectedPortChanged; … … 173 199 } 174 200 175 pr ivatevoid InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {201 protected void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) { 176 202 string filePath = InstanceParameter.Value.Value; 177 203 TtpUtils.Import(filePath, out tspCoordinates, out distanceType, … … 196 222 } 197 223 224 protected virtual void MetaSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) { 225 if (MetaSolverOrchestrationPort.ConnectedPort == null) return; 226 227 var node = MetaSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode; 228 if (node == null) return; 229 230 var hook = new HookOperator { Name = "Meta Eval Hook" }; 231 hook.Parameters.Add(new LookupParameter<RealVector>("RealVector") { Hidden = true }); 232 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true }); 233 node.EvalHook = hook; 234 235 node.OrchestrationPort.CloneParametersFromPort(MetaSolverOrchestrationPort); 236 node.EvaluationPort.CloneParametersFromPort(MetaSolverEvaluationPort); 237 node.EvaluationPort.ConnectedPort = MetaSolverEvaluationPort; 238 } 239 240 protected virtual void TspSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) { 241 if (TspSolverOrchestrationPort.ConnectedPort == null) return; 242 243 var node = TspSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode; 244 if (node == null) return; 245 246 node.OrchestrationPort.CloneParametersFromPort(TspSolverOrchestrationPort); 247 } 248 249 protected virtual void KspSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) { 250 if (KspSolverOrchestrationPort.ConnectedPort == null) return; 251 252 var node = KspSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode; 253 if (node == null) return; 254 255 node.OrchestrationPort.CloneParametersFromPort(KspSolverOrchestrationPort); 256 } 257 198 258 public override void Prepare(bool clearRuns = false) { 199 259 Results.Clear(); 200 201 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();202 var msgFlags = OrchestrationMessage.Prepare | OrchestrationMessage.SetEvalHook;203 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns;204 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags);205 var problem = new VariegationProblem();206 problem.Encoding.Length = KspParameter.Value.Length;207 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } });208 metaMsg["Problem"] = problem;209 MetaSolverOrchestrationPort.SendMessage(metaMsg);210 260 } 211 261 … … 255 305 messageActions.Add(MetaSolverEvaluationPort, MetaSolverEvaluationPortMessage); 256 306 messageActions.Add(TspSolverOrchestrationPort, TspSolverOrchestrationPortMessage); 257 messageActions.Add(TspSolverEvaluationPort, TspSolverEvaluationPortMessage);258 307 messageActions.Add(KspSolverOrchestrationPort, KspSolverOrchestrationPortMessage); 259 messageActions.Add(KspSolverEvaluationPort, KspSolverEvaluationPortMessage);260 308 261 309 messageActions[port](message); … … 291 339 private void KspSolverEvaluationPortMessage(IMessage message) { } 292 340 #endregion 293 294 #region Event Handlers295 private void MetaSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {296 if (MetaSolverOrchestrationPort.ConnectedPort == null) return;297 298 var node = MetaSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;299 if (node == null) return;300 301 var hook = new HookOperator { Name = "Meta Eval Hook" };302 hook.Parameters.Add(new LookupParameter<RealVector>("RealVector") { Hidden = true });303 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });304 node.EvalHook = hook;305 306 node.OrchestrationPort.CloneParametersFromPort(MetaSolverOrchestrationPort);307 node.EvaluationPort.CloneParametersFromPort(MetaSolverEvaluationPort);308 node.EvaluationPort.ConnectedPort = MetaSolverEvaluationPort;309 }310 311 private void TspSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {312 if (TspSolverOrchestrationPort.ConnectedPort == null) return;313 314 var node = TspSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;315 if (node == null) return;316 317 var hook = new HookOperator { Name = "TSP Eval Hook" };318 hook.Parameters.Add(new LookupParameter<Permutation>("TSPTour") { Hidden = true });319 hook.Parameters.Add(new LookupParameter<DoubleValue>("TSPTourLength") { Hidden = true });320 node.EvalHook = hook;321 322 node.OrchestrationPort.CloneParametersFromPort(TspSolverOrchestrationPort);323 node.EvaluationPort.CloneParametersFromPort(TspSolverEvaluationPort);324 node.EvaluationPort.ConnectedPort = TspSolverEvaluationPort;325 }326 327 private void KspSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {328 if (KspSolverOrchestrationPort.ConnectedPort == null) return;329 330 var node = KspSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;331 if (node == null) return;332 333 var hook = new HookOperator { Name = "KSP Eval Hook" };334 hook.Parameters.Add(new LookupParameter<BinaryVector>("KnapsackSolution") { Hidden = true });335 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });336 node.EvalHook = hook;337 338 node.OrchestrationPort.CloneParametersFromPort(KspSolverOrchestrationPort);339 node.EvaluationPort.CloneParametersFromPort(KspSolverEvaluationPort);340 node.EvaluationPort.ConnectedPort = KspSolverEvaluationPort;341 }342 #endregion343 341 } 344 342 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode1.cs
r14610 r14616 42 42 private TtpOrchestratorNode1(TtpOrchestratorNode1 original, Cloner cloner) : base(original, cloner) { } 43 43 public TtpOrchestratorNode1() : this("TtpOrchestratorNode1") { } 44 public TtpOrchestratorNode1(string name) : base(name) { } 44 public TtpOrchestratorNode1(string name) : base(name) { 45 MetaSolverOrchestrationPort = CreateOrchestrationPort<VariegationProblem>(MetaSolverName); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"); 47 TspSolverOrchestrationPort = CreateOrchestrationPort<TourProfitProblem>(TspSolverName); 48 KspSolverOrchestrationPort = CreateOrchestrationPort<BinaryKnapsackProblem>(KspSolverName); 49 } 45 50 46 51 public override IDeepCloneable Clone(Cloner cloner) { 47 52 return new TtpOrchestratorNode1(this, cloner); 53 } 54 55 public override void Prepare(bool clearRuns = false) { 56 base.Prepare(clearRuns); 57 58 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage(); 59 var msgFlags = OrchestrationMessage.Prepare | OrchestrationMessage.SetEvalHook; 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem(); 63 problem.Encoding.Length = KspParameter.Value.Length; 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); 65 metaMsg["Problem"] = problem; 66 MetaSolverOrchestrationPort.SendMessage(metaMsg); 48 67 } 49 68 -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode2.cs
r14610 r14616 41 41 private TtpOrchestratorNode2(TtpOrchestratorNode2 original, Cloner cloner) : base(original, cloner) { } 42 42 public TtpOrchestratorNode2() : this("TtpOrchestratorNode2") { } 43 public TtpOrchestratorNode2(string name) : base(name) { } 43 public TtpOrchestratorNode2(string name) : base(name) { 44 MetaSolverOrchestrationPort = CreateOrchestrationPort<VariegationProblem>(MetaSolverName); 45 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"); 46 TspSolverOrchestrationPort = CreateOrchestrationPort<TravelingSalesmanProblem>(TspSolverName); 47 KspSolverOrchestrationPort = CreateOrchestrationPort<LootProfitProblem>(KspSolverName); 48 } 44 49 45 50 public override IDeepCloneable Clone(Cloner cloner) { 46 51 return new TtpOrchestratorNode2(this, cloner); 52 } 53 54 public override void Prepare(bool clearRuns = false) { 55 base.Prepare(clearRuns); 56 57 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage(); 58 var msgFlags = OrchestrationMessage.Prepare | OrchestrationMessage.SetEvalHook; 59 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 60 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 61 var problem = new VariegationProblem(); 62 problem.Encoding.Length = TspParameter.Value.Coordinates.Rows * 2; 63 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); 64 metaMsg["Problem"] = problem; 65 MetaSolverOrchestrationPort.SendMessage(metaMsg); 47 66 } 48 67 -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode3.cs
r14610 r14616 42 42 private TtpOrchestratorNode3(TtpOrchestratorNode3 original, Cloner cloner) : base(original, cloner) { } 43 43 public TtpOrchestratorNode3() : this("TtpOrchestratorNode3") { } 44 public TtpOrchestratorNode3(string name) : base(name) { } 44 public TtpOrchestratorNode3(string name) : base(name) { 45 MetaSolverOrchestrationPort = CreateOrchestrationPort<VariegationProblem>(MetaSolverName); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"); 47 TspSolverOrchestrationPort = CreateOrchestrationPort<TravelingSalesmanProblem>(TspSolverName); 48 KspSolverOrchestrationPort = CreateOrchestrationPort<BinaryKnapsackProblem>(KspSolverName); 49 } 45 50 46 51 public override IDeepCloneable Clone(Cloner cloner) { 47 52 return new TtpOrchestratorNode3(this, cloner); 53 } 54 55 public override void Prepare(bool clearRuns = false) { 56 base.Prepare(clearRuns); 57 58 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage(); 59 var msgFlags = OrchestrationMessage.Prepare | OrchestrationMessage.SetEvalHook; 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem(); 63 problem.Encoding.Length = KspParameter.Value.Length + TspParameter.Value.Coordinates.Rows * 2; 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); 65 metaMsg["Problem"] = problem; 66 MetaSolverOrchestrationPort.SendMessage(metaMsg); 48 67 } 49 68 -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratorNode.cs
r14610 r14616 36 36 public abstract class OrchestratorNode : Node, IOrchestratorNode { 37 37 #region Constants 38 pr ivateconst string OrchestrationMessageParameterName = "OrchestrationMessage";38 protected const string OrchestrationMessageParameterName = "OrchestrationMessage"; 39 39 protected const string OrchestrationPortNameSuffix = "OrchestrationPort"; 40 40 protected const string EvaluationPortNameSuffix = "EvaluationPort"; … … 97 97 } 98 98 99 protected void AddOrchestrationPort<T>(string solverName) 100 where T : class, IProblem { 99 protected IMessagePort CreateOrchestrationPort<T>(string solverName) where T : class, IProblem { 101 100 var orchestrationPort = new MessagePort(solverName + OrchestrationPortNameSuffix); 102 101 orchestrationPort.Parameters.Add(new PortParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage") { … … 109 108 Type = PortParameterType.Input 110 109 }); 111 Ports.Add(orchestrationPort);110 return orchestrationPort; 112 111 } 113 112 114 protected void AddEvaluationPort<T>(string solverName, string solutionName, string qualityName) where T : class, IItem {113 protected IMessagePort CreateEvaluationPort<T>(string solverName, string solutionName, string qualityName) where T : class, IItem { 115 114 var evaluationPort = new MessagePort(solverName + EvaluationPortNameSuffix); 116 115 evaluationPort.Parameters.Add(new PortParameter<T>(solutionName) { … … 120 119 Type = PortParameterType.Input | PortParameterType.Output 121 120 }); 122 Ports.Add(evaluationPort);121 return evaluationPort; 123 122 } 124 123
Note: See TracChangeset
for help on using the changeset viewer.