Measuring and displaying agent duration in states [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 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

Related

Acuity level - nurse - anylogic [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 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.

Will take less time if i execute command in single line databricks notebook? [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 3 years ago.
Improve this question
I want to understand time constraint if i execute any command in single line vs multiple lines in databricks notebook.
Suppose i am running any command(line of codes) in multiple line(cells) and same command i am execute in single line, will it take less time?
Yes. It is impacting the execution time duration.
Simply I am printing the "Hello World" String in two different cells and calculating the execution time using the below code.
val t1 = System.nanoTime
val duration = (System.nanoTime - t1) / 1e9d
Attaching the screenshot for more details.
1) Executing the two print statement in one cell.
2) Executing the two print statement in two separate cells.
Hope that helps.

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

Routine Check Between Two Dates Perl [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Trying to build a routine script in perl that will twice a month on the (15th and the End Of The Month)
Run a query that gets all users that were created within a date interval. (on the 15th get all customers created from the first till that day! and at the end of the month get all users created from 15th to that current day)
Normally Id say this wouldnt be an issue to just do it within the query. However this script will be run twice a month every month! I have to take into consideration shorter months and leap years!
Is there anyway to do this within perl without going into an overly large if condition?
You can use Date::Calc module function Days_in_Month
use Date::Calc qw(:all);
# Days_in_Month
my ($year,$month) = (2013,12);
$days = Days_in_Month($year,$month);
Why tackle this in perl?
cron is perfectly able to run files scripts at checkpoints.
you can then use the date interval from the query, as you would normally.

Spring Batch append common batch step at jobs in execution context whose name contains "abc" [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 8 years ago.
Improve this question
I would like to know if there is way to consolidate a common spring batch step which is executed at the end of most of my batch jobs.
I know about abstract job but it only let me prepend step not append steps. I would like to see if there is any easy way short of me doing some fancy ApllicationContextAware and then extracting all batch jobs and appending common step to all of them.
Hopefully there is a better way.
If I understand correctly, you need to perform some activity at the end of most jobs.
In that case, you may use a Job Execution Listener.
The afterJob() method is always executed and you can have your processing there. Use the same listener for multiple jobs.
This link will give you an idea.