taking data from excel - one by one

Use this forum to post Vensim related questions.
Post Reply
tbs14
Junior Member
Posts: 9
Joined: Wed Nov 04, 2009 1:57 am

taking data from excel - one by one

Post 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
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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
tbs14
Junior Member
Posts: 9
Joined: Wed Nov 04, 2009 1:57 am

Post 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.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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).
tbs14
Junior Member
Posts: 9
Joined: Wed Nov 04, 2009 1:57 am

Post 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
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Post 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
tbs14
Junior Member
Posts: 9
Joined: Wed Nov 04, 2009 1:57 am

Post 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
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Post 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.
Attachments
PlantCapac.mdl
(3.71 KiB) Downloaded 857 times
tbs14
Junior Member
Posts: 9
Joined: Wed Nov 04, 2009 1:57 am

Post by tbs14 »

TQVM:) I will give it a try.
Post Reply