Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2205_OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork4.cs @ 16879

Last change on this file since 16879 was 14895, checked in by jkarder, 8 years ago

#2205: worked on optimization networks

  • added lrp networks (4, 5)
  • fixed lrp evaluation
  • updated flp models
  • updated to cplex 12.7
File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Algorithms.CMAEvolutionStrategy;
25using HeuristicLab.Algorithms.GeneticAlgorithm;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Encodings.RealVectorEncoding;
29using HeuristicLab.Optimization;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31using HeuristicLab.Problems.FacilityLocation;
32using HeuristicLab.Problems.FacilityLocation.CplexSolver;
33using HeuristicLab.Problems.VehicleRouting;
34using HeuristicLab.Problems.VehicleRouting.Encodings.General;
35using HeuristicLab.Selection;
36
37namespace HeuristicLab.Networks.IntegratedOptimization.LocationRouting {
38  [Item("LrpNetwork4", "Version 4 of a TTP optimization network.")]
39  [Creatable("Optimization Networks")]
40  [StorableClass]
41  public sealed class LrpNetwork4 : LrpNetwork, IOptimizer {
42    [StorableConstructor]
43    private LrpNetwork4(bool deserializing) : base(deserializing) { }
44    private LrpNetwork4(LrpNetwork4 original, Cloner cloner) : base(original, cloner) { }
45    public LrpNetwork4() : this("LrpNetwork4") { }
46    public LrpNetwork4(string name) : base(name) {
47      Orchestrator = new LrpOrchestratorNode4(OrchestratorNodeName);
48      MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName);
49      FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName);
50      VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName);
51
52      var cmaes = new CMAEvolutionStrategy();
53      var vp = new MinimizationVariegationProblem<RealVectorEncoding>();
54      cmaes.Problem = vp;
55      var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single();
56      cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
57      cmaes.MaximumGenerations = 80;
58      MetaSolver.Algorithm = cmaes;
59      Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort;
60
61      var cplexSolver = new FLPCplexSolver();
62      cplexSolver.Problem = new FacilityLocationProblem();
63      cplexSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0);
64      FlpSolver.Algorithm = cplexSolver;
65      Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort;
66
67      var ga = new GeneticAlgorithm();
68      ga.Problem = new VehicleRoutingProblem();
69      ga.PopulationSize.Value = 100;
70      var crossover = ga.CrossoverParameter.ValidValues.OfType<MultiVRPSolutionCrossover>().Single(x => x.Name == "MultiVRPSolutionCrossover");
71      ga.CrossoverParameter.Value = crossover;
72      ga.MaximumGenerations.Value = 100;
73      var mutator = ga.MutatorParameter.ValidValues.OfType<MultiVRPSolutionManipulator>().Single(x => x.Name == "MultiVRPSolutionManipulator");
74      ga.MutatorParameter.Value = mutator;
75      var selector = ga.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single();
76      ga.SelectorParameter.Value = selector;
77      VrpSolver.Algorithm = ga;
78      Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort;
79    }
80
81    public override IDeepCloneable Clone(Cloner cloner) {
82      return new LrpNetwork4(this, cloner);
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.