Search code examples
anylogic

How to count no of agents who have spent X days in the system in Anylogic


I am building invoice processing simulation model. invoice creation date is the source generation date . Every Invoice will have due date which varies. 31 days, 60 days, 90 days. Any agent generated at resource I can add these days to the source generation date and get due date. Next step is at point I should know how many invoices are past due date . e.g 10 invoices are between 1- 5 days, 15 invoices are between 6 to 20 days etc. I have created three variable in the agent population. Start time, end time and Due time double DueTime= (time()-dateToTime (due_date));

This is calculating DueTime correctly.

Then in the main I am trying to compute the count of agent

int x_1_5=  count( invoices, p -> p.DueTime >1 && p.DueTime<=5 );
age_1_5=String.valueOf(x_1_5);

This is giving me 0 as output. Is there a way to do do this ?


Solution

  • You are only calculating your DueDate variable once at the start of the agent creation.

    You need to turn it into a function getDueTime() that returns the double value when called. Just paste return (time()-dateToTime (due_date)); into the function and then in your counter call

    int x_1_5= count( invoices, p -> p.getDueTime() >1 && p.getDueTime()<=5 );

    Variables do not act like functions and vice versa.