I am trying to work out how to use the "Population of agents" radio button functionality in the Advanced section of the "Queue" block from the process library.
I am able to successfully select the "Population of agents" option and specify the number of queues to be in the population however I am then unable to direct agents to any of the queues in the population. Ultimately, I need to send agents to specific queues in the collection (population) but I can't seem to work out how to do that.
The screenshot shows a bit more of what I am trying to achieve:
Even though you have the option to create a population of queues, there's no possible use for it since you can't add an agent to the queue without a flow (for insteance enter block)
In order to make a good population of queues, you need to create a population of agents called for instance QueueAgent
And in this queue agent you will have
enter->queue->exit
Then you can choose to what queue to send your agent to send it by using queueAgents.get(index).enter.take(agent) where index is the queue index to which your agent needs to be sent
the exit block will send your agent back to an enter block that will be connected to speacialtyProcesses
The only blocks in which it makes sense to create a population are the blocks that create agents such as source or enter blocks.
Related
I am developing a model comprised of m consecutive machines in which n agents must be processed in random sequences of machines. I want to have an intelligent agent (Reinforcement Learning) to, in each action, set the priority rule to rank queued agents in each machine.
The problem I have is that I am not sure if I am correctly changing the queueing order of agents in each queue, whenever the ranking rule is changed.
After some googling, I found this post, which seems to be what I want.:
Change priority rule of a Queue block at runtime in Anylogic
In this post, user Stuart Rossiter posted an interesting solution, (case 2 - using service block), which consists of sorting the agents queued on the embedded service's queue, using self.queue.sortAgents().
However, AnyLogic does not recognize this expression, as when I try to use it, I get the error "queue cannot be resolved or is not a field". After some more googling, I was able to find that the embedded queue of services can be accessed through service.seize.queue; however, even through this way, the method sortAgents() cannot be used, as I get an error saying that the method is undefined.
So, I am asking how can I reorder the agents in the embedded queue of a service after changing the ranking rule in runtime?
Obviously, I am assuming that playing with the task priority of the service would not be enough, as that would only be used to rank the order of agents that arrive to the queue after the ranking rule is set, i.e., it does not update the order of jobs queued before the ranking rule is changed (this is also clearly explained by the same user Stuart Rossiter).
Thank you.
Suppose I have the following supply chain model see model model1
Agents are communicating with each other through a defined network and send messages to each other through ports. for example, demand is generated for customers through their ports and send as "orders" upstream to facilities. Upstream facilities send "shipments" to downstream facilities
and stats are collected at each node.
The model seems to work for 2 echelons but when one facility is connected to two facilities downstream as desired I get the following error "Agent can't be in several flowcharts at the time. At least two flowchart blocks are in conflict" see error. Based on the description it seems the agent "shipment" is sent to two facilities at the same time.
My question is how could I avoid this conflict?
more information about each node:
Agents' "orders" enter through each node's port and are capture as Enter. take(msg), follow a flowchart, and exit as Agent "shipment" to each destination. Each agent "order" has a double amount and port destination. see facility node
any suggestions please?
You must make sure that you do not send agents into a flowchart that is already in another flow chart, correct. This is bad model design.
One way to debug and find the root issue: before sending any message agent, check currentBlock()!=null and traceln the agent and the block. Also pause the model.
You can then see where you want to (re)send that agent that is already in some other flowchart block.
You probably send message agents out that are still somewhere else.
PS: For messages, you probably do not want to use flow charts at all but normal message passing. This avoids these pains here as you can easily send the same message to several agents. Check how message passing is done in the example agent models
I'm simulating abandonment by waiting customers in a queue environment. I'm assuming that a person will abandon a queue if they notice that people who were in the queue ahead of them have left the queue (amongst other things like their own time in queue). To do this, I need to capture the details of the people already waiting in a queue when a new person joins the queue. I figure I need a collection created in the customer agent that i can store agent details of those ahead of them in queue. I can then use code to "populate" this collection via the on enter action of the queue block. but I'm not sure how to progress. I am struggling with how to find the IDs of agents in a queue and collect values of their parameters. Any help will be appreciated! Thank you.
When a new agent enters the queue you can use a for loop to cycle through all the agents in the queue and add it to a variable inside the agent.
Take the following simple example.
There is a custom agent type MyAgent it has a collection of type ArrayList accepting objects of type MyAgent.
Now when an agent enters a queue I can store the agents ahead of it in the queue in the following way
Please note the limit of the for loop is i < self.size()-1, if you don't add the -1 the agent will add itself to the list. (assuming your queue is FIFO (First in first out) the new agent will be the last in the list.
I am using a priority based queue to pick agents from a pallet rack. Priority of agents can be 0 or 1. If there are 10 agents in palletRack, I want to pick all the agents having priority=1 first. My problem in the current flowchart is: Agents with priority=0 are pickup up before agents with priority=1. May be because the agents enter & leave the Queue block one by one, multiple agents aren't present in the Queue block at the same time so that they can be sorted. How to resolve this?
put a hold block between queueStorage2 and pickFromStorage1 and on the on enter action of queueStorage2, you check if all your agents are there, and if they are (with whatever condition you need to check to be sure everything is there) you unblock the hold with hold.unblock();
I'm trying to emulate what QUEST does when a buffer is queried for a certain Part. In there if the part is not in the buffer the request is left pending and if a Part arrives to the buffer it's released to the machine requesting it. I have also seen this behavior in SimPy which is another DES engine.
I can't seem to find a simple way to do this in AL. The queue block has the following methods:
release(agent): Will return false and forget about the request if there's not an agent as the one specified
remove(agent): Will return null if there's no agent in the queue
So those methods won't do what I want...
It gets a little more complicated as the queue contains agents with parameters and I want to request a specific set of parameters (let's say the agents have a number parameter that can go from 1 to 3 and I'm only interested in agents in the queue if this parameter has the value 2).
Also there's a series of agents pulling this agents from the queue simultaneously and I'd like a priority to be set (let's say FIFO)
so there's a couple things that I've tried and have lead me nowhere:
Using a seize block instead of queue and adding the agents to the embedded queue in the seize block. -> I can't find the proper method to seize from the buffer in a different way from a buffer block (so I moved to option 2) but seize does have a promising customize resource choice that could help with the parameter down-selection
Using a seize block and storing the agents in a pool as resources. issues with dynamic creation of resources, seizing the appropriate one etc...
Creating a queue of requests that have returned null from a queue. This sounds like an overkill but I'll look into it
All of those appear to be a bit complex for such a simple thing in other softwares for simulation so I'm wondering if I'm missing something or if someone has come across this issue before
Suggestion 1: may it helps you to store the agents in the queue in a collection (or different collections, according to the parameter settings). Events: "on enter" and "on exit"
Suggestion 2: may the Wait - block helps you here?