#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.Optimization.Operators;
using HeuristicLab.Parameters;
using HEAL.Attic;
using HeuristicLab.Problems.VehicleRouting.Interfaces;
namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
[Item("PotvinPDRearrangeMoveTabuMaker", "Declares a given rearrange move as tabu.")]
[StorableType("6E0FA87D-669A-4586-AD56-7DE38A2F54D1")]
public class PotvinPDRearrangeMoveTabuMaker : TabuMaker, IPotvinPDRearrangeMoveOperator, IPotvinOperator, IVRPMoveOperator {
public ILookupParameter PDRearrangeMoveParameter {
get { return (ILookupParameter)Parameters["PotvinPDRearrangeMove"]; }
}
public ILookupParameter VRPMoveParameter {
get { return PDRearrangeMoveParameter; }
}
public ILookupParameter VRPToursParameter {
get { return (ILookupParameter)Parameters["VRPTours"]; }
}
public ILookupParameter ProblemInstanceParameter {
get { return (LookupParameter)Parameters["ProblemInstance"]; }
}
public ILookupParameter DistanceParameter {
get { return (ILookupParameter)Parameters["Distance"]; }
}
public ILookupParameter OverloadParameter {
get { return (ILookupParameter)Parameters["Overload"]; }
}
public ILookupParameter TardinessParameter {
get { return (ILookupParameter)Parameters["Tardiness"]; }
}
public ILookupParameter PickupViolationsParameter {
get { return (ILookupParameter)Parameters["PickupViolations"]; }
}
[StorableConstructor]
protected PotvinPDRearrangeMoveTabuMaker(StorableConstructorFlag _) : base(_) { }
protected PotvinPDRearrangeMoveTabuMaker(PotvinPDRearrangeMoveTabuMaker original, Cloner cloner) : base(original, cloner) { }
public PotvinPDRearrangeMoveTabuMaker()
: base() {
Parameters.Add(new LookupParameter("PotvinPDRearrangeMove", "The moves that should be made."));
Parameters.Add(new LookupParameter("VRPTours", "The VRP tours considered in the move."));
Parameters.Add(new LookupParameter("ProblemInstance", "The VRP problem instance"));
Parameters.Add(new LookupParameter("Distance", "The distance of the individual"));
Parameters.Add(new LookupParameter("Overload", "The overload of the individual"));
Parameters.Add(new LookupParameter("Tardiness", "The tardiness of the individual"));
Parameters.Add(new LookupParameter("PickupViolations", "The number of pickup violations."));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new PotvinPDRearrangeMoveTabuMaker(this, cloner);
}
protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) {
PotvinPDRearrangeMove move = PDRearrangeMoveParameter.ActualValue;
double baseQuality = moveQuality;
if (quality < moveQuality) baseQuality = quality; // we make an uphill move, the lower bound is the solution quality
double distance = 0;
if (DistanceParameter.ActualValue != null)
distance = DistanceParameter.ActualValue.Value;
double overload = 0;
if (OverloadParameter.ActualValue != null)
overload = OverloadParameter.ActualValue.Value;
double tardiness = 0;
if (TardinessParameter.ActualValue != null)
tardiness = TardinessParameter.ActualValue.Value;
int pickupViolations = 0;
if (PickupViolationsParameter.ActualValue != null)
pickupViolations = PickupViolationsParameter.ActualValue.Value;
return new PotvinPDRelocateMoveAttribute(baseQuality, move.Tour, move.City, distance, overload, tardiness, pickupViolations);
}
}
}