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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2016
Thomas Wyssenbach
Guest
 
Posts: n/a
Downloads: 3
Uploads: 0
Question Problem by exporting global tables to csv files from experimenter

Hello FlexSim Community

I am struggling with another "simple issue": My model records an extended protocol of flow items into a global table during simulation runtime. Each hour has a record of around 200 entries (rows) with around 100 variables (columns, some are num, some are str). The tables are set to "use bundles" and are resetted by an "OnModelReset" call in FlexScript. So far so good - that part works.
In order to post analyze approx. 100 scenarios with each approx. 1000 simulation runs, I would like to use the experimenter functionality (1000 replications per 100 scenarios). I have researched and played around quite a bit so far and have not yet found the solution to properly export global tables to csv files with the experimenter and the "end of replication" call. In order to avoid writing in any "wrong" directories, I have hardcoded the path in the exportable()-function.
The following observations were made on the simplified model in the attachment (the point two is similar to the observations in my actual model):
1. If I use all columns in the global table as numbers only (no string records), it does write (only sometime, after restart FlexSim) around 10 lines on the csv, instead of the expected hundreds.
2. The model attached has one column with num and one with str. This results in writing each file with: 1 entries, [Time, Machine]. From this I conclude, that the reference is fine; as it gets the column headers. Anyhow - no data is written, nor is the header written correctly in the csv.
Any hints, tips or tricks on how to do this correctly with all "child" and other instances considered? Thanks a lot for your support.
PS: Honestly, I cannot follow/understand the thread https://www.flexsim.com/community/fo...e+experimenter completely, especially the part with transferring the data between the instances.
rgs, Tom
Attached Files
File Type: fsm Globaltable.fsm (20.5 KB, 475 views)
Reply With Quote
  #2  
Old 05-24-2016
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: 1166
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

First, change your End of Replication code so that it only fires on the child process running the replication and not on the main process:

Code:
if(not(objectexists(childexpfolder))) { // firing on the hidden child process
	exporttable(reftable("GlobalTable_Data"),concat("C:/test/test_",numtostring(scenario),"-",numtostring(replication),".csv"),1,0); // write column headers, no row headers
}
Second, it looks like exporttable() has a bug when using Bundle data. I'll add a note to the dev list to fix that.

In the meantime, you could try changing your tables to not use Bundle data (if you have enough memory to hold all the data you need), or you could write a custom script using fileopen(), fpt(), fpf(), fpd(), fpr(), and fileclose() to write the csv file manually within for() loops through the table data. Here is an updated script that works around the exporttable() bundle bug:

Code:
/**Custom Code*/
double replication = param(1);
double scenario = param(2);
treenode childexpfolder = param(3);

if(not(objectexists(childexpfolder))) { // firing on the hidden child process
	treenode table = reftable("GlobalTable_Data");
	string filename = concat("C:/test/test_",numtostring(scenario),"-",numtostring(replication),".csv");
	int colHeaders = 1;
	int rowHeaders = 0;
	if (getdatatype(table) == DATATYPE_BUNDLE) {
		fileopen(filename);
		if (colHeaders) {
			if (rowHeaders) {
				fpt(", ");
			}
			for (int col = 1; col <= gettablecols(table); col++) {
				fpt(gettableheader(table, 2, col));
				if (col != gettablecols(table)) {
					fpt(", ");
				}
			}
			fpr();
		}
		for (int row = 1; row <= gettablerows(table); row++) {
			if (rowHeaders) {
				fpt(gettableheader(table, 1, row)); fpt(", ");
			}
			for (int col = 1; col <= gettablecols(table); col++) {
				int colDatatype = getbundlefieldtype(table, col-1);
				if (colDatatype == BUNDLE_FIELD_TYPE_STR) {
					fpt(gettablestr(table, row, col));
				} else {
					fpf(gettablenum(table, row, col));
				}
				if (col != gettablecols(table)) {
					fpt(", ");
				}
			}
			fpr();
		}
		fileclose();
	} else {
		exporttable(table,filename,colHeaders,rowHeaders); // write column headers, no row headers
	}
}
Third, we are migrating to a new support system at https://answers.flexsim.com

You can now post questions like this on that system instead of this forum. The new system has better formatting, tagging, and search capabilities.

Last edited by Phil BoBo; 05-24-2016 at 05:00 PM.
Reply With Quote
The Following 3 Users Say Thank You to Phil BoBo For This Useful Post:
arunkrmahadeva (05-24-2016), Steven Hamoen (05-25-2016), Thomas Wyssenbach (05-25-2016)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting global table to Excel mearjun Q&A 16 08-05-2014 09:26 AM
Global Table export problem by using end of replication trigger in teh experimenter Peppino Q&A 16 02-22-2013 04:38 AM
Exporting Global Tables with Excel 2007 david_white Q&A 8 11-11-2008 10:34 AM
Limit in the completion hints? Global Tables, Global Variables, etc.? Tom David Gripes and Goodies 6 09-09-2008 04:05 PM


All times are GMT -6. The time now is 02:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.