convolution equation writing

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

convolution equation writing

Post by Archiver »


Hello everyone,

I have a problem with indices k and m, where m is alias of k.
and these are varying as k = 1 to 96; m= 1 to 95.

now the equation that i have to write is-

p(k) = sum(m, pd(m)*x(k-m+1));

here pd(k) is input power, and x(k) is binary variable, and p(k) is positive variable.
But i am facing problem in writing this equation.
The code is-

set k /1*96/

alias(m,k);
set lim(m) /1*95/;

parameter pd(k);


variables
z;
positive variable
p(k);
binary variable
x(k);

equations
cost
power(k);

power(k).. p(k)=e= sum(m$lim(m),pd(m)*x(k-m+1));







The parameters price and power are imported from excel sheet.
but i am not able to write this equation as GAMS considers indices as character and any operation between two indices or like '-m' wont work.

PLEASE help me through this equation
if i simplify this equation, then i get

p(k)= pd(1)*x(k) + pd(2)*x(k-1) + ....................+ pd(k)*x(1);

but i am getting problem with variable x as indices is varying in reverse order. So i am not able to write it in this way also.

Please help, it is urgent.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: convolution equation writing

Post by Archiver »


Hi,

The following does the trick:

set k /1*96/
alias(m,k);
set lim(m) /1*95/;
parameter pd(k);
variables
z;
positive variable
p(k);
binary variable
x(k);
equations
cost
power(k);
power(k).. p(k)=e= sum(m$lim(m),pd(m)*x(k-(ord(m)-1)));
cost.. z=e=0;
model mym /all/;
option limrow=100;
pd(k) = ord(k);
solve mym min z us mip;

k and m are not numbers to you can do arithmetic with them. But you can use the lag/lead functionality in GAMS (http://www.gams.com/help/topic/gams.doc ... dOperators). You can confirm that the equation is generated correctly by looking at the Equation Listing section in the listing file:

---- power =E=
power(1).. p(1) - x(1) =E= 0 ; (LHS = 0)
power(2).. p(2) - 2*x(1) - x(2) =E= 0 ; (LHS = 0)
power(3).. p(3) - 3*x(1) - 2*x(2) - x(3) =E= 0 ; (LHS = 0)
power(4).. p(4) - 4*x(1) - 3*x(2) - 2*x(3) - x(4) =E= 0 ; (LHS = 0)
power(5).. p(5) - 5*x(1) - 4*x(2) - 3*x(3) - 2*x(4) - x(5) =E= 0 ; (LHS = 0)
...

Hope this helps,
Michael

On Wednesday, March 2, 2016 at 2:37:09 AM UTC-5, jaishree choudhary wrote:

Hello everyone,

I have a problem with indices k and m, where m is alias of k.
and these are varying as k = 1 to 96; m= 1 to 95.

now the equation that i have to write is-

p(k) = sum(m, pd(m)*x(k-m+1));

here pd(k) is input power, and x(k) is binary variable, and p(k) is positive variable.
But i am facing problem in writing this equation.
The code is-

set k /1*96/

alias(m,k);
set lim(m) /1*95/;

parameter pd(k);


variables
z;
positive variable
p(k);
binary variable
x(k);

equations
cost
power(k);

power(k).. p(k)=e= sum(m$lim(m),pd(m)*x(k-m+1));







The parameters price and power are imported from excel sheet.
but i am not able to write this equation as GAMS considers indices as character and any operation between two indices or like '-m' wont work.

PLEASE help me through this equation
if i simplify this equation, then i get

p(k)= pd(1)*x(k) + pd(2)*x(k-1) + ....................+ pd(k)*x(1);

but i am getting problem with variable x as indices is varying in reverse order. So i am not able to write it in this way also.

Please help, it is urgent.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Post Reply