question

Farah A avatar image
0 Likes"
Farah A asked Jason Lightfoot commented

How to run the optimizer from the process flow automatically ?

Hello everyone,

I'm new to optQuest and i would like to run it automatically from process flow to test different scenarios when a given event happens.

I'm taking as a simple example the following case to illustrate what i want to do:

- I have a conveyor connected then to three different machines with different processing time

- On arrival to a given decision point, i would like to trigger the optimizer from process flow automatically so that i can test different possible scenarios ( considering processing time of the different machines and their availabilities) in order to minimize the total production time and return the results in the console

Is it possible to do so?

Here is the illustrative model : PT4.fsm

Thanks in advance for your help !!

FlexSim 22.2.2
optimizer run
pt4.fsm (54.2 KiB)
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
0 Likes"
Jordan Johnson answered Jason Lightfoot commented

FlexSim's optimizer isn't built for this use case. The optimizer in FlexSim sets parameters, then runs the model to the stop time, then records Performance Measures. The optimizer invokes many runs of the model, searching for parameter values that optimize system performance.

Your description sounds like the opposite: run the model for a bit, then run the optimizer in the middle, then continue running the model.

So how do you make a smart decision for each item? You need an algorithm or policy that makes a smart decision every time an item arrives for processing. There are a few ways you could get that algorithm:

  • You could write one yourself. This would mean writing code that looks at the current state of the model and tries to make a smart decision. When an item arrives, you'd run your custom code to get a decision.
  • You could use an existing solver. FlexSim can connect to Python libraries or to C++. If there is a solver in either of those platforms that can solve this particular problem, you could just use that. When an item arrives, you'd invoke the solver to get a decision.
  • You could learn about and use Reinforcement Learning. It's a big task to make an RL-ready model. But if you did, then you could train an agent to be good at making the decision. It takes a long time to train an agent. But once trained, you can use the agent in real life to make the same decision over and over again. You can even test the agent in the model; when an item arrives, you can just ask the agent what to do. Here's a link to FlexSim's RL documentation: https://docs.flexsim.com/en/23.0/ModelLogic/ReinforcementLearning/WorkingWithGym/GettingStarted/GettingStarted.html
· 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.

Farah A avatar image Farah A commented ·

Okay, I understand better. Thank you for your answer!

What about having a command to open a FlexSim model automatically, and once it is open, it runs the optimizer automatically?
I saw that there is a trigger "On Model Open," however, is there a command to launch an existing parametrized optimizer, import the results and close the model ?

0 Likes 0 ·
Allister Wilson avatar image Allister Wilson Farah A commented ·

Depending on exactly what you intend to do, that may be possible.

Here are some resources to get you started in that direction :

Automatically Configure and Run a FlexSim Model - FlexSim Community (see Ben Wilson's answer regarding the command line interface)

https://docs.flexsim.com/en/23.0/Reference/Tools/Experimenter/Experimenter.html#advanced (On End Of Job trigger, which you could use to export results)

You can right click in the experimenter window and select View > Explore Structure in order to see how the user interface starts an experiment / optimisation job.

The FlexSimPy project may also be of interest : https://docs.flexsim.com/en/23.0/Reference/DeveloperAdvancedUser/ControllingFlexSimExternally/ControllingFlexSimExternally.html#python

0 Likes 0 ·
Farah A avatar image Farah A Allister Wilson commented ·

Thanks for your answer !! Ben Wilson's answer regarding the command line interface is working well for me to open a model.

However, im still struggling with the command line to open the optimizer automatically. Here is captures of the optimizer tree structure as suggested, but i dont seem to understand how im suppose to use it. I tried to copy the code but im getting errors. I would appreciate any suggestions on how to do it.

Thanks.

capture1.png

capture2.png

0 Likes 0 ·
capture1.png (64.1 KiB)
capture2.png (75.7 KiB)
Show more comments

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.