Hi all,
I want to use Jsprit for cab allocation in an organisation to minimize the transportation cost.
So it looked similar to pickup and delivery to me.
So i created two cabs, with different capacities
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, 2).setCostPerDistance(1).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
.setStartLocation(Location.newInstance("0")).setType(type).build();
VehicleType type1 = VehicleTypeImpl.Builder.newInstance("type1").addCapacityDimension(0, 1).setCostPerDistance(1).build();
VehicleImpl vehicle1 = VehicleImpl.Builder.newInstance("vehicle1")
.setStartLocation(Location.newInstance("0")).setType(type1).build();
Three services, ie 3 employees to be picked like the following
ervice s1 = Service.Builder.newInstance("1").addSizeDimension(0, 1).setLocation(Location.newInstance("1")).build();
Service s2 = Service.Builder.newInstance("2").addSizeDimension(0, 1).setLocation(Location.newInstance("2")).build();
Service s3 = Service.Builder.newInstance("3").addSizeDimension(0, 1).setLocation(Location.newInstance("3")).build();
This is how i Build the routing problem :
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().setFleetSize(FleetSize.FINITE).setRoutingCost(costMatrix)
.addVehicle(vehicle1).addVehicle(vehicle).addJob(s1).addJob(s2).addJob(s3).build();
Below diagram shows my CostDistanceMatrix :
Solution I am getting is very Odd and giving very bad result.:
| indicator | value |
+---------------+----------+
| noJobs | 3 |
| noServices | 3 |
| noShipments | 0 |
| fleetsize | FINITE |
+--------------------------+
+----------------------------------------------------------+
| solution |
+---------------+------------------------------------------+
| indicator | value |
+---------------+------------------------------------------+
| costs | 44.0 |
| noVehicles | 2 |
| unassgndJobs | 0 |
+----------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route | vehicle | activity | job | arrTime | endTime | costs |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1 | vehicle | start | - | undef | 0 | 0 |
| 1 | vehicle | service | 1 | 0 | 0 | 10 |
| 1 | vehicle | service | 2 | 0 | 0 | 14 |
| 1 | vehicle | end | - | 0 | undef | 34 |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 2 | vehicle1 | start | - | undef | 0 | 0 |
| 2 | vehicle1 | service | 3 | 0 | 0 | 5 |
| 2 | vehicle1 | end | - | 0 | undef | 10 |
+--------------------------------------------------------------------------------------------------------------------------------+
It should be "vehicle" going to pick 1 and 3.
and "vehicle1" should go to pick 2. But its not happening.
What I am doing wrong?
Thanks And Regards,
Chaitanya Tanwar