question

Nicolas Mbz avatar image
1 Like"
Nicolas Mbz asked Nicolas Mbz commented

How to export tables "Model.parameters" by code ?

I would like to export some tables after experimenter. I don't find the way to export the table Model.parameters.

for exemple, for Global Tables I use : exporttable(Table("A"));

Is there a way ?

Thanks in advance

FlexSim 22.2.1
exportmodel.parameterssummary
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Nicolas M25, was Jordan Johnson's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
1 Like"
Jordan Johnson answered Nicolas Mbz commented

To export parameter/performance measure values after an experimenter:

The parameters and performance measures are stored in the results database file. If click the View Results button on the Experimenter, and go to the Result Tables tab, by default you'll see a table called "Summary". You can query that table, dump it to a node, and then export it:

treenode dump = Model.find("Tools").subnodes.assert("dump");
Table.query("SELECT * FROM Experiment.Summary").cloneTo(Table(dump));
exporttable(dump, "path/to/file.csv");
dump.destroy();

You can also add more summary tables and configure them individually. You can choose which columns are present, and choose some options about how to aggregate the performance measures. See Experiment Result Tables for more information.

To export a Parameter Table in general:

ParamTableExportTest.fsm

The basic idea is to find the table structure for the Parameter Table in the tree. Then, the goal is to use exporttable(). But if you just export the table structure, you'll see that the CSV file has "Value: 1" in the value column, rather than just the value.

So instead of dumping it directly, the code in the model first runs a query, so that we can get a better value for column ("1" rather than "Value: 1"). At first, I used the query:

Table result = Table.query("SELECT Name, $2 AS Value, [Display Units], Description FROM $1", paramTableNode, $iter(1).subnodes[2].value);

That works fine, if all your parameters are numbers, text, or null. If they are containers (arrays or maps) then the value needs to be written in a sensible way. So I added a user command that converts those values to JSON, and use that in the query.

This workaround is not straightforward, and maybe a better one is out there. I'll add a request to the dev list to export Parameter Tables more easily.


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Nicolas Mbz avatar image Nicolas Mbz commented ·
Thanks a lot for your answer, I will try :)
0 Likes 0 ·
Nicolas Mbz avatar image Nicolas Mbz commented ·
Thanks, it works :)
0 Likes 0 ·