Cumulative Sums in GAMS

Reply-to: gamsworld@googlegroups.com

Dear GAMS users,

I am new to GAMS, so please accept my apology in advance to post crazy
questions.
I need a ‘‘Cumulative Sum’’ in GAMS, but it seems that it is not that
simple!
For example, I have 4 quantities that are properly defined: q1, q2,
q3, q4.
I need to define 4 constraints, like the following ones:

const1 … q1 =l= a1 ;
const2 … q1+q2 =l= a2 ;
const3 … q1+q2+q3 =l= a3 ;
const4 … q1+q2+q3+q4 =l= a4 ;

when I am using such equations, I encounter with the following error:

$150 Symbolic equations redefined.

For more information I have included my program as well:

Thanks in advance!
All the best,
Ebrahim

*-----------------------------------------------------------------------------------------------------------------------------
Scalar L ‘max no. of re-transmissions’ /4/ ;
Scalar N ‘no. of info bits’ /1200/ ;
Scalar P_max ‘Power budget’ /1/ ;
Scalar lambda ‘mean of exponential distribution’ /7.5/ ;

Set ell ‘index of each transmission in HARQ process’
/ 1 * 4 / ;

parameter zeta(ell) ‘CSI at each round based on an exponential
r.v.’ ;
zeta(ell) = -lambda * log(uniform(0.001,1));
Parameter M ‘no. of channel uses per packet’ ;
M = N / L ;
Parameter
epsilon(ell) the probability of successful transmission at
each round
/ 1 0.900
2 0.950
3 0.990
4 0.999 / ;

Parameter c(ell) ‘objective function linear weights’ ;
c(ell) = epsilon(ell) ;
Variables
P(ell) ‘power allocated to current retransmission’
t(ell) ‘slack variables’
f0 ‘weighted power’
q(ell)
uL(ell) ;

Positive Variable P ;
Positive Variable t ;

Equations
objective ‘Define objective function’
rateConstraint(ell) ‘Service guarantee for i’
powerConstraint(ell) ‘Power upper limit’
Eq(ell)
upperLimit ;

Eq(ell) … q(ell) =e= exp(lambda / P(ell)) * Gamma(0) *
Gammareg(lambda/P(ell),0) ;
upperLimit(ell) … uL(ell) =e= t(ell) * (1-epsilon(ell)) ;

objective … f0 =e= sum(ell , (1-epsilon(ell)) * P(ell)) ;
powerConstraint(ell) … P(ell) =l= P_max ;
rateConstraint(‘1’) … L - (1/log(2)) * (q(‘1’)) =l= uL(‘1’) ;
rateConstraint(‘2’) … L - (1/log(2)) * (q(‘1’) + q(‘2’)) =l=
uL(‘2’) ;
rateConstraint(‘3’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’)) =l=
uL(‘3’) ;
rateConstraint(‘4’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’) +
q(‘4’)) =l= uL(‘4’) ;

Model powerAllocation /all/ ;
Solve powerAllocation using dnlp minimizing f0 ;
*Display P.l ;

*-----------------------------------------------------------------------------------------------------------------------------

\

Hello Ebrahim,

You can deal with the error you mentioned adding alias and ord functions as:

alias (ell, el); *** after defining the set ell
rateConstraint(ell) … L - (1/log(2)) * (sum(el$[ord(el) wrote:

Dear GAMS users,

I am new to GAMS, so please accept my apology in advance to post crazy
questions.
I need a ‘‘Cumulative Sum’’ in GAMS, but it seems that it is not that
simple!
For example, I have 4 quantities that are properly defined: q1, q2,
q3, q4.
I need to define 4 constraints, like the following ones:

const1 … q1 =l= a1 ;
const2 … q1+q2 =l= a2 ;
const3 … q1+q2+q3 =l= a3 ;
const4 … q1+q2+q3+q4 =l= a4 ;

when I am using such equations, I encounter with the following error:

$150 Symbolic equations redefined.

For more information I have included my program as well:

Thanks in advance!
All the best,
Ebrahim

*-----------------------------------------------------------------------------------------------------------------------------
Scalar L ‘max no. of re-transmissions’ /4/ ;
Scalar N ‘no. of info bits’ /1200/ ;
Scalar P_max ‘Power budget’ /1/ ;
Scalar lambda ‘mean of exponential distribution’ /7.5/ ;

Set ell ‘index of each transmission in HARQ process’
/ 1 * 4 / ;

parameter zeta(ell) ‘CSI at each round based on an exponential
r.v.’ ;
zeta(ell) = -lambda * log(uniform(0.001,1));
Parameter M ‘no. of channel uses per packet’ ;
M = N / L ;
Parameter
epsilon(ell) the probability of successful transmission at
each round
/ 1 0.900
2 0.950
3 0.990
4 0.999 / ;

Parameter c(ell) ‘objective function linear weights’ ;
c(ell) = epsilon(ell) ;
Variables
P(ell) ‘power allocated to current retransmission’
t(ell) ‘slack variables’
f0 ‘weighted power’
q(ell)
uL(ell) ;

Positive Variable P ;
Positive Variable t ;

Equations
objective ‘Define objective function’
rateConstraint(ell) ‘Service guarantee for i’
powerConstraint(ell) ‘Power upper limit’
Eq(ell)
upperLimit ;

Eq(ell) … q(ell) =e= exp(lambda / P(ell)) * Gamma(0) *
Gammareg(lambda/P(ell),0) ;
upperLimit(ell) … uL(ell) =e= t(ell) * (1-epsilon(ell)) ;

objective … f0 =e= sum(ell , (1-epsilon(ell)) * P(ell)) ;
powerConstraint(ell) … P(ell) =l= P_max ;
rateConstraint(‘1’) … L - (1/log(2)) * (q(‘1’)) =l= uL(‘1’) ;
rateConstraint(‘2’) … L - (1/log(2)) * (q(‘1’) + q(‘2’)) =l=
uL(‘2’) ;
rateConstraint(‘3’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’)) =l=
uL(‘3’) ;
rateConstraint(‘4’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’) +
q(‘4’)) =l= uL(‘4’) ;

Model powerAllocation /all/ ;
Solve powerAllocation using dnlp minimizing f0 ;
*Display P.l ;

*-----------------------------------------------------------------------------------------------------------------------------


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Muhajir,

Thanks a million!
It works now!


On Feb 16, 12:17 pm, Muhajir wrote:

Hello Ebrahim,

You can deal with the error you mentioned adding alias and ord functions as:

alias (ell, el); *** after defining the set ell
rateConstraint(ell) … L - (1/log(2)) * (sum(el$[ord(el) > =l= uL(ell) ; *** this constraint will do all the constraints(‘1’) to (‘4’)

Hope this helps!

On Thu, Feb 16, 2012 at 11:46 AM, Ebrahim wrote:

Dear GAMS users,

I am new to GAMS, so please accept my apology in advance to post crazy
questions.
I need a ‘‘Cumulative Sum’’ in GAMS, but it seems that it is not that
simple!
For example, I have 4 quantities that are properly defined: q1, q2,
q3, q4.
I need to define 4 constraints, like the following ones:

const1 … q1 =l= a1 ;
const2 … q1+q2 =l= a2 ;
const3 … q1+q2+q3 =l= a3 ;
const4 … q1+q2+q3+q4 =l= a4 ;

when I am using such equations, I encounter with the following error:

$150 Symbolic equations redefined.

For more information I have included my program as well:

Thanks in advance!
All the best,
Ebrahim

*--------------------------------------------------------------------------­---------------------------------------------------
Scalar L ‘max no. of re-transmissions’ /4/ ;
Scalar N ‘no. of info bits’ /1200/ ;
Scalar P_max ‘Power budget’ /1/ ;
Scalar lambda ‘mean of exponential distribution’ /7.5/ ;

Set ell ‘index of each transmission in HARQ process’
/ 1 * 4 / ;

parameter zeta(ell) ‘CSI at each round based on an exponential
r.v.’ ;
zeta(ell) = -lambda * log(uniform(0.001,1));
Parameter M ‘no. of channel uses per packet’ ;
M = N / L ;
Parameter
epsilon(ell) the probability of successful transmission at
each round
/ 1 0.900
2 0.950
3 0.990
4 0.999 / ;

Parameter c(ell) ‘objective function linear weights’ ;
c(ell) = epsilon(ell) ;
Variables
P(ell) ‘power allocated to current retransmission’
t(ell) ‘slack variables’
f0 ‘weighted power’
q(ell)
uL(ell) ;

Positive Variable P ;
Positive Variable t ;

Equations
objective ‘Define objective function’
rateConstraint(ell) ‘Service guarantee for i’
powerConstraint(ell) ‘Power upper limit’
Eq(ell)
upperLimit ;

Eq(ell) … q(ell) =e= exp(lambda / P(ell)) * Gamma(0) *
Gammareg(lambda/P(ell),0) ;
upperLimit(ell) … uL(ell) =e= t(ell) * (1-epsilon(ell)) ;

objective … f0 =e= sum(ell , (1-epsilon(ell)) * P(ell)) ;
powerConstraint(ell) … P(ell) =l= P_max ;
rateConstraint(‘1’) … L - (1/log(2)) * (q(‘1’)) =l= uL(‘1’) ;
rateConstraint(‘2’) … L - (1/log(2)) * (q(‘1’) + q(‘2’)) =l=
uL(‘2’) ;
rateConstraint(‘3’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’)) =l=
uL(‘3’) ;
rateConstraint(‘4’) … L - (1/log(2)) * (q(‘1’) + q(‘2’) + q(‘3’) +
q(‘4’)) =l= uL(‘4’) ;

Model powerAllocation /all/ ;
Solve powerAllocation using dnlp minimizing f0 ;
*Display P.l ;

*--------------------------------------------------------------------------­---------------------------------------------------


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.- Hide quoted text -

  • Show quoted text -

    \