question

Leo L6 avatar image
0 Likes"
Leo L6 asked Jason Lightfoot edited

Create Experiment Table/Scenarios by Code

Hi,

I previously asked a question on creating model parameters by code (thanks @Jason Lightfoot !)

I have that working and now I would like to create experiment scenarios by code as well. I know there is the range-based experimenter option, but what I would like to do is create something with more flexibility that that.

To start off, I was thinking of the function_s command that @Jason Lightfoot provided to create a new parameter. Namely, the following:

  1. Table params=paramT.find(">variables/parameters");
  2. treenode newParam=function_s(paramT,"addParameter");


Is there a similar command for adding a new scenario perhaps? Once I have that, then I was thinking I could then use a Table class again to add/update the experimenter scenario table.

Thanks again for any help!

FlexSim 22.0.0
experimenterflexscriptcode
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

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

Here's the syntax for adding a scenario and setting a parameter value for it assuming the scenario table already has one scenario.

string job="Experiment1";
Table scenarioT=Table(Model.find("Tools/Experimenter>variables/jobs/"+job+"/scenarios/valueTable"));
scenarioT.addRow();
treenode newScenario=last(scenarioT);
int row=newScenario.rank;
newScenario.name="MyScenario2";
scenarioT[row]["Parameter1"]=10;
5 |100000

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