question

Steven avatar image
0 Likes"
Steven asked Steven edited

How to obtain the simulation data after executing go() in script console?

Dear all,

When using go () to run the model in the script console, I want to get the simulation output data immediately. The details are as follows: before executing FlexScript, Table("Result")[9][1] is 699.

1646616270851.png

After executing FlexScript, the printed table ("result") [9] [1] is still 699 instead of the new value 517.

1646616386389.png

I found that FlexScript will execute the next code immediately after executing go(), regardless of whether the simulation ends or not. Is there any way to get the simulation results in the code after go()?

I've been troubled by this problem for several days. This is my model, Mymodel.fsm

Please help me, thanks.@Phil BoBo @Ben Wilson


FlexSim 20.1.3
flexscriptmodel runoutput data
1646616270851.png (52.2 KiB)
1646616386389.png (55.3 KiB)
mymodel.fsm (260.4 KiB)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·
Please work with the experimenter tool!!! The script console has not got a feature like wait until finished. You expect an behavior that does not exist in this environment.
0 Likes 0 ·
Steven avatar image Steven Joerg Vogel commented ·

Thank you very much for reminding me. But I don't know how to run Experimenter through FlexScript. Because this is only part of my research, I will use Experimenter to get the output when necessary. So I need to call Experimenter through FlexScript and get its result.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Steven commented ·
If you explain more about what you're trying to do you'll get a better answer. It sounds like a move to the latest beta may help you if you have access to current versions.
0 Likes 0 ·
Show more comments

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Steven edited

The simulation is not run entirely within the call to the go() command.

The go() command sets a variable in the program that tells it to start processing simulation events. The event processing does not happen in-line within the execution of that FlexScript function.

If you want a callback when your model is finished, then you need to add code somewhere else that fires when your model is finished. 'When your model is finished' will depend on the model. It is up to you to determine when that is and where your code should go. Perhaps in a user event at a specific time, you should stop the model and record the results.

· 7
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Steven avatar image Steven commented ·

Thank you for your answer. I see.

So there's no way to get simulation results in the script console, right? Because the problem I study is simulation-based optimization, it needs to run the model constantly to obtain the output data. Is there any way to solve this problem?

0 Likes 0 ·
Ralf Gruber avatar image Ralf Gruber ♦ Steven commented ·
Steven,

the easiest solution would be to use FlexSim´s built-in optimizer, OptQuest. It is not free of charge, though, but you won´t have to worry about communication timing, as you have to now. I assume you are trying to connect to an external optimizer?

Good luck


0 Likes 0 ·
Steven avatar image Steven Ralf Gruber ♦ commented ·

Yeah, OptQuest is not free, so I don't consider using it.

Actually, I have solved my problem in the c++ program which is a heuristics algorithm by using a bat file that launches flexsim and runs the model, but it consumes a lot of time because it needs to open and close flexsim constantly. therefore, I want to reprogramme with flexscript in the script console, which can save time to open flexsim.

So I encountered the problem mentioned at the beginning

0 Likes 0 ·
Show more comments
Joerg Vogel avatar image Joerg Vogel Steven commented ·

@Steven, your last comment is in fact a really good new question. Please consider it to ask this in a new thread, because there have been similar questions in the past. It would be nice to collect currently supported methods to optimize internally and externally with FlexSim.

Regards Joerg

0 Likes 0 ·
Steven avatar image Steven Joerg Vogel commented ·
yeah, it's a good idea, maybe there is a good way!
0 Likes 0 ·