VECTOR SELECT unweighted units

Use this forum to post Vensim related questions.
Post Reply
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

VECTOR SELECT unweighted units

Post by rob_n »

Hi,

I'm using VECTOR SELECT to perform SUM and VMIN type calculations on large matrices.
Say Result = VECTOR SELECT(selection_array, expression_array, ..., numerical_action, ...),
Units checking appears to look for
units(Result) = units(selection_array)*units(expression_array).
This is correct when numerical_action is in 0..4, when the aggregation is weighted by selection_array.
I think this is not correct when numerical_action is in 6..10, when the aggregation simply looks for non-zero elements of selection_array. In this case the proper units check is
units(Result) = units(expression_array).

If selection_array is dimensionless, then no units errors. Sometimes selection_array is inherently dimensional (e.g. parts/unit).

A work-around to avoid units errors is to define a dimensionless version of selection_array for use in the VECTOR_SELECT calculation. But if selection_array is large, this is not a great solution.

Another work-around is to ignore the unit errors. I don't like to make a habit of that!

A third approach would be to patch the VECTOR SELECT units check algorith.

Any other ideas?

An example is attached.

Best regards,
Rob
test_VECTOR_SELECT.mdl
(4.91 KiB) Downloaded 139 times
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: VECTOR SELECT unweighted units

Post by rob_n »

Erratum:
for numerical_action = 1, the units check should be
units(Result) = PROD(units(selection_array*expression_array))
for numerical_action = 7, the units check should be
units(Result) = PROD(units(expression_array))

But you get the idea
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: VECTOR SELECT unweighted units

Post by tomfid »

I think you're correct, at least in principle. However, I think there's also a good argument for maintaining parallel between the weighted and unweighted aggregation units (the first six and the 2nd six). The PROD methods are a bit problematic, because the units vary with the dimensionality of the arrays, which can't be understood simply from syntax. Best practice would be to take PROD only of dmnl inputs (which may be the only physically sensible approach in many cases anyway). I'll see what's possible, but I think this is unlikely to change soon.
Post Reply