hello

I have this situation in GAMS:

Sets

i / 1*8761 /

j / discharge/ ;

Scalar

nt / 0.5 /

ng / 0.35 /

FIT / 3.1683 /

E / 140000 /

Rp / 26000 /

Ypua / 6 /;

Variable

sysben

Renergy

**Q(i,j)**

IR

Rfood

IR.lo =100;

IR.up =1000;

Equation

energy

food

income;

energy … Renergy =e= E * nt * ng * FIT ;

food … **Rfood =e= (sum(j, Q(i,j))/8761) * IR * Rp * Ypua ;**

income … sysben =e= Renergy + Rfood ;

I can’t define my Q(i,j)

The Q(i,j) has the data using excel

I searched,but I did not find solution. How can I fix it? and Can you fix it?

Hello,

(sum(j, Q(i,j))/8761) * IR * Rp * Ypua ;

the right term of food… (constraint) is a function of i, since you sum all over j.

However, the left term is Rfood which is just a variable.

Thus, I think you have to define Rfood → Rfood(i) and change the code like below:

See the << sign.

Sets

i / 1*8761 /

j / discharge/ ;

Scalar

nt / 0.5 /

ng / 0.35 /

FIT / 3.1683 /

E / 140000 /

Rp / 26000 /

Ypua / 6 /;

Variable

sysben(i) <<

Renergy

Q(i,j)

IR

Rfood

IR.lo =100;

IR.up =1000;

Equation

energy

food(i) <<

income(i); <<

energy … Renergy =e= E * nt * ng * FIT ;

food(i) … Rfood(i) =e= (sum(j, Q(i,j))/8761) * IR * Rp * Ypua ; <<

income(i) … sysben(i) =e= Renergy + Rfood(i) ; <<

Hope this work.

Best,

Thank you for your suggestion

there is success

But all my content is like this

…

Sets

i / 1*8761 /

j / discharge/ ;

Scalar

nt / 0.5 /

ng / 0.35 /

FIT / 3.1683 /

E / 140000 /

Rp / 26000 /

Ypua / 6 /;

Variable

sysben(i)

Renergy

Q(i,j)

IR

Rfood(i) ;

IR.lo =100;

IR.up =1000;

Equation

energy

food(i)

income(i);

energy … Renergy =e= E * nt * ng * FIT ;

food(i) … Rfood(i) =e= (sum(j, Q(i,j))/8761) * IR * Rp * Ypua ;

income(i) … sysben(i) =e= Renergy + Rfood(i) ;

Model practise

/all /;

*=== Import from Excel using GDX utilities

*=== First unload to GDX file (occurs during compilation phase)

$call gdxxrw.exe waterdata.xlsx par=Level rng=sheet!A1:B8762

*=== Now import data from GDX

Parameter Level(i,j);

$gdxin waterdata.gdx

$load Level

$gdxin

*=== Fix variables to values from Excel file

Q.FX(i,j) = Level(i,j);

display Level, Q.L;

solve practise using nlp maximizing sysben ;

display

sysben.L,

Renergy.L,

Q.l,

Rfood.L ,

IR.L ;

…

It will show

Error 148(Dimension different - The symbol is referenced with more/less

indices as declared)

I would like to know how to modify this to make it work properly?