Element by Element Multplication in GAMS

Problems with syntax of GAMS
Post Reply
ManT
User
User
Posts: 12
Joined: 5 years ago

Element by Element Multplication in GAMS

Post by ManT »

Hi,

I need help with the correct syntax for element by element multiplication using GAMS. My shortcode is attached.
GamsAssitance.gms
(1.5 KiB) Downloaded 297 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Element by Element Multplication in GAMS

Post by Renger »

Hi
Works fine for me, when I run your code after correcting some non-related errors. But perhaps you are looking for something else.

I attach the corrected version.
Cheers
Renger
GamsAssitance.gms
(1.57 KiB) Downloaded 278 times
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
ManT
User
User
Posts: 12
Joined: 5 years ago

Re: Element by Element Multplication in GAMS

Post by ManT »

GamsAssitance_Fixed.gms
(1.31 KiB) Downloaded 212 times
Renger wrote: 4 years ago Hi
Works fine for me, when I run your code after correcting some non-related errors. But perhaps you are looking for something else.

I attach the corrected version.
Cheers
RengerGamsAssitance.gms
Many thanks for your quick response. I want to apologize for not explaining my problem correctly. I would want to do the following.
Essentially, I would like to scale each hourly load by the factor in tscaling(ss)
So
Pd.t1 = ss1*Pd.
Pd.t2 =ss2*Pd
Pd.t3=ss3*Pd
Pd.t24=ss24*Pd

so I get a new Table BD(d,b,t,*) but original values scaled by tscaling(ss)

I attach my initial data set.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Element by Element Multplication in GAMS

Post by Renger »

Hi
As both sets have the same number of elements (24), you can use a loop using the order of the elements.
For example, if you want to multiply Pd(t) with tscaling(ss), this would look like this:

Code: Select all

loop(t, 
 loop(ss$(ord(t) = ord(ss), 
        Pd(t) = Pd(t) * tscaling(ss);
   );
);

I hope this helps
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: Element by Element Multplication in GAMS

Post by dirkse »

Why don't you just index the parameter tscaling() by t instead of ss? I.e. make it

parameter tscaling(t) /
t1 0.826
blah blah
/;

The set ss is not really helping you.
Post Reply