help-glpk
[Top][All Lists]

## Re: [Help-glpk] Even integer numbers

 From: Kevin Hunter Kesling Subject: Re: [Help-glpk] Even integer numbers Date: Mon, 03 Nov 2014 22:31:23 -0500 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

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. 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


 Wolfram can expound much more eloquently than I: http://mathworld.wolfram.com/EvenNumber.html