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.CMAEvolutionStrategy;
|
---|
25 | using HeuristicLab.Algorithms.GeneticAlgorithm;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
29 | using HeuristicLab.Optimization;
|
---|
30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
31 | using HeuristicLab.Problems.FacilityLocation;
|
---|
32 | using HeuristicLab.Problems.FacilityLocation.CplexSolver;
|
---|
33 | using HeuristicLab.Problems.VehicleRouting;
|
---|
34 | using HeuristicLab.Problems.VehicleRouting.Encodings.General;
|
---|
35 | using HeuristicLab.Selection;
|
---|
36 |
|
---|
37 | namespace 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 | 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 LrpNetwork2(this, cloner);
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|