Not giving optimized results at all

69 views
Skip to first unread message

chaitanya tanwar

unread,
Sep 11, 2015, 2:44:33 PM9/11/15
to jsprit-ma...@googlegroups.com
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
 

chaitanya tanwar

unread,
Sep 11, 2015, 2:45:56 PM9/11/15
to jsprit-ma...@googlegroups.com
PFA, If the pic is not clear in the previous mail


Thanks.
WP_20150912_001.jpg

Stefan Schroeder

unread,
Sep 11, 2015, 3:13:07 PM9/11/15
to jsprit-ma...@googlegroups.com
Hi,

your suggested solution yields total costs of 56. Jsprit calculates 44 which are cost savings of over 20 percent. What do you find odd here?

Best
Stefan

Am 11/09/15 um 20:44 schrieb chaitanya tanwar:
--
You received this message because you are subscribed to the Google Groups "jsprit-mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-...@googlegroups.com.
To post to this group, send email to jsprit-ma...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsprit-mailing-list.
For more options, visit https://groups.google.com/d/optout.

chaitanya tanwar

unread,
Sep 11, 2015, 3:36:56 PM9/11/15
to jsprit-mailing-list
If "Vehicle" goes to pick 1 and then 3 and comes back to 0 as its maximum capacity is 2 the total cost is 16
and then "Vehicle1" goes to pick 2 from the shorter route which is going to 2 (cost 20) then coming back to 0 from the route which passes from 3 whose cost will be 20 + 2 + 5 = 27

and total cost = 43

There can be more shorter paths. 
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-list+unsub...@googlegroups.com.

Stefan Schroeder

unread,
Sep 11, 2015, 3:47:45 PM9/11/15
to jsprit-ma...@googlegroups.com
Then you need to redefine your matrix. Jsprit does not calcuate shortest paths for you. Thus costs from 0 to 2 should be 7 rather than 20. So make sure your matrix reflects shortest paths.

Am 11/09/15 um 21:36 schrieb chaitanya tanwar:
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-...@googlegroups.com.

Chaitanya Tanwar

unread,
Sep 12, 2015, 5:01:25 AM9/12/15
to jsprit-ma...@googlegroups.com
Thanks Stefan. But can you share why jsprit chose not to calculate shortest distance? As it can really help to reduce the cost of the transportation.

And can you share some links where i can read about how exactly jsprit works.

Thanks And Regards.

From: Stefan Schroeder
Sent: ‎12/‎09/‎2015 01:17 AM
To: jsprit-ma...@googlegroups.com
Subject: Re: [jsprit-mailing-list] Not giving optimized results at all

| 1       | vehicle              | end   �

[The entire original message is not included.]
Reply all
Reply to author
Forward
0 new messages