Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/23/17 14:49:07 (7 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • switched from IConfigurationPorts to IMessagePorts
  • removed option to clone algorithms in OrchestratedAlgorithmNodes
  • made properties of TourProfitProblem storable
  • fixed event handler registration
File:
1 edited

Legend:

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

    r14586 r14598  
    1 using HeuristicLab.Algorithms.CMAEvolutionStrategy;
    2 using HeuristicLab.Algorithms.LocalSearch;
    3 using HeuristicLab.Algorithms.ParameterlessPopulationPyramid;
    4 using HeuristicLab.Common;
    5 using HeuristicLab.Core;
    6 using HeuristicLab.Core.Networks;
    7 using HeuristicLab.Data;
    8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     1//using HeuristicLab.Algorithms.CMAEvolutionStrategy;
     2//using HeuristicLab.Algorithms.LocalSearch;
     3//using HeuristicLab.Algorithms.ParameterlessPopulationPyramid;
     4//using HeuristicLab.Common;
     5//using HeuristicLab.Core;
     6//using HeuristicLab.Core.Networks;
     7//using HeuristicLab.Data;
     8//using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    99
    10 namespace HeuristicLab.Networks.IntegratedOptimization {
    11   [Item("TtpNetwork3", "An optimization network for the TTP.")]
    12   [Creatable("Optimization Networks")]
    13   [StorableClass]
    14   // standard ttp
    15   // cmaes variegates ksp values and tsp coordinates
    16   // 1) init cmaes (length = ksp.values.length)
    17   // 2) start cmaes
    18   // 3) evaluate vector as follows:
    19   // 4) change ksp values and tsp coordinates (mult by factor in vector)
    20   // 5) best ksp
    21   // 6) best tsp
    22   // 7) return ttp quality
    23   public sealed class TtpNetwork3 : Network {
    24     [StorableConstructor]
    25     private TtpNetwork3(bool deserializing) : base(deserializing) { }
    26     private TtpNetwork3(TtpNetwork3 original, Cloner cloner) : base(original, cloner) { }
    27     public TtpNetwork3() : base("TtpNetwork3") {
    28       var orchestratorNode = new TtpOrchestratorNode3();
    29       Nodes.Add(orchestratorNode);
     10//namespace HeuristicLab.Networks.IntegratedOptimization {
     11//  [Item("TtpNetwork3", "An optimization network for the TTP.")]
     12//  [Creatable("Optimization Networks")]
     13//  [StorableClass]
     14//  // standard ttp
     15//  // cmaes variegates ksp values and tsp coordinates
     16//  // 1) init cmaes (length = ksp.values.length)
     17//  // 2) start cmaes
     18//  // 3) evaluate vector as follows:
     19//  // 4) change ksp values and tsp coordinates (mult by factor in vector)
     20//  // 5) best ksp
     21//  // 6) best tsp
     22//  // 7) return ttp quality
     23//  public sealed class TtpNetwork3 : Network {
     24//    [StorableConstructor]
     25//    private TtpNetwork3(bool deserializing) : base(deserializing) { }
     26//    private TtpNetwork3(TtpNetwork3 original, Cloner cloner) : base(original, cloner) { }
     27//    public TtpNetwork3() : base("TtpNetwork3") {
     28//      var orchestratorNode = new TtpOrchestratorNode3();
     29//      Nodes.Add(orchestratorNode);
    3030
    31       var metaSolverNode = new OrchestratedAlgorithmNode("MetaSolver");
    32       var cmaes = new CMAEvolutionStrategy();
    33       cmaes.MaximumEvaluatedSolutions = 3000;
    34       cmaes.Engine = new ParallelEngine.ParallelEngine();
    35       metaSolverNode.Algorithm = cmaes;
    36       orchestratorNode.MetaSolverOrchestrationPort.ConnectedPort = metaSolverNode.OrchestrationPort;
    37       Nodes.Add(metaSolverNode);
     31//      var metaSolverNode = new OrchestratedAlgorithmNode("MetaSolver");
     32//      var cmaes = new CMAEvolutionStrategy();
     33//      cmaes.MaximumEvaluatedSolutions = 3000;
     34//      cmaes.Engine = new ParallelEngine.ParallelEngine();
     35//      metaSolverNode.Algorithm = cmaes;
     36//      orchestratorNode.MetaSolverOrchestrationPort.ConnectedPort = metaSolverNode.OrchestrationPort;
     37//      Nodes.Add(metaSolverNode);
    3838
    39       var tspSolverNode = new OrchestratedAlgorithmNode("TspSolver") { CloneAlgorithm = true };
    40       var ls = new LocalSearch();
    41       ls.Problem = orchestratorNode.TspParameter.Value;
    42       ls.MaximumIterations.Value = 100;
    43       tspSolverNode.Algorithm = ls;
    44       orchestratorNode.TspSolverOrchestrationPort.ConnectedPort = tspSolverNode.OrchestrationPort;
    45       Nodes.Add(tspSolverNode);
     39//      var tspSolverNode = new OrchestratedAlgorithmNode("TspSolver") { CloneAlgorithm = true };
     40//      var ls = new LocalSearch();
     41//      ls.Problem = orchestratorNode.TspParameter.Value;
     42//      ls.MaximumIterations.Value = 100;
     43//      tspSolverNode.Algorithm = ls;
     44//      orchestratorNode.TspSolverOrchestrationPort.ConnectedPort = tspSolverNode.OrchestrationPort;
     45//      Nodes.Add(tspSolverNode);
    4646
    47       var kspSolverNode = new OrchestratedAlgorithmNode("KspSolver") { CloneAlgorithm = true };
    48       var p3 = new ParameterlessPopulationPyramid();
    49       p3.Problem = orchestratorNode.KspParameter.Value;
    50       p3.MaximumRuntime = 3;
    51       kspSolverNode.Algorithm = p3;
    52       orchestratorNode.KspSolverOrchestrationPort.ConnectedPort = kspSolverNode.OrchestrationPort;
    53       Nodes.Add(kspSolverNode);
     47//      var kspSolverNode = new OrchestratedAlgorithmNode("KspSolver") { CloneAlgorithm = true };
     48//      var p3 = new ParameterlessPopulationPyramid();
     49//      p3.Problem = orchestratorNode.KspParameter.Value;
     50//      p3.MaximumRuntime = 3;
     51//      kspSolverNode.Algorithm = p3;
     52//      orchestratorNode.KspSolverOrchestrationPort.ConnectedPort = kspSolverNode.OrchestrationPort;
     53//      Nodes.Add(kspSolverNode);
    5454
    55       #region Import
    56       DoubleMatrix tspCoordinates;
    57       IntValue kspCapacity; IntArray kspItemWeights; IntArray kspItemValues;
    58       IntArray ttpAvailability; DoubleValue ttpMinSpeed; DoubleValue ttpMaxSpeed; DoubleValue ttpRentingRatio;
    59       TtpImporter.ImportTtpInstance(@"ttp-instances\berlin52-ttp\berlin52_n51_uncorr_01.ttp",
    60           out tspCoordinates,
    61           out kspCapacity, out kspItemValues, out kspItemWeights,
    62           out ttpAvailability, out ttpMinSpeed, out ttpMaxSpeed, out ttpRentingRatio);
     55//      #region Import
     56//      DoubleMatrix tspCoordinates;
     57//      IntValue kspCapacity; IntArray kspItemWeights; IntArray kspItemValues;
     58//      IntArray ttpAvailability; DoubleValue ttpMinSpeed; DoubleValue ttpMaxSpeed; DoubleValue ttpRentingRatio;
     59//      TtpImporter.ImportTtpInstance(@"ttp-instances\berlin52-ttp\berlin52_n51_uncorr_01.ttp",
     60//          out tspCoordinates,
     61//          out kspCapacity, out kspItemValues, out kspItemWeights,
     62//          out ttpAvailability, out ttpMinSpeed, out ttpMaxSpeed, out ttpRentingRatio);
    6363
    64       var tsp = orchestratorNode.TspParameter.Value;
    65       tsp.Coordinates = tspCoordinates;
     64//      var tsp = orchestratorNode.TspParameter.Value;
     65//      tsp.Coordinates = tspCoordinates;
    6666
    67       var ksp = orchestratorNode.KspParameter.Value;
    68       ksp.KnapsackCapacity = kspCapacity;
    69       ksp.Encoding.Length = kspItemValues.Length;
    70       ksp.Values = kspItemValues;
    71       ksp.Weights = kspItemWeights;
     67//      var ksp = orchestratorNode.KspParameter.Value;
     68//      ksp.KnapsackCapacity = kspCapacity;
     69//      ksp.Encoding.Length = kspItemValues.Length;
     70//      ksp.Values = kspItemValues;
     71//      ksp.Weights = kspItemWeights;
    7272
    73       orchestratorNode.AvailabilityParameter.Value = ttpAvailability;
    74       orchestratorNode.MinSpeedParameter.Value = ttpMinSpeed;
    75       orchestratorNode.MaxSpeedParameter.Value = ttpMaxSpeed;
    76       orchestratorNode.RentingRatioParameter.Value = ttpRentingRatio;
    77       #endregion
    78     }
     73//      orchestratorNode.AvailabilityParameter.Value = ttpAvailability;
     74//      orchestratorNode.MinSpeedParameter.Value = ttpMinSpeed;
     75//      orchestratorNode.MaxSpeedParameter.Value = ttpMaxSpeed;
     76//      orchestratorNode.RentingRatioParameter.Value = ttpRentingRatio;
     77//      #endregion
     78//    }
    7979
    80     public override IDeepCloneable Clone(Cloner cloner) {
    81       return new TtpNetwork3(this, cloner);
    82     }
    83   }
    84 }
     80//    public override IDeepCloneable Clone(Cloner cloner) {
     81//      return new TtpNetwork3(this, cloner);
     82//    }
     83//  }
     84//}
Note: See TracChangeset for help on using the changeset viewer.