Random Function and Subscript

Use this forum to post Vensim related questions.
Post Reply
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Random Function and Subscript

Post by husnafezaahmad »

Hello there,

It has been a while i've been here. Hope all is good, especially in this pandemic.

Anyway, i wolud like to ask regarding on this one issue that i got upon completing my model.

I have a variable that i have assigned to a subscript. This subscript contains 10 elements. Let me put it this way;

variable name : Generator A
subscript : Units Gen A
subscript elements : Unit 1 - Unit 10

Screen Shot 2021-01-31 at 00.26.38.png
Screen Shot 2021-01-31 at 00.26.38.png (20.33 KiB) Viewed 4067 times


What i want is, i want Generator A to generate at random any value ranged in Total Demand. By that, i mean each elements in Generator A will be having a random values according to the range set in Total Demand. So the output will looks like this:


Generator A
[Unit 1] 10000
[Unit 2] 12790
[Unit 3] 0
................ and so on.


I'm so looking forward to any solution that u guys can give me. Thanks in advance.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Random Function and Subscript

Post by Administrator »

Is this what you mean?

Code: Select all

TOTAL DEMAND[UNIT 1] = 10000
TOTAL DEMAND[UNIT 2] = 12790
TOTAL DEMAND[UNIT 3] = 0

GENERATOR A[unit] = RANDOM UNIFORM (0, TOTAL DEMAND[UNIT], NOISE SEED)
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
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

That looks like what i'm looking for.
Thanks so much, Admin. I'll try to do it, and hope it works well with my model.

Thanks once again :)
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

Hi there,

I think i couldn't use that solution. Here is the bigger picture of what i'm doing.
Screen Shot 2021-02-01 at 00.30.24.png
Screen Shot 2021-02-01 at 00.30.24.png (34.58 KiB) Viewed 4048 times
This is what i have in Total Generation
Screen Shot 2021-02-01 at 00.32.09.png
Screen Shot 2021-02-01 at 00.32.09.png (27.1 KiB) Viewed 4048 times

So, the idea is to have that Total Generation, let say

at Year 0 = 38,657, i want to distribute that value to all 4 technologies i have there (coal generation, gas generation, hydro generation, RE generation), randomly.

But, each technology has different subscript elements.
Coal Generation is assigned to 14 elements.
Gas Generation assigned to 25 elements.
Hydro Generation assigned to 19 elements.
RE generation is assigned to 40 elements.


Eg;

_____________________________________________________
Year 0
Total Generation = 38,657 MW

Coal Generation [Coal 1] = 1200 MW
Coal Generation [Coal 2] = 1300 MW
.
.
.
Coal Generation[Coal 14] = 2400 MW
Gas Generation[Gas 1] = 9000 MW
Gas Generation[Gas 2] = 3500 MW
.
.
.
.
Gas Generation{Gas 25] = 1200 MW
Hydro Generation[Hydro 1] = 650 MW
.
.
.
Hydro Generation[Hydro 19] = 300 MW
RE Generation[RE 1] = 150 MW
.
.
.
RE Generation[RE 40] = 100 MW
_____________________________________________________


I hope i have made a better explaination and hope that u can help me.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Random Function and Subscript

Post by Administrator »

It would help if you upload the model (it will save us guessing about what you are doing).

How do you split total generation into the four types? And then how is the total coal generation split between the 14 coal elements?

We do have some allocation functions, but it would be easier if you upload the model so we can see exactly what you are trying to do.

One other thing. I'd expect "Total generation" to be the sum of all the other generation types, not split between them.
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
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Random Function and Subscript

Post by tomfid »

It sounds like you want total generation to be a fixed number, allocated among all the sources with some random noise in the individual sizes or shares. Normalization is a common way to do this:

prelim unit size[x] = 500 + RANDOM UNIFORM(-100,100,0)
prelim total size = SUM(prelim unit size[x!])
normalized unit size[x] = prelim unit size[x]*(desired total size/prelim total size)
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

Administrator wrote: Mon Feb 01, 2021 7:25 am It would help if you upload the model (it will save us guessing about what you are doing).

How do you split total generation into the four types? And then how is the total coal generation split between the 14 coal elements?

We do have some allocation functions, but it would be easier if you upload the model so we can see exactly what you are trying to do.

One other thing. I'd expect "Total generation" to be the sum of all the other generation types, not split between them.

Yes, the "Total Generation" comes from an expression. Attached is the model that i'm working with. My issue is at "Maximum Demand" view.
Attachments
1.0(a) NPV to calculate Gen Mix.mdl
(31.7 KiB) Downloaded 141 times
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

tomfid wrote: Mon Feb 01, 2021 1:37 pm It sounds like you want total generation to be a fixed number, allocated among all the sources with some random noise in the individual sizes or shares. Normalization is a common way to do this:

prelim unit size[x] = 500 + RANDOM UNIFORM(-100,100,0)
prelim total size = SUM(prelim unit size[x!])
normalized unit size[x] = prelim unit size[x]*(desired total size/prelim total size)
Sorry Tom, but i couldn't get the picture of your solution there.
Do u mind to explain it further.
Once again, sorry to hassle you.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Random Function and Subscript

Post by tomfid »

I'm still not sure what the goal is. Can you restate?

So far it sounds like:
- each unit generates a random amount
- the sum of generation across all the units = demand

I could imagine other constraints, for example that some units are bigger than others.
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

tomfid wrote: Mon Feb 01, 2021 11:04 pm I'm still not sure what the goal is. Can you restate?

So far it sounds like:
- each unit generates a random amount
- the sum of generation across all the units = demand

I could imagine other constraints, for example that some units are bigger than others.
It's okay if the some units having bigger value than the others.

So how can i do that?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Random Function and Subscript

Post by tomfid »

random coal hydro.mdl
(3.4 KiB) Downloaded 186 times
husnafezaahmad
Senior Member
Posts: 80
Joined: Sun Feb 02, 2020 5:10 am
Vensim version: DSS

Re: Random Function and Subscript

Post by husnafezaahmad »

Thank u so much, Tom!

I hope it works well with me.
But whatever it is, thank u so much for spending your precious time to help me :)
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Random Function and Subscript

Post by tomfid »

You're welcome, & good luck.
Post Reply