Hi All,
So I have a weird issue where the results come back exactly the same as the original data set.
I have a function that creates services & shipments and build them as:
// Service
Service.Builder.newInstance(instanceName)
.setName(details.get("invoice").toString())
.setLocation(setLocation(instanceName, coords[0], coords[1]))
.setServiceTime((Double) details.get("serviceTime")/60)
.addRequiredSkill("TSP").setTimeWindow(TimeWindowSet).build()
// Shipment
Shipment.Builder.newInstance(instanceName)
.setName(details.get("invoice").toString())
.setPickupLocation(setLocation(instanceName, coords[0], coords[1]))
.setDeliveryLocation(setLocation(instanceName2, coords2[0], coords2[1]))
.setDeliveryTimeWindow(TimeWindowSet).addRequiredSkill("TSP")
.setDeliveryServiceTime((Double) details.get("serviceTime")/60)
.build();
I have tried using a large capacity for the vehicles when they are created and giving each job a weight of 0 - as suggested in the github docs for TSP.
When creating the problem, also in a function:
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
ArrayList<Service> SERVICES = new ArrayList<>();
ArrayList<Shipment> SHIPMENTS = new ArrayList<>();
for(Service service: List.of(services)) {
SERVICES.add(service);
}
for(Shipment shipment: List.of(shipments)) {
SHIPMENTS.add(shipment);
}
Collections.shuffle(SERVICES);
Collections.shuffle(SHIPMENTS);
if(trucks.length > 0) vrpBuilder.addAllVehicles(List.of(trucks));
if(services.length > 0) vrpBuilder.addAllJobs(SERVICES);
if(shipments.length > 0) vrpBuilder.addAllJobs(SHIPMENTS);
vrpBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
vrpBuilder.setRoutingCost(createCostMatrix());
VehicleRoutingProblem problem = vrpBuilder.build();
return problem;
Note the Collections.shuffle() call was just to test the Algorithm to see if it was actually arranging them in a determined order after sending it to the algorithm
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(problem);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
return Solutions.bestOf(solutions);
Does anybody have any suggestions as to what could be the issue? Thanks for your help!