Acuity level - nurse - anylogic [closed] - simulation

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
Please any idea how to model the following in any logic using block and a simple code:
we have resourcepool of 14 nurses
one nurse can supervise up to 4 patients (supervise means she only watch them and can not watch more than 4 at the same time, when one patient leaves she can take another patient in his place but max 4 per nurse)
during the supervision she can serve only one patient of the four at the same time, so the other three patients need to wait (for example one of the four patient needs drug injection, so she can do that for him then see the requirement of the second patient if any)
the nurse should not wait for the four patients to arrive. So batch here don't wotk?
This is very challenging, I read previous questions and answers but did not work such as batch or multiplying the number of nurees by 4 .. etc
Is there a simple trick to do that?
Thank you

Great question! This is a difficult logic to implement. The nurse is assigned to up to 4 people and then she can serve 1 of them at a time.
To do this I would have a patient be assigned to a nurse upon entry. They would search for the first nurse that has less than 4 people assigned and then "register" with this nurse. Then if they need treatment you would have the patient wait to seize the nurse it has been assigned to.
To start create a new agent called nurse, with a variable of type LinkedHashSet that will store agent of type patient.
In the agent parameters remember to set the nurse as resource unit.
Create resource pool of nurses and a population for nurses, adding new resource units to the nurse population
Now when a patient need to assign it self to a nurse do this function on your nurse population.
Nurse availableNurse = findFirst(nurses, e -> e.assignedPatients.size() < 4);
agent.nurse = availableNurse;
availableNurse.assignedPatients.add(agent);
You can call this code when ever a patient enters a process modelling library block where it gets assigned to a nurse. (I also added a nurse variable to the patient so that the patient knows which nurse it is assigned to)
Now when a patient needs to seize a nurse for an injection or some other activity it can know to seize the nurese assigned to it.

Related

Measuring and displaying agent duration in states [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I would like to build on to the query from the following link: Agent time-in-state statistics
In my scenario, I have a varying number of agents and I need to display the duration spent in each state by all the agents within the resource pool on a bar chart. In short, each bar in the bar chart must display the total time spent in a specific state for all the agents.
Is there any way to let the bar chart data be a value that loops through the agents within the resource pool and sum up their total duration in each state which is periodically refreshed? Thanks!
As per your referenced answer you need to record the time spent in each state using a variable, and then display this variable in the barchart.
See example below
I have a an agent with a simple statechart and for each state I record the time you enter the state to a variable in the agent. Then when you exit I save the duration (difference between the enter time and the current time) to a variable on main.
On main there is a population of these agents, all of them saving the time they spent in each state to the variables on main.
Then also on main I have a bar chart that simply displays the variables
And here is result when you run it

Using the same service block for different tasks in anylogic

I am currently busy with a project at a hospital. I need to create a simulation model replicating the processes at the hospital. I have a problem with regards to one counter or service desk at the hospital. The staff member at the service desk needs to perform two different tasks, depending on the type of patient. How do I programme the service block to perform two different tasks?. For now,enter image description here I have split the block into two different blocks using the same staff member. Is there another way that I can go about this?
The staff member at the service desk needs to perform two different tasks, depending on the type of patient.
If the task only differs in duration, you can easily adjust the task duration by patient type in the Service delay property (assuming your patients are agents of types PatientType1 and PatientType2):
For more complex tasks, you can create a function that returns the duration and takes your requesting patient as an input argument, for example f_getDelayByPatient(MyPatientType patient)
Then, the service block can use that function in the "Delay time" code section to compute it for each arriving patient using f_getDelayByPatient(agent)

Assign one task to one customer per day in task assignment Optaplanner

I want help regarding Optaplanner task assignment changes, below is the complete information about the same:-
I have 70 tasks each task takes 2 to 8 hours which is defined for each task, the priority of each task is low and there is a low affinity between employees and customers, these tasks are associated with 37 customers.
My question is that how can I assign these tasks to employees such that if a task of a customer is assigned to an employee then for that day another task of that customer shall not be assigned to the same or another employee. Can someone help with drl rule or java constraint for the same?
Not knowing your data model, I'm going to make some assumptions on the fields available. The constraint could look like this:
.from(Task.class)
.ifExistsOther(Task.class,
Joiners.equal(Task::getCustomer),
Joiners.equal(Task::getDay))
.penalize("Two tasks for the same customer on the same day", ...)
It's up to you to decide how hard the penalty should be. If you want to eliminate this situation, you should make it a hard constraint - a solution with this constraint broken will not be feasible.
(EDIT) There is also another option, and that is to make the situation impossible in the data model. If you create one planning entity for each customer+day combination, it will be absolutely impossible for a single customer to have more tasks happening on one day.

"Anylogic" Inventory management

I want to simulate a hospital. A patient(disease is illustrated with color) arrives at the hospital, and the doctor needs a medical cart to treat patient.
The medical cart have four different item categories. Three of the item categories relates to the color of the patient and one item category is used at every patient.
When a patient arrives a certain amount of the medical cart gets drained, until it reaches a certain inventory level and the cart is transferred to a location to be filled up. For instance blue patient arrives and blue stock is lowered along with the general stock. If there is three blue patients in a row the carts needs is send to be refilled even though it still have stock for other patients.
An full example of the thinking: There are 40 carts available-each with medicin etc. for 4 blue patients, 3 green,2 red and 10 general. If first four patients are blue the carts needs to be refilled and a new cart is activated.
So the patient flow is described with discrete modeling using the processes modeling librabry, but I cant quite figure out how to create the medical carts in a way such as the inventory levels depend on the number of patients that arrives and at a certain level be filled up. Should I use agent based or system dynamic modelling or continue with discrete modeling?
Your Cart MUST be a resource that is seized by the doctor... When you release the cart you create a selectOutput asking the question if the cart is filled or not with the necessary items... If it's not it goes refill as you can see in the following image:
Now to ask the "itemsMissing" question... you need your resource to be a Cart agent with one variable for each item that keeps count of how many items remain.
This is what I would do... but you need to investigate probably how the release block works with the resource task end block, which is something I can't teach here, so you will have to investigate the help documentation if you don't know.... And probably you will have to adapt this example to your particular case.

AnyLogic Model- Patient Scheduling Project

I am currently working on a project to model outpatient appointment scheduling for a local hospital. The goal of this project is to model their current situation and then adjust different factors to reduce the wait time until the next available appointment. We are using AnyLogic to create the model. At this hospital the current system is as follows:
A patient calls and schedules an appointment with one of the hospitals 19 sub-specialties.
         - appointment will either be a first time consultation lasting 1 hour or a follow up appointment lasting 15 minutes.
Patient waits 1 week-6 months until their appointment date (based on sub-specialty)
Patient is seen by a doctor and then exits the system
We have approached the problem in two ways, the first was to attach the schedule to the resource pool which consists of the doctors for a single sub specialty. This would allow the schedule to change as the number of doctors change. The second approach was to attach the schedule to the source which consists of the patients entering the system. This better controls the flow of individuals into the system.
We are having difficulties figuring out how to configure the model so that it accurately shows the result of adding more doctors while still allowing the flexibility we need in scheduling different length appointments in multiple sub-specialties.
If anyone has experience with AnyLogic Scheduling, has dealt with a similar problem, or has any advice on how to proceed, I would appreciate the input.
Thanks!
If I understand correctly, you want to change the number of resources you have according to a certain schedule...
In the schedule you need to you use integer type and then create your schedule based however you want. In the action you can use "value" as a variable that corresponds to the value of the current schedule value. The action in the schedule is activated everytime the schedule changes... so you can simply do resourcePool.set_capacity(value);
With this you have the flexibility to use different length appointments... You can use one different schedule for each sub-specialty