Wolfgang
Wolfgang

Reputation: 896

jsprit getting started: conceptional advice

I’m sorry, this is not a specific question. As I’m new to Jsprit I need some conceptional help on how to start solving a problem.

My example:

I started with only have one vehicle with start and end position. There are several pickup positions with priorities and only one depot position for delivery. The vehicle should drive 1 day, then 2 days break than another day with given begin/end- time for each day. The start/end- Positions are defined per day (1 and 4). The vehicle can return to its end position on the 1st day including a load, but on the 4th day the last position should be the depot to unload (and return empty).

I want to pickup as many items as possible based on the priority and the vehicles 2d load constraint, if there are too much pickups they will be ignored. The vehicle can return to the depot for unloads several times per day. I also thought of altering the pickup priorities before starting on day 4.

Upvotes: 4

Views: 424

Answers (1)

matt6frey
matt6frey

Reputation: 133

I would run the solution twice a week and remove any stops that are to be completed the first day, since they are no longer required for the next solution. If the truck can start anywhere the second day, then the start location will need to be updated for the second day. Otherwise, if it's starting from the warehouse both days, the start and end location are the same for both days.

First you want to define your vehicle type and vehicle:

// Vehicle Type
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance("Your vehicle type")
    .addCapacityDimension(0, capacity)
    .setMaxVelocity(maxSpeed) // in meters per second
    .setCostPerDistance(value)
    .build();

VehicleImpl vehicle = VehicleImpl.Builder.newInstance(fleet[i])
    .setType(vehicleType)
    .setEarliestStart(start).setLatestArrival(end)
    .setStartLocation(location) // Warehouse location
    .setEndLocation(location) // warehouse location
    .build();

Next, create your jobs. The service jobs are started from the warehouse and the pickup jobs can start from a store location and drop off to the target location. With this, I would define pickups and service jobs and then add them to the VRP:

// Service Jobs
Service.Builder.newInstance(instanceName)
    .setName("Unique Name").setLocation(
         new Location.Builder()
         .newInstance().setId("Unique ID")
         .setCoordinate(new Coordinate(x, y))
    )
    .addSizeDimension(0, 1) // accounts for vehicle capacity
    .build();

// Shipment Jobs
Shipment.Builder.newInstance(instanceName)
    .setName("Unique Name")
    .setPickupLocation(
         new Location.Builder()
         .newInstance().setId("Unique ID")
         .setCoordinate(new Coordinate(x, y))
    )
    .setDeliveryLocation(
         new Location.Builder()
         .newInstance().setId("Unique ID")
         .setCoordinate(new Coordinate(x, y))
    )
    .addSizeDimension(0, 1)
    .build();

// You can add priorities to jobs how you like with .setPriority()

You can loop through your jobs and create either job based on the type and add it to the VRP. Also looking into the cost matrix can help with your solution. (Check out: Using a cost matrix)

Afterwards, run your solution.

Cheers!

Upvotes: 1

Related Questions