AnsweredAssumed Answered

Unable to add constraint

Question asked by Pallav Mishra on Jun 16, 2013
Latest reply on Aug 6, 2014 by Susanne.Heip

My problem is this:

 

I have to minimize the total cost of generating power from 4 generators operating in 6 periods. The min and max power generated by each generator sets the lower and upper bounds. I have been given the marginal cost of running the generators as well as hot and cold start costs. Also, for each period, I have been given the total power that needs to be produced. The optimization equation is to minimize the total cost across all periods. Here's my code. The code is not throwing errors but its not calculating the power generated from each of the four generators. Would really appreciate if someone could help me find the logical bug in my code:

 

model economicdispatch
uses "mmxprs"; !gain access to the Xpress-Optimizer solver

declarations
GENCOUNT = 1..4
PERIOD = 1..6
PMAX: array(GENCOUNT) of integer
PMIN: array(GENCOUNT) of integer
MCOST: array(GENCOUNT) of real
HSTART: array(GENCOUNT) of integer
CSTART: array(GENCOUNT) of integer
INIT: array(GENCOUNT) of integer
LOAD: array (PERIOD) of integer
COST: array(PERIOD, GENCOUNT) of mpvar
POWER: array(GENCOUNT) of integer
end-declarations
PMAX :: [100,150,200,250]
PMIN :: [25,50,60,0]
MCOST :: [15.45, 17.3467, 26.9, 36.9]
HSTART :: [50, 60, 100, 90]
CSTART :: [500, 700, 800, 900]
INIT :: [2, -3, -5, -7]
LOAD :: [250,200,390,250,130,300]
forall(i in PERIOD) do
forall(j in GENCOUNT) do
if(INIT(j)>0)then
COST(i,j) = HSTART(j)+MCOST(j)*POWER(j)
else
COST(i,j)= CSTART(j)+MCOST(j)*POWER(j)
end-if
writeln("The power generated by Unit ",j," in Period ",i," is ", POWER(j))
end-do
end-do
forall(j in GENCOUNT) do
LOWER(j):= POWER(j)> PMIN(j)
UPPER(j):= POWER(j)<=PMAX(j)
end-do
forall(i in PERIOD)sum(j in GENCOUNT)POWER(j) < LOAD(i)
TOTALCOST := sum(i in PERIOD, j in GENCOUNT)COST(i,j)
minimize(TOTALCOST)
writeln("The minimum cost is ", getobjval)

end-model

Outcomes