Is there a function to match a code with a value and return

Use this forum to post Vensim related questions.
Post Reply
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Is there a function to match a code with a value and return

Post by JozefSL »

I want to calculate “Plant Fuel Cost” from two arrays: “Plant Fuel Type” and “Area Fuel Prices”. The first array (Plant Fuel Type) lists the fuel codes for all power plants, while the second array (Area Fuel Prices) list the actual fuel prices in an area for the next 10 time periods.

I wonder is there a function that will match the fuel type with the price in every cycle and return the price in place of the code?

Thank you very much for your help.
Jozef
Attachments
MatchCode2Value.mdl
(1.97 KiB) Downloaded 295 times
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Post by JozefSL »

The attached file is the input table for the model.
Attachments
Input3.xls
(15 KiB) Downloaded 298 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

From the spreadsheet you have data on

Fuel Cost[Area,FuelType]

so all you need to do is associate an Area and FuelType with each plant. Probably it is easiest to do this as two vectors

Plant Area[plant]=2,4,1,5
Plant Fuel Type[plant] = 4,2,1,2

where the number correspond the subscript elements in Area and FuelType.

Then use

plant cost[plant] = VECTOR ELM MAP(Fuel Cost[Area1,FuleType1],(Plant Area[plant]-1) * ELMCOUNT(FuelType) + Plant Fuel Type[plant]-1)

Note the use of multiplication by ELMCOUNT to map the 2 dimensional offset off Fuel Cost.
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Post by JozefSL »

Bob, thank you very much for your help. The VECTOR ELM MAP is rather a tricky function, but I feel I am finally getting closer to understand it. Attached is a model that illustrates the solution. Again thank you very much for your help.

Jozef
Attachments
MatchCode2Value_3.mdl
(2.5 KiB) Downloaded 299 times
Post Reply