1

I want to assign priority to my agents and then queue them based on that. I have an agent Container which has two parameters carrier (which can be either Truck or Train) & priority (which is to be assigned with some value). 50% of agents where carrier=Truck and 50% of agents where carrier=Train should be assigned priority 1 and rest should be zero. How can I do that?

This is my model. [model]. I want to move the above mentioned agents from storage1 to rackPick block on priority.

Thanks in advance.

1 Answers1

0

This can be achieved by creating an integer 'priority' field in the agent and then setting it to 0 or 1 based on random(0.5) value in the on at exit action of the originating Source and then checking that field in the Queue to get priority. It won't be exactly 50% but pretty close for a large enough number of agent.

Artem P.
  • 816
  • 1
  • 6
  • 8
  • I didn't get you. I want to select 50% agents where agent.carrier=truck and 50% agents where agent.carrier=train and then assign agent.priority=1 for these selected agents. Can you please elaborate on how to use random(0.5) here? – Chhandosee Bhattacharya Apr 30 '21 at 15:42
  • Could you please clarify whether you want to do this when the agents are created (i.e. in a **Source** component) or are all agents created at the same, perhaps in the beginning of the simulation, and you'd like to select 50% from 2 different populations? – Artem P. Apr 30 '21 at 15:58
  • So, I have a population of agents called Container where 10 agents get generated at a time. This Container agent has a parameter carrier (values: truck, train). I want to choose 50% agents where agent.carrier=Truck & agent.carrier=Train and assign priority 1 to them. Ideally, I would want to do this before exiting the storage1 block. – Chhandosee Bhattacharya Apr 30 '21 at 16:43
  • In this case the simplest thing to do is to use a ternary operator in the `on Enter` action of the **RackStore** object 'storage1' like so: `agent.priority = randomTrue(0.5) ? 1 : 0;` for each type (truck or train). – Artem P. May 02 '21 at 20:49