Vector Reorder error message

Use this forum to post Vensim related questions.
Post Reply
drw
Member
Posts: 40
Joined: Wed Mar 25, 2009 1:10 pm

Vector Reorder error message

Post by drw »

In order to optimise and reduce the computational and memory overhead of a fairly large hourly power generation dispatch model I am trying to separate some of the preprocessing calculations before the dispatch part of the model. In creating this smaller model I am finding that some of the logic which worked fine in the larger model is now throwing an error message which I cannot understand the cause behind. The function causing the issue is the vector reorder function and throws the error message “Arguments out of range in REORDER function”.

In the simple model attached (see VectorReorderSimple.mdl), there is a variable called “Marginal SRMC by day and hour by rank sorted” which simply sorts a set of daily prices from lowest to highest. We are using a few subscripts here: days; hours and a set of prices by two technologies. The time step is annual. This simple model works fine, however, the issue arises when we add additional logic that uses the result of this variable (see VectorReorderAdditionalLogic.mdl). I should note that parts of the additional logic is more computational complex in that the days and hours are turned into the 8760 equivalent hours in the year plus there are pointers within the subscripts to point to the previous hour.

I am using DSS v6.4b.

Many thanks for any assistance.

Cheers
Dave
Attachments
VectorReorderSamples.zip
(197.95 KiB) Downloaded 207 times
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: Vector Reorder error message

Post by Administrator »

I'm struggling to find the problem here.

"cost to store energy" has no value for [pumped,FH1], "energy consumed" is also missing a calculation, so I'm guessing that something is wrong with the mapping calculations (but I'm struggling to find it).

Are you using any other vector functions?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
drw
Member
Posts: 40
Joined: Wed Mar 25, 2009 1:10 pm

Re: Vector Reorder error message

Post by drw »

Thanks for looking at this. To simplify the mdl file that I posted, I pretty much stripped out all the input elements that feed into this section (i.e. all the get VDFs, get Excel function) and these are highlighted in orange and set to a constant 0. The only exception is the "Marginal SRMC" where I have temporarily added in a random function so we can see whether the sort function is working correctly. Therefore you pretty much should get zero in the "additional logic" part or something that wont compute because of the "vector reorder" issue but in theory there shouldn't be missing calculations.

There are only two vector functions used in this part. 1) a VECTOR SORT ORDER in "Marginal SRMC by day and hour by rank" and 2) a VECTOR REORDER in "Marginal SRMC by day and hour by rank sorted".

Assuming that you get the same "out of range" error message, a quick way to see the model working correctly is to set the two equations in the variable "Charging state for full load hour" to a constant 0. When doing this the model runs with no errors and you will see prices flowing through to the variables starting "Threshold price". This tends to suggest to me that the model is not computing the elements for "Marginal SRMC by day and hour by rank sorted" before the rest of the model.

Thanks again,
Dave
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Vector Reorder error message

Post by tomfid »

I haven't had a chance to look at this, but here's a trick for forcing the equation ordering if you suspect an issue. Suppose you have:

a = something
b = VECTOR SORT ORDER( a )
c = VECTOR REORDER( a, b )
d = c

You could add:
e = SUM( a[i!] )
and modify
d = c + 0*e

If that changes the answer, it demonstrates an ordering bug.
drw
Member
Posts: 40
Joined: Wed Mar 25, 2009 1:10 pm

Re: Vector Reorder error message

Post by drw »

Thanks for the suggestion. Tried that both linked and unlinked to the "additional logic" part and unfortunately still have the same "out of range in reorder" error message.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Vector Reorder error message

Post by tomfid »

There's definitely a bug here. Working on it.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Vector Reorder error message

Post by tomfid »

I don't have a fix for the bug, but I have a fix for the model.

I think the reason the bug surfaces is that you have three equations written with 8760 individual elements. I think that confuses the compiler, and it makes the model slow to parse. Since these are actually regular patterns, the solution is to use array mapping.

Normally, I'd use VECTOR SELECT or just SUM, for better causal tracing through the mappings, but in this case VECTOR ELM MAP will run faster.

I implemented that here, and the REORDER error also goes away, presumably because the parsing task is simpler.
FixVectorReorderAdditionalLogic2.mdl
(24.12 KiB) Downloaded 224 times
drw
Member
Posts: 40
Joined: Wed Mar 25, 2009 1:10 pm

Re: Vector Reorder error message

Post by drw »

Thanks a lot, that is awesome. Love it when there is a smarter and more efficient way of doing the modelling. I definitely need to get my head around this vector elm map function as I imagine it should be able to simplify other parts of my model too!

Many thanks again for your assistance. It is very much appreciated!
Dave
Post Reply