Creating a constraint with multiple equal signs

365 views
Skip to first unread message

Cord Kaldemeyer

unread,
Dec 18, 2014, 11:39:35 AM12/18/14
to

I want to make sure that a variable has the same value on the the following 3 positions at a certain position of a set.


Mathematically, this could be desribed like this (better ideas are welcome):


model.turb_p_el[t] == model.turb_p_el[t + 1] == model.turb_p_el[t + 2] == model.turb_p_el[t + 3] for all t element of {0,4,8,12,...}


I have tried the following but always get an error (ERROR:coopr.pyomo:evaluating expression: No value for uninitialized NumericValue object turb_p_el[0] (expression: turb_p_el[0] == turb_p_el[1]) .....) since only one equation per rule seems to be accepted.


# Control Reserve: blocks of 4 hours

ctrl_res_block_start = list(np.arange(0, timesteps_max, 4))



def ctrl_res_block_constr_rule(model, t):


    if t in ctrl_res_block_start:


        return (model.turb_p_el[t]


                == model.turb_p_el[t + 1]


                == model.turb_p_el[t + 2]


                == model.turb_p_el[t + 3])


    else:


        return Constraint.Skip


model.ctrl_res_block_constr = Constraint(model.T,


                                         rule=ctrl_res_block_constr_rule)


A solution would be to create the rule multiple times with indices only comparing two variables which is quite a lot of effort..


Is there any smart way to realize this?


Thanks in advance

Cord

Siirola, John D

unread,
Dec 18, 2014, 2:22:34 PM12/18/14
to pyomo...@googlegroups.com

We do not support “chained” equality relationships like this.  Each equality relationship must be specified as a separate constraint (i.e., a == b, b == c, etc.).

 

def ctrl_res_block_constr_rule(model, t, i):

    if t in ctrl_res_block_start:

        return model.turb_p_el[t] ==  model.turb_p_el[t + i]

    else:

        return Constraint.Skip

 

model.ctrl_res_block_constr = Constraint(model.T, [1,2,3]

                                         rule=ctrl_res_block_constr_rule)

 

 

john

 

 

From: pyomo...@googlegroups.com [mailto:pyomo...@googlegroups.com] On Behalf Of Cord Kaldemeyer
Sent: Thursday, December 18, 2014 9:40 AM
To: pyomo...@googlegroups.com
Subject: [EXTERNAL] Creating a constraint with multiple equal signs

 

I want to make sure that a variable has the same value on the the following 3 positions at a certain position of a set.

 

Mathematically, this could be desribed like this (better ideas are welcome):

 

model.turb_p_el[t] == model.turb_p_el[t + 1] == model.turb_p_el[t + 2] == model.turb_p_el[t + 3] for all t element of {0,4,8,12,...}

 

I have tried the following but always get an error (ERROR:coopr.pyomo:evaluating expression: No value for uninitialized NumericValue object turb_p_el[0] (expression: turb_p_el[0] == turb_p_el[1]) .....) since only one equation per rule seems to be accepted.

 

# Control Reserve: blocks of 4 hours





p
, li { white-space: pre-wrap; }


ctrl_res_block_start = list(np.arange(0, timesteps_max, 4))



 



def ctrl_res_block_constr_rule(model, t):



    if t in ctrl_res_block_start:



        return (model.turb_p_el[t]



                == model.turb_p_el[t + 1]



                == model.turb_p_el[t + 2]



                == model.turb_p_el[t + 3])



    else:



        return Constraint.Skip



model.ctrl_res_block_constr = Constraint(model.T,



                                         rule=ctrl_res_block_constr_rule)

 

A solution would be to create the rule multiple times with indices only comparing two variables which is quite a lot of effort..

 

Is there any smart way to realize this?

 

Thanks in advance

Cord

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cord Kaldemeyer

unread,
Dec 21, 2014, 8:12:11 AM12/21/14
to pyomo...@googlegroups.com
I was hoping for another answer.. ;-) Thank you anyway!
...
Reply all
Reply to author
Forward
0 new messages