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

I see several problems with this formulation:

1. 'POWER' need to be decision variables of type 'mpvar' as these are unknowns

for which you want to obtain solution values

2.The line

writeln("The power generated by Unit ",j," in Period ",i," is ", POWER(j))

is misplaced: you can only report on results after the call to optimization.

3. You will need addditional decision variables to represent the numbers of generators

starting up per time period and the total number of generators running per period.

Please take a look at the example file 'a6electr.mos' that comes with the Xpress distribution,

it shows how to implement a problem of this type.

You can also find this file in the online Xpress examples database:

http://examples.xpress.fico.com/example.pl#mosel_book