question

MPeyman avatar image
0 Likes"
MPeyman asked Kavika F answered

save output via custom code

Hi All,

I have connected my model to python and I want to get the result with different runs. So here In the attached model I'm trying to save the out put of each run in the statcol.csv file but always it gives me 0 for the column.

this is the out put of the python that connected to the flexsim and read the statcol.csv file. i tried to get 5 runs but it gives me 3 without any information and get stuck.

Operator tableRow EntryTime ExitTime

0 operator1 1.0 0.0 0.0

1 operator2 2.0 0.0 0.0

simulation elapsed time: 6.5s

Operator tableRow EntryTime ExitTime

0 operator1 1.0 0.0 0.0

1 operator2 2.0 0.0 0.0

simulation elapsed time: 5.78s

Operator tableRow EntryTime ExitTime

0 operator1 1.0 0.0 0.0

1 operator2 2.0 0.0 0.0

simulation elapsed time: 7.32s

p1.png

peyman-flex-model-original_Zones.fsm

FlexSim 23.0.8
connectionsoutputstatcollector
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

Kavika F avatar image
0 Likes"
Kavika F answered

Hey @MPeyman, I feel like you're not getting much data because you export the statistics collector table after .5 seconds of the model running.

1710176033553.png

Have you tried extending that time?


1710176033553.png (18.2 KiB)
· 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.

MPeyman avatar image MPeyman commented ·

Dear @Kavika F , I remove the part of simulation close and add the code in On Stop. and it saved correctly. But the problem is that, when the simulation finished his work manually I have to stop the simulation. so it save the data and run again, since I defined to run it 5 times. But I don't want to manually stop, I would like automatically after finishing the process it get stop. How is it possible?

e.png

peyman-flex-model-original_Zones.fsm

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ MPeyman commented ·
You can put your code in the 'On End of Replication' trigger of the experimenter and use that to run 5 replications.
0 Likes 0 ·
MPeyman avatar image MPeyman Jason Lightfoot ♦♦ commented ·

dear @Jason Lightfoot , thanks for your command.

firstly where can I find "On End of Replication" because on Model trigger, I only have 4 options which is open, reset, start and end.

second: in my python code I sometime I run flexsim 5 time for the short run and sometime I run it 10 times that defines as a long run. So when the first run gets finish then it should save to the csv and the second run open automatically. but for now I have to stop manually.

0 Likes 0 ·
Show more comments