It would be nice if any simulation model could be put together graphically, in drag and drop manner. In practice, however, only very simple models are created using a mouse and not touching the keyboard. As you try to better reflect the real world in the model, you inevitably realize that you need to use probability distributions, evaluate expressions and test conditions containing properties of different objects, define custom data structures, and design the corresponding algorithms. These things are better done in text, not in graphics, and therefore any simulation modeling tool includes a textual scripting language.
From the very beginning we did not want to invent a proprietary scripting language for AnyLogic. Moreover, the creation of AnyLogic was much inspired by Java, which we consider to be the ideal language for modelers. On one hand Java is sufficiently high level language where you do not need to care about memory allocation, distinguish between objects and references, and so on. On the other hand, Java is a full-fledged object-oriented programming language with high performance. In Java you can define and manipulate data structures of any desired complexity, develop efficient algorithms, use numerous packages available from Sun™/Oracle™ and other vendors. Java is supported by the industry leaders, and as Java improves, AnyLogic modelers automatically benefit from it.
A model developed in AnyLogic is fully mapped to Java code and, having been linked with the AnyLogic simulation engine (also written in Java), and, optionally, with a Java optimizer, becomes a completely independent standalone Java application. This makes AnyLogic models cross-platform: they can run on any Java-enabled environment.
A frequently asked question is “How much Java do I need to know to be successful with AnyLogic?”. The good news is that you do not need to learn object-oriented programming. The “backbone Java class structure” of the model is automatically generated by AnyLogic. In a typical model, Java code is present in small portions written in various properties of the graphically created model objects. This can be an expression, a function call, a couple of statements. Therefore, you need to become familiar with the fundamental data types, learn the basics of Java syntax, and understand that to do something with a model object you need to call its function.
This section of the AnyLogic help is by no means a complete description of the Java language, nor is it an introduction to Java suitable for programmers. This is a collection of information that will allow you to manipulate data and model objects in AnyLogic models. It is sufficient for a typical modeler. For those who plan to write sophisticated Java code, use object-oriented programming, and work with external Java packages, we recommend learning Java with a good textbook, for example, one of those ones:
- Bruce Eckel. “Thinking in Java”, available on Amazon.
- “Head First Java. Your Brain on Java — A Learner’s Guide” By Bert Bates, Kathy Sierra. Publisher: O'Reilly Media.
You can also find some concise but very helpful information about Java here: W3Schools Online Web Tutorials.
For details on Java classes, see the Java SDK documentation.
-
How can we improve this article?
-