ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
Global variable as experiment variable
Hello,
I use a global variable as experiment variable in the experimenter. But it seems that the global variable doesn't change. I can use all possible values but the simulation takes always the value which stays originally in the global variable. If it should not be possible to change global variables with the experimenter, do you have an idea how I can change variables which I wrote directly in the code of time triggers of some objects? thanks in advance Matthias |
#2
|
|||
|
|||
Hi Matthias,
If it is not to much work I should suggest that you replace the Global Variable with a label. What I sometimes do is using a BasicFR which I have a Global Variable pointing to. The I can use getlablenum(GV_Node,"xxxx"); to read a label value, where GV_Node is the global variable to the BasicFR. If you use the global variable in many place you can try to define a label which value then assign to the global variable. You should do the assign OnReset on a object. This is 2 way I directly can come up with, there are probably more ways to do it. Lars-Olof |
The Following User Says Thank You to Lars-Olof Leven For This Useful Post: | ||
Matthias Hofmann (11-06-2008) |
#3
|
|||
|
|||
Hello Matthias and other Flexsim Users,
An easy way to use a 'Global Variable' as an experiment variable is to define a Global Table that contains the value. You can refer to a cell of a Global Table in your experimenter path. Esther |
The Following User Says Thank You to Esther Bennett For This Useful Post: | ||
Steven Hamoen (09-08-2009) |
#4
|
||||
|
||||
Matthias,
I know that this is an old thread but I think that these solutions may be valuable to others. If you wanted to change a global variable value then you could accomplish this in one of three ways, all of which use the experimenter triggers. The triggers you will want to use are the Start of Scenario and Start of Replication triggers. The first method would be to just set the global variable in the trigger based off of a global table look up or off of a hard coded set of values. This is a little harder to change because the values are not located on the experimenter. The second method would be to have the experimenter change a label or some other node value in the model and then use the trigger to set the global variable based on that value. The nodes that are changed by the experimenter are updated prior to the execution of the triggers so this would work well and you can update the values in the experimenter. It is very similar to the solution from Lars but you still get to use the global variable in your code. The third method would be to set the global variable based on the values listed in the experimener table editor directly. In the triggers you can get to the values through the use of the following code: double scenario = parval(2); //This is a default line in the trigger int column = 1; //The column that holds the data in the table editor value = getnodenum(rank(rank(node("/ExperimentVariables", up(c)), scenario + 1), column)); The third method is a little harder to grasp but once you get it, it should be very effective for you. Good Luck, Brandon
__________________
thats not normal. |
The Following 5 Users Say Thank You to Brandon Peterson For This Useful Post: | ||
Phil BoBo (09-08-2009) |
Thread | Thread Starter | Forum | Replies | Last Post |
Edit Value of Variable in Flexscript Node | Joe Allen | Q&A | 19 | 09-17-2008 05:39 PM |
Using a Variable number of Operators for Processing | Brandon Peterson | Tips and Tricks | 4 | 07-16-2008 09:16 AM |
Auto check of variable type ranges | RalfGruber | Gripes and Goodies | 0 | 06-14-2008 02:15 PM |
Assign an array to a variable | AlanZhang | Q&A | 6 | 04-24-2008 01:59 PM |
Display Global Variable | Sung Kim | Q&A | 4 | 02-24-2008 11:24 PM |