ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Healthcare (HC) > FlexSim HC: Q&A
Downloads

FlexSim HC: Q&A Questions about FlexSim Healthcare

  #1  
Old 09-20-2015
Pongjetanapong Pongjetanapong is offline
Flexsim User
 
Join Date: Jul 2013
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 8
Thanked 2 Times in 2 Posts
Rep Power: 85
Pongjetanapong is on a distinguished road
Default 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  
Old 09-21-2015
arunkrmahadeva's Avatar
arunkrmahadeva arunkrmahadeva is offline
CCS, India
 
Join Date: Sep 2013
Location: India
Posts: 71
Downloads: 67
Uploads: 0
Thanks: 285
Thanked 101 Times in 51 Posts
Rep Power: 145
arunkrmahadeva is a jewel in the rougharunkrmahadeva is a jewel in the rougharunkrmahadeva is a jewel in the rougharunkrmahadeva is a jewel in the rough
Default 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
Attached Files
File Type: fsm On Open Experimenter.fsm (61.6 KB, 634 views)
The Following 3 Users Say Thank You to arunkrmahadeva For This Useful Post:
Pongjetanapong (09-23-2015)
  #3  
Old 09-21-2015
Jing Chen
Guest
 
Posts: n/a
Downloads: 2
Uploads: 0
Default

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?
Attached Thumbnails
Click image for larger version
Name:	QQ截图20150921213314.png
Views:	587
Size:	22.7 KB
ID:	3032  
  #4  
Old 09-21-2015
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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  
Old 09-23-2015
Pongjetanapong Pongjetanapong is offline
Flexsim User
 
Join Date: Jul 2013
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 8
Thanked 2 Times in 2 Posts
Rep Power: 85
Pongjetanapong is on a distinguished road
Red face

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  
Old 09-24-2015
Matthew Gillespie Matthew Gillespie is offline
Flexsim Software Products, Inc.
 
Join Date: Mar 2014
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Matthew Gillespie is on a distinguished road
Default

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.
  #7  
Old 09-24-2015
Pongjetanapong Pongjetanapong is offline
Flexsim User
 
Join Date: Jul 2013
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 8
Thanked 2 Times in 2 Posts
Rep Power: 85
Pongjetanapong is on a distinguished road
Default

Hi Matthew,

Thank you for your suggestion. I did check the "save output files for each replication". It didn't work. Flexsim and Flexim HC are quite different.
  #8  
Old 09-28-2015
Pongjetanapong Pongjetanapong is offline
Flexsim User
 
Join Date: Jul 2013
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 8
Thanked 2 Times in 2 Posts
Rep Power: 85
Pongjetanapong is on a distinguished road
Default

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);
  #9  
Old 09-28-2015
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

c is the view that is executing OnPress. In the OnModelOpen trigger, you can't reference the Experimenter view because it might not be open.
  #10  
Old 09-28-2015
Matthew Gillespie Matthew Gillespie is offline
Flexsim Software Products, Inc.
 
Join Date: Mar 2014
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Matthew Gillespie is on a distinguished road
Default

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.
Attached Files
File Type: fsm ExperimenterOutputExample.fsm (60.5 KB, 600 views)


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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.