Steven avatar image
1 Like"
Steven asked Jordan Johnson answered

Interaction of simulation and optimization

Dear all:

Recently, i'm studying simulation-based optimization, and i constructed a heuristics algorithm which needs to use flexsim to compute objective function.

Actually, I have solved the problem with the c++, which uses a bat file to launch flexsim and run 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. (generally, objective function is mean value of more times simulation. Fortunately, it has been implemented in processflow.)

However, the key problem is in script console i can't obtain the result of the simulation which is launched by go(); in addition, i founded that go() is only responsible for starting the simulation, but when it ends is unknown. even if knowing, I can't control flexsim to execute the next code of go () at the end of the simulation.

I have posted a similar problem, see How to obtain the simulation data after executing go() in script console?

Does anybody have a better idea, tell me, thanks!!!

FlexSim 20.1.3
flexscriptoptimizationoutput data
5 |100000

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

1 Answer

Jordan Johnson avatar image
Jordan Johnson answered

One approach might be to use sockets to communicate between FlexSim and some other program. This article demonstrates using sockets to control flexsim, using sockets. The article uses python as the "controlling" language, but you could use C++. In addition, the article is implementing logic for reinforcement learning, but the optimization case may actually be a little simpler:

In version 22.1 (which is currently in beta), you can control flexsim directly from python, although I think you have to use visual studio to build a dll. More information can be found here:

5 |100000

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