1

I want to read information about distributions of delay times from an Excel file (already imported into an AnyLogic database table). The format is "distribution(parameter1, parameter2,...)", so for example uniform (0, 0) or normal(0, 1). Is there a direct way for doing this or would I need to delve deeper into programming to link the table directly to the delay duration?

This is what the corresponding information from the database table could look like: Database Table

Maybe some background information before I am showing you the code I wrote so far: In total there are 3-4 columns containing distribution information. For these, I am summing up those rows that meet certain criteria from other string-type rows in that db table.

The first part of the code shows another constraint: The above-described summing up of rows only needs to be done with a given probability (also taken from the database table). This I am trying to achieve by drawing a random uniform(0,1) number and assigning it to a variable. Only if my drawn number is smaller than the probability stated in the database table, do I proceed with the summing up.

So here is what I tried: Code Attempt

And the errors I am getting are "Unresolved reference: XYZ". Most likely because the distributions from the db table couldn't be interpreted, so no random numbers are generated... I set the corresponding columns to type "Code" already, but this doesn't seem to be the way unfortunately.

Can someone help?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

2

There is a nice function "executeExpression". More on that here: How to read probability distributions from a database and save them in collections

  • good point, forgot about that one :) – Benjamin Nov 05 '21 at 17:44
  • Great, thank you! However, this function doesn't seem to work for me -I tried wrapping it around only the distribution like so: select(executeExpression(distribution)).from(work_plan).where(work_plan.station.eq("11"), work_plan.ccg.eq("2")); and also around the entire line this way: executeExpression(select(distribution).from(work_plan).where(work_plan.station.eq("11"), work_plan.ccg.eq("2"))); but neither of them results in the "X cannot be resolved to a variable" error disappearing... Do you have any ideas as to why this might be? – user17334485 Nov 08 '21 at 07:04
  • The issue is most likely in the rest of the code I wrote so far... is the select(X).from(Y).where(Z = "A", B = "C") syntax something that can be done in AnyLogic? – user17334485 Nov 08 '21 at 07:54