Prioritize services

602 views
Skip to first unread message

David Miranda

unread,
Aug 27, 2015, 6:30:28 AM8/27/15
to jsprit-mailing-list
Hi,

How can I model the prioritization of services? For example, give preference to services that are urgent instead of normal services?

Thanks

He Huang

unread,
Aug 28, 2015, 3:30:48 AM8/28/15
to jsprit-mailing-list
Hi David,

I am not the developer of jsprit, and I am just trying to provide an answer to your question.

If you want the priority jobs done before a certain time, say, 12PM, you can set a time window with an early end time for those priority jobs;

If you want the priority jobs at or near the beginning of the route, say, top 10 in the sequence, I think you can set a custom constraint - I personally have never tried with this approach, though.

Hopefully it helps.

Best regards,
He

David Miranda

unread,
Aug 28, 2015, 9:45:29 AM8/28/15
to jsprit-mailing-list
Hi He,

Thank you for your help. I'm not sure if that resolves.

I want my services continue to have capacity constraints and time window. However I want to add the restriction of priority, so that if there tasks that have to be left out, or the same time window, the urgent take precedence over normal.

Thanks

He Huang

unread,
Aug 30, 2015, 11:29:10 PM8/30/15
to jsprit-mailing-list
Hi David,

Oh, I thought you wanted the priority jobs to be done prior to the normal ones.

I think your request will need a custom objective function in which the cost for unassigned priority jobs should be larger than that for unassigned normal jobs, so in this way normal jobs will be unassigned rather than priority ones, if they have to. See this post on how to set custom objective function, and the example provided by Stefan was to double the penalty for unassigned jobs - so perhaps you will only need to add an if() here.

Note that it is possible that you will need a soft constraint as well - I am not sure about this, though.

Hopefully it helps.

Best regards,
He

Stefan Schröder

unread,
Sep 14, 2015, 2:57:29 AM9/14/15
to jsprit-mailing-list
Hi David,

He is correct. You need a SoftContraint and a custom objective function. With the soft constraint, SoftRouteConstraint might be sufficient, you can for example decrease the insertion costs of a priority job by a certain value v so that it is more likely that a priority job will be inserted. At the same time you should consider this in your objective function, e.g. add (-1)*v if your priority job is assigned.

Best,
Stefan

Martin

unread,
Jan 23, 2016, 12:29:23 PM1/23/16
to jsprit-mailing-list
Hello Stefan, He and David,

I tried to experiment solution proposed by Stefan, using both SoftRouteConstraint and objective function: sometimes it works sometimes not. 

Let me explain:
I need priority jobs to make sure these jobs are done roughly at the beginning of the sequence, e.g. top 25% of all jobs (this is not an hard constraint). So I implemented SoftRouteConstraint returning negative cost for these priority jobs. Then I implemented the objective function to minor cost when priority jobs are within the top sequence.

Sometimes it provide good results (priority jobs are well within the starting sequence), but this is not consistent because in the objective function which provides all routes, some jobs never vary (always stays at the same order in the sequence) within all routes, so obviously the implementation of objective function has no effect if this is the priority job which stays at the same order. I'm using schrimpf algo (best insertion) maybe this algo is not capable to provide enough various route to let a chance schedule high priority jobs at the starting sequence? How to configure the algo to provide more route "variation"?

Hope this is clear, if not, please let me know.

Thanks,
Martin

Martin

unread,
Jan 23, 2016, 12:43:57 PM1/23/16
to jsprit-mailing-list
And if I change the implementation of SoftRouteConstraint to minor cost for priority job only when the insertion index (JobInsertionContext) is low so close to the starting sequence? But how to retrieve insertion index from JobInsertionContext? I talk about this callback:
public double getCosts(final JobInsertionContext insertionContext)

He Huang

unread,
Jan 24, 2016, 10:48:35 PM1/24/16
to jsprit-mailing-list
Hi Martin,

First of all, the mailing list has been moved to https://discuss.graphhopper.com/c/jsprit

Now to your question, you need a activity level constraint rather than a route level one, as your problem is different from David's - his problem only involves that priority jobs need to be routed, and yours requires handling the position of the priority jobs in the route. Check SoftActivityConstraint.

There are some similar posts in the new mailing list, for example: this and this.

Best regards,
He
Reply all
Reply to author
Forward
0 new messages