Changeset 14621
- Timestamp:
- 01/31/17 09:30:07 (8 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/HeuristicLab.Networks.IntegratedOptimization.LocationRouting-3.3.csproj
r14604 r14621 180 180 <None Include="Properties\AssemblyInfo.cs.frame" /> 181 181 <None Include="Plugin.cs.frame" /> 182 <Compile Include="LrpNetwork.cs" /> 183 <Compile Include="LrpNetwork2.cs" /> 184 <Compile Include="LrpOrchestratorNode.cs" /> 185 <Compile Include="LrpOrchestratorNode2.cs" /> 182 186 <Compile Include="LrpUtils.cs" /> 183 187 <Compile Include="LrpNetwork1.cs" /> -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs
r14613 r14621 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Algorithms.CMAEvolutionStrategy; … … 27 26 using HeuristicLab.Common; 28 27 using HeuristicLab.Core; 29 using HeuristicLab.Core.Networks;30 28 using HeuristicLab.Optimization; 31 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 40 38 [Creatable("Optimization Networks")] 41 39 [StorableClass] 42 public sealed class LrpNetwork1 : Network, IOptimizer { 43 #region Nodes 44 public LrpOrchestratorNode1 Orchestrator { 45 get { return (LrpOrchestratorNode1)Nodes["Orchestrator"]; } 46 } 47 48 public OrchestratedAlgorithmNode MetaSolver { 49 get { return (OrchestratedAlgorithmNode)Nodes["MetaSolver"]; } 50 } 51 52 public OrchestratedAlgorithmNode LrpSolver { 53 get { return (OrchestratedAlgorithmNode)Nodes["LrpSolver"]; } 54 } 55 56 public OrchestratedAlgorithmNode VrpSolver { 57 get { return (OrchestratedAlgorithmNode)Nodes["VrpSolver"]; } 58 } 59 #endregion 60 40 public sealed class LrpNetwork1 : LrpNetwork, IOptimizer { 61 41 [StorableConstructor] 62 42 private LrpNetwork1(bool deserializing) : base(deserializing) { } 63 private LrpNetwork1(LrpNetwork1 original, Cloner cloner) : base(original, cloner) { 64 RegisterEvents(); 65 } 66 public LrpNetwork1() : base("LrpNetwork1") { 67 var orchestratorNode = new LrpOrchestratorNode1("Orchestrator"); 68 Nodes.Add(orchestratorNode); 43 private LrpNetwork1(LrpNetwork1 original, Cloner cloner) : base(original, cloner) { } 44 public LrpNetwork1() : this("LrpNetwork1") { } 45 public LrpNetwork1(string name) : base(name) { 46 Orchestrator = new LrpOrchestratorNode1(OrchestratorNodeName); 47 MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName); 48 FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName); 49 VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName); 69 50 70 var metaSolverNode = new OrchestratedAlgorithmNode("MetaSolver");71 51 var cmaes = new CMAEvolutionStrategy(); 72 52 var vp = new VariegationProblem(); … … 74 54 cmaes.Problem = vp; 75 55 cmaes.MaximumGenerations = 80; 76 metaSolverNode.Algorithm = cmaes; 77 orchestratorNode.MetaSolverOrchestrationPort.ConnectedPort = metaSolverNode.OrchestrationPort; 78 Nodes.Add(metaSolverNode); 56 MetaSolver.Algorithm = cmaes; 57 Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort; 79 58 80 var flpSolverNode = new OrchestratedAlgorithmNode("FlpSolver");81 59 var cplexSolver = new FLPCplexSolver(); 82 60 cplexSolver.Problem = new FacilityLocationProblem(); 83 61 cplexSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0); 84 flpSolverNode.Algorithm = cplexSolver; 85 orchestratorNode.FlpSolverOrchestrationPort.ConnectedPort = flpSolverNode.OrchestrationPort; 86 Nodes.Add(flpSolverNode); 62 FlpSolver.Algorithm = cplexSolver; 63 Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort; 87 64 88 var vrpSolverNode = new OrchestratedAlgorithmNode("VrpSolver");89 65 var ga = new GeneticAlgorithm(); 90 66 ga.Problem = new VehicleRoutingProblem(); … … 97 73 var selector = ga.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single(); 98 74 ga.SelectorParameter.Value = selector; 99 vrpSolverNode.Algorithm = ga; 100 orchestratorNode.VrpSolverOrchestrationPort.ConnectedPort = vrpSolverNode.OrchestrationPort; 101 Nodes.Add(vrpSolverNode); 102 103 RegisterEvents(); 75 VrpSolver.Algorithm = ga; 76 Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort; 104 77 } 105 78 … … 107 80 return new LrpNetwork1(this, cloner); 108 81 } 109 110 [StorableHook(HookType.AfterDeserialization)]111 private void AfterDeserialization() {112 RegisterEvents();113 }114 115 private void RegisterEvents() {116 MetaSolver.AlgorithmChanged += MetaSolver_AlgorithmChanged;117 RegisterAlgorithmEvents();118 }119 120 private void RegisterAlgorithmEvents() {121 var algorithm = MetaSolver.Algorithm;122 if (algorithm == null) return;123 124 algorithm.ExecutionStateChanged += OnExecutionStateChanged;125 algorithm.ExecutionTimeChanged += OnExecutionTimeChanged;126 algorithm.Prepared += OnPrepared;127 algorithm.Started += OnStarted;128 algorithm.Paused += OnPaused;129 algorithm.Stopped += OnStopped;130 algorithm.ExceptionOccurred += OnExceptionOccurred;131 }132 133 private void MetaSolver_AlgorithmChanged(object sender, EventArgs e) {134 RegisterAlgorithmEvents();135 }136 137 #region IOptimizer Members138 public RunCollection Runs { get { return MetaSolver.Algorithm.Runs; } }139 public IEnumerable<IOptimizer> NestedOptimizers { get { yield break; } }140 public ExecutionState ExecutionState { get { return MetaSolver.Algorithm.ExecutionState; } }141 public TimeSpan ExecutionTime { get { return MetaSolver.Algorithm.ExecutionTime; } }142 143 public void Prepare() { Prepare(false); }144 public void Prepare(bool clearRuns) { Orchestrator.Prepare(clearRuns); }145 public void Start() { Orchestrator.StartAsync(); }146 public void Pause() { Orchestrator.Pause(); }147 public void Stop() { Orchestrator.Stop(); }148 #endregion149 150 private void OnExecutionStateChanged(object sender, EventArgs e) { OnExecutionStateChanged(); }151 private void OnExecutionTimeChanged(object sender, EventArgs e) { OnExecutionTimeChanged(); }152 private void OnPrepared(object sender, EventArgs e) { OnPrepared(); }153 private void OnStarted(object sender, EventArgs e) { OnStarted(); }154 private void OnPaused(object sender, EventArgs e) { OnPaused(); }155 private void OnStopped(object sender, EventArgs e) { OnStopped(); }156 private void OnExceptionOccurred(object sender, EventArgs<Exception> e) { OnExceptionOccurred(e.Value); }157 158 public event EventHandler ExecutionStateChanged;159 private void OnExecutionStateChanged() {160 var handler = ExecutionStateChanged;161 if (handler != null) handler(this, EventArgs.Empty);162 }163 164 public event EventHandler ExecutionTimeChanged;165 private void OnExecutionTimeChanged() {166 var handler = ExecutionTimeChanged;167 if (handler != null) handler(this, EventArgs.Empty);168 }169 170 public event EventHandler Prepared;171 private void OnPrepared() {172 var handler = Prepared;173 if (handler != null) handler(this, EventArgs.Empty);174 }175 176 public event EventHandler Started;177 private void OnStarted() {178 var handler = Started;179 if (handler != null) handler(this, EventArgs.Empty);180 }181 182 public event EventHandler Paused;183 private void OnPaused() {184 var handler = Paused;185 if (handler != null) handler(this, EventArgs.Empty);186 }187 188 public event EventHandler Stopped;189 private void OnStopped() {190 var handler = Stopped;191 if (handler != null) handler(this, EventArgs.Empty);192 }193 194 public event EventHandler<EventArgs<Exception>> ExceptionOccurred;195 private void OnExceptionOccurred(Exception exception) {196 var handler = ExceptionOccurred;197 if (handler != null) handler(this, new EventArgs<Exception>(exception));198 }199 82 } 200 83 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs
r14616 r14621 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Text.RegularExpressions;26 using System.Threading;27 24 using HeuristicLab.Common; 28 25 using HeuristicLab.Core; 29 26 using HeuristicLab.Core.Networks; 30 27 using HeuristicLab.Data; 31 using HeuristicLab.Encodings.BinaryVectorEncoding;32 28 using HeuristicLab.Encodings.IntegerVectorEncoding; 33 using HeuristicLab.Encodings.PermutationEncoding;34 29 using HeuristicLab.Encodings.RealVectorEncoding; 35 using HeuristicLab.Operators;36 30 using HeuristicLab.Optimization; 37 using HeuristicLab.Parameters;38 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 39 32 using HeuristicLab.Problems.FacilityLocation; 40 33 using HeuristicLab.Problems.VehicleRouting; 41 using HeuristicLab.Problems.VehicleRouting.Encodings.General;42 34 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 43 35 … … 45 37 [Item("LrpOrchestratorNode1", "Orchestrator for LRP optimization network version 1.")] 46 38 [StorableClass] 47 public sealed class LrpOrchestratorNode1 : OrchestratorNode { 48 #region Constants 49 private const string InstanceParameterName = "Instance"; 50 private const string FlpParameterName = "FLP"; 51 private const string VrpParameterName = "VRP"; 52 private const string MetaSolverName = "MetaSolver"; 53 private const string FlpSolverName = "FlpSolver"; 54 private const string VrpSolverName = "VrpSolver"; 55 #endregion 56 57 private CancellationTokenSource cts; 58 private ResultCollection vrpResults, flpResults; 59 60 [Storable] 61 int nrOfDepots, nrOfCustomers; 62 [Storable] 63 double[,] depotCoordinates = new double[0, 0], customerCoordinates = new double[0, 0]; 64 [Storable] 65 LrpUtils.DistanceType distanceType; 66 [Storable] 67 double[] depotCapacities = new double[0], customerDemands = new double[0], depotCosts = new double[0]; 68 [Storable] 69 double vehicleCapacity, vehicleCost; 70 71 #region Parameters 72 public IFixedValueParameter<TextFileValue> InstanceParameter { 73 get { return (IFixedValueParameter<TextFileValue>)Parameters[InstanceParameterName]; } 74 } 75 76 public IValueParameter<FacilityLocationProblem> FlpParameter { 77 get { return (IValueParameter<FacilityLocationProblem>)Parameters[FlpParameterName]; } 78 } 79 80 public IValueParameter<VehicleRoutingProblem> VrpParameter { 81 get { return (IValueParameter<VehicleRoutingProblem>)Parameters[VrpParameterName]; } 82 } 83 #endregion 84 85 #region Ports 86 public IMessagePort MetaSolverOrchestrationPort { 87 get { return (IMessagePort)Ports[MetaSolverName + OrchestrationPortNameSuffix]; } 88 } 89 90 public IMessagePort MetaSolverEvaluationPort { 91 get { return (IMessagePort)Ports[MetaSolverName + EvaluationPortNameSuffix]; } 92 } 93 94 public IMessagePort FlpSolverOrchestrationPort { 95 get { return (IMessagePort)Ports[FlpSolverName + OrchestrationPortNameSuffix]; } 96 } 97 98 public IMessagePort FlpSolverEvaluationPort { 99 get { return (IMessagePort)Ports[FlpSolverName + EvaluationPortNameSuffix]; } 100 } 101 102 public IMessagePort VrpSolverOrchestrationPort { 103 get { return (IMessagePort)Ports[VrpSolverName + OrchestrationPortNameSuffix]; } 104 } 105 106 public IMessagePort VrpSolverEvaluationPort { 107 get { return (IMessagePort)Ports[VrpSolverName + EvaluationPortNameSuffix]; } 108 } 109 #endregion 110 39 public sealed class LrpOrchestratorNode1 : LrpOrchestratorNode { 111 40 [StorableConstructor] 112 41 private LrpOrchestratorNode1(bool deserializing) : base(deserializing) { } 113 private LrpOrchestratorNode1(LrpOrchestratorNode1 original, Cloner cloner) : base(original, cloner) { 114 nrOfDepots = original.nrOfDepots; 115 nrOfCustomers = original.nrOfCustomers; 116 depotCoordinates = (double[,])original.depotCoordinates.Clone(); 117 customerCoordinates = (double[,])original.customerCoordinates.Clone(); 118 distanceType = original.distanceType; 119 depotCapacities = (double[])original.depotCapacities.Clone(); 120 customerDemands = (double[])original.customerDemands.Clone(); 121 depotCosts = (double[])original.depotCosts.Clone(); 122 vehicleCapacity = original.vehicleCapacity; 123 vehicleCost = original.vehicleCost; 124 125 RegisterEvents(); 126 } 42 private LrpOrchestratorNode1(LrpOrchestratorNode1 original, Cloner cloner) : base(original, cloner) { } 127 43 public LrpOrchestratorNode1() : this("LrpOrchestratorNode1") { } 128 44 public LrpOrchestratorNode1(string name) : base(name) { 129 #region Configure Parameters 130 Parameters.Add(new FixedValueParameter<TextFileValue>(InstanceParameterName)); 131 Parameters.Add(new ValueParameter<FacilityLocationProblem>(FlpParameterName, new FacilityLocationProblem())); 132 Parameters.Add(new ValueParameter<VehicleRoutingProblem>(VrpParameterName, new VehicleRoutingProblem() { ProblemInstance = new CVRPProblemInstance() })); 133 #endregion 134 135 #region Configure Ports 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 143 RegisterEvents(); 144 #endregion 45 MetaSolverOrchestrationPort = CreateOrchestrationPort<VariegationProblem>(MetaSolverName); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName, "RealVector", "Quality"); 47 FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName); 48 VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName); 145 49 } 146 50 … … 149 53 } 150 54 151 [StorableHook(HookType.AfterDeserialization)]152 private void AfterDeserialization() {153 RegisterEvents();154 }155 156 private void RegisterEvents() {157 InstanceParameter.Value.ToStringChanged += InstanceParameter_Value_ToStringChanged;158 MetaSolverOrchestrationPort.ConnectedPortChanged += MetaSolverOrchestrationPort_ConnectedPortChanged;159 VrpSolverOrchestrationPort.ConnectedPortChanged += VrpSolverOrchestrationPort_ConnectedPortChanged;160 FlpSolverOrchestrationPort.ConnectedPortChanged += FlpSolverOrchestrationPort_ConnectedPortChanged;161 }162 163 private void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {164 string filePath = InstanceParameter.Value.Value;165 LrpUtils.Import(filePath, out nrOfDepots, out nrOfCustomers,166 out depotCoordinates, out customerCoordinates,167 out distanceType,168 out depotCapacities, out customerDemands, out depotCosts,169 out vehicleCapacity, out vehicleCost);170 171 var flp = FlpParameter.Value;172 flp.CustomerDemandsParameter.Value = new DoubleArray(customerDemands);173 flp.DeliveryCostsParameter.Value = new DoubleMatrix(LrpUtils.GetFlpDeliveryCosts(depotCoordinates, customerCoordinates, distanceType));174 flp.DepotCapacitiesParameter.Value = new DoubleArray(depotCapacities);175 flp.Encoding.Length = nrOfCustomers;176 flp.OpeningCostsParameter.Value = new DoubleArray(depotCosts);177 178 var vrpInstance = (CVRPProblemInstance)VrpParameter.Value.ProblemInstance;179 vrpInstance.Capacity.Value = vehicleCapacity;180 vrpInstance.FleetUsageFactor.Value = vehicleCost;181 vrpInstance.OverloadPenalty.Value = vehicleCost * 1000.0;182 183 var crossover = VrpParameter.Value.OperatorsParameter.Value.OfType<MultiVRPSolutionCrossover>().Single(x => x.Name == "MultiVRPSolutionCrossover");184 foreach (var c in crossover.Operators)185 crossover.Operators.SetItemCheckedState(c, c.Name.StartsWith("Potvin"));186 var mutator = VrpParameter.Value.OperatorsParameter.Value.OfType<MultiVRPSolutionManipulator>().Single(x => x.Name == "MultiVRPSolutionManipulator");187 foreach (var m in mutator.Operators)188 mutator.Operators.SetItemCheckedState(m, Regex.IsMatch(m.Name, @"Potvin(One|Two).*"));189 190 Prepare();191 }192 193 55 public override void Prepare(bool clearRuns = false) { 194 Results.Clear();56 base.Prepare(clearRuns); 195 57 196 58 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage(); … … 199 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 200 62 var problem = new VariegationProblem(); 201 problem.Encoding.Length = FlpParameter.Value.Encoding.Length* 2;202 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { 0.0, 2.0 } });63 problem.Encoding.Length = nrOfCustomers * 2; 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); 203 65 metaMsg["Problem"] = problem; 204 66 MetaSolverOrchestrationPort.SendMessage(metaMsg); 205 67 } 206 68 207 public override void Start() {208 cts = new CancellationTokenSource();209 210 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();211 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Start);212 MetaSolverOrchestrationPort.SendMessage(metaMsg);213 }214 215 public override void Pause() {216 cts.Cancel();217 218 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();219 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Pause);220 MetaSolverOrchestrationPort.SendMessage(metaMsg);221 222 var vrpMsg = VrpSolverOrchestrationPort.PrepareMessage();223 vrpMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);224 VrpSolverOrchestrationPort.SendMessage(vrpMsg);225 226 var kspMsg = FlpSolverOrchestrationPort.PrepareMessage();227 kspMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);228 FlpSolverOrchestrationPort.SendMessage(kspMsg);229 }230 231 public override void Stop() {232 cts.Cancel();233 234 var metaMsg = MetaSolverOrchestrationPort.PrepareMessage();235 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);236 MetaSolverOrchestrationPort.SendMessage(metaMsg);237 238 var vrpMsg = VrpSolverOrchestrationPort.PrepareMessage();239 vrpMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);240 VrpSolverOrchestrationPort.SendMessage(vrpMsg);241 242 var kspMsg = FlpSolverOrchestrationPort.PrepareMessage();243 kspMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Stop);244 FlpSolverOrchestrationPort.SendMessage(kspMsg);245 }246 247 protected override void ProcessMessage(IMessage message, IMessagePort port, CancellationToken token) {248 var messageActions = new Dictionary<IMessagePort, Action<IMessage>>();249 messageActions.Add(MetaSolverOrchestrationPort, MetaSolverOrchestrationPortMessage);250 messageActions.Add(MetaSolverEvaluationPort, MetaSolverEvaluationPortMessage);251 messageActions.Add(VrpSolverOrchestrationPort, VrpSolverOrchestrationPortMessage);252 messageActions.Add(VrpSolverEvaluationPort, VrpSolverEvaluationPortMessage);253 messageActions.Add(FlpSolverOrchestrationPort, FlpSolverOrchestrationPortMessage);254 messageActions.Add(FlpSolverEvaluationPort, FlpSolverEvaluationPortMessage);255 256 messageActions[port](message);257 258 base.ProcessMessage(message, port, token);259 }260 261 69 #region MetaSolver Message Handling 262 private void MetaSolverOrchestrationPortMessage(IMessage message) { } 263 264 private void MetaSolverEvaluationPortMessage(IMessage message) { 70 protected override void MetaSolverEvaluationPortMessage(IMessage message) { 265 71 var factors = (RealVector)message["RealVector"]; 266 72 … … 324 130 } 325 131 #endregion 326 327 #region VrpSolver Message Handling328 private void VrpSolverOrchestrationPortMessage(IMessage message) {329 var results = (ResultCollection)message["Results"];330 if (results.ContainsKey("Best valid VRP Solution")) {331 vrpResults = results;332 }333 }334 335 private void VrpSolverEvaluationPortMessage(IMessage message) { }336 #endregion337 338 #region KspSolver Message Handling339 private void FlpSolverOrchestrationPortMessage(IMessage message) {340 var results = (ResultCollection)message["Results"];341 if (results.ContainsKey("Best Solution")) {342 flpResults = results;343 }344 }345 346 private void FlpSolverEvaluationPortMessage(IMessage message) { }347 #endregion348 349 #region Event Handlers350 private void MetaSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {351 if (MetaSolverOrchestrationPort.ConnectedPort == null) return;352 353 var node = MetaSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;354 if (node == null) return;355 356 var hook = new HookOperator { Name = "Meta Eval Hook" };357 hook.Parameters.Add(new LookupParameter<RealVector>("RealVector") { Hidden = true });358 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });359 node.EvalHook = hook;360 361 node.OrchestrationPort.CloneParametersFromPort(MetaSolverOrchestrationPort);362 node.EvaluationPort.CloneParametersFromPort(MetaSolverEvaluationPort);363 node.EvaluationPort.ConnectedPort = MetaSolverEvaluationPort;364 }365 366 private void VrpSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {367 if (VrpSolverOrchestrationPort.ConnectedPort == null) return;368 369 var node = VrpSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;370 if (node == null) return;371 372 var hook = new HookOperator { Name = "VRP Eval Hook" };373 hook.Parameters.Add(new LookupParameter<Permutation>("VRPTours") { Hidden = true });374 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });375 node.EvalHook = hook;376 377 node.OrchestrationPort.CloneParametersFromPort(VrpSolverOrchestrationPort);378 node.EvaluationPort.CloneParametersFromPort(VrpSolverEvaluationPort);379 node.EvaluationPort.ConnectedPort = VrpSolverEvaluationPort;380 }381 382 private void FlpSolverOrchestrationPort_ConnectedPortChanged(object sender, EventArgs e) {383 if (FlpSolverOrchestrationPort.ConnectedPort == null) return;384 385 var node = FlpSolverOrchestrationPort.ConnectedPort.Parent as OrchestratedAlgorithmNode;386 if (node == null) return;387 388 var hook = new HookOperator { Name = "FLP Eval Hook" };389 hook.Parameters.Add(new LookupParameter<BinaryVector>("IntegerVector") { Hidden = true });390 hook.Parameters.Add(new LookupParameter<DoubleValue>("Quality") { Hidden = true });391 node.EvalHook = hook;392 393 node.OrchestrationPort.CloneParametersFromPort(FlpSolverOrchestrationPort);394 node.EvaluationPort.CloneParametersFromPort(FlpSolverEvaluationPort);395 node.EvaluationPort.ConnectedPort = FlpSolverEvaluationPort;396 }397 #endregion398 132 } 399 133 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork.cs
r14616 r14621 31 31 [Item("TtpNetwork", "An abstract base class for TTP optimization networks.")] 32 32 [StorableClass] 33 public abstract class TtpNetwork : Network {33 public abstract class TtpNetwork : Network, IOptimizer { 34 34 #region Constants 35 35 protected const string OrchestratorNodeName = "Orchestrator"; … … 104 104 if (algorithm == null) return; 105 105 106 algorithm.ExecutionStateChanged += OnExecutionStateChanged;107 algorithm.ExecutionTimeChanged += OnExecutionTimeChanged;108 algorithm.Prepared += OnPrepared;109 algorithm.Started += OnStarted;110 algorithm.Paused += OnPaused;111 algorithm.Stopped += OnStopped;112 algorithm.ExceptionOccurred += OnExceptionOccurred;106 algorithm.ExecutionStateChanged += (s, e) => OnExecutionStateChanged(); 107 algorithm.ExecutionTimeChanged += (s, e) => OnExecutionTimeChanged(); 108 algorithm.Prepared += (s, e) => OnPrepared(); 109 algorithm.Started += (s, e) => OnStarted(); 110 algorithm.Paused += (s, e) => OnPaused(); 111 algorithm.Stopped += (s, e) => OnStopped(); 112 algorithm.ExceptionOccurred += (s, e) => OnExceptionOccurred(e.Value); 113 113 } 114 114 … … 167 167 } 168 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); }177 169 } 178 170 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs
r14616 r14621 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Optimization;28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 28 … … 32 31 [Creatable("Optimization Networks")] 33 32 [StorableClass] 34 public sealed class TtpNetwork1 : TtpNetwork , IOptimizer{33 public sealed class TtpNetwork1 : TtpNetwork { 35 34 [StorableConstructor] 36 35 private TtpNetwork1(bool deserializing) : base(deserializing) { } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs
r14616 r14621 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Optimization;28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 28 … … 32 31 [Creatable("Optimization Networks")] 33 32 [StorableClass] 34 public sealed class TtpNetwork2 : TtpNetwork , IOptimizer{33 public sealed class TtpNetwork2 : TtpNetwork { 35 34 [StorableConstructor] 36 35 private TtpNetwork2(bool deserializing) : base(deserializing) { } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs
r14616 r14621 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Optimization;28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 28 … … 32 31 [Creatable("Optimization Networks")] 33 32 [StorableClass] 34 public sealed class TtpNetwork3 : TtpNetwork , IOptimizer{33 public sealed class TtpNetwork3 : TtpNetwork { 35 34 [StorableConstructor] 36 35 private TtpNetwork3(bool deserializing) : base(deserializing) { } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode.cs
r14616 r14621 199 199 } 200 200 201 pr otectedvoid InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {201 private void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) { 202 202 string filePath = InstanceParameter.Value.Value; 203 203 TtpUtils.Import(filePath, out tspCoordinates, out distanceType,
Note: See TracChangeset
for help on using the changeset viewer.