Create Experiment Table/Scenarios by Code

Create Experiment Table/Scenarios by Code

leo_l6
Not applicable
264 Views
1 Reply
Message 1 of 2

Create Experiment Table/Scenarios by Code

leo_l6
Not applicable

[ FlexSim 22.0.0 ]

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!

0 Likes
Accepted solutions (1)
265 Views
1 Reply
Reply (1)
Message 2 of 2

jason_lightfoot_adsk
Autodesk
Autodesk
Accepted solution

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;