Unit commitment & binary variable problem

Hi folks,

I met one problem when I run my unit commitment code. From the result
report, we can find that some generators are not on, but it’s so
strange that I find all binary variables u(g,t) remained 1. This does
not make sense since we know that in this case some binary variables
should be 0.

So, I’m wondering if some one can help me out of this problem. I will
appreciate it very much for your warm help.

I post the codes below. Please feel free to contact me.

Thank you in advance.

John

\

  • Test
    Sets
    t hourly time period /13/
    g number of generator /1
    3/
    head /low, upp,
    c,su/;
    Scalar BC average cost of biogas in dollars per liter /
    0.1/;
    Parameters

PL(t) hourly load demand in kW
/1 30
2 110
3 70/

Table Gen(g, head) generator sets data
Low Upp C su
1 0 24 10 10
2 0 25 8 20
3 10 45 5 30;

Variables
P(g,t) generator output in time t in kW
u(g,t) unit status ON or OFF
Tf total cost of biogas consumption
Pbatt(t) battery hourly state of charge in kW
v(g,t) start up variable;

Binary variable u;
P.up(g,t) = Gen(g,“upp”);
P.lo(g,t) = Gen(g,“low”);
Pbatt.lo(t) = 0;
Pbatt.up(t) = 50;
v.up(g,t) = 1;
v.lo(g,t) = 0;

Equations

TBC total hourly biogas consumption cost
GenLow(g,t) generator output lower bound
GenUpp(g,t) generator output upper bound
SU(g,t) generatot start up equation
SysCon(t) system energy balance constraint;

TBC… Tf =e= sum((g,t), BC*Gen(g,“c”)*P(g,t)
+v(g,t)*Gen(g,“su”));

GenLow(g,t)… P.lo(g,t) =e= Gen(g,“low”)*u(g,t);

GenUpp(g,t)… P.up(g,t) =e= Gen(g,“upp”)*u(g,t);

SU(g,t)… v(g,t) =g= u(g,t)-u(g,t-1);

SysCon(t)… sum(g, P(g,t))-PL(t)+Pbatt(t) =e= 0;

model MOO /all/;

solve MOO using mip minimizing Tf;

\

Hi John

I see at least two problems in your code:

First, in your formulation, the upper and lower bounds on generator
outputs imply that the binary variables MUST be one in order for the
model to be feasible.
Indeed, P.up and P.lo must be understood as parameters, not as
variables : the solver cannot alter their value. Hence, the
constraints
GenLow(g,t) … P.lo(g,t) =e= Gen(g,“low”)*u(g,t);
GenUpp(g,t) … P.up(g,t) =e= Gen(g,“upp”)*u(g,t);
for generator 1 are “transmitted” to the solver as:
GenLow(“1”,t) … 0 =e= 0 * u(“1”,t) ;
GenUpp(“1”,t) … 24 =e= 24 * u(“1”,t);
which, obviously, can only be satisfied with u=1.

You should write your constraints as:
GenLow(g,t) … P(g,t) =g= Gen(g,“low”)*u(g,t);
GenUpp(g,t) … P(g,t) =l= Gen(g,“upp”)*u(g,t);
in order to fix this first problem.

Second, the interest of having binary variables here is to be able to
model the startup costs.
But this will have no impact is the minimum technical output is zero
(as for generators 1 and 2).
Nothing will prevent the model from keeping binary variables to 1,
while setting the production level at zero, and hence incurring no
startup costs at all.
You can only “force” startup costs (and binary dispatch) if the
minimum output level is strictly positive.


Hope this helps,
cheers
dax




On 20 juin, 23:31, John wrote:

Hi folks,

I met one problem when I run my unit commitment code. From the result
report, we can find that some generators are not on, but it’s so
strange that I find all binary variables u(g,t) remained 1. This does
not make sense since we know that in this case some binary variables
should be 0.

So, I’m wondering if some one can help me out of this problem. I will
appreciate it very much for your warm help.

I post the codes below. Please feel free to contact me.

Thank you in advance.

John

  • Test
    Sets
    t hourly time period /13/
    g number of generator /1
    3/
    head /low, upp,
    c,su/;
    Scalar BC average cost of biogas in dollars per liter /
    0.1/;
    Parameters

       PL(t)     hourly load demand in kW
       /1        30
        2        110
        3        70/
    

    Table Gen(g, head) generator sets data
    Low Upp C su
    1 0 24 10 10
    2 0 25 8 20
    3 10 45 5 30;

    Variables
    P(g,t) generator output in time t in kW
    u(g,t) unit status ON or OFF
    Tf total cost of biogas consumption
    Pbatt(t) battery hourly state of charge in kW
    v(g,t) start up variable;

    Binary variable u;
    P.up(g,t) = Gen(g,“upp”);
    P.lo(g,t) = Gen(g,“low”);
    Pbatt.lo(t) = 0;
    Pbatt.up(t) = 50;
    v.up(g,t) = 1;
    v.lo(g,t) = 0;

    Equations

       TBC                   total hourly biogas consumption cost
       GenLow(g,t)      generator output lower bound
       GenUpp(g,t)      generator output upper bound
       SU(g,t)               generatot start up equation
       SysCon(t)          system energy balance constraint;
    
       TBC.. Tf =e= sum((g,t), BC*Gen(g,"c")*P(g,t)
    

+v(g,t)*Gen(g,“su”));

     GenLow(g,t).. P.lo(g,t) =e= Gen(g,"low")*u(g,t);

     GenUpp(g,t).. P.up(g,t) =e= Gen(g,"upp")*u(g,t);

     SU(g,t).. v(g,t) =g= u(g,t)-u(g,t-1);

     SysCon(t).. sum(g, P(g,t))-PL(t)+Pbatt(t) =e= 0;

model MOO /all/;

solve MOO using mip minimizing Tf;

\

Hi Dax,

Thank you very much for your immediate warm help. Your suggestions
indeed helped me solve my problem.

I’m just new to GAMS so any help at the very beginning will inspire me
a lot. I deeply appreciate your help.

I hope we could communicate via this platform for discussion about
problems we meet.

Your suggestions are very professional.

Hope you have a good day.

Best regards,

John

On Jun 22, 12:27 am, Dax wrote:

Hi John

I see at least two problems in your code:

First, in your formulation, the upper and lower bounds on generator
outputs imply that the binary variables MUST be one in order for the
model to be feasible.
Indeed, P.up and P.lo must be understood as parameters, not as
variables : the solver cannot alter their value. Hence, the
constraints
GenLow(g,t) … P.lo(g,t) =e= Gen(g,“low”)*u(g,t);
GenUpp(g,t) … P.up(g,t) =e= Gen(g,“upp”)*u(g,t);
for generator 1 are “transmitted” to the solver as:
GenLow(“1”,t) … 0 =e= 0 * u(“1”,t) ;
GenUpp(“1”,t) … 24 =e= 24 * u(“1”,t);
which, obviously, can only be satisfied with u=1.

You should write your constraints as:
GenLow(g,t) … P(g,t) =g= Gen(g,“low”)*u(g,t);
GenUpp(g,t) … P(g,t) =l= Gen(g,“upp”)*u(g,t);
in order to fix this first problem.

Second, the interest of having binary variables here is to be able to
model the startup costs.
But this will have no impact is the minimum technical output is zero
(as for generators 1 and 2).
Nothing will prevent the model from keeping binary variables to 1,
while setting the production level at zero, and hence incurring no
startup costs at all.
You can only “force” startup costs (and binary dispatch) if the
minimum output level is strictly positive.

Hope this helps,
cheers
dax

On 20 juin, 23:31, John wrote:

Hi folks,

I met one problem when I run my unit commitment code. From the result
report, we can find that some generators are not on, but it’s so
strange that I find all binary variables u(g,t) remained 1. This does
not make sense since we know that in this case some binary variables
should be 0.

So, I’m wondering if some one can help me out of this problem. I will
appreciate it very much for your warm help.

I post the codes below. Please feel free to contact me.

Thank you in advance.

John

  • Test
    Sets
    t hourly time period /13/
    g number of generator /1
    3/
    head /low, upp,
    c,su/;
    Scalar BC average cost of biogas in dollars per liter /
    0.1/;
    Parameters
     PL(t)     hourly load demand in kW
     /1        30
      2        110
      3        70/

Table Gen(g, head) generator sets data
Low Upp C su
1 0 24 10 10
2 0 25 8 20
3 10 45 5 30;

Variables
P(g,t) generator output in time t in kW
u(g,t) unit status ON or OFF
Tf total cost of biogas consumption
Pbatt(t) battery hourly state of charge in kW
v(g,t) start up variable;

Binary variable u;
P.up(g,t) = Gen(g,“upp”);
P.lo(g,t) = Gen(g,“low”);
Pbatt.lo(t) = 0;
Pbatt.up(t) = 50;
v.up(g,t) = 1;
v.lo(g,t) = 0;

Equations

     TBC                   total hourly biogas consumption cost
     GenLow(g,t)      generator output lower bound
     GenUpp(g,t)      generator output upper bound
     SU(g,t)               generatot start up equation
     SysCon(t)          system energy balance constraint;
     TBC.. Tf =e= sum((g,t), BC*Gen(g,"c")*P(g,t)

+v(g,t)*Gen(g,“su”));

     GenLow(g,t).. P.lo(g,t) =e= Gen(g,"low")*u(g,t);
     GenUpp(g,t).. P.up(g,t) =e= Gen(g,"upp")*u(g,t);
     SU(g,t).. v(g,t) =g= u(g,t)-u(g,t-1);
     SysCon(t).. sum(g, P(g,t))-PL(t)+Pbatt(t) =e= 0;

model MOO /all/;

solve MOO using mip minimizing Tf;- Hide quoted text -

  • Show quoted text -

    \