#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 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;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
[Item("MultiVRPMoveMaker", "Peforms multiple moves on a given VRP encoding and updates the quality.")]
[StorableClass]
public class LambdaInterchangeMoveMaker : VRPMoveOperator, IMoveMaker, IMultiVRPMoveOperator {
public override bool CanChangeName {
get { return false; }
}
public ILookupParameter QualityParameter {
get { return (ILookupParameter)Parameters["Quality"]; }
}
public ILookupParameter MoveQualityParameter {
get { return (ILookupParameter)Parameters["MoveQuality"]; }
}
public ILookupParameter VRPMoveParameter {
get { return (ILookupParameter)Parameters["VRPMove"]; }
}
public ILookupParameter RandomParameter {
get { return (ILookupParameter)Parameters["Random"]; }
}
public ILookupParameter MoveVehcilesUtilizedParameter {
get { return (ILookupParameter)Parameters["MoveVehiclesUtilized"]; }
}
public ILookupParameter MoveTravelTimeParameter {
get { return (ILookupParameter)Parameters["MoveTravelTime"]; }
}
public ILookupParameter MoveDistanceParameter {
get { return (ILookupParameter)Parameters["MoveDistance"]; }
}
public ILookupParameter MoveOverloadParameter {
get { return (ILookupParameter)Parameters["MoveOverload"]; }
}
public ILookupParameter MoveTardinessParameter {
get { return (ILookupParameter)Parameters["MoveTardiness"]; }
}
public ILookupParameter VehcilesUtilizedParameter {
get { return (ILookupParameter)Parameters["VehiclesUtilized"]; }
}
public ILookupParameter TravelTimeParameter {
get { return (ILookupParameter)Parameters["TravelTime"]; }
}
public ILookupParameter DistanceParameter {
get { return (ILookupParameter)Parameters["Distance"]; }
}
public ILookupParameter OverloadParameter {
get { return (ILookupParameter)Parameters["Overload"]; }
}
public ILookupParameter TardinessParameter {
get { return (ILookupParameter)Parameters["Tardiness"]; }
}
[StorableConstructor]
protected LambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { }
protected LambdaInterchangeMoveMaker(LambdaInterchangeMoveMaker original, Cloner cloner) : base(original, cloner) { }
public override IDeepCloneable Clone(Cloner cloner) {
return new LambdaInterchangeMoveMaker(this, cloner);
}
public LambdaInterchangeMoveMaker()
: base() {
Parameters.Add(new LookupParameter("Quality", "The quality of the solution."));
Parameters.Add(new LookupParameter("MoveQuality", "The relative quality of the move."));
Parameters.Add(new LookupParameter("VRPMove", "The generated moves."));
Parameters.Add(new LookupParameter("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
Parameters.Add(new LookupParameter("MoveVehiclesUtilized", "The number of vehicles utilized."));
Parameters.Add(new LookupParameter("MoveTravelTime", "The total travel time."));
Parameters.Add(new LookupParameter("MoveDistance", "The distance."));
Parameters.Add(new LookupParameter("MoveOverload", "The overload."));
Parameters.Add(new LookupParameter("MoveTardiness", "The tardiness."));
Parameters.Add(new LookupParameter("VehiclesUtilized", "The number of vehicles utilized."));
Parameters.Add(new LookupParameter("TravelTime", "The total travel time."));
Parameters.Add(new LookupParameter("Distance", "The distance."));
Parameters.Add(new LookupParameter("Overload", "The overload."));
Parameters.Add(new LookupParameter("Tardiness", "The tardiness."));
}
public override IOperation Apply() {
IOperation next = base.Apply();
IVRPEncoding solution = VRPToursParameter.ActualValue as IVRPEncoding;
IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove;
DoubleValue moveQuality = MoveQualityParameter.ActualValue;
DoubleValue quality = QualityParameter.ActualValue;
//perform move
VRPToursParameter.ActualValue = move.MakeMove();
quality.Value = moveQuality.Value;
VehcilesUtilizedParameter.ActualValue = MoveVehcilesUtilizedParameter.ActualValue;
TravelTimeParameter.ActualValue = MoveTravelTimeParameter.ActualValue;
DistanceParameter.ActualValue = MoveDistanceParameter.ActualValue;
OverloadParameter.ActualValue = MoveOverloadParameter.ActualValue;
TardinessParameter.ActualValue = MoveTardinessParameter.ActualValue;
return next;
}
}
}