Sven F avatar image
Sven F asked Eric M commented

Connect with Python solver to create planning

Hi all,

We created a Python solver which solves a routing problem for a given planning horizon. We would like to use this solver in FlexSim to test the solver for different scenarios. Also we want to test the different parameters, constraints and test best capacities.

To connect the solver I've seen a possible way to connect FlexSim using a custom module with C++ to Python. However, we have no experience in creating DLL's.

Does it take a lot of time to understand creating a DLL that connects to Python? Or is there another way to connect to a Python script?

We need the workflow to be as followed:

1. Generate set of jobs in FlexSim every 15min runtime
2. Send set of jobs with data to Python script
3. Run optimizer
4. Return the suggested routing to FlexSim
5. Execute the plan in FlexSim that is returned
6. Start over again at 1.

FlexSim 21.1.3
pythonflexsim 21.1.3dll makersolver
· 1
5 |100000

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

Eric M avatar image Eric M commented ·

Hi @Sven F, was steven.hamoen's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Steven Hamoen avatar image
1 Like"
Steven Hamoen answered Sven F commented

Hello @Sven F, if you want to dive deeper into the DLL solution look here There you can find a link for the DLL sdk's (1 of you want to create a module and 1 if you just want to create a DLL) I don't think it is that complicated but I do think you can also do it differently.

For instance you could create the set of jobs in a file (whether that be txt, csv, xml or some json format) and start the python program from within flexsim (runprogram command) I think the most complicated part is the wait loop where you have to wait for an answer. You could set the runspeed very slow or use a loop that keeps polling for a file to appear or something.

Another solution could be to setup a socket communication between FlexSim and your python application. Sockets can be blocking so that might help in this case. Look at clientxxx commands

A third option would be to work with http requests. Look at the http objects in the FlexSim API reference.

I hope this gives you some ideas.

· 1
5 |100000

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

Sven F avatar image Sven F commented ·

Thank you for listing these options. We will try the DLL solution an if we can't get it working we'll try one of the other ones.

0 Likes 0 ·