ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
Run Experiment on model start
Hi All,
Is there a Flexscript command that run the Experimenter? I've tried applicationcommand("runexperiment"). It doesn't seem to work. I would like the model to automatically start running the experimenter upon opening. If I use go(); or runfunction(); it would only run the model once while the experimenter is set for multiple runs. I'm doing this to automate the model runs so that the variables in the model can be changed based on Flexsim's output and input from another program. Thank you in advance for your help Ploy |
#2
|
||||
|
||||
Experimenter Run on Model Open
Dear Pongjetanapong,
The attached model is done on basic Flexsim, which may help you to solve your problem. Regards, Arun KR, CCS, India |
The Following 3 Users Say Thank You to arunkrmahadeva For This Useful Post: | ||
Pongjetanapong (09-23-2015) |
#3
|
|||
|
|||
Thanks arunkrmahadeva,
Your model works well! But I have some doubts about your codes. I comment the code in line20-23 out, and it still works well. I put this code in other trigger and try to use breakpoint to find out what is "runstatus", while it seems to be nothing (as shown in the pic below) Would you please tell me what these codes use for? |
#4
|
||||
|
||||
He copied that code from the OnPress on the Run Experiment button.
Outside of that location, those lines of code won't do anything. They are updating the "Experiment Status" window that shows the progress of the experiment run. You don't need those lines of code to run the experimenter programmatically. |
The Following 3 Users Say Thank You to Phil BoBo For This Useful Post: | ||
Pongjetanapong (09-23-2015) |
#5
|
|||
|
|||
Hi All,
Thank you for your contribution. I've tried the codes but it doesn't seem to work on Flexsim HC. It does seem to activate the experimenter but the output files are not generated. Actually, just applicationcommand("runexperiment") would do the same but still does not produce any output files Last edited by Pongjetanapong; 09-23-2015 at 07:59 PM. |
#6
|
|||
|
|||
If you want the experiment to generate output files you need to activate the output. There are 2 ways to do this. Either check the "Save output files for each replication" checkbox on the experimenter or go to Statistics > Output Raw Data and check the "Activate" checkbox on the GUI that pops up. This GUI will also allow you to specify what data is exported.
|
#8
|
|||
|
|||
Hi Phil,
I found the following code in the On Press command of the Run experiment Could you please help explain to me how I can get a reference to the node "c" so that I can use it in the On model open trigger? Is it possible? applylinks(ownerview(c)); treenode expfolder = node("/Tools/Experimenter", model()); treenode exec = node("MAIN:/project/exec"); treenode reps = node("/replications", exec); treenode runstate = node("MAIN:/project/exec/replications/runstate"); int nrscenarios = get(node("/NumberOfScenarios", expfolder)); int nrreps = get(node("/NumberOfRunsPerScenario", expfolder)); set(node("/NumberOfScenarios", reps), nrscenarios); set(node("/NumberOfRunsPerScenario", reps), nrreps); int statehistory = getbundlenrentries(node("MAIN:/project/model/Tools/Output>variables/DataBundles/StateHistory")) > 0; if(getbundlenrentries(runstate) == 0 && !statehistory) { buildnodeflexscript(expfolder); applicationcommand("runexperiment"); } else { applicationcommand("killexperiment"); clearbundle(runstate); applicationcommand("reset"); } treenode runstatus = node("../RunStatus",c); setvarnum(runstatus,"initialized",0); function_s(runstatus,"Update"); applylinks(c, 1); |
#10
|
|||
|
|||
Activating the output will generate output files, maybe you're not looking in the right place? I've attached a model made in HC 5.0.4 where the experiment runs on model open and a Patient History csv file is created for each replication. These csv files are created in my FlexSimHC 5 Projects folder. You might need to change the output directory in Statistics > Output Raw Data.
|
Thread | Thread Starter | Forum | Replies | Last Post |
How to set Model Start Time from Excel? | Mauricio Souza | Q&A | 3 | 08-13-2015 08:42 AM |
Unable to set model start time with custom repeating Time Table? | Ryan Davis | Q&A | 1 | 04-30-2014 05:00 PM |
Why can persons come back original position in experiment model ? | Dane Lee | Q&A | 3 | 07-30-2009 08:03 PM |
Command overview does not start because XML does not start | Tom David | Q&A | 0 | 09-17-2008 12:11 AM |
Start Flexsim and model from externally via a batch file | Tom David | Q&A | 3 | 09-12-2007 03:17 PM |