#region License Information /* HeuristicLab * Copyright (C) 2002-2014 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.Operators; using HeuristicLab.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.Orienteering { [Item("OrienteeringShakingOperator", @"The used neighborhood operator is based on a two point exchange move. A move in the k-th neighborhood consists of removing k consecutive vertices from the tour, starting at a randomly selected position. Afterwards, a sorted list of all vertices not yet included in the current tour is built. The vertices are sorted in descending order with respect to the objective value increase using the current weights. Out of the first three entries with the highest ranking in this list, one randomly selected vertex is reinserted into the current tour at the same position as the removed vertices. This way, l new vertices are inserted into the tour. The largest neighborhood is a complete exchange of all vertices on the tour. The shaking procedure does not guarantee that the new tour does not exceed the cost limit Tmax. Therefore, in a repair step, a sorted list of all vertices in the tour is created. The vertices are sorted in descending order with respect to costs saved when removing the vertex from the tour. Vertices are removed as long as the cost limit is violated. (Schilde et. al. 2009)")] [StorableClass] public class OrienteeringShakingOperator : SingleSuccessorOperator, IMultiNeighborhoodShakingOperator { public IValueLookupParameter CurrentNeighborhoodIndexParameter { get { return (IValueLookupParameter)Parameters["CurrentNeighborhoodIndex"]; } } public ILookupParameter NeighborhoodCountParameter { get { return (ILookupParameter)Parameters["NeighborhoodCount"]; } } [StorableConstructor] private OrienteeringShakingOperator(bool deserializing) : base(deserializing) { } private OrienteeringShakingOperator(OrienteeringShakingOperator original, Cloner cloner) : base(original, cloner) { //RegisterEventHandlers(); } public OrienteeringShakingOperator() : base() { Parameters.Add(new ValueLookupParameter("CurrentNeighborhoodIndex", "The index of the operator that should be applied (k).")); Parameters.Add(new LookupParameter("NeighborhoodCount", "The number of operators that are available.")); //RegisterEventHandlers(); } public override IDeepCloneable Clone(Cloner cloner) { return new OrienteeringShakingOperator(this, cloner); } [StorableHook(HookType.AfterDeserialization)] private void AfterDeserialization() { //RegisterEventHandlers(); } public override IOperation Apply() { // TODO return base.Apply(); } } }