Beginner's guide to AnyLogic

An experienced-based guide to getting started with AnyLogic from scratch.


This is a special guest blog post by Yash Mishra. We asked Yash to write an article outlying his experience when he recently started learning AnyLogic. He retold his journey, focussing on the roadblocks he experienced along the way and the steps he took to overcome them.



Background

One fine day, we discussed how to enhance a client’s experience while showcasing the new capabilities we are building for them. Corporate presentations are highly dependent on the presenter’s skill to keep the audience engaged but still, there is one more aspect to it. It is about how the client can relate to your presentation. Clients are constantly asking: “What is there in it for me?”. It was precisely at this time that simulation came to our minds. By simulating a client’s process, you gain the following benefits:

  • A thorough understanding of the client’s process and problems within it,

  • The client will be able to easily relate as you will be showcasing his business process in motion.

This marked the beginning of my simulation journey.


We looked at multiple simulation software like AnyLogic, Business Optics, Arena, Simulink, etc. Each tool was explored by one individual in the team, and I was tasked to look at AnyLogic. Luckily, we ended up selecting AnyLogic.


The Expedition

It feels like going into a completely new town with a new culture and no acquaintances. So, I decided to start by going to the tourist information office, the AnyLogic website. It looked like another corporate website that showed what they do but was quite unintuitive to a beginner like me. Then I reached a section for resources and videos (which is the most preferred medium to attain knowledge nowadays). I saw some webinars related to AI and covid and started to get a little sense about AnyLogic.

Then I decided to look at some example models. I started by simply running models like covid vaccination drive, Agent-based epidemic, etc. I understood and related to the animations, but the big question was how to build anything remotely as cool as what I saw... There seems to be no tutorial available here, almost no Youtube playlist for beginners. I searched for resources to learn AnyLogic, and I stumbled upon this book with a very tempting title, “AnyLogic in 3 days”.

The book has a recipe for four different models built from scratch. It is a simple step-by-step tutorial for learning Agent-Based simulation, discrete event simulation, and system dynamics simulation. If someone starts today, I suggest going through the book slowly but thoroughly. Maybe finish 1 model in 2 days or even slower if it helps build your understanding. As I was eager to learn the tool and the book was the only medium to do it, I finished it in just two days. Only to realize later that since I did not get my hands dirty with modeling, I gained significantly less in return regarding understanding.


Evaluation Stage

No sooner did my manager cum mentor Rajarajan TR throw a problem statement towards me to solve using AnyLogic. It was simply a black box model with details defined in an excel file. The basic structure of the model was as follows:

  1. No. of resources.

  2. Cost of each resource.

  3. Fixed task handing time.

  4. Package incoming packets and send them for shipping.

I used a system dynamics modeling approach to solve this. I used a dynamic variable to define the incoming stock and another static parameter to build it. When I look back today, it was a "nothing model." I might even disown the model today. Still, it was the first stepping stone toward learning AnyLogic.


The First real project

When we decided to go with AnyLogic as our simulation tool of choice, we selected a real-life use case. Our objective was to showcase the impact of introducing an AI engine in the human-based as-is process of the client. It was essential to show the client their as-is process first, which helps them relate to the simulation. And then show what happens if your business grows and volumes increase and how the AI engine helps deal with increased volumes without hiring more human resources.

gif

Data Collection

We realized the subprocesses are a critical aspect of the whole system and will be helpful to present a holistic view of the overall process. We collected data around each subprocess like the amount of time taken at each activity, team size, fallouts at each stage, etc.


Model Build

We started by using the process modeling library. Initially, we took a source block and a few service blocks in the middle to imitate sub-processes and finished the process with a sink block.

Then we iteratively kept adding select output blocks to showcase fallouts from each subprocess. Next, we added a resource pool to represent the team. Now the challenge was to add shift timings to the team. While researching Youtube, we discovered the “schedule block,” which allows imitating the shift timings. We also wanted to create a scenario where orders would sit in a queue white the shift is not active. We did that by using a queue along with a subsequent hold block. We discovered a very cool feature about AnyLogic — Java programming. (If you want to up your Java game in AnyLogic, you can check out a Udemy course here)

One could simply use an event block that allows us to program the hold to block the queue exit when shift is off and unblock it when shift is on. This was a real discovery because it gave us the flexibility to customize the model. We did end up using programming capability extensively.

Unfortunately, we realized very late that we would require something to represent an order. I again went back into research mode, but something unexpected happened. Being part of a large organization has an advantage : you have some probability/chances to find someone who would have used this tool in the past. We also found two such champions in Ignacio Brottier and Brian Erik Ovrum, who were sitting in another corner of the world. None of us knew that they would be instrumental in our journey going forward. They helped us understand that an agent might help us imitate an incoming order. They also helped us conceptualize what the order should look like — it may have some product name, quantity, price, and incoming and outgoing timestamps. We created this agent and used the parameters to derive various other metrics. And I realized it’s never too late to try!!!

Once we modeled the as-is process, it was time to bring in the AI engine. So, we created a separate route for the as-is process where the orders will go for AI processing first and then, if needed, fall into the human queue. To switch between as-is and to-be scenarios, we used a button with a select output programmed to route everything towards an AI engine if the button is on. Everything will continue directly to the human queue if the button is off. Again, Java programing was very helpful in this switching feature which I will elaborate on further in a while.


The Demo

Now, we had our model ready in an up and running state. We were very excited while presenting it to the leadership, who were very appreciative of the work, but they were a little wary of so many numbers flowing from each block. It was like a plate filled with amazing food, but you can only eat to a certain capacity.



gif


Presentation Layer

We took a step back and decided to create a separate presentation layer over what we had built. At this juncture, the work we did to make the switch to toggle between as-is and to-be scenarios and view areas, that I learned in the AnyLogic in 3 days book, was to become the base of our presentation layer. While creating the switch, we didn’t use a button control as it looked very basic. Instead, we used images of the two states of a toggle button, i.e., on and off. We used programming to hide and unhide the images. E.g., When the model starts, one will see the toggle button image in the off state, but when you click on the image, the off-state image is set to invisible, and the on-state image will become visible and vice versa. We again used this logic to hide and unhide in creating a high-level overview of the overall process. We created slides of as-is and to-be scenarios, each containing only the essential sub-processes. We then saved these slides as images to be used in the model. Then, we created motion paths to let the orders move over the images of sub-processes to give them a progressive motion feel. Then we surrounded the high-level process view images with panes containing charts to provide an excellent visual interface. This view was used to display the impact of an AI engine on the process without shooting too many numbers at the viewer. These charts showcased metrics like backlog, orders processed by value ($) and volume, aging buckets, team utilization, cost of operations, etc.


Final Touches

We even enhanced the real-life experience by adding a function that sends email when the backlog crosses a certain threshold during the simulation run. We did it using external java libraries within AnyLogic. The ability to use external Java libraries makes AnyLogic a very powerful tool. One can refer to this example model to learn to use an external java library.


Learnings

This was my first real project into AnyLogic, and the experience was like a roller coaster in full swing. The learning curve tends to be very steep initially, probably because of the scarcity of learning resources, and you tend to latch onto any learning material that comes your way. Even after doing a project, there is a danger of experiencing a flattening in the trajectory of the learning curve ever so slightly if you do not continue to build models.

In the models that I developed next, I have realized the importance of a few more things that I will discuss in future blogs.

  • Collecting statistics from a model in an excel file.

  • The importance of Object-Oriented Programming concepts.

  • Exploring and sharing the example models to learn more.

The real learning for me as a beginner is to take a straightforward use case and build it using whatever knowledge you have, and if you get stuck somewhere, refer to the book or research online and ask questions on stack overflow. Some experienced and extremely helpful people like Jaco-Ben, Felipe, Benjamin etc. who are always there to answer your questions, especially on Stack Overflow. If you are lucky enough, you may also find experienced people in your organization to support you. One must also look at the videos from AnyLogic conferences which acts as a great source to know the community, understand current trends, and stay motivated.


In short, I can suggest the following practical road map



Keep modeling!

Yash

 

Yash Mishra is a guest writer for the AnyLogic Modeler. Feel free to connect with him over LinkedIn.


If you need any assistance on your AnyLogic journey, check our recommendations here or contact us for more info.


What next?

If you liked this post, you are welcome to read more posts by following the links above to similar posts. Why not subscribe to our blog or follow us on any of the social media accounts for future updates. The links are in the Menu bar at the top, or the footer at the bottom. You can also join the mobile app here!


If you want to contact us for some advice, maybe a potential partnership or project or just to say "Hi!", feel free to get in touch here, and we will get back to you soon!




535 views0 comments

Recent Posts

See All