Partly relaxing binary variables

95 views
Skip to first unread message

Tomasz Gorecki

unread,
Jul 15, 2021, 1:52:52 PM7/15/21
to Pyomo Forum

Hello,

I have a simpler question and then a more complex one that is related
First, is it possible to relax a particular (possibly indexed) binary variable and solve the corresponding problem. I know I can rebuild the problem from scratch, but I would find it convenient to not have to do that.

I am actually formulating multi-stage problem, and I therefore use as Index for almost all my variables the Set

RangeSet(0, N-1)

What I really want to do (more complex)
Some of the decision variables (say u and v) are binary and indexed by the time. I have a bunch of time-indexed constraints.  I'd like to relax the tail of this variable, meaning keep binary decision for the first K stages and use a continuous relaxation for the last N-K stages. I am looking for an elegant way to do this. 

I suppose I could define two sets [0,K-1] and [K, N-1] and try to define indexed variables and constraints on those two sets (u_head, u_tail, v_head, v_tail) and define two indexed constraints for each constraints I previously had. I already find this cumbersome. Where it would get really ugly is that I also have constraints that relate consecutive stages (rate constraints for example), which would then require that I mix u_head and u_tail for some specific indices...

If there was a way to just do everything in one go, it'd be more elegant. If I could somehow have u=[u_head,u_tail] and define constraints on this it would much easier.

Any suggestions is welcome, keeping in mind I have complex code so I need to do everything in a "generic" way !

thanks in advance

Siirola, John D

unread,
Jul 15, 2021, 2:11:46 PM7/15/21
to pyomo...@googlegroups.com

The short answer is “yes”: all you have to do is change the relevant variable domains.  The one catch is that you want to make sure that you maintain the variable bounds (Variables can get their domains from two sources: the bounds explicitly set by the user and the variable’s domain).  The general paradigm that should work for your use case is:

 

                # given a variable m.x

                tmp = m.x.bounds

                m.x.domain = Reals

                m.x.setlb(tmp[0])

                m.x.setub(tmp[1])

 

The loop to do some / all of the VarData in an Indexed variable is relatively straightforward (but, because of the “bounds issue”, you will want to do it one VarData at a time)

 

John

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/2b028cab-4384-48a9-abf5-724970330ddfn%40googlegroups.com.

Tomasz Gorecki

unread,
Jul 16, 2021, 4:14:43 AM7/16/21
to Pyomo Forum
Okay I will try that. Thanks for the quick reply
Reply all
Reply to author
Forward
0 new messages