At 7:31am -0400 Wed, 01 Oct 2014, Zvonko Bregar wrote:
Hi everybody,
Does there exist an expression
That forces
An integer variable X \in { 1, 2, 3, ...}
To take the values only from even numbers
X \in {2, 4, 6, ...}
I'm a bit late to this party, but it seems to me you only need a single
second integer variable. That is, the definition of an even number is
one that is twice another integer.[1] In mathematical form:
even_number = 2 * any_integer
In mathematical optimization then, you can just use a second integer
variable and constraint:
X and Y are general integers
X = 2*Y
If you need it constrained further (e.g., greater than 0 as you
specified in your question), it's your choice how to do that. Any of
these would work to satisfy your question's example lower bound, and
more than one would be overkill/wasted computing time:
X >= 1
X >= 2
Y >= 1
I'd assume GLPK can handle this just fine.
Kevin
[1] Wolfram can expound much more eloquently than I:
http://mathworld.wolfram.com/EvenNumber.html
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk