AnyLogic Enumerations
AnyLogic is a tool for creating agent-based, system-dynamics-based, or, as the name implies, any-kind-of-logic-based, simulation models. The neat thing is that one can also mix the supported kinds of logics, thereby creating for example a discrete, agent-based model with continuous elements. This is what I am currently trying to do. Another neat thing is that AnyLogic is Java-based, such that one can not only write Java-code almost anywhere in the tool, but one can also create and use external Java libraries. This provides an extraordinary level of flexibility. Anyway, since AnyLogic is all new to me, I thought I'd blog different issues as they arise.One of the first problems I encountered, was to deal with Enumerations. They are easily created, but I had problems figuring out how to access the elements from the code. The solution turned out to be emabarassingly simple: whereas I tried to access the enumeration elements using syntax int someVariable = EnumerationName.ELEMENTNAME, I realised that this can only be done if someVariable is of type EnumItem. Obvious in retrospect, however, I wasn't even aware of the existence of the class EnumItem, and it's not mentioned in the manual. I also believe that in for example C#, one can cast the Enum type to an int, using syntax int x = (int)Enumtype.ELEMENT;, though attempting this in AnyLogic gives a compilation error. Further, in some cases the syntax EnumerationName.ELMNAME is required, but in other cases only ELMNAME is accepted. I have not yet found the pattern for where the different syntaxes are to be used.
Oh, and the enumeration itself appears to be of type EnumIndex (both types are documented in the AnyLogic class reference).
1 Comments:
Hi Laila,
Have you tried linking Anylogic with MySQL. I have tried to without much success. Thanks
David
Post a Comment
<< Home