Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork2.cs @ 14628

Last change on this file since 14628 was 14628, checked in by jkarder, 7 years ago

#2205: worked on optimization networks

  • added variegation problem for minimization and maximization
  • refactored some classes
File size: 3.8 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("LrpNetwork2", "Version 2 of a TTP optimization network.")]
39  [Creatable("Optimization Networks")]
40  [StorableClass]
41  public sealed class LrpNetwork2 : LrpNetwork, IOptimizer {
42    [StorableConstructor]
43    private LrpNetwork2(bool deserializing) : base(deserializing) { }
44    private LrpNetwork2(LrpNetwork2 original, Cloner cloner) : base(original, cloner) { }
45    public LrpNetwork2() : this("LrpNetwork2") { }
46    public LrpNetwork2(string name) : base(name) {
47      Orchestrator = new LrpOrchestratorNode2(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      cmaes.MaximumGenerations = 80;
56      MetaSolver.Algorithm = cmaes;
57      Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort;
58
59      var cplexSolver = new FLPCplexSolver();
60      cplexSolver.Problem = new FacilityLocationProblem();
61      cplexSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0);
62      FlpSolver.Algorithm = cplexSolver;
63      Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort;
64
65      var ga = new GeneticAlgorithm();
66      ga.Problem = new VehicleRoutingProblem();
67      ga.PopulationSize.Value = 100;
68      var crossover = ga.CrossoverParameter.ValidValues.OfType<MultiVRPSolutionCrossover>().Single(x => x.Name == "MultiVRPSolutionCrossover");
69      ga.CrossoverParameter.Value = crossover;
70      ga.MaximumGenerations.Value = 100;
71      var mutator = ga.MutatorParameter.ValidValues.OfType<MultiVRPSolutionManipulator>().Single(x => x.Name == "MultiVRPSolutionManipulator");
72      ga.MutatorParameter.Value = mutator;
73      var selector = ga.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single();
74      ga.SelectorParameter.Value = selector;
75      VrpSolver.Algorithm = ga;
76      Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort;
77    }
78
79    public override IDeepCloneable Clone(Cloner cloner) {
80      return new LrpNetwork2(this, cloner);
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.