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 Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 06-12-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default Global Table export problem by using end of replication trigger in teh experimenter

Hallo boys and girls,

i try to export a global table what i fill dynamicly in the simulation.
I use that code below to export the table as .csv, it's working fine but it doesn't expot the table what is used in the replication. It exports the table what i can see when i go over the menu Tools>Global Tables>gt_prog.

Code:
/**Table export*/
double replication = parval(1);
double scenario = parval(2);
treenode childexpfolder = parnode(3);
{
	string filename = "zeiten";
	filename = concat(filename , "_S" , numtostring(scenario,0,0) , "_R" , numtostring(replication,0,0) , ".csv");
	string directory = modeldir();
	if(stringlen(directory) < 3)
		directory = documentsdir();
	exporttable(reftable("gt_prog"),concat(directory,filename),1,0);
}
  #2  
Old 06-12-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Quote:
Originally Posted by Peppino View Post

Code:
/**Table export*/
    exporttable(reftable("gt_prog"),concat(directory,filename),1,0);
}
I think what you describe that comes out is exactly correct. Here you tell Flexsim to export global table "gt_prog" and you tell us that that is what you see. So if you want a different table to be exported you have to change the "reftable()" part of your code
  #3  
Old 06-12-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

This gets called twice so I think you'll need to test that childexpfolder does not exist before exporting the table.
  #4  
Old 06-13-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default

Quote:
This gets called twice so I think you'll need to test that childexpfolder does not exist before exporting the table.
I'm actually not sure what you mean, so i tried this code below but it is not working. I get the same result, it didn't export the table what is used in the replication.

Code:
/**Table export*/
double replication = parval(1);
double scenario = parval(2);
treenode childexpfolder = parnode(3);
{
	string filename = "zeiten";
	childexpfolder = reftable("gt_prog");
	filename = concat(filename , "_S" , numtostring(scenario,0,0) , "_R" , numtostring(replication,0,0) , ".csv");
	string directory = modeldir();
	if(stringlen(directory) < 3)
		directory = documentsdir();
	exporttable(childexpfolder,concat(directory,filename),1,0);
}
  #5  
Old 06-13-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Before the braces in your first example put:
if(not(objectexists(childexpfolder)))

and you shouldn't reassign childexpfolder - it is passed in for a purpose : to act as a container to pass data from the replication instance back to the master model instance (hence the two calls - one in the replication instance and one in the master instance)

Last edited by Jason Lightfoot; 06-13-2012 at 04:48 AM.
  #6  
Old 06-13-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default

I test the childexpfolder, it allready exists. Now i get no export. And now???? I don't now how to handel that childexpfolder.

Quote:
if(!(objectexists(childexpfolder)))
{
string filename = "zeiten";

filename = concat(filename , "_S" , numtostring(scenario,0,0) , "_R" , numtostring(replication,0,0) , ".csv");
string directory = modeldir();
if(stringlen(directory) < 3)
directory = documentsdir();

exporttable(reftable("gt_prog"),concat(directory,f ilename),1,0);
}
  #7  
Old 06-13-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

It should not exist in the child instances of the experiment.

Please post the model.
  #8  
Old 06-13-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default

That is my complet model.
Attached Files
File Type: fsm IST-ZustandV1.fsm (163.9 KB, 91 views)
  #9  
Old 06-13-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

It looks like they'll be written to your Documents/Flexsim 6 Projects folder
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Peppino (06-13-2012)
  #10  
Old 06-13-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default

Thank's Jason, it's working.

That is the first code what i don't understand.
Why it's working now, and why it's saving in documentsdir() and not in modeldir()?

Maybe because my model is in my dropbox folder? Normally not!

My not understanding is based on that childexpfolder.
  #11  
Old 06-13-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

It looks like the child instances don't have modeldir() set which could be an omission - I've sent an email to the developers.

The End of Replication trigger has a picklist example of returning global table information back to the master model from the experimenter's child instances in the End of Replication trigger.

The engine is calling the trigger in the child first and then in the master for each replication end event. It passes the experiment folder of the child (so /Tools/Experimenter) to the master as childexpfolder. This is to give the child process a chance to write information into that folder that the master can then read. When the child gets called, childexpfolder is NULL, so for clarity you could add a variable:

int ischild=not(objectexists(childexpfolder));

or define a macro:

#define ISCHILD not(objectexists(childexpfolder))
  #12  
Old 06-13-2012
Peppino Peppino is offline
Flexsim User
 
Join Date: May 2012
Location: Leverkusen, Germany
Posts: 27
Downloads: 1
Uploads: 0
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 98
Peppino is on a distinguished road
Default

Ok, i think i understand what you meen. Thank's
  #13  
Old 09-18-2012
gadirajus gadirajus is offline
Flexsim User
 
Join Date: Aug 2010
Posts: 8
Downloads: 19
Uploads: 0
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
gadirajus is on a distinguished road
Default How to updata a table using the tables in each replication.

This post was very helpful for my model, where I needed to export a Global table after each replication. How can we have a single global table (At Experiment Level) that is updated using the global table of each replication.
For example: let us say at the end of each replication I have a table: TABLE1.
I need a table EXPERIMENTTABLE to show the sum/average of TABLE1 across replications.
Thanks
  #14  
Old 09-18-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

If you look at the Endof Replication code for Global tables template, you'll see the line :
settablennum(table,row,col,gettablenum(tablecopy,row,col));

Instead of this just loop through ALL the rows and columns and increment the cells. So for the sum it's this for each cell:
inc(gettablecell(table,row,col),gettablenum(tablecopy,row,col));

To maintain an average you need to know the number of replications completed so far which you should be able to store in a global variable.

Then it's just :
nreps++; //our global variable

and then for each cell:
settablenum(table,row,col,(gettablenum(table,row,col)*(nreps-1)+gettablenum(tablecopy,row,col))/nreps);

Also - if you've not done so already - it might be worth taking a look at the PFMs of the Experimenter as they allow powerful reporting across replications.
  #15  
Old 09-19-2012
gadirajus gadirajus is offline
Flexsim User
 
Join Date: Aug 2010
Posts: 8
Downloads: 19
Uploads: 0
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
gadirajus is on a distinguished road
Default THank you

THanks Jason.
  #16  
Old 02-21-2013
michaelsmith michaelsmith is offline
TMN Simulation -Australia
 
Join Date: Aug 2007
Location: Hobart Tasmania
Posts: 62
Downloads: 7
Uploads: 0
Thanks: 31
Thanked 19 Times in 12 Posts
Rep Power: 170
michaelsmith will become famous soon enough
Default

Jason

Did you get a reply on this?
"It looks like the child instances don't have modeldir() set which could be an omission - I've sent an email to the developers."

Mike
  #17  
Old 02-22-2013
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Yes, it's on the list to fix and for now you can access these instead of using the commands. (Thanks Phil).

gets(node("MAIN:/1/environment/compilesave/currentfile"))
gets(node("MAIN:/1/environment/compilesave/modeldir"))
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Phil BoBo (02-22-2013)


Thread Thread Starter Forum Replies Last Post
Experimenter Export Susan Pevovar Q&A 6 06-02-2011 05:20 PM
problem with excel export Congshi Wang Q&A 1 12-09-2010 09:24 AM
Problem with OnModelOpen trigger juan alberto Q&A 3 09-20-2010 07:00 AM
Export of statistic data from Experimenter Matthias Hofmann Q&A 1 11-04-2008 09:05 AM
Can I make a column of a global table to type table? qin tian Q&A 0 10-01-2008 09:27 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.