question

Patrick Zweekhorst avatar image
0 Likes"
Patrick Zweekhorst asked Jordan Johnson commented

Export Results to CSV File does not work anymore in Experimenter 2022

Hi,

If you select the option Export Results to CSV File from the drop-down options at the On End Of Job in the experimenter you will get an exception when the code is executed. This code looks to be the same code as in FlexSim 2021, but the experimenter has changed quite a bit. I assume it is a bug and that this code should have been updated?

Thank you in advance.

Patrick

FlexSim 22.0.1
experimenterend of job
5 |100000

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

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jordan Johnson commented

That's a good catch. It's definitely an oversight, and needs to be addressed. I'll add it to the dev list.

For now, your best bet is to configure a Result Table in the Performance Measures window. Once that table looks close enough, you can then query that table, and export the result, with code like the following:

treenode dumpNode = Model.find("Tools").subnodes.assert("dump");
dumpNode.dataType = DATATYPE_BUNDLE;
Table.query("SELECT * FROM [Experiment.MyResultTable]").cloneTo(Table(dumpNode));
exporttable(dumpNode, someFilePath, 1);
dumpNode.destroy();

That original pickoption had many columns per Performance Measure, including mean, standard deviation, and lower and upper confidence intervals. Getting those additional columns would be harder, but not impossible; it would just require some additional post-processing.

· 3
5 |100000

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

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·
Hi @Jordan Johnson,

Thanks for your answer. We can definitely work with that. If we click on view results -> generate report we can already export everything, including the performance measures to Excel. This is fine for me right now. Your code solution is however a good option for other cases. Thanks

0 Likes 0 ·
Alessio Merlo avatar image Alessio Merlo commented ·
Hi @ jordan,

does a similar code exist to get the values of a performance measure?

Something like:

Table res = Table.query("SELECT * FROM Experimenter.pfms_value WHERE pfms.Name = My_PFM_Name")

I create a custom code to query the database directly, but it is tricky and "not official".

Thanks in advance!

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Alessio Merlo commented ·

All the current built-in tables for getting Experiment data put the Performance Measures as columns:

SELECT Scenario, MyPerformanceMeasure FROM Experiment.PerformanceMeasures

To all who read further: the code below queries the result database directly. It may not work in future versions. Use at your own risk.

Since you mentioned querying the database yourself, I thought I'd provide an example. The query below produces a table with one row per scenario per replication per performance measure.

treenode exp = Model.find("Tools/Experimenter");
Database.Connection db = function_s(exp, "getDBConnection");

int shouldDisconnect = 0;
if (!db.isConnected) {
    if (!db.connect()) {
        return 0;
    }
    shouldDisconnect = 1;
}

string stmtText = "\
SELECT s.id, s.name, t.replication, p.name, pv.value \
FROM scenarios s \
JOIN tasks t ON t.scenario_id = s.id \
JOIN pfm_values pv ON pv.task_id = t.id \
JOIN pfms p ON pv.pfm_id = p.id \
WHERE p.name = ? \
";

var stmt = db.prepareStatement(stmtText);
if (stmt) {
    stmt.bindParam(1, "Throughput", Database.DataType.Unknown);
    var result = stmt.execute();
    while (result.fetchNext()) {
        // Do something with the result. Here I print them
        Array values = Array(result.numFields);
        for (int i = 1; i <= values.length; i++) {
            values[i] = result[i];
        }
        print(values);
    }
} else {
    // Otherwise, print the error message  for why the statement wouldn't compile
    print(function_s(db.as(treenode), "getErrorMessage"));
}

if (shouldDisconnect) {
    db.disconnect();
}
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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