Changeset 11520 for branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Nodes/KSPTSPConnector.cs
- Timestamp:
- 11/03/14 01:15:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Nodes/KSPTSPConnector.cs
r11519 r11520 25 25 using HeuristicLab.Encodings.BinaryVectorEncoding; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Problems.TravelingSalesman; 27 28 using System.Linq; 28 29 … … 33 34 [StorableConstructor] 34 35 protected KSPTSPConnector(bool deserializing) : base(deserializing) { } 35 protected KSPTSPConnector(KSPTSPConnector original, Cloner cloner) : base(original, cloner) { } 36 protected KSPTSPConnector(KSPTSPConnector original, Cloner cloner) 37 : base(original, cloner) { 38 RegisterEvents(); 39 } 36 40 public KSPTSPConnector() 37 41 : base("KSPTSPConnector") { 38 42 Initialize(); 43 RegisterEvents(); 39 44 } 40 45 public KSPTSPConnector(string name) 41 46 : base(name) { 42 47 Initialize(); 48 RegisterEvents(); 43 49 } 44 50 public KSPTSPConnector(string name, string description) 45 51 : base(name, description) { 46 52 Initialize(); 53 RegisterEvents(); 54 } 55 56 [StorableHook(HookType.AfterDeserialization)] 57 private void AfterDeserialization() { 58 RegisterEvents(); 47 59 } 48 60 … … 62 74 ksp.Parameters.Add(new PortParameter<DoubleValue>("Quality") { Type = PortParameterType.Input | PortParameterType.Output }); 63 75 ksp.Parameters.Add(new PortParameter<DoubleValue>("TransportCosts") { Type = PortParameterType.Output }); 64 ksp. MessageReceived += Knapsack_MessageReceived;76 ksp.Parameters.Add(new PortParameter<PathTSPTour>("Route") { Type = PortParameterType.Output }); 65 77 66 78 var tsp = new GenericPort("TSP Connector"); 67 79 Ports.Add(tsp); 68 80 tsp.Parameters.Add(new PortParameter<DoubleMatrix>("Coordinates") { Type = PortParameterType.Output }); 69 ksp.Parameters.Add(new PortParameter<DoubleValue>("BestQuality") { Type = PortParameterType.Input }); 81 tsp.Parameters.Add(new PortParameter<PathTSPTour>("Best TSP Solution") { Type = PortParameterType.Input }); 82 tsp.Parameters.Add(new PortParameter<DoubleValue>("BestQuality") { Type = PortParameterType.Input }); 83 } 84 85 protected virtual void RegisterEvents() { 86 var ksp = (IGenericPort)Ports["KSP Connector"]; 87 ksp.MessageReceived += Knapsack_MessageReceived; 70 88 } 71 89 … … 97 115 tspMsg["Coordinates"] = coords; 98 116 tspConnectorPort.SendMessage(tspMsg, e.Value2); 117 var tspSolution = (PathTSPTour)tspMsg["Best TSP Solution"]; 99 118 var tspQuality = ((DoubleValue)tspMsg["BestQuality"]).Value; 100 119 … … 102 121 ((DoubleValue)kspMsg["Quality"]).Value = kspQuality - factor * tspQuality; 103 122 kspMsg["TransportCosts"] = new DoubleValue(factor * tspQuality); 123 kspMsg["Route"] = tspSolution; 104 124 } 105 125 }
Note: See TracChangeset
for help on using the changeset viewer.