Page 1 of 1

taking data from excel - one by one

Posted: Tue Apr 20, 2010 3:49 am
by tbs14
I have been thinking on how to do a particular task using Vensim Pro for some days.

I have a schedule of power plants to be constructed in an excel file. But before I want to construct a plant, I want to evaluate the market price ( a variable that I have already determined). If the price is higher than the plant marginal price (a constant), I want to get the first power plants in the schedule. I know how to do it if I need to do it just once. But I want to repeat this cycle again when the next market price is higher than the plant marginal price where I would take the second power plant in the list.


Do you know how I can do this? Thanks

Posted: Tue Apr 20, 2010 9:30 am
by bob@vensim.com
Use something like

Construction Start Flag[plant] = IF THEN ELSE(price > marginal cost[plant] :AND: previous plant finished[plant],1,0)
previous plant finished[P1] = 1
previous plant finished[LaterPlant] = plant finished[EarliearPlant]
LaterPlant: P2,P3,P4
EarlierPlant: P1,P2,P3 -> LaterPlant

Posted: Wed Apr 21, 2010 1:21 am
by tbs14
TQ for the suggestion. But I am still not sure how the data can be obtained from Excel.The command 'Get Excel constants' needs me to specify the cell and I am not sure how to update the cell number for me to get the second value.

Posted: Wed Apr 21, 2010 9:02 am
by bob@vensim.com
You will need to read in all the data from excel at once - assuming it is running across use

cost from excel[plant] = GET XLS CONSTANTS('filename.xls','Sheet1','A1')

then all of the values in row 1 will be read (as many as there are plants).

Posted: Wed Apr 21, 2010 11:18 pm
by tbs14
I see. Will I be able to get the data one by one from Excel if I were to use Vensim DSS and use VB to get the values? Then I can feed the constant one by one to Vensim DSS to run my model. Will that work or would it be rather tricky to do that?

Thanks

Posted: Thu Apr 22, 2010 1:27 pm
by tomfid
I think we need a little more information ...

All GET XLS information is loaded at the beginning of a run. Why would the cell for a particular plant's information change? Is excel updating plant information dynamically?

Tom

Posted: Thu Apr 22, 2010 9:42 pm
by tbs14
Actually I want the variable in Vensim that takes the data from Excel to be updated as the model runs. For example, first it takes the data from cell E1 and perform some task then take data from cell E2 and repeat the process till all the Excel data has been taken. My specific problem is I have a list in Excel with the plant name and its corresponding LRMC,capacity etc. When the market price> LRMC[Plant 1], I want to get the capacity [Plant 1] for my computation. Then when the market price> LRMC[Plant 2], I want to take the capacity[Plant 2] and so on. I hope my description is OK now.

Vensim seems to allow only taking data from one cell or a set of data with corresponding time.


I know how to do this using other programming language where I can assign counters and update a variable in a loop but not sure how I can do this with Vensim. That is why I am considering using VB. Will that be possible? TQ

Posted: Thu Apr 22, 2010 11:38 pm
by tomfid
OK ... now I understand. I think you want something like the attached model.

It builds plants in discrete increments, when market price > plant cost. In the case of a tie (two plants with same cost), both get built at the same time. If you don't want that, you could probably use VECTOR SORT to order plants and select one at a time.

Note that this model has no notion of demand, or construction underway, and thus might do silly things that a real plant construction decision would avoid.

Posted: Mon Apr 26, 2010 4:32 am
by tbs14
TQVM:) I will give it a try.