question

Jeremy R avatar image
1 Like"
Jeremy R asked Andrew O commented

Get experimenter job name at end of scenario

When completing a scenario, I would like to export the run data for that scenario into a folder with the scenario title, which is then contained in a folder with the job title.

In "On End of Replication" from the Experimenter, the scenario index and replication number are directly provided, and I can retrieve the scenario title from the task Map. But I cannot figure out any way to get the job title.

I can access the jobs node within the experimenter, but I don't have any direct way to know which job corresponds to my current scenario.

Is there any way to retrieve the job title during "On End of Replication"?

FlexSim 22.2.2
experimenterscenariojobs
· 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.

Andrew O avatar image Andrew O commented ·

Hi @Jeremy R, was Felix Möhlmann'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

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered

I don't know of any way to directly access the experiment name.

My suggestion would be to add the experiment title to the scenario name and then split the string up in the trigger. Editing the scenario names can be done automatically with the following code.

// Add experiment name to the front of scenario, separated by "|".
treenode jobs = Model.find("Tools/Experimenter>variables/jobs");
for(int i = 1; i <= jobs.subnodes.length; i++)
{
    treenode experiment = jobs.subnodes[i];
    treenode scenarioTable = experiment.subnodes["scenarios"].subnodes["valueTable"];
    for(int sce = 1; sce <= scenarioTable.subnodes.length; sce++)
    {
        treenode scenario = scenarioTable.subnodes[sce];
        if(!(scenario.name.startsWith(experiment.name)))
        {
            scenario.name = experiment.name + "|" + scenario.name;
        }
    }
}

1663309664240.png

// Retrieve names in trigger
string scenarioName = task["scenarioName"];
Array splitString = scenarioName.split("|");
string experimentName = splitString[1];
scenarioName = splitString[2];

1663309664240.png (2.5 KiB)
5 |100000

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