question

Neisser V avatar image
1 Like"
Neisser V asked ·

How can I integrate an optimization c++ algorithm into flexsim for simulation?

I am looking for an integration of a metaheuristic algorithm made in c++ with flexsim in the same way Optquest does, so i whould like to know if it is possible to find a tutorial or a guide to do that.

custom codeoptimizationc++ and user commands
5 |100000 characters needed characters left characters exceeded

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

Jordan Johnson avatar image
4 Likes"
Jordan Johnson answered ·

If your issue is cost, it would probably be cheaper (in terms of time) to just buy an OptQuest license.

If your issue is that you want to control the metaheuristic, instead of using OptQuest's, then you could perhaps use the dll approach. However, if I were attempting it, I would write a C++ program that does the following:

  1. Writes a file (maybe a .csv file) that has the variables for FlexSim
  2. Opens a FlexSim model that has the following triggers:
    1. OnModelOpen - reads the input file, configures the model, and calls run(). You may also want to use the commandlineparam() command in that trigger, so that you can open the model manually and not have it start running immediately. You could also use that command to determine which random stream to use (if you are running replications).
    2. OnModelStop - writes an output file with the performance measures, and then calls exit(). This trigger should also probably check the command line parameter.
  3. The C++ program waits for the output file to appears
  4. Once the output file appears, the C++ program reads that file, and uses those results to run the metaheuristic.
  5. Using the results of the metaheuristic, the C++ program writes another file.

In this way, you can write your own optimization algorithm. If you are running replications, you could launch many flexsims at once, all opening the same model, and wait for all replication results to appear.

· 3
5 |100000 characters needed characters left characters exceeded

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

Hi @jordan.johnson, I think my issue is that I need to control the metaheuristic, so, that's why i cannot use the OptQuest approach. I would like to write the C++ program you mention but I have not to much idea of how to do it. I'd appreciate any help you may share with me regarding your expertise in the matter. Thanks!

0 Likes 0 ·

Hi @jordan.johnson can you helpme'

0 Likes 0 ·

Hi Neisser, for additional help on this question, you will need to contact your local distributor. Advice or help on developing a C++ application is outside the scope of this forum.

1 Like 1 ·
Steven Hamoen avatar image
2 Likes"
Steven Hamoen answered ·

@Neisser V You first have to create the DLL in C++ containing the algorithm. If you have that you can call those functions from FlexSim. There are 2 ways to create a DLL. One is the (slightly older) DLL Maker The other option is using the module SDK

So please check them out and their documentation.

· 1
5 |100000 characters needed characters left characters exceeded

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

Which of those option would you recommend to start my project?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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