Hi all!

I’m currently working on a model that use an excel file, with binary inputs for 8760 hours (1 year.) The file is structured so that in the interested column you have either a 1 or a 0. GAMS is reading correctly the file but the problem occurs later.

Practically I need to code this statement "**if x(t)=1 then g(t)=A, else g(t)=B** "

the why I used in GAMS is the following ( I wrote it just after the Equations description) :

if (pk(t)=e= 1,

cg(t)=36.367;

else

cg(t)=47.898;

);

However I got an error saying that an uncontrolled set is entered as a costant. (actually I got various errors but this is the first that appears and otehr mistakes are only related to this one because before using this statement everything was working).

Any Idea How?

The Full Code is:

*** SETS DEFINITION ***

Sets

*** PLANTS DEFINITION

i units /chp,pv,sto,grid/

CHP(i) /chp/

Grid(i) /grid/

Storage(i) /sto/

Power(i) /chp,grid/

*** TIME PERIODS

t time /t0001*t8760/

;

$call=xls2gms r=a1:b8760 i=PV.xls o=PV.inc

$call=xls2gms r=a1:b8760 i=PD.xls o=PD.inc

$call=xls2gms r=a1:b8760 i=HD.xls o=HD.inc

$call=xls2gms r=a1:b8760 i=Peak.xls o=Peak.inc

*** PARAMETERS DEFINITION ***

Parameters

*** Costs Parameters

a(i) Power Production Costs [Euro\MWh] /chp 25.028/

c(i) Start-up Costs [Euro] /chp 400/

*** Production Parameters

pmin(i) Minimum Power Production [MW] /chp 0.9588, grid 0/

pmax(i) Maximum Power Production [MW] /chp 4.794/

lmin(i) Minimum Level of Storage [MWh] /sto 0/

lmax(i) Maximum Level of Storage [MWh] /sto 350/

*** Other Parameters

delta(i) Heat-To-Power ratio /chp 3.979/

***CHECK THESE VALUES

char_eff(i) Charging Efficiency of the Storage /sto 0.96/

dis_eff(i) Discharging Efficiency of the Storage /sto 0.98/

st_eff(i) Storage Efficciency /sto 0.9566/

;

Scalar

f_up Ramp Up Rate /1/

f_down Ramp Down Rate /0.6/

;

Parameter

*** Solar Production ***

s(t) solar production [MWh]

/

$include PV.inc

/

;

*** Demand Parameters

Parameter pd(t) power demand (MWh)

/

$include PD.inc

/

;

Parameter hd(t) heat demand (MWh)

/

$include HD.inc

/

;

Parameter pk(t) Peak Variable [-]

/

$include peak.inc

/

;

*** VARIABLES DEFINITION ***

Free Variables

*** Objective Function Variable

z Total costs [Euro]

cg(t) Power Cost from Grid [Euro\MWh]

;

Positive Variables

*** Generation Variables

p(i,t) Power Generation Level [MWh]

q(i,t) Heat Generation Level [MWh]

q_ch(i,t) Storage Charging Level [MWh]

q_dis(i,t) Storage Discharging Level [MWh]

l(i,t) Storage Level [MWh]

***Start Up Variable

v(i,t) Start-Up [-]

x(i,t) Shut-Down [-]

;

Binary Variable

*** Online Status Variable

u(i,t) Online Status [-]

;

*** EQUATIONS DEFINITION ***

Equations

Costs Total Costs

MinGenPow(i,t) Minimum Power Generation Level When Online [MW]

MaxGenPow(i,t) Maximum Power Generation Level When Online [MW]

HeatToPow(i,t) Heat To Power Ratio

*MaxGenHeat(i,t) Maximum Heat Generation Level When Online [MW]

StartUp(i,t) Start-Up Status

ShutDown(i,t) Shut Down Status

RampUp(i,t) Ramp-Up Status

RampDown(i,t) Ramp-Down Status

BalancePow(t) Balance Power Demand

BalanceHeat(t) Balance Heat Demand

StorageLevel(i,t) Balance of Storage Level

MinStorageLevel(i,t) Minimum Level of the Storage

MaxStorageLevel(i,t) Maximum Level of the Storage

;

if (pk(t)=e= 1,

cg(t)=36.367;

else

cg(t)=47.898;

);

*** Total Cost Equation, Objective Function

Costs … z =e= sum(t,sum(i$(CHP(i)),a(i)*p(i,t)+c(i)*(v(i,t)+x(i,t)))

- sum(i$(Grid(i)),cg*p(i,t));

*** Power Generation Level Equations h +10000000*(dslackplus(t)+dslackminus(t))

MinGenPow(i,t)$Power(i) … p(i,t) =g= pmin(i)*u(i,t);

MaxGenPow(i,t)$CHP(i) … p(i,t) =l= pmax(i)*u(i,t);

*** Heat Generation Level Equations

HeatToPow(i,t)$(CHP(i)) … q(i,t) =e= delta(i)*p(i,t);

*** Start-Up and Ramp-Up Equations

StartUp(i,t)(CHP(i)) .. u(i,t)-u(i,t--1) =l= v(i,t);
ShutDown(i,t)(CHP(i)) … u(i,t)-u(i,t–1) =g= x(i,t);

RampUp(i,t)(CHP(i)) .. p(i,t)-p(i,t--1) =l= f_up*pmax(i);
RampDown(i,t)(CHP(i)) … p(i,t–1)-p(i,t) =l= f_down*pmax(i);

*** Demand Equations

BalancePow(t) … sum(i$(Power(i)),p(i,t)) =e= pd(t)-s(t);

BalanceHeat(t) … q(‘chp’,t)+q_dis(‘sto’,t)-q_ch(‘sto’,t) =e= hd(t);

*** Storage Equations

StorageLevel(i,t)(Storage(i)).. l(i,t) =e= st_eff(i)*l(i,t--1)+q_ch(i,t)*char_eff(i)-q_dis(i,t)/dis_eff(i);
MinStorageLevel(i,t)(Storage(i))… l(i,t) =g= lmin(i);

MaxStorageLevel(i,t)$(Storage(i))… l(i,t) =l= lmax(i);

*** END OF THE MODEL ***

*** SOLVE THE MODEL ***

Model uc /all/;

Solve uc using rmip minimizing z;

Display z.l, u.l, p.l, q.l,l.l,HD,PD,s, q_ch.l, q_dis.l;