ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 01-16-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default Does there exist a function that can calculate the time weighted average of a value in a Global tabl

I have a value in a Global table. The value changes through time.
I want to calculate the time weighted average of the value as a PFM in the experimenter tool.

But I cannot find a function to do this.
Does there exist a function that can calculate the time weighted average of a value in a Global table?

Last edited by Cliff King; 01-20-2008 at 11:14 PM.
  #2  
Old 01-18-2008
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

There are no functions that calculate a time weighted average, but the formula is pretty easy: A = (V1*T1 + V2*T2 + ...) / TotalTime

You could also use the Recorder object which will dynamically calculate a running weighted average by time or by occurence. Choose these options on the Recorder:

Type of Data: User-defined Data
Output type: Min/Max/Average
Weight averages by time
  #3  
Old 01-19-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default

Thanks,Cliff.
Yes, now I am using recorder to get the value.
Then I want to get the value of recorder in the experimenter PFM trigger.
I use the getnodenum() function to get the value of the recorder.
But it doesn't work. Below is what I use.

getnodenum(node("/Recorder1>variables>graphdata>MAIN:/project/model/Tools/GlobalTables/Table1/variables/data/total/1/AvgValue", model()));

The function doesn't return correct.
Why? How to reslove it? Please help.



  #4  
Old 01-19-2008
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

Unfortunately the name of the row node in the graphdata table variable of a Recorder object happens to be the path to the node(s) it is recording, which in your case is MAIN:/project/model/Tools/GlobalTables/Table1/variables/data/total/1. This confuses Flexsim when it tries to follow the path in your getnodenum(node()) expression as you can imagine. You also made the mistake of using > when you needed to use /. Remember that > is used to "dive" into the object data of a node, and / is used to simply drop down one level in hierarchy.

I suggest you refer to the row node in the graphdata table by rank instead of name. In a string defining the path to a node, if the first character following a special character is a number then it is interpreted as the rank of the next node rather than the name. So in other words, if your recorded variable is in the sixth row of the graphdata table, you could use this expression:

getnodenum(node("/Recorder1>variables/graphdata/6/AvgValue", model()));

As a tip, one sure way to get the full path to a node in the tree using all ranks is to right-click on the node in the tree and choose Edit | Designate This Node so(), then from a Script window type nodetopath(so(),0); and hit Execute. You can then copy the string from the window and paste it directly into node(" ") This will always work so long as you do not change the ranks of any nodes refered to in the path. Those nodes which might change rank in the model, you will need to replace the rank number with the name of the node/object.

This will
  #5  
Old 01-20-2008
qin tian qin tian is offline
Flexsim User
 
Join Date: Dec 2007
Location: Shanghai, China
Posts: 137
Downloads: 115
Uploads: 0
Thanks: 59
Thanked 3 Times in 3 Posts
Rep Power: 161
qin tian is on a distinguished road
Default

Great,thank you Cliff.


Thread Thread Starter Forum Replies Last Post
Displaying the simulation time with the various date/time formats. Regan Blackett Tips and Tricks 12 11-12-2012 08:01 AM
Excel and global tables Bill Nordgren Q&A 2 10-15-2007 04:36 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.