protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour, IVRPEncoding solution) { TourInsertionInfo tourInfo = new TourInsertionInfo(solution.GetVehicleAssignment(solution.GetTourIndex(tour))); eval.InsertionInfo.AddTourInsertionInfo(tourInfo); double distance = 0.0; double quality = 0.0; //simulate a tour, start and end at depot for (int i = 0; i <= tour.Stops.Count; i++) { int start = 0; if (i > 0) start = tour.Stops[i - 1]; int end = 0; if (i < tour.Stops.Count) end = tour.Stops[i]; //drive there double currentDistace = instance.GetDistance(start, end, solution); distance += currentDistace; StopInsertionInfo stopInfo = new StopInsertionInfo(start, end); tourInfo.AddStopInsertionInfo(stopInfo); } //Fleet usage quality += instance.FleetUsageFactor.Value; //Distance quality += instance.DistanceFactor.Value * distance; eval.Distance += distance; eval.VehicleUtilization += 1; tourInfo.Quality = quality; eval.Quality += quality; }
protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, out bool feasible) { StopInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index); double costs = 0; feasible = true; double startDistance, endDistance; costs += instance.GetInsertionDistance(insertionInfo.Start, customer, insertionInfo.End, solution, out startDistance, out endDistance); return(costs); }
protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, out bool feasible) { StopInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index); double costs = 0; feasible = true; double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End, solution); double newDistance = instance.GetDistance(insertionInfo.Start, customer, solution) + instance.GetDistance(customer, insertionInfo.End, solution); costs += instance.DistanceFactor.Value * (newDistance - distance); return(costs); }
protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour, IVRPEncoding solution) { TourInsertionInfo tourInfo = new TourInsertionInfo(solution.GetVehicleAssignment(solution.GetTourIndex(tour))); eval.InsertionInfo.AddTourInsertionInfo(tourInfo); double distance = 0.0; double quality = 0.0; //simulate a tour, start and end at depot for (int i = 0; i <= tour.Stops.Count; i++) { int start = 0; if (i > 0) { start = tour.Stops[i - 1]; } int end = 0; if (i < tour.Stops.Count) { end = tour.Stops[i]; } //drive there double currentDistace = instance.GetDistance(start, end, solution); distance += currentDistace; StopInsertionInfo stopInfo = new StopInsertionInfo(start, end); tourInfo.AddStopInsertionInfo(stopInfo); } //Fleet usage quality += instance.FleetUsageFactor.Value; //Distance quality += instance.DistanceFactor.Value * distance; eval.Distance += distance; eval.VehicleUtilization += 1; eval.Quality += quality; tourInfo.Quality = quality; }
public void AddStopInsertionInfo(StopInsertionInfo info) { stopInsertionInfos.Add(info); }