How make change algorithm to choose nearest pickup as last pickup

Hi everyone,

I have a problem that when i run jsprit it takes nearest point for service and then other points in graph but In my scenario that nearest points should be process last not first. for example let us suppose i have 3 points A,B,C and P is my depot,when i run solution i am getting A->C->B where A is near to depot P , how can i force to make solution B->C->A as it has A is nearest point. please suggest some solution.

Hi @mndpsngh21,

You can force an activity to be inserted as the last in a route by a hard activity constraint, which will include two parts:

  1. if newAct is a target activity, then return not fulfilled if nextAct is not End;

  2. return not fulfilled if prevAct is a target activity.

Hopefully I have not missed anything.

Best regards,

1 Like

Hi @jie31best,

Thanks for reply. Your solution works perfectly if i know that next pickup is far than targetActivity, But I want jsprit should insert farest point as first and based on that it should service other job.I hope i am able to explain please let me know if clarification required.

If I understand your problem clearly you want Jsprit to service farthest node first. Iā€™m assuming here that you know the farthest node. In that case you can use solution provided by @jie31best with few modification

  1. Use Initial route to add farthest node in route.

  2. Use hard activity constraint if nextAct is farthest node return not fulfilled