What is ChatGPT? If you ask it, it will tell you that it is an AI-powered chatbot built on top of the OpenAI language model GPT-3. It goes on to explain more in detail, but basically all you need to know is that you can ask it questions and it will provide answers.
But what types of questions? Maybe you are not sure about your vacation plans. Tell ChatGPT that you have $5,000 and you want to travel somewhere in South America just to relax. Maybe you don’t know what book to read next (important on a relaxing vacation). Explain to ChatGPT the genres you like and maybe some examples of books you have read. After your relaxing vacation, you might feel like making a new start. Give ChatGPT some information about yourself and ask it to prepare or update your resume. Finally, you have your dream job where you need to develop simulation models using AnyLogic.
Now, can you use ChatGPT to help with this new job? Will it be able to support you when working with AnyLogic? In this blog post and webinar, we will explore the answers to these questions and explain how useful ChatGPT can be in the field of simulation modeling.
If you prefer a more traditional approach to learning a topic, check out the AnyLogic book, which explains how project managers can benefit from various simulation modeling techniques.
First time using AnyLogic?
As a first-time user, or someone unfamiliar with AnyLogic who has never even built a model, ChatGPT can help you. Ask it about modeling, and how to build a model in AnyLogic, and it will give you a step-by-step guide from opening AnyLogic to analyzing the results. Context is very important, so be clear about what you are doing, and if you are going wrong or getting lost, just open a new window and start again.
In the webinar, the AnyLogic team gave ChatGPT a simple instruction to help build a system dynamics simulation of a bass diffusion model, and the results it produced were almost perfect. Take a look at the prompt that was given and the detailed response on the right. ChatGPT makes it very clear what to do and how to do it.
An introduction to Java
If you don’t know anything about Java (which is used in AnyLogic for scripting extensions), ask ChatGPT to give you some information. Of course, it would be useful if you had a little knowledge of this before in order to be able to ask the right questions, but this is not completely necessary. This is a really interactive way of learning programming and using it at the same time.
Queries on existing models
If you already have a model that you or someone else built, and there is something you don’t understand or just forgot about regarding the code, you can take what was written and copy and paste it in ChatGPT. Formulate a simple question asking for an explanation of this code, and you will get your answer.
Continue asking questions to understand more if you are still unsure. A good trick to remember is that you can also ask ChatGPT to comment on any formula that you input or that it creates, and you can put this in your model and use it for future reference.
Adding new features to a model
Using AnyLogic in a traditional way doesn’t really require a lot of Java, but more advanced users may want to use it to develop more detailed and complicated models. In the webinar, the AnyLogic team used an example of the customization of agent placement on the screen to illustrate this. ChatGPT helped generate code and fix any errors that occurred.
Another interesting example that was illustrated was constructing a HyperSQL query to create customized views of multiple tables. Now, you can either have knowledge of HyperSQL, consult the handbook about how to construct queries, or just simply explain to ChatGPT what you have, including constraints such as primary and foreign keys and different tables. Then ask it to write the desired query. Copy and paste this into your model, and see if it works. Also, don’t forget to verify that it is accurate.
Finally, an example of using third-party libraries in AnyLogic. Traditionally, to have data connections within models, it is necessary to reference an external database or Excel file. In this example, however, a public API can be used to access a service that will provide the information that is needed automatically on model start-up. As a result, you would need a function that reaches out to this API to query this information, process it, and then add the appropriate agents to the model to initialize it.
So, as you have seen, the steps when using ChatGPT are pretty similar every time. Give it some information, tell it some rules about how Java works in AnyLogic, and then give it anything else that is necessary when working in AnyLogic. After this, you will receive detailed instructions on what you are looking for. As usual, copy and paste the code into your model and run it. If an error occurs, you can either fix it yourself or take the simpler route and send it back to ChatGPT to be fixed.
The future is in language models
ChatGPT is a great tool that can really help to improve your basic understanding of simulation modeling in AnyLogic or take it to the next level if you are already experienced. Also, while this tool may be the most talked about now, there are many other language processing tools that can perform the same functions. Try some others and see how they compare.
It is essential to remember that the answers may not always be 100% correct, so don’t blindly follow what you see. Try to understand what is given to you and verify everything. After all, it is still AI and is not perfect.
Check out the webinar below, where you can also find more in-depth explanations of the examples given in this blog post and additional materials, including example prompts and models, in the video description.
After that, download AnyLogic Personal Learning Edition and explore the software in more detail with or without ChatGPT.
Once you know all the tips and tricks for mastering AnyLogic, it's time to try it out.