#region License Information /* HeuristicLab * Copyright (C) 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.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Parameters; using HEAL.Attic; namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { [Item("PotvinPDExchangeMoveEvaluator", "Evaluates a exchange move for a PDP representation. ")] [StorableType("092A4B82-1387-4887-9E0A-88F7D01862F6")] public sealed class PotvinPDExchangeMoveEvaluator : PotvinMoveEvaluator, IPotvinPDExchangeMoveOperator { public ILookupParameter PDExchangeMoveParameter { get { return (ILookupParameter)Parameters["PotvinPDExchangeMove"]; } } 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 PotvinPDExchangeMoveEvaluator(StorableConstructorFlag _) : base(_) { } public PotvinPDExchangeMoveEvaluator() : base() { Parameters.Add(new LookupParameter("PotvinPDExchangeMove", "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 PotvinPDExchangeMoveEvaluator(this, cloner); } private PotvinPDExchangeMoveEvaluator(PotvinPDExchangeMoveEvaluator original, Cloner cloner) : base(original, cloner) { } protected override void EvaluateMove() { PotvinPDExchangeMove move = PDExchangeMoveParameter.ActualValue; PotvinEncoding newSolution = PDExchangeMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding; PotvinPDExchangeMoveMaker.Apply(newSolution, move, ProblemInstance); UpdateEvaluation(newSolution); } } }