Page 1 of 1

Random Function and Subscript

Posted: Sat Jan 30, 2021 4:32 pm
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 4117 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.

Re: Random Function and Subscript

Posted: Sun Jan 31, 2021 7:48 am
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)

Re: Random Function and Subscript

Posted: Sun Jan 31, 2021 4:03 pm
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 :)

Re: Random Function and Subscript

Posted: Sun Jan 31, 2021 4:53 pm
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 4098 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 4098 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.

Re: Random Function and Subscript

Posted: Mon Feb 01, 2021 7:25 am
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.

Re: Random Function and Subscript

Posted: Mon Feb 01, 2021 1:37 pm
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)

Re: Random Function and Subscript

Posted: Mon Feb 01, 2021 5:42 pm
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.

Re: Random Function and Subscript

Posted: Mon Feb 01, 2021 5:45 pm
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.

Re: Random Function and Subscript

Posted: Mon Feb 01, 2021 11:04 pm
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.

Re: Random Function and Subscript

Posted: Tue Feb 02, 2021 1:52 pm
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?

Re: Random Function and Subscript

Posted: Tue Feb 02, 2021 5:44 pm
by tomfid
random coal hydro.mdl
(3.4 KiB) Downloaded 189 times

Re: Random Function and Subscript

Posted: Wed Feb 03, 2021 4:34 am
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 :)

Re: Random Function and Subscript

Posted: Wed Feb 03, 2021 6:22 pm
by tomfid
You're welcome, & good luck.