#region License Information /* HeuristicLab * Copyright (C) 2002-2010 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 HeuristicLab.Core; using HeuristicLab.Encodings.PermutationEncoding; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Data; using HeuristicLab.Common; using HeuristicLab.Optimization; using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; namespace HeuristicLab.PDPSimulation.Operators { [Item("DynPotvinPDExchangeMoveEvaluator", "Evaluates a exchange move for a PDP representation. ")] [StorableClass] public sealed class DynPotvinPDExchangeMoveEvaluator : PotvinMoveEvaluator, IDynPotvinPDExchangeMoveOperator { public ILookupParameter PDExchangeMoveParameter { get { return (ILookupParameter)Parameters["DynPotvinPDExchangeMove"]; } } public override ILookupParameter VRPMoveParameter { get { return PDExchangeMoveParameter; } } public ILookupParameter MemoriesParameter { get { return (ILookupParameter)Parameters["Memories"]; } } public IValueParameter AdditionFrequencyMemoryKeyParameter { get { return (IValueParameter)Parameters["AdditionFrequencyMemoryKey"]; } } public IValueParameter LambdaParameter { get { return (IValueParameter)Parameters["Lambda"]; } } [StorableConstructor] private DynPotvinPDExchangeMoveEvaluator(bool deserializing) : base(deserializing) { } public DynPotvinPDExchangeMoveEvaluator() : base() { Parameters.Add(new LookupParameter("DynPotvinPDExchangeMove", "The move that should be evaluated.")); Parameters.Add(new LookupParameter("Memories", "The TS memory collection.")); Parameters.Add(new ValueParameter("AdditionFrequencyMemoryKey", "The key that is used for the addition frequency in the TS memory.", new StringValue("AdditionFrequency"))); Parameters.Add(new ValueParameter("Lambda", "The lambda parameter.", new DoubleValue(0.015))); } public override IDeepCloneable Clone(Cloner cloner) { return new DynPotvinPDExchangeMoveEvaluator(this, cloner); } private DynPotvinPDExchangeMoveEvaluator(DynPotvinPDExchangeMoveEvaluator original, Cloner cloner) : base(original, cloner) { } protected override void EvaluateMove() { DynPotvinPDExchangeMove move = PDExchangeMoveParameter.ActualValue; PotvinEncoding newSolution = PDExchangeMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding; DynPotvinPDExchangeMoveMaker.Apply(newSolution, move, ProblemInstance); UpdateEvaluation(newSolution); } } }