#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.CMAEvolutionStrategy;
using HeuristicLab.Algorithms.GeneticAlgorithm;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Encodings.RealVectorEncoding;
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("LrpNetwork2", "Version 2 of a TTP optimization network.")]
[Creatable("Optimization Networks")]
[StorableClass]
public sealed class LrpNetwork2 : LrpNetwork, IOptimizer {
[StorableConstructor]
private LrpNetwork2(bool deserializing) : base(deserializing) { }
private LrpNetwork2(LrpNetwork2 original, Cloner cloner) : base(original, cloner) { }
public LrpNetwork2() : this("LrpNetwork2") { }
public LrpNetwork2(string name) : base(name) {
Orchestrator = new LrpOrchestratorNode2(OrchestratorNodeName);
MetaSolver = new OrchestratedAlgorithmNode(MetaSolverNodeName);
FlpSolver = new OrchestratedAlgorithmNode(FlpSolverNodeName);
VrpSolver = new OrchestratedAlgorithmNode(VrpSolverNodeName);
var cmaes = new CMAEvolutionStrategy();
var vp = new MinimizationVariegationProblem();
cmaes.Problem = vp;
var cmaAnalyzer = cmaes.Analyzer.Operators.OfType().Single();
cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true);
cmaes.MaximumGenerations = 80;
MetaSolver.Algorithm = cmaes;
Orchestrator.MetaSolverOrchestrationPort.ConnectedPort = MetaSolver.OrchestrationPort;
var cplexSolver = new FLPCplexSolver();
cplexSolver.Problem = new FacilityLocationProblem();
cplexSolver.MaximumRuntimeParameter.Value.Value = TimeSpan.FromSeconds(3.0);
FlpSolver.Algorithm = cplexSolver;
Orchestrator.FlpSolverOrchestrationPort.ConnectedPort = FlpSolver.OrchestrationPort;
var ga = new GeneticAlgorithm();
ga.Problem = new VehicleRoutingProblem();
ga.PopulationSize.Value = 100;
var crossover = ga.CrossoverParameter.ValidValues.OfType().Single(x => x.Name == "MultiVRPSolutionCrossover");
ga.CrossoverParameter.Value = crossover;
ga.MaximumGenerations.Value = 100;
var mutator = ga.MutatorParameter.ValidValues.OfType().Single(x => x.Name == "MultiVRPSolutionManipulator");
ga.MutatorParameter.Value = mutator;
var selector = ga.SelectorParameter.ValidValues.OfType().Single();
ga.SelectorParameter.Value = selector;
VrpSolver.Algorithm = ga;
Orchestrator.VrpSolverOrchestrationPort.ConnectedPort = VrpSolver.OrchestrationPort;
}
public override IDeepCloneable Clone(Cloner cloner) {
return new LrpNetwork2(this, cloner);
}
}
}