#region License Information
/* HeuristicLab
* Copyright (C) 2002-2019 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 HEAL.Fossil;
using HeuristicLab.Problems.VehicleRouting.Interfaces;
using HeuristicLab.Problems.VehicleRouting.Variants;
namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
[Item("MultiVRPMoveTabuChecker", "Checks if a VRP move is tabu.")]
[StorableType("5688A0E6-7EB0-43E2-9D9F-AB68D689148B")]
public class MultiVRPMoveTabuChecker : SingleSuccessorOperator, IMultiVRPMoveOperator, ITabuChecker, IGeneralVRPOperator {
public ILookupParameter VRPMoveParameter {
get { return (ILookupParameter)Parameters["VRPMove"]; }
}
public ILookupParameter VRPToursParameter {
get { return (ILookupParameter)Parameters["VRPTours"]; }
}
public ILookupParameter ProblemInstanceParameter {
get { return (LookupParameter)Parameters["ProblemInstance"]; }
}
public ILookupParameter> TabuListParameter {
get { return (ILookupParameter>)Parameters["TabuList"]; }
}
public ILookupParameter MoveTabuParameter {
get { return (ILookupParameter)Parameters["MoveTabu"]; }
}
public IValueLookupParameter MaximizationParameter {
get { return (IValueLookupParameter)Parameters["Maximization"]; }
}
public ILookupParameter MoveQualityParameter {
get { return (ILookupParameter)Parameters["MoveQuality"]; }
}
public ValueParameter UseAspirationCriterionParameter {
get { return (ValueParameter)Parameters["UseAspirationCriterion"]; }
}
public BoolValue UseAspirationCriterion {
get { return UseAspirationCriterionParameter.Value; }
set { UseAspirationCriterionParameter.Value = value; }
}
[StorableConstructor]
protected MultiVRPMoveTabuChecker(StorableConstructorFlag _) : base(_) { }
public MultiVRPMoveTabuChecker()
: base() {
Parameters.Add(new LookupParameter("VRPMove", "The move."));
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("MoveTabu", "The variable to store if a move was tabu."));
Parameters.Add(new LookupParameter>("TabuList", "The tabu list."));
Parameters.Add(new ValueParameter("UseAspirationCriterion", "Whether to use the aspiration criterion or not.", new BoolValue(true)));
Parameters.Add(new ValueLookupParameter("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem."));
Parameters.Add(new LookupParameter("MoveQuality", "The quality of the current move."));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new MultiVRPMoveTabuChecker(this, cloner);
}
protected MultiVRPMoveTabuChecker(MultiVRPMoveTabuChecker original, Cloner cloner)
: base(original, cloner) {
}
public override IOperation Apply() {
IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove;
ITabuChecker tabuChecker;
if (UseAspirationCriterion.Value)
tabuChecker = move.GetSoftTabuChecker();
else
tabuChecker = move.GetTabuChecker();
(tabuChecker as IVRPMoveOperator).VRPMoveParameter.ActualName = VRPMoveParameter.Name;
OperationCollection next = new OperationCollection(base.Apply());
next.Insert(0, ExecutionContext.CreateOperation(tabuChecker));
return next;
}
}
}