#region License Information /* HeuristicLab * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Linq; using HeuristicLab.Algorithms.GeneticAlgorithm; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.BinaryVectorEncoding; using HeuristicLab.Optimization; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.FacilityLocation; using HeuristicLab.Problems.FacilityLocation.CplexSolver; using HeuristicLab.Problems.VehicleRouting; using HeuristicLab.Problems.VehicleRouting.Encodings.General; using HeuristicLab.Selection; namespace HeuristicLab.Networks.IntegratedOptimization.LocationRouting { [Item("LrpNetwork5", "Version 5 of a TTP optimization network.")] [Creatable("Optimization Networks")] [StorableClass] public sealed class LrpNetwork5 : LrpNetwork, IOptimizer { [StorableConstructor] private LrpNetwork5(bool deserializing) : base(deserializing) { } private LrpNetwork5(LrpNetwork5 original, Cloner cloner) : base(original, cloner) { } public LrpNetwork5() : this("LrpNetwork5") { } public LrpNetwork5(string name) : base(name) { Orchestrator = new LrpOrchestratorNode5(OrchestratorNodeName); MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName); FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName); VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName); var metaSolver = new GeneticAlgorithm(); metaSolver.Problem = new MinimizationVariegationProblem(); metaSolver.PopulationSize.Value = 20; var c1 = metaSolver.CrossoverParameter.ValidValues.OfType().Single(); metaSolver.CrossoverParameter.Value = c1; metaSolver.MaximumGenerations.Value = 80; var m1 = metaSolver.MutatorParameter.ValidValues.OfType().Single(); metaSolver.MutatorParameter.Value = m1; var s1 = metaSolver.SelectorParameter.ValidValues.OfType().Single(); metaSolver.SelectorParameter.Value = s1; MetaSolver.Algorithm = metaSolver; Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort; var flpSolver = new FLPCplexSolver(); flpSolver.Problem = new FacilityLocationProblem(); flpSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0); FlpSolver.Algorithm = flpSolver; Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort; var vrpSolver = new GeneticAlgorithm(); vrpSolver.Problem = new VehicleRoutingProblem(); vrpSolver.PopulationSize.Value = 100; var c2 = vrpSolver.CrossoverParameter.ValidValues.OfType().Single(x => x.Name == "MultiVRPSolutionCrossover"); vrpSolver.CrossoverParameter.Value = c2; vrpSolver.MaximumGenerations.Value = 100; var m2 = vrpSolver.MutatorParameter.ValidValues.OfType().Single(x => x.Name == "MultiVRPSolutionManipulator"); vrpSolver.MutatorParameter.Value = m2; var s2 = vrpSolver.SelectorParameter.ValidValues.OfType().Single(); vrpSolver.SelectorParameter.Value = s2; VrpSolver.Algorithm = vrpSolver; Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort; } public override IDeepCloneable Clone(Cloner cloner) { return new LrpNetwork5(this, cloner); } } }