ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 28 Sep 2015 13:20:24 -0500Binary variable in mixed integer linear programhttps://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/Hi asksage!
I'm using the `MixedIntegerLinearProgram` class to model a mixed integer linear program. I am using binary variables created e.g. by `x = mip.new_variable(binary=True, name="x")`. Now, I am using this variable e.g. by `x[0]` or `x[3,2]`. When I create a constraint using sums over binary variables, this sum is in the integers, as it should be. However, I am wondering if there is another way to easily add such variables together over `GF(2)` such that e.g. `x[0] + x[0]` disappears from the equation?
I ask because my model is too complicated to write by hand, so I am using some auxiliary methods to construct constraints and variables, etc.
I hope you can help me out!Mon, 28 Sep 2015 01:58:51 -0500https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/Answer by Nathann for <p>Hi asksage!</p>
<p>I'm using the <code>MixedIntegerLinearProgram</code> class to model a mixed integer linear program. I am using binary variables created e.g. by <code>x = mip.new_variable(binary=True, name="x")</code>. Now, I am using this variable e.g. by <code>x[0]</code> or <code>x[3,2]</code>. When I create a constraint using sums over binary variables, this sum is in the integers, as it should be. However, I am wondering if there is another way to easily add such variables together over <code>GF(2)</code> such that e.g. <code>x[0] + x[0]</code> disappears from the equation?</p>
<p>I ask because my model is too complicated to write by hand, so I am using some auxiliary methods to construct constraints and variables, etc.</p>
<p>I hope you can help me out!</p>
https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?answer=29628#post-id-29628No sorry, I do not think that any of the solvers we use support that.
Did you think of modelling your problem as a SAT problem instead? Could it help? Obviously it may not be possible depending on what you want to solve, but it may also be easier with this other formalism. Mon, 28 Sep 2015 02:18:03 -0500https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?answer=29628#post-id-29628Comment by Nathann for <p>No sorry, I do not think that any of the solvers we use support that.</p>
<p>Did you think of modelling your problem as a SAT problem instead? Could it help? Obviously it may not be possible depending on what you want to solve, but it may also be easier with this other formalism. </p>
https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29642#post-id-29642https://groups.google.com/forum/#!forum/sage-supportMon, 28 Sep 2015 13:20:24 -0500https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29642#post-id-29642Comment by Nathann for <p>No sorry, I do not think that any of the solvers we use support that.</p>
<p>Did you think of modelling your problem as a SAT problem instead? Could it help? Obviously it may not be possible depending on what you want to solve, but it may also be easier with this other formalism. </p>
https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29641#post-id-29641I do not know, but you should ask on sage-support. Other will know better than I, and they may not read this thread.Mon, 28 Sep 2015 13:20:06 -0500https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29641#post-id-29641Comment by mmlauridsen for <p>No sorry, I do not think that any of the solvers we use support that.</p>
<p>Did you think of modelling your problem as a SAT problem instead? Could it help? Obviously it may not be possible depending on what you want to solve, but it may also be easier with this other formalism. </p>
https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29629#post-id-29629Hi Nathann, thanks for your quick reply. That is unfortunately. Alternatively, if only I could find a way that I can make a list of binary symbolic variables x[0] , ..., x[n-1] that I can work with over GF(2), this would give me something to go from. While this is somewhat unrelated, would you know how to accomplish this?Mon, 28 Sep 2015 02:34:05 -0500https://ask.sagemath.org/question/29626/binary-variable-in-mixed-integer-linear-program/?comment=29629#post-id-29629