Changeset 14628
- Timestamp:
- 01/31/17 16:54:03 (8 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 2 added
- 1 deleted
- 16 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs
r14621 r14628 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Encodings.RealVectorEncoding; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 50 51 51 52 var cmaes = new CMAEvolutionStrategy(); 52 var vp = new VariegationProblem(); 53 vp.SetMaximization(false); 53 var vp = new MinimizationVariegationProblem<RealVectorEncoding>(); 54 54 cmaes.Problem = vp; 55 55 cmaes.MaximumGenerations = 80; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork2.cs
r14621 r14628 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Encodings.RealVectorEncoding; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 50 51 51 52 var cmaes = new CMAEvolutionStrategy(); 52 var vp = new VariegationProblem(); 53 vp.SetMaximization(false); 53 var vp = new MinimizationVariegationProblem<RealVectorEncoding>(); 54 54 cmaes.Problem = vp; 55 55 cmaes.MaximumGenerations = 80; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode.cs
r14621 r14628 50 50 protected const string FlpSolverName = "FlpSolver"; 51 51 protected const string VrpSolverName = "VrpSolver"; 52 protected const string OrchestrationPortNameSuffix = "OrchestrationPort"; 53 protected const string EvaluationPortNameSuffix = "EvaluationPort"; 52 54 #endregion 53 55 54 56 protected CancellationTokenSource cts; 55 protected ResultCollection flpResults, vrpResults;56 57 57 58 [Storable] … … 309 310 310 311 #region FlpSolver Message Handling 311 protected virtual void FlpSolverOrchestrationPortMessage(IMessage message) { 312 var results = (ResultCollection)message["Results"]; 313 if (results.ContainsKey("Best Solution")) { 314 flpResults = results; 315 } 316 } 312 protected virtual void FlpSolverOrchestrationPortMessage(IMessage message) { } 317 313 318 314 protected virtual void FlpSolverEvaluationPortMessage(IMessage message) { } … … 320 316 321 317 #region VrpSolver Message Handling 322 protected virtual void VrpSolverOrchestrationPortMessage(IMessage message) { 323 var results = (ResultCollection)message["Results"]; 324 if (results.ContainsKey("Best valid VRP Solution")) { 325 vrpResults = results; 326 } 327 } 318 protected virtual void VrpSolverOrchestrationPortMessage(IMessage message) { } 328 319 329 320 private void VrpSolverEvaluationPortMessage(IMessage message) { } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs
r14621 r14628 43 43 public LrpOrchestratorNode1() : this("LrpOrchestratorNode1") { } 44 44 public LrpOrchestratorNode1(string name) : base(name) { 45 MetaSolverOrchestrationPort = CreateOrchestrationPort< VariegationProblem>(MetaSolverName);46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName , "RealVector", "Quality");47 FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName );48 VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName );45 MetaSolverOrchestrationPort = CreateOrchestrationPort<MinimizationVariegationProblem<RealVectorEncoding>>(MetaSolverName + OrchestrationPortNameSuffix); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName + EvaluationPortNameSuffix, "RealVector", "Quality"); 47 FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName + OrchestrationPortNameSuffix); 48 VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName + OrchestrationPortNameSuffix); 49 49 } 50 50 … … 60 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem();62 var problem = new MinimizationVariegationProblem<RealVectorEncoding>(); 63 63 problem.Encoding.Length = nrOfCustomers * 2; 64 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); … … 85 85 cts.Token.ThrowIfCancellationRequested(); 86 86 87 var flpResults = (ResultCollection)flpMsg["Results"]; 87 88 var bestFlpSolution = (IntegerVector)flpResults["Best Solution"].Value; 88 89 var flpSolution = FlpParameter.Value.GetSolution(bestFlpSolution); … … 109 110 cts.Token.ThrowIfCancellationRequested(); 110 111 112 var vrpResults = (ResultCollection)vrpMsg["Results"]; 111 113 var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone(); 112 114 vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution)); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode2.cs
r14621 r14628 43 43 public LrpOrchestratorNode2() : this("LrpOrchestratorNode2") { } 44 44 public LrpOrchestratorNode2(string name) : base(name) { 45 MetaSolverOrchestrationPort = CreateOrchestrationPort< VariegationProblem>(MetaSolverName);46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName , "RealVector", "Quality");47 FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName );48 VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName );45 MetaSolverOrchestrationPort = CreateOrchestrationPort<MinimizationVariegationProblem<RealVectorEncoding>>(MetaSolverName + OrchestrationPortNameSuffix); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName + EvaluationPortNameSuffix, "RealVector", "Quality"); 47 FlpSolverOrchestrationPort = CreateOrchestrationPort<FacilityLocationProblem>(FlpSolverName + OrchestrationPortNameSuffix); 48 VrpSolverOrchestrationPort = CreateOrchestrationPort<VehicleRoutingProblem>(VrpSolverName + OrchestrationPortNameSuffix); 49 49 } 50 50 … … 60 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem();62 var problem = new MinimizationVariegationProblem<RealVectorEncoding>(); 63 63 problem.Encoding.Length = nrOfDepots * 2; 64 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); … … 85 85 cts.Token.ThrowIfCancellationRequested(); 86 86 87 var flpResults = (ResultCollection)flpMsg["Results"]; 87 88 var bestFlpSolution = (IntegerVector)flpResults["Best Solution"].Value; 88 89 var flpSolution = FlpParameter.Value.GetSolution(bestFlpSolution); … … 109 110 cts.Token.ThrowIfCancellationRequested(); 110 111 112 var vrpResults = (ResultCollection)vrpMsg["Results"]; 111 113 var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone(); 112 114 vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution)); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.MachineLearning/HeuristicLab.Networks.IntegratedOptimization.MachineLearning-3.3.csproj
r14625 r14628 111 111 <Private>False</Private> 112 112 </Reference> 113 <Reference Include="HeuristicLab.Networks.IntegratedOptimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">114 <SpecificVersion>False</SpecificVersion>115 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Networks.IntegratedOptimization-3.3.dll</HintPath>116 <Private>False</Private>117 </Reference>118 113 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 119 114 <SpecificVersion>False</SpecificVersion> … … 189 184 <None Include="HeuristicLab.snk" /> 190 185 <None Include="Plugin.cs.frame" /> 191 <None Include="Properties\AssemblyInfo.frame" /> 186 <None Include="Properties\AssemblyInfo.cs.frame" /> 187 </ItemGroup> 188 <ItemGroup> 189 <ProjectReference Include="..\HeuristicLab.Networks.IntegratedOptimization\3.3\HeuristicLab.Networks.IntegratedOptimization-3.3.csproj"> 190 <Project>{b6263d3e-dcaf-42b0-a440-3deef1ff0429}</Project> 191 <Name>HeuristicLab.Networks.IntegratedOptimization-3.3</Name> 192 <Private>False</Private> 193 </ProjectReference> 192 194 </ItemGroup> 193 195 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.MachineLearning/Properties/AssemblyInfo.cs.frame
r14627 r14628 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs
r14621 r14628 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 … … 43 44 44 45 var cmaes = new CMAEvolutionStrategy(); 45 cmaes.Problem = new VariegationProblem();46 cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 46 47 cmaes.MaximumGenerations = 80; 47 48 MetaSolver.Algorithm = cmaes; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs
r14621 r14628 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 … … 43 44 44 45 var cmaes = new CMAEvolutionStrategy(); 45 cmaes.Problem = new VariegationProblem();46 cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 46 47 cmaes.MaximumGenerations = 80; 47 48 MetaSolver.Algorithm = cmaes; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs
r14621 r14628 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 … … 43 44 44 45 var cmaes = new CMAEvolutionStrategy(); 45 cmaes.Problem = new VariegationProblem();46 cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 46 47 cmaes.MaximumGenerations = 80; 47 48 MetaSolver.Algorithm = cmaes; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode.cs
r14621 r14628 29 29 using HeuristicLab.Encodings.RealVectorEncoding; 30 30 using HeuristicLab.Operators; 31 using HeuristicLab.Optimization;32 31 using HeuristicLab.Parameters; 33 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 49 48 protected const string TspSolverName = "TspSolver"; 50 49 protected const string KspSolverName = "KspSolver"; 50 protected const string OrchestrationPortNameSuffix = "OrchestrationPort"; 51 protected const string EvaluationPortNameSuffix = "EvaluationPort"; 51 52 #endregion 52 53 53 54 protected CancellationTokenSource cts; 54 protected ResultCollection tspResults, kspResults;55 55 56 56 [Storable] … … 319 319 320 320 #region TspSolver Message Handling 321 protected virtual void TspSolverOrchestrationPortMessage(IMessage message) { 322 var results = (ResultCollection)message["Results"]; 323 if (results.ContainsKey("Best TSP Solution")) { 324 tspResults = results; 325 } 326 } 321 protected virtual void TspSolverOrchestrationPortMessage(IMessage message) { } 327 322 328 323 protected virtual void TspSolverEvaluationPortMessage(IMessage message) { } … … 330 325 331 326 #region KspSolver Message Handling 332 protected virtual void KspSolverOrchestrationPortMessage(IMessage message) { 333 var results = (ResultCollection)message["Results"]; 334 if (results.ContainsKey("Best Solution")) { 335 kspResults = results; 336 } 337 } 327 protected virtual void KspSolverOrchestrationPortMessage(IMessage message) { } 338 328 339 329 private void KspSolverEvaluationPortMessage(IMessage message) { } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode1.cs
r14616 r14628 43 43 public TtpOrchestratorNode1() : this("TtpOrchestratorNode1") { } 44 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 );45 MetaSolverOrchestrationPort = CreateOrchestrationPort<MaximizationVariegationProblem<RealVectorEncoding>>(MetaSolverName + OrchestrationPortNameSuffix); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName + EvaluationPortNameSuffix, "RealVector", "Quality"); 47 TspSolverOrchestrationPort = CreateOrchestrationPort<TourProfitProblem>(TspSolverName + OrchestrationPortNameSuffix); 48 KspSolverOrchestrationPort = CreateOrchestrationPort<BinaryKnapsackProblem>(KspSolverName + OrchestrationPortNameSuffix); 49 49 } 50 50 … … 60 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem();62 var problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 63 63 problem.Encoding.Length = KspParameter.Value.Length; 64 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); … … 81 81 cts.Token.ThrowIfCancellationRequested(); 82 82 83 var kspResults = (ResultCollection)kspMsg["Results"]; 83 84 var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone(); 84 85 var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone(); … … 106 107 cts.Token.ThrowIfCancellationRequested(); 107 108 109 var tspResults = (ResultCollection)tspMsg["Results"]; 108 110 var bestTspSolution = (Permutation)tspResults["Best TSP Solution"].Value.Clone(); 109 111 var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone(); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode2.cs
r14616 r14628 42 42 public TtpOrchestratorNode2() : this("TtpOrchestratorNode2") { } 43 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 );44 MetaSolverOrchestrationPort = CreateOrchestrationPort<MaximizationVariegationProblem<RealVectorEncoding>>(MetaSolverName + OrchestrationPortNameSuffix); 45 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName + EvaluationPortNameSuffix, "RealVector", "Quality"); 46 TspSolverOrchestrationPort = CreateOrchestrationPort<TravelingSalesmanProblem>(TspSolverName + OrchestrationPortNameSuffix); 47 KspSolverOrchestrationPort = CreateOrchestrationPort<LootProfitProblem>(KspSolverName + OrchestrationPortNameSuffix); 48 48 } 49 49 … … 59 59 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 60 60 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 61 var problem = new VariegationProblem();61 var problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 62 62 problem.Encoding.Length = TspParameter.Value.Coordinates.Rows * 2; 63 63 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); … … 82 82 cts.Token.ThrowIfCancellationRequested(); 83 83 84 var tspResults = (ResultCollection)tspMsg["Results"]; 84 85 var bestTspSolution = (PathTSPTour)tspResults["Best TSP Solution"].Value.Clone(); 85 86 var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone(); … … 103 104 cts.Token.ThrowIfCancellationRequested(); 104 105 106 var kspResults = (ResultCollection)kspMsg["Results"]; 105 107 var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone(); 106 108 var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone(); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode3.cs
r14616 r14628 43 43 public TtpOrchestratorNode3() : this("TtpOrchestratorNode3") { } 44 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 );45 MetaSolverOrchestrationPort = CreateOrchestrationPort<MaximizationVariegationProblem<RealVectorEncoding>>(MetaSolverName + OrchestrationPortNameSuffix); 46 MetaSolverEvaluationPort = CreateEvaluationPort<RealVector>(MetaSolverName + EvaluationPortNameSuffix, "RealVector", "Quality"); 47 TspSolverOrchestrationPort = CreateOrchestrationPort<TravelingSalesmanProblem>(TspSolverName + OrchestrationPortNameSuffix); 48 KspSolverOrchestrationPort = CreateOrchestrationPort<BinaryKnapsackProblem>(KspSolverName + OrchestrationPortNameSuffix); 49 49 } 50 50 … … 60 60 if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns; 61 61 metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags); 62 var problem = new VariegationProblem();62 var problem = new MaximizationVariegationProblem<RealVectorEncoding>(); 63 63 problem.Encoding.Length = KspParameter.Value.Length + TspParameter.Value.Coordinates.Rows * 2; 64 64 problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } }); … … 84 84 cts.Token.ThrowIfCancellationRequested(); 85 85 86 var kspResults = (ResultCollection)kspMsg["Results"]; 86 87 var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone(); 87 88 var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone(); … … 115 116 cts.Token.ThrowIfCancellationRequested(); 116 117 118 var tspResults = (ResultCollection)tspMsg["Results"]; 117 119 var bestTspSolution = (Permutation)tspResults["Best TSP Solution"].Value.Clone(); 118 120 var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone(); -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/HeuristicLab.Networks.IntegratedOptimization-3.3.csproj
r14619 r14628 131 131 <ItemGroup> 132 132 <Compile Include="IOrchestratorNode.cs" /> 133 <Compile Include="MaximizationVariegationProblem.cs" /> 134 <Compile Include="MinimizationVariegationProblem.cs" /> 133 135 <Compile Include="OrchestratedAlgorithmNode.cs" /> 134 136 <Compile Include="OrchestrationMessage.cs" /> 135 137 <Compile Include="OrchestratorNode.cs" /> 136 <Compile Include="VariegationProblem.cs" />137 138 <None Include="Plugin.cs.frame" /> 138 139 <None Include="Properties\AssemblyInfo.cs.frame" /> -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratedAlgorithmNode.cs
r14624 r14628 65 65 [StorableConstructor] 66 66 protected OrchestratedAlgorithmNode(bool deserializing) : base(deserializing) { } 67 protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner) 68 : base(original, cloner) { 67 protected OrchestratedAlgorithmNode(OrchestratedAlgorithmNode original, Cloner cloner) : base(original, cloner) { 69 68 EvalHook = cloner.Clone(original.EvalHook); 70 69 RegisterEvents(); 71 70 } 72 71 public OrchestratedAlgorithmNode() : this("OrchestratedAlgorithmNode") { } 73 public OrchestratedAlgorithmNode(string name) 74 : base(name) { 72 public OrchestratedAlgorithmNode(string name) : base(name) { 75 73 var orchestrationPort = new MessagePort(OrchestrationPortName); 76 74 Ports.Add(orchestrationPort); … … 97 95 #region Port Events 98 96 private void OrchestrationPort_MessageReceived(object sender, EventArgs<IMessage, CancellationToken> e) { 99 var message = e.Value;100 var orchestrationMessage = ((EnumValue<OrchestrationMessage>)message["OrchestrationMessage"]).Value;97 var requestMessage = e.Value; 98 var messageFlags = ((EnumValue<OrchestrationMessage>)requestMessage["OrchestrationMessage"]).Value; 101 99 102 100 #region Prepare 103 if ( orchestrationMessage.HasFlag(OrchestrationMessage.Prepare)) {101 if (messageFlags.HasFlag(OrchestrationMessage.Prepare)) { 104 102 switch (Algorithm.ExecutionState) { 105 103 case ExecutionState.Prepared: … … 110 108 var prob = (IHeuristicOptimizationProblem)problemMsgVal.Value.Clone(); 111 109 112 if ( orchestrationMessage.HasFlag(OrchestrationMessage.SetEvalHook)) {110 if (messageFlags.HasFlag(OrchestrationMessage.SetEvalHook)) { 113 111 var instEval = prob.Evaluator as InstrumentedOperator; 114 112 if (instEval != null && EvalHook != null) instEval.AfterExecutionOperators.Add(EvalHook); … … 140 138 } 141 139 142 Algorithm.Prepare( orchestrationMessage.HasFlag(OrchestrationMessage.ClearRuns));140 Algorithm.Prepare(messageFlags.HasFlag(OrchestrationMessage.ClearRuns)); 143 141 } 144 142 break; … … 148 146 149 147 #region Start 150 if ( orchestrationMessage.HasFlag(OrchestrationMessage.Start)) {148 if (messageFlags.HasFlag(OrchestrationMessage.Start)) { 151 149 switch (Algorithm.ExecutionState) { 152 150 case ExecutionState.Prepared: … … 175 173 176 174 if (sendResultMessage) { 177 message["Results"] = (ResultCollection)Algorithm.Results.Clone();178 var msg= OrchestrationPort.PrepareMessage();179 msg["Results"] = (ResultCollection)Algorithm.Results.Clone();180 OrchestrationPort.SendMessage( msg);175 requestMessage["Results"] = (ResultCollection)Algorithm.Results.Clone(); 176 var responseMessage = OrchestrationPort.PrepareMessage(); 177 responseMessage["Results"] = (ResultCollection)Algorithm.Results.Clone(); 178 OrchestrationPort.SendMessage(responseMessage); 181 179 } else sendResultMessage = true; 182 180 break; … … 186 184 187 185 #region Pause 188 if ( orchestrationMessage.HasFlag(OrchestrationMessage.Pause)) {186 if (messageFlags.HasFlag(OrchestrationMessage.Pause)) { 189 187 if (Algorithm.ExecutionState == ExecutionState.Started) { 190 188 sendResultMessage = false; 191 189 try { 192 190 Algorithm.Pause(); 193 } 194 catch (InvalidOperationException) { 191 } catch (InvalidOperationException) { 195 192 // ExecutionState might have changed since we accepted the message 196 193 } … … 200 197 201 198 #region Stop 202 if ( orchestrationMessage.HasFlag(OrchestrationMessage.Stop)) {199 if (messageFlags.HasFlag(OrchestrationMessage.Stop)) { 203 200 switch (Algorithm.ExecutionState) { 204 201 case ExecutionState.Started: … … 206 203 try { 207 204 Algorithm.Stop(); 208 } 209 catch (InvalidOperationException) { 205 } catch (InvalidOperationException) { 210 206 // ExecutionState might have changed since we accepted the message 211 } 212 catch (NullReferenceException) { 207 } catch (NullReferenceException) { 213 208 // BasicAlgorithm might have stopped since we accepted the message 214 209 // CancellationTokenSource is null in this case -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization/3.3/OrchestratorNode.cs
r14624 r14628 28 28 using HeuristicLab.Data; 29 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters;31 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 31 … … 35 34 [StorableClass] 36 35 public abstract class OrchestratorNode : Node, IOrchestratorNode { 37 //TODO remove suffixes38 #region Constants39 protected const string OrchestrationMessageParameterName = "OrchestrationMessage";40 protected const string OrchestrationPortNameSuffix = "";41 protected const string EvaluationPortNameSuffix = "";42 #endregion43 44 36 [Storable] 45 37 private ParameterCollection parameters; … … 63 55 [StorableConstructor] 64 56 protected OrchestratorNode(bool deserializing) : base(deserializing) { } 65 protected OrchestratorNode(OrchestratorNode original, Cloner cloner) 66 : base(original, cloner) { 57 protected OrchestratorNode(OrchestratorNode original, Cloner cloner) : base(original, cloner) { 67 58 results = cloner.Clone(original.results); 68 59 parameters = cloner.Clone(original.parameters); … … 71 62 } 72 63 73 protected OrchestratorNode() 74 : base("OrchestratorNode") { 64 protected OrchestratorNode() : base("OrchestratorNode") { 75 65 results = new ResultCollection(); 76 66 parameters = new ParameterCollection(); 77 Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));78 67 readOnlyParameters = null; 79 68 } 80 protected OrchestratorNode(string name) 81 : base(name) { 69 protected OrchestratorNode(string name) : base(name) { 82 70 results = new ResultCollection(); 83 71 parameters = new ParameterCollection(); 84 Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));85 72 readOnlyParameters = null; 86 73 } 87 protected OrchestratorNode(string name, string description) 88 : base(name, description) { 74 protected OrchestratorNode(string name, string description) : base(name, description) { 89 75 results = new ResultCollection(); 90 76 parameters = new ParameterCollection(); 91 Parameters.Add(new ValueParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage", new EnumValue<OrchestrationMessage>()));92 77 readOnlyParameters = null; 93 78 } … … 102 87 } 103 88 104 protected IMessagePort CreateOrchestrationPort<T>(string solverName) where T : class, IProblem {105 var orchestrationPort = new MessagePort( solverName + OrchestrationPortNameSuffix);89 protected IMessagePort CreateOrchestrationPort<T>(string portName) where T : class, IProblem { 90 var orchestrationPort = new MessagePort(portName); 106 91 orchestrationPort.Parameters.Add(new PortParameter<EnumValue<OrchestrationMessage>>("OrchestrationMessage") { 107 92 Type = PortParameterType.Output … … 116 101 } 117 102 118 protected IMessagePort CreateEvaluationPort<T>(string solverName, string solutionName, string qualityName) where T : class, IItem {119 var evaluationPort = new MessagePort( solverName + EvaluationPortNameSuffix);103 protected IMessagePort CreateEvaluationPort<T>(string portName, string solutionName, string qualityName) where T : class, IItem { 104 var evaluationPort = new MessagePort(portName); 120 105 evaluationPort.Parameters.Add(new PortParameter<T>(solutionName) { 121 106 Type = PortParameterType.Input
Note: See TracChangeset
for help on using the changeset viewer.