#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.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Problems.VehicleRouting {
[Item("VRPMoveEvaluator", "A base class for operators which evaluate VRP moves.")]
[StorableClass]
public abstract class VRPMoveEvaluator : VRPOperator, IVRPMoveEvaluator, IMoveOperator {
public override bool CanChangeName {
get { return false; }
}
public ILookupParameter VRPToursParameter {
get { return (ILookupParameter)Parameters["VRPTours"]; }
}
public ILookupParameter FleetUsageFactor {
get { return (ILookupParameter)Parameters["EvalFleetUsageFactor"]; }
}
public ILookupParameter TimeFactor {
get { return (ILookupParameter)Parameters["EvalTimeFactor"]; }
}
public ILookupParameter DistanceFactor {
get { return (ILookupParameter)Parameters["EvalDistanceFactor"]; }
}
public ILookupParameter OverloadPenalty {
get { return (ILookupParameter)Parameters["EvalOverloadPenalty"]; }
}
public ILookupParameter TardinessPenalty {
get { return (ILookupParameter)Parameters["EvalTardinessPenalty"]; }
}
public ILookupParameter QualityParameter {
get { return (ILookupParameter)Parameters["Quality"]; }
}
public ILookupParameter MoveQualityParameter {
get { return (ILookupParameter)Parameters["MoveQuality"]; }
}
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"]; }
}
[StorableConstructor]
protected VRPMoveEvaluator(bool deserializing) : base(deserializing) { }
protected VRPMoveEvaluator(VRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
protected VRPMoveEvaluator()
: base() {
Parameters.Add(new LookupParameter("VRPTours", "The VRP tours."));
Parameters.Add(new LookupParameter("Quality", "The quality of a VRP solution."));
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("MoveQuality", "The evaluated quality of a move on a VRP solution."));
Parameters.Add(new LookupParameter("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
Parameters.Add(new LookupParameter("EvalTimeFactor", "The time factor considered in the evaluation."));
Parameters.Add(new LookupParameter("EvalDistanceFactor", "The distance factor considered in the evaluation."));
Parameters.Add(new LookupParameter("EvalOverloadPenalty", "The overload penalty considered in the evaluation."));
Parameters.Add(new LookupParameter("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation."));
}
protected abstract TourEvaluation GetMoveQuality();
public override IOperation Apply() {
TourEvaluation tourEval = GetMoveQuality();
MoveQualityParameter.ActualValue = new DoubleValue(tourEval.Quality);
MoveDistanceParameter.ActualValue = new DoubleValue(tourEval.Distance);
MoveVehcilesUtilizedParameter.ActualValue = new DoubleValue(tourEval.VehcilesUtilized);
MoveOverloadParameter.ActualValue = new DoubleValue(tourEval.Overload);
MoveTardinessParameter.ActualValue = new DoubleValue(tourEval.Tardiness);
MoveTravelTimeParameter.ActualValue = new DoubleValue(tourEval.TravelTime);
return base.Apply();
}
}
}