Hello
I'm looking for a way to add 2 subscripted variables (var1 and var2) together so that the largest element of var2 is added to the first element of var1, the second largest element of var2 is added to the second element of var1... and so on.
I have seen the functions vector reorder and vector sort order, but they do not appear in the ref manual. Could someone explain these functions to me or propose another way to do this. Many thanks.
ordering vectors
-
- Super Administrator
- Posts: 4600
- Joined: Wed Mar 05, 2003 3:10 am
Hello Chester,
The Vensim documentation on the web contains some help,
http://www.vensim.com/documentation/html/22782.htm
I would use the sort function (to give "sorted vars"), then something like
addition param[subrange 2] =
sum (
if then else ( sorted vars[sub range 1!] = subrange 2
, sorted vector[sub range 1!] + vector to be added to[subrange 2]
, 0 ) )
Is this ok to follow?
Tony.
The Vensim documentation on the web contains some help,
http://www.vensim.com/documentation/html/22782.htm
I would use the sort function (to give "sorted vars"), then something like
addition param[subrange 2] =
sum (
if then else ( sorted vars[sub range 1!] = subrange 2
, sorted vector[sub range 1!] + vector to be added to[subrange 2]
, 0 ) )
Is this ok to follow?
Tony.
-
- Junior Member
- Posts: 14
- Joined: Tue Mar 25, 2003 9:25 am
-
- Super Administrator
- Posts: 4600
- Joined: Wed Mar 05, 2003 3:10 am
I have asked for clarification (I would expect the same results as you).
If you are still using our external function library, you could use the SORT ASCEND/DESCEND funciotns. That should work as expected (not zero based though).
Syntax is something like
SORT ASCEND 1D ( vector, size of vector, trigger).
Tony.
If you are still using our external function library, you could use the SORT ASCEND/DESCEND funciotns. That should work as expected (not zero based though).
Syntax is something like
SORT ASCEND 1D ( vector, size of vector, trigger).
Tony.
-
- Super Administrator
- Posts: 4600
- Joined: Wed Mar 05, 2003 3:10 am
-
- Junior Member
- Posts: 14
- Joined: Tue Mar 25, 2003 9:25 am