question

Hanifi.Yilmaz avatar image
0 Likes"
Hanifi.Yilmaz asked Kavika F answered

FlexSimPy - run simulation from python

I just extended a genetic algorithm with flexsim. Now i have two problems, where i dont know where it comes from.

1.) The model gets "destroyed" every time it finishes an optimization process. Flexsim opens a script console for every run, i dont know why.

- Do I have to open the model in every run or just once at the start?

- When do i have to stop the controller? Only in the end or for every solution in the optimization?


1678795268870.png

2.) Python automatically restarts the script: I dont know if this problem has to do with flexsim or python. After some iterations, i always get the information "Restart python shell". Do you know where it can come from?

1678795588162.png

Thanks.

FlexSim 22.2.4
flexsimpy
1678795268870.png (67.2 KiB)
1678795588162.png (3.4 KiB)
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Hanifi.Yilmaz, were Kavika's comments helpful? If so, please let us know and we'll convert them to an accepted 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

Kavika F avatar image
0 Likes"
Kavika F answered
Hey @Hanifi.Yilmaz, from the looks of your screenshot, it is opening a System Console each run, which makes me think that there's an error in your model that is trying to print a statement.

If you have no license, then you can't run an optimization job with the experimenter. You also can't run any scripts within FlexSim.

· 7
5 |100000

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

Hanifi.Yilmaz avatar image Hanifi.Yilmaz commented ·

Hey @Kavika F


I have a license and i dont use the experimenter at the Moment. The Problem is deterministic.

Even when i set every solution from the algorithm manually in Flexsim, i got the same result as in Python. It solves the Problem, but destroys the Model. I use the Controller.setParameter(name,value)method to set the parameters in flexsim. Maybe the problem is the way of using the methods of flexsimpy. Do i have To open the script only once? And what does the „Controller.stop()“ methods exactly do?


Another question: Is it possible to start the Experimenter with FlexSimPy to make MC Simulations? My next step is to solve a stochastic problem.

Thanks

0 Likes 0 ·
Hanifi.Yilmaz avatar image Hanifi.Yilmaz commented ·
Update: I solved the first problem. My mistake was that i opened the script in every iteration instead of opening it once. For the other (2) problem, i dont have a solution.. The script always restarts itself. @Kavika F
0 Likes 0 ·
Kavika F avatar image Kavika F ♦ Hanifi.Yilmaz commented ·
Is there a loop in your code calling itself? Could you post it so I could see what could be happening?
0 Likes 0 ·
Hanifi.Yilmaz avatar image Hanifi.Yilmaz Kavika F ♦ commented ·

I just debugged the script multiple times and i know where the error comes from now. I have a list in python with values from [1...30]. Also i have 30 paramaters in flexsim and i set a value to every parameter with python. And this is the exact line where the script restarts hisself. Is there another way to give an array directly from python to flexsim? I saw this "send" and "receive" labels in the TestFlexsimPy model which sends and gets values from the model. But i dont understand how you implemented this treenodes and what this exactly does.1678976805055.png

0 Likes 0 ·
1678976805055.png (12.2 KiB)
Show more comments