Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/31/17 16:54:03 (7 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • added variegation problem for minimization and maximization
  • refactored some classes
Location:
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork1.cs

    r14621 r14628  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Encodings.RealVectorEncoding;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    4344
    4445      var cmaes = new CMAEvolutionStrategy();
    45       cmaes.Problem = new VariegationProblem();
     46      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    4647      cmaes.MaximumGenerations = 80;
    4748      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork2.cs

    r14621 r14628  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Encodings.RealVectorEncoding;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    4344
    4445      var cmaes = new CMAEvolutionStrategy();
    45       cmaes.Problem = new VariegationProblem();
     46      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    4647      cmaes.MaximumGenerations = 80;
    4748      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpNetwork3.cs

    r14621 r14628  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Encodings.RealVectorEncoding;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    4344
    4445      var cmaes = new CMAEvolutionStrategy();
    45       cmaes.Problem = new VariegationProblem();
     46      cmaes.Problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    4647      cmaes.MaximumGenerations = 80;
    4748      MetaSolver.Algorithm = cmaes;
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode.cs

    r14621 r14628  
    2929using HeuristicLab.Encodings.RealVectorEncoding;
    3030using HeuristicLab.Operators;
    31 using HeuristicLab.Optimization;
    3231using HeuristicLab.Parameters;
    3332using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4948    protected const string TspSolverName = "TspSolver";
    5049    protected const string KspSolverName = "KspSolver";
     50    protected const string OrchestrationPortNameSuffix = "OrchestrationPort";
     51    protected const string EvaluationPortNameSuffix = "EvaluationPort";
    5152    #endregion
    5253
    5354    protected CancellationTokenSource cts;
    54     protected ResultCollection tspResults, kspResults;
    5555
    5656    [Storable]
     
    319319
    320320    #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) { }
    327322
    328323    protected virtual void TspSolverEvaluationPortMessage(IMessage message) { }
     
    330325
    331326    #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) { }
    338328
    339329    private void KspSolverEvaluationPortMessage(IMessage message) { }
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode1.cs

    r14616 r14628  
    4343    public TtpOrchestratorNode1() : this("TtpOrchestratorNode1") { }
    4444    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);
    4949    }
    5050
     
    6060      if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns;
    6161      metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags);
    62       var problem = new VariegationProblem();
     62      var problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    6363      problem.Encoding.Length = KspParameter.Value.Length;
    6464      problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } });
     
    8181      cts.Token.ThrowIfCancellationRequested();
    8282
     83      var kspResults = (ResultCollection)kspMsg["Results"];
    8384      var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone();
    8485      var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone();
     
    106107      cts.Token.ThrowIfCancellationRequested();
    107108
     109      var tspResults = (ResultCollection)tspMsg["Results"];
    108110      var bestTspSolution = (Permutation)tspResults["Best TSP Solution"].Value.Clone();
    109111      var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone();
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode2.cs

    r14616 r14628  
    4242    public TtpOrchestratorNode2() : this("TtpOrchestratorNode2") { }
    4343    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);
    4848    }
    4949
     
    5959      if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns;
    6060      metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags);
    61       var problem = new VariegationProblem();
     61      var problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    6262      problem.Encoding.Length = TspParameter.Value.Coordinates.Rows * 2;
    6363      problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } });
     
    8282      cts.Token.ThrowIfCancellationRequested();
    8383
     84      var tspResults = (ResultCollection)tspMsg["Results"];
    8485      var bestTspSolution = (PathTSPTour)tspResults["Best TSP Solution"].Value.Clone();
    8586      var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone();
     
    103104      cts.Token.ThrowIfCancellationRequested();
    104105
     106      var kspResults = (ResultCollection)kspMsg["Results"];
    105107      var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone();
    106108      var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone();
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.TravelingThief/3.3/TtpOrchestratorNode3.cs

    r14616 r14628  
    4343    public TtpOrchestratorNode3() : this("TtpOrchestratorNode3") { }
    4444    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);
    4949    }
    5050
     
    6060      if (clearRuns) msgFlags |= OrchestrationMessage.ClearRuns;
    6161      metaMsg["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(msgFlags);
    62       var problem = new VariegationProblem();
     62      var problem = new MaximizationVariegationProblem<RealVectorEncoding>();
    6363      problem.Encoding.Length = KspParameter.Value.Length + TspParameter.Value.Coordinates.Rows * 2;
    6464      problem.Encoding.Bounds = new DoubleMatrix(new[,] { { -1.0, 1.0 } });
     
    8484      cts.Token.ThrowIfCancellationRequested();
    8585
     86      var kspResults = (ResultCollection)kspMsg["Results"];
    8687      var bestKspSolution = (BinaryVector)kspResults["Best Solution"].Value.Clone();
    8788      var kspCapacity = (IntValue)KspParameter.Value.KnapsackCapacity.Clone();
     
    115116      cts.Token.ThrowIfCancellationRequested();
    116117
     118      var tspResults = (ResultCollection)tspMsg["Results"];
    117119      var bestTspSolution = (Permutation)tspResults["Best TSP Solution"].Value.Clone();
    118120      var coordinates = (DoubleMatrix)TspParameter.Value.Coordinates.Clone();
Note: See TracChangeset for help on using the changeset viewer.