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 |
|
---|
22 | using System;
|
---|
23 | using System.Linq;
|
---|
24 | using HeuristicLab.Algorithms.GeneticAlgorithm;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Encodings.BinaryVectorEncoding;
|
---|
28 | using HeuristicLab.Optimization;
|
---|
29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
30 | using HeuristicLab.Problems.FacilityLocation;
|
---|
31 | using HeuristicLab.Problems.FacilityLocation.CplexSolver;
|
---|
32 | using HeuristicLab.Problems.VehicleRouting;
|
---|
33 | using HeuristicLab.Problems.VehicleRouting.Encodings.General;
|
---|
34 | using HeuristicLab.Selection;
|
---|
35 |
|
---|
36 | namespace HeuristicLab.Networks.IntegratedOptimization.LocationRouting {
|
---|
37 | [Item("LrpNetwork5", "Version 5 of a TTP optimization network.")]
|
---|
38 | [Creatable("Optimization Networks")]
|
---|
39 | [StorableClass]
|
---|
40 | public sealed class LrpNetwork5 : LrpNetwork, IOptimizer {
|
---|
41 | [StorableConstructor]
|
---|
42 | private LrpNetwork5(bool deserializing) : base(deserializing) { }
|
---|
43 | private LrpNetwork5(LrpNetwork5 original, Cloner cloner) : base(original, cloner) { }
|
---|
44 | public LrpNetwork5() : this("LrpNetwork5") { }
|
---|
45 | public LrpNetwork5(string name) : base(name) {
|
---|
46 | Orchestrator = new LrpOrchestratorNode5(OrchestratorNodeName);
|
---|
47 | MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName);
|
---|
48 | FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName);
|
---|
49 | VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName);
|
---|
50 |
|
---|
51 | var metaSolver = new GeneticAlgorithm();
|
---|
52 | metaSolver.Problem = new MinimizationVariegationProblem<BinaryVectorEncoding>();
|
---|
53 | metaSolver.PopulationSize.Value = 20;
|
---|
54 | var c1 = metaSolver.CrossoverParameter.ValidValues.OfType<MultiBinaryVectorCrossover>().Single();
|
---|
55 | metaSolver.CrossoverParameter.Value = c1;
|
---|
56 | metaSolver.MaximumGenerations.Value = 80;
|
---|
57 | var m1 = metaSolver.MutatorParameter.ValidValues.OfType<SinglePositionBitflipManipulator>().Single();
|
---|
58 | metaSolver.MutatorParameter.Value = m1;
|
---|
59 | var s1 = metaSolver.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single();
|
---|
60 | metaSolver.SelectorParameter.Value = s1;
|
---|
61 | MetaSolver.Algorithm = metaSolver;
|
---|
62 | Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort;
|
---|
63 |
|
---|
64 | var flpSolver = new FLPCplexSolver();
|
---|
65 | flpSolver.Problem = new FacilityLocationProblem();
|
---|
66 | flpSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0);
|
---|
67 | FlpSolver.Algorithm = flpSolver;
|
---|
68 | Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort;
|
---|
69 |
|
---|
70 | var vrpSolver = new GeneticAlgorithm();
|
---|
71 | vrpSolver.Problem = new VehicleRoutingProblem();
|
---|
72 | vrpSolver.PopulationSize.Value = 100;
|
---|
73 | var c2 = vrpSolver.CrossoverParameter.ValidValues.OfType<MultiVRPSolutionCrossover>().Single(x => x.Name == "MultiVRPSolutionCrossover");
|
---|
74 | vrpSolver.CrossoverParameter.Value = c2;
|
---|
75 | vrpSolver.MaximumGenerations.Value = 100;
|
---|
76 | var m2 = vrpSolver.MutatorParameter.ValidValues.OfType<MultiVRPSolutionManipulator>().Single(x => x.Name == "MultiVRPSolutionManipulator");
|
---|
77 | vrpSolver.MutatorParameter.Value = m2;
|
---|
78 | var s2 = vrpSolver.SelectorParameter.ValidValues.OfType<TournamentSelector>().Single();
|
---|
79 | vrpSolver.SelectorParameter.Value = s2;
|
---|
80 | VrpSolver.Algorithm = vrpSolver;
|
---|
81 | Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort;
|
---|
82 | }
|
---|
83 |
|
---|
84 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
85 | return new LrpNetwork5(this, cloner);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|