Search code examples
simulationanylogic

Using database columns data in a parameter and then in function (or use anywhere in the model)


I want to import a schedule consisting of patient arrival time and their id and their type and simulate it n times, to check the performance metrics. I have imported a table ( half of it) in a database see table, and parameters mapping to it parameter source block, and generated arrivals according to the arrival date in the table.

I want to set service time in service block based on what patient type it is. I used patType paprameter and wrote this in delaytime (agent.patType == A ? 59.5+46*beta(0.331,1.44):(agent.patType == B ? poisson(42.1): triangular(9.5, 20, 29.5))), but it shows error A and B cannot be resolved to a variable. I also tried importing other table only with service times and patient type, but didn't worked. I am stuck at this initial step of running schedule for a day, any help would be really very helpful. There might be already answered queries similar to this but a idea to this problem will be very helpful.


Solution

  • Is the parameter patType of type String? Then the formula should be (agent.patType.equals("A") ? 59.5+46*beta(0.331,1.44):(agent.patType.equals("B") ? poisson(42.1): triangular(9.5, 20, 29.5)))

    You forgot to put your String values between double quotes and AnyLogic thought they were variables. Also it's best to use the .equals() method for comparing Strings instead of the == operator.