Can you create new simulation elements during model run in AnyLogic? - Stack Overflow

is there a way to dynamically, during the runtime of a simulation model, to create new elements into yo

is there a way to dynamically, during the runtime of a simulation model, to create new elements into your simulation model?

If I'd want to for example, add a button, that CREATES a new queue element. I know, for this usecaseI could just premodel the "to-be-added-queue" and then just "enable" it with the button, but I really want to know if there is a way to really DYNAMICALLY alter the model structure?

Lets say I have a Digital Twin of my Factory running, using AnyLogic as the simulation model and I'd like to make the integration of new system elements as easy as possible. Is there a way, I could prewrite a script, which requieres a table with the input: "Are you a delay (bool)", "Where do you get your input from(String)" and "Where does your output go to(String)", "Whats your delay time (double)" and then, I could just press a button and a new element would appear in my already running simulation with the proper connections. (Maybe I could have this completely autonomous for example, without any human interaction at all. It could be monitored by an event reading a table describing the system structure and every time it notices a change it alters the system)

I really don't want to hear "just do it manually". I know I could do that, that is not what I am asking. I simply want to know if "Yes" or "No" there is a way to use CODE to create those elements during runtime?

One option I have discovered for myself so far is, that you can open the .apl-file in a text editor and just edit the XML-part of the file describing the simulation model. I have been successful in creating new delays, positioning them, connecting them etc. but this was rather manual and labor intensive. I also ran some prompts with chatGPT to try to alter these by first presenting the structure of the .apl file, specifically the part that determines the model elements and then letting it have a go in editing the file. It worked. This could propably also be a viable solution in my use-case, only requiering a re-initialization of the simulation run, but as I said.

I wish to inquire if there is a solution using the simulation itself or rather code running inside the simulation itself, durign runtime?

Thanks! :)

is there a way to dynamically, during the runtime of a simulation model, to create new elements into your simulation model?

If I'd want to for example, add a button, that CREATES a new queue element. I know, for this usecaseI could just premodel the "to-be-added-queue" and then just "enable" it with the button, but I really want to know if there is a way to really DYNAMICALLY alter the model structure?

Lets say I have a Digital Twin of my Factory running, using AnyLogic as the simulation model and I'd like to make the integration of new system elements as easy as possible. Is there a way, I could prewrite a script, which requieres a table with the input: "Are you a delay (bool)", "Where do you get your input from(String)" and "Where does your output go to(String)", "Whats your delay time (double)" and then, I could just press a button and a new element would appear in my already running simulation with the proper connections. (Maybe I could have this completely autonomous for example, without any human interaction at all. It could be monitored by an event reading a table describing the system structure and every time it notices a change it alters the system)

I really don't want to hear "just do it manually". I know I could do that, that is not what I am asking. I simply want to know if "Yes" or "No" there is a way to use CODE to create those elements during runtime?

One option I have discovered for myself so far is, that you can open the .apl-file in a text editor and just edit the XML-part of the file describing the simulation model. I have been successful in creating new delays, positioning them, connecting them etc. but this was rather manual and labor intensive. I also ran some prompts with chatGPT to try to alter these by first presenting the structure of the .apl file, specifically the part that determines the model elements and then letting it have a go in editing the file. It worked. This could propably also be a viable solution in my use-case, only requiering a re-initialization of the simulation run, but as I said.

I wish to inquire if there is a solution using the simulation itself or rather code running inside the simulation itself, durign runtime?

Thanks! :)

Share Improve this question edited Mar 12 at 14:56 Benjamin 12.8k4 gold badges19 silver badges33 bronze badges asked Mar 12 at 13:26 WermutWermut 451 silver badge4 bronze badges 1
  • 1 pls only use the anylogic tag, else you confuse 1000s of Java programmers who have no idea what you talk about :) – Benjamin Commented Mar 12 at 14:56
Add a comment  | 

1 Answer 1

Reset to default 2

Yes. Encapsulate the queue into an agent-type, add enter/exit blocks around it and instantiate as desired. You can send your agents through the most complex flowchart/agent structure that way.

Literally drag in a Queue, right-click and select "create agent type" (or something like that)

See here for a good starting point: https://youtu.be/OWwjKqKUA1A?si=6nNgi0ljTfgFC4j9

You can also write scripts to alter the alp file itself, but you need to have a thorough understanding of the structure. But it is totally possible and not rocket science...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744749815a4591525.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信