public static void Apply(PotvinEncoding solution, PotvinVehicleAssignmentMove move, IVRPProblemInstance problemInstance) { int vehicle1 = solution.VehicleAssignment[move.Tour1]; int vehicle2 = solution.VehicleAssignment[move.Tour2]; solution.VehicleAssignment[move.Tour1] = vehicle2; solution.VehicleAssignment[move.Tour2] = vehicle1; }
protected PotvinVehicleAssignmentMove(PotvinVehicleAssignmentMove original, Cloner cloner) : base(original, cloner) { this.Tour1 = original.Tour1; this.Tour2 = original.Tour2; this.Individual = cloner.Clone(Individual) as PotvinEncoding; }
protected override void PerformMove() { PotvinVehicleAssignmentMove move = VehicleAssignmentMoveParameter.ActualValue; PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding; Apply(newSolution, move, ProblemInstance); newSolution.Repair(); VRPToursParameter.ActualValue = newSolution; }
protected override void EvaluateMove() { PotvinVehicleAssignmentMove move = VehicleAssignmentMoveParameter.ActualValue; PotvinEncoding newSolution = VehicleAssignmentMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding; PotvinVehicleAssignmentMoveMaker.Apply(newSolution, move, ProblemInstance); UpdateEvaluation(newSolution); }
protected override PotvinVehicleAssignmentMove[] GenerateMoves(PotvinEncoding individual, IVRPProblemInstance problemInstance) { List <PotvinVehicleAssignmentMove> result = new List <PotvinVehicleAssignmentMove>(); PotvinVehicleAssignmentMove move = Apply(individual, ProblemInstance, RandomParameter.ActualValue); if (move != null) { result.Add(move); } return(result.ToArray()); }
public override IOperation Apply() { ItemList <IItem> tabuList = TabuListParameter.ActualValue; double moveQuality = MoveQualityParameter.ActualValue.Value; bool useAspiration = UseAspirationCriterion.Value; bool isTabu = false; PotvinVehicleAssignmentMove move = VehicleAssignmentMoveParameter.ActualValue; foreach (IItem tabuMove in tabuList) { PotvinVehicleAssignmentMoveAttribute attribute = tabuMove as PotvinVehicleAssignmentMoveAttribute; if (attribute != null) { double distance = 0; if (MoveDistanceParameter.ActualValue != null) { distance = MoveDistanceParameter.ActualValue.Value; } double overload = 0; if (MoveOverloadParameter.ActualValue != null) { overload = MoveOverloadParameter.ActualValue.Value; } double tardiness = 0; if (MoveTardinessParameter.ActualValue != null) { tardiness = MoveTardinessParameter.ActualValue.Value; } IVRPProblemInstance instance = ProblemInstanceParameter.ActualValue; double quality = attribute.Distance * instance.DistanceFactor.Value; IHomogenousCapacitatedProblemInstance cvrp = instance as IHomogenousCapacitatedProblemInstance; if (cvrp != null) { quality += attribute.Overload * cvrp.OverloadPenalty.Value; } ITimeWindowedProblemInstance vrptw = instance as ITimeWindowedProblemInstance; if (vrptw != null) { quality += attribute.Tardiness * vrptw.TardinessPenalty.Value; } if (!useAspiration || moveQuality >= quality) { if (attribute.Tour == move.Tour1 && attribute.Vehicle == move.Individual.GetVehicleAssignment(move.Tour2)) { isTabu = true; break; } if (attribute.Tour == move.Tour2 && attribute.Vehicle == move.Individual.GetVehicleAssignment(move.Tour1)) { isTabu = true; break; } if (attribute.Distance == distance && attribute.Overload == overload && attribute.Tardiness == tardiness) { isTabu = true; break; } } } } MoveTabuParameter.ActualValue = new BoolValue(isTabu); return(base.Apply()); }