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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
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
|
||||
|
||||
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
|
#4
|
|||
|
|||
Quote:
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
|
|||
|
|||
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
|
|||
|
|||
I test the childexpfolder, it allready exists. Now i get no export. And now???? I don't now how to handel that childexpfolder.
Quote:
|
#9
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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)) |
#13
|
|||
|
|||
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
|
|||
|
|||
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. |
#16
|
|||
|
|||
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
|
|||
|
|||
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 |