Custom Vehicle with Multiple Pickups & 2-Tiered Selection

Do you have objects, models, libraries, path decorators, textures, symbols, custom API code, documentation, or anything else others might find useful? Please attach it here with a brief description.
Post Reply
Simio Team Member
Posts: 86
Joined: Sun Feb 22, 2009 11:14 pm

Custom Vehicle with Multiple Pickups & 2-Tiered Selection

Post by DanSpice » Thu Apr 19, 2012 4:48 pm

The attached model illustrates 2 concepts: 1st the ability to pick up Entities mid-route, 2nd how to create a 2 Task Selection Strategy when deciding who to pick up.
In this model, there are high priority Entities (illustrated by the red Entities) that are created at HiPrioSource. These Entities are to be loaded first, even with low priority Entities waiting. And when the high priority Entity is loaded the vehicle takes it directly to the sink. However, when a low priority Entity is loaded, the vehicle is supposed to stop and pick up any other waiting low priority Entities that are waiting along the vehicle’s route to the sink. So, to maximize the number of Entities loaded, the vehicle wants to pick up at the farthest location (LowPrioSource1) so that it can pick up any waiting Entities as it passes through LowPrioSource2.

Now the Vehicle chooses the next Entity to pick up based on its Task Selection Strategy where it can be Largest/Smallest Priority or Largest/Smallest Distance – but it can’t be both. In this example, we want to FIRST make the decision based on Priority, THEN if we know its low priority we want to base it on Largest Distance.

Because we want to first base it on Priority we set the Task Selection Strategy to Highest Priority. This means that it will handle the first tier of the decision process for us. Creating the second tier requires us to customize the Standard Library Vehicle. So we subclass a Vehicle and add an Entity Reference State called ‘NextEntityToPickup’. Then we Override the OnVisitingNode Process in this new vehicle and about 2/3s of the way through the process, after Decide-IfIdel and before the Plan Visit-NewTransportationTask we place a Search step. This Search Step searches the QueueState ‘MyVehicle.CurrentNetwork.VisitRequestQueue’ (the queue of all waiting Entities) with a Search Type of ‘MaximizeReturnValue’ with a Return Value Expression of ‘MyVehicle.NetworkDistanceTo.Node(Candidate.Entity.CurrentNode)’ – meaning the Entity that is farthest away from me. This Step will find the farthest Entity out of all waiting Entities, so on the Found Branch we assign NextEntityToPickup the value of ‘Object’ – meaning the specific Entity that is farthest away.

*Note, we have to reset the NextEntityToPickup State before this Search.

Now, in the OnEvaluatingTranportRequest Add-on process we place a Decide Step with the following expression ‘Math.If((MyVehicle.ResourceState==0) && (MyVehicle.NextEntityToPickup != Nothing), MyVehicle.NextEntityToPickup == Entity, True)’ and a Reject Assignment on the False Branch. So, this expression says If the MyVehicle is Idle and there IS a value for NextEntityToPickup, Then “am I the next Entity to pick up?” (which gets evaluated by every Entity), if it is not idle or there is no value for NextEntityToPickup then continue on – the vehicle will pick you up.

So, this combination of letting the Vehicle handle the Priority mixed with Finding > Assigning > and Checking the Farthest Entities will give you the 2 tiered Task Selection that was desired.

Also, don’t forget that this Vehicle is supposed to pick up low priority Entities Mid-Route. Doing this requires further Customization of the OnVisitingNode Process. Right after the Execute-Entered Add-On Process Step we placed a Search Step that checks to see if there is any High Priority Entities in the Ride Station. If the Ride Station has a High Priority Entity OR it is completely empty, the process will continue on as normal. If the Ride Station is NOT empty and it is carrying a Low Priority Entity, that means we can try to pick up more Entities along the way. To do this, we just force the Vehicle to try to DropOff/PickUp at this node (which it would not do normally, unless it was at the dropoff node). If there are no Entities to pick up or drop off at this node, both the Pickup and Dropoff Nodes will fail and the token will eventually route itself out of the process and the Vehicle will continue on. If there are waiting Entities, the vehicle is forced to pick them up by avoiding the logic that would normally tell the Vehicle to exit the node.
Custom Pickup
(97.39 KiB) Downloaded 763 times
Dan Spice

Applications Engineer, Simio LLC

Posts: 5
Joined: Thu Nov 04, 2010 1:47 am

Re: Custom Vehicle with Multiple Pickups & 2-Tiered Selectio

Post by zsliu » Thu Apr 19, 2012 7:53 pm


Simio Insider
Posts: 291
Joined: Mon Aug 03, 2009 12:01 am
Location: China

Re: Custom Vehicle with Multiple Pickups & 2-Tiered Selectio

Post by jzhou » Thu Apr 19, 2012 7:57 pm

Thank you , Dan.


Post Reply