I am presently making use of the jsprit library to create routes for cab companies. One of the critical constraints that we have to handle are that of Escorts/Security personnel. During the time of 7AM/7PM, if there are any female employees in a vehicle, an escort must be present. Different companies have different rules. The end result of adding an escort is that the effective vehicle capacity is one less.
These are the two different regulations that different companies have
- If the first or last employee in a route is female, then an escort needs to be provided.
- If there is at least one female employee in a route, an escort has to be provided.
I’ve tried implementing this as an HardActivityConstraint, but the difficulty I am experiencing is that newAct, prevAct, etc don’t retain the information of the sex of the employee.
It would be very helpful if you could offer a suggestion as to how I should implement these constraints in jsprit. Thank you very much for your time.
newAct and prevAct are independent of the vehicles and drivers. Therefore, assigning sex of employees to the specific activity is basically a pre-assignment of driver and location. However, you can assign sex of employee to the vehicle (e.g. newVehicle). Since each vehicle is assigned an index (after adding it to VehicleRoutingProblem) you can setup an array of sexes, i.e. indexOfVehicle --> sex of employee and use it for your HardActivityConstraint.
Let me know whether this helps you already.
Thank you very much for your response, I will try what you suggest and will get back to you.
I do not understand how assigning a sex to a specific activity is a pre-assignment of driver and location.
I meant it related to the driver. thus, if you have a female driver, it is a pre-assignment if you assign this driver to any specific activity. however, if it is a female who is picked up at a certain location, it does make sense to assign sex to this activity. this is as easy as assigning sex to vehicles. activities also get an index once you add the underlying job (service or shipment) to the vrp, thus you can also memorize the information in an array mapping activity-index to sex.
Yes, that helps! Thank you.
I’m trying to implement similar example. Could you help me here? How exactly did you implement the constraint,[quote=“Anirban_Mandal, post:1, topic:310”]
2. If there is at least one female employee in a route, an escort has to be provided.
What I did in order to solve this is only take care of the fact that when an escort is provided, the capacity of the vehicle is effectively reduced by 1. I maintain a hash of (employee id, sex). Also the id of any Shipment or of a Job is set to the employee id.
An instance of prevAct, newAct, or nextAct can be cast into a job/shipment.
As an example, if you have a Job
PickupService p = (PickupService) prevAct;
Job J = p.getJob();
Next we can get the Job id using J.getId(), and use our hash of <job id’s, sex> to get the sex of the employee. If there is a female, we can check if the number of jobs <= vehicle capacity -1.
I am new to jsprit library and trying to implement vrp using jsprit library to create routes. I have a special requirement for female employees
If the first or last employee in a route is female, then an escort needs to be provided, and that too depending on time.
For eg: During the time of 7AM/7PM, if first or last employee in a route is female, in a vehicle, an escort must be present.
Cab drivers are all male, so there is no case of assigning sex of employee to a vehicle.
I am facing challenges in implementation the HardActivityConstraint using above suggestions and comments.
It would be very helpful if you could offer a suggestion as to how I should implement these constraints(HardActivityConstraint) in jsprit. Thank you very much for your time.