Do I have to press the plus button multiple times?

Do I have to press the plus button multiple times?

__ANON_USER__1
Not applicable
7 Views
2 Replies
Message 1 of 3

Do I have to press the plus button multiple times?

__ANON_USER__1
Not applicable

[ FlexSim 19.0.9 ]


About Experiment Tool.

I made 100 scenarios of 100 variables.
I have saved it in an Excel spreadsheet.


To write a scenario in the Experiment tool,
Do I have to press the plus button 100 times and 100 times?


Or
Is there a way to increase the total to 100 rows and 100 columns?


0 Likes
Accepted solutions (1)
8 Views
2 Replies
Replies (2)
Message 2 of 3

Ben_WilsonADSK
Community Manager
Community Manager

Hi anonymous user, was joerg.vogel's answer helpful? If so, please click the red "Accept" button on 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 or comment back to reopen your question.

0 Likes
Message 3 of 3

mischa_spelt
Advisor
Advisor
Accepted solution

Hi,

It is possible to get this done with a smart Excel Import and a little bit of scripting. I have attached a sample model for FlexSim 20.2, in which I did the following.

1. I reproduced your Excel workbook: ScenariosVariables.xlsx

2. I created an Excel Import to import the workbook into /Tools/Experimenter/ExperimentVariables. To get all the data, I had to check "Use Row Headers" and "Use Column Headers" and explicitly specify starting and total values:

32344-1599208942250.png

3. I checked "Execute Post Import Code" and then clicked the "Post Import Code" button to add a bit of script, that will get the table in the exact form the Experimenter expects. This is what I put there:

int onreset = param(1); //1 if this code is being called on Reset of the model, 0 otherwise

treenode target = model.find("/Tools/Experimenter/ExperimentVariables");

// Set the number of scenarios
model.find("/Tools/Experimenter/NumberOfScenarios").value = target.first.subnodes.length - 1;

for(treenode variable = target.first; variable; variable = variable.next)
{
    // Variable should be an Object
    variable.dataType = DATATYPE_OBJECT;    
    for(int i = 1; i <= variable.subnodes.length; i++)
    {
        if(i == 1) {
            // The first node, pointing to the data, should be called variable
            variable.subnodes.name = "Variable";
        } else {
            // Make sure the subsequent nodes have string datatype             
            Variant value = variable.subnodes.value;
            variable.subnodes.dataType = DATATYPE_STRING;
            variable.subnodes.value = value.join("");            
            
            // For aesthetic reasons, copy the scenario name from the first variable, too.
            variable.subnodes.name = target.first.subnodes.name;            
        }
    }
}

4. Run the Excel import.

5. Profit.

32345-1599209010110.png

Here is a complete demo model for 20.2.