Interaction of simulation and optimization

Interaction of simulation and optimization

zhu_m3
Not applicable
18 Views
1 Reply
Message 1 of 2

Interaction of simulation and optimization

zhu_m3
Not applicable

[ FlexSim 20.1.3 ]

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!!!

Accepted solutions (1)
19 Views
1 Reply
Reply (1)
Message 2 of 2

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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:
https://answers.flexsim.com/articles/112703/reinforcement-learning-using-previous-versions.html

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:
https://github.com/flexsim/FlexSimPy

.


Jordan Johnson
Principal Software Engineer
>

0 Likes