Passing a cost at a discrete time to a variable

Use this forum to post Vensim related questions.
Post Reply
Phill
Senior Member
Posts: 156
Joined: Wed Jun 04, 2014 2:18 pm
Vensim version: DSS

Passing a cost at a discrete time to a variable

Post by Phill »

Hello,

I have a model (extract sketch attached) that includes a sequence for building new hotel properties. Once a hotel is built, the level OpenHotel, subscripted for the new properties, changes from a zero to a one. At that time, I want to pass a construction cost to a new variable, so that when OpenHotel=1, ConstructionCost=$10,000,000. My problem is that I'm passing this cost on every week after OpenHotel changes from 0 to 1, rather than only in the week that change occurs (because OpenHotel remains at 1 every week from that point on, indicating that the hotel is now open). How can I make that a one-off change, so that ConstructionCost receives $10,000,000 in the week construction is completed and zero in subsequent weeks?
Attachments
Hotel construction.mdl
(4.12 KiB) Downloaded 266 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing a cost at a discrete time to a variable

Post by tomfid »

Hotel construction 2.mdl
(5.97 KiB) Downloaded 279 times
Here are two general strategies - changes highlighted.

Option A is to charge the construction with the flow when it occurs. Option B is to detect changes in the stock, using DELAY FIXED to keep track of the previous value, and charge accordingly. I think A is the preferred approach here, because B could get fooled if there were other flows associated with the stock of completed hotels. However, B is sometimes useful in other circumstances.

I made two a few other changes: a units synonym for hotel=hotels, and replaced the check of Time=X with PULSE(X,TIME STEP). Checks for Time equal to an exact value can fail due to roundoff error, so PULSE is generally more robust.

Hope this helps.

Tom
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by LAUJJL »

Anotther option quite similar to Tom's. I made some changes too to the initial model that did not work.

Regards.

JJ
Attachments
Hotel%20construction[2].mdl
(6.46 KiB) Downloaded 256 times
Phill
Senior Member
Posts: 156
Joined: Wed Jun 04, 2014 2:18 pm
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by Phill »

Thank you both. I had thought of the PULSE variable, but wasn't sure, as it's use isn't very clear from the Vensim manual, but it worked very well. Excellent help, as usual.
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

Hello there,

I think i have the same problem like this.

Attached is my model. In my model, i have additional generation which is then will be divided into 4 different technologies (oil generation, hydro generation, and coal generation). I don't have any problem on this part. But once a technology is appointed with additional generation, the technology need to be divided into smaller variable. For example, hydro generation will be divided into 10 discrete variables with random value of generation (kW). Tried to use IF THEN ELSE, but couldn't solve my problem. Also tried to adapt the solution that Laujjl had suggested in previous model, but i came to the dead end.

Do u guys have any better solution for me?

Your help is much appreciated.
Attachments
additional gen.mdl
(17.94 KiB) Downloaded 203 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing a cost at a discrete time to a variable

Post by tomfid »

What is the purpose of this change? Is it so that you can have synthetic plants that are dispatched separately?

If so, you could build up your array of plants hierarchically, as:

hydro : (h1-h10)
coal : (c1-c10)
etc.
plant : hydro, coal, oil, gas

Then new hydro capacity for each of the 10 hydro subrange elements could be brought online individually.

However, this seems like a lot of work for little benefit if you don't have real plant data. A simpler option would be to use a lookup or the ALLOC functions to dispatch plants with some diversity in the grid price at which they come online.
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

tomfid wrote: Sat Jul 18, 2020 4:07 pm What is the purpose of this change? Is it so that you can have synthetic plants that are dispatched separately?

If so, you could build up your array of plants hierarchically, as:

hydro : (h1-h10)
coal : (c1-c10)
etc.
plant : hydro, coal, oil, gas
Hello Tom! Thanks for responding and so sorry for the late respond.

Yup, this change is much needed because i want to have plants that can dispatch separately.
tomfid wrote: Sat Jul 18, 2020 4:07 pm Then new hydro capacity for each of the 10 hydro subrange elements could be brought online individually.

However, this seems like a lot of work for little benefit if you don't have real plant data. A simpler option would be to use a lookup or the ALLOC functions to dispatch plants with some diversity in the grid price at which they come online.
i do have real plant data. The real data has been used to decide how much additional generation do we need in future. I tried to use ALLOC function, but i couldn't get the idea. Can u please help to guide me?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing a cost at a discrete time to a variable

Post by tomfid »

I can, but it'll probably be a few days because the SD conference is underway. Hopefully someone else can jump in first.
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

tomfid wrote: Tue Jul 21, 2020 2:15 pm I can, but it'll probably be a few days because the SD conference is underway. Hopefully someone else can jump in first.
If lets say no one come to my rescue, i really hope that u can help me Tom. It's okay, i can wait.
Thanks in advance, Tom. Have fun during your SD conference :)
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

Dear Tom,

I hope i still can get ideas from you.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing a cost at a discrete time to a variable

Post by tomfid »

I would try something like the following:
- grab the ALLOCATE AVAILABLE.mdl sample in the help system https://www.vensim.com/documentation/
- rename/reinterpret "total supply" as "electricity demand"
- replace the "region" subscript with your plant type subscript, e.g., the hierarchical version plant : hydro, coal, oil, gas
- set priority = -variable cost[plant]/reference cost
- rename shipments[plant] to "generation" to reflect that it will be the generation for each plant
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

tomfid wrote: Tue Jul 28, 2020 2:40 pm I would try something like the following:
- grab the ALLOCATE AVAILABLE.mdl sample in the help system https://www.vensim.com/documentation/
- rename/reinterpret "total supply" as "electricity demand"
- replace the "region" subscript with your plant type subscript, e.g., the hierarchical version plant : hydro, coal, oil, gas
- set priority = -variable cost[plant]/reference cost
- rename shipments[plant] to "generation" to reflect that it will be the generation for each plant
Dear Tom,

I didn't understand on the priority = -variable cost[plant]/reference cost part. What is that mean?
I'm so sorry to burden you.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Passing a cost at a discrete time to a variable

Post by tomfid »

In the example model, which is actually at https://www.vensim.com/documentation/fn ... iority.htm, the language for "supply" and "demand" needs to be changed, because "supply" in your context is total electricity demand, "demand" is generation capacity by [plant], and "shipments" is actual generation by [plant].

You want plants to be dispatched so that the lowest cost plants run first. Therefore priority[plant} should be a function that decreases as cost increases. The appropriate cost basis is the variable cost, i.e. fuel + emissions fees + operations & maintenance.
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Passing a cost at a discrete time to a variable

Post by husnafezaahmad »

Thank you so much, Tom. I've tried your suggestion and it works so well just like what i want :)

tomfid wrote: Wed Jul 29, 2020 9:17 pm In the example model, which is actually at https://www.vensim.com/documentation/fn ... iority.htm, the language for "supply" and "demand" needs to be changed, because "supply" in your context is total electricity demand, "demand" is generation capacity by [plant], and "shipments" is actual generation by [plant].

You want plants to be dispatched so that the lowest cost plants run first. Therefore priority[plant} should be a function that decreases as cost increases. The appropriate cost basis is the variable cost, i.e. fuel + emissions fees + operations & maintenance.
Post Reply