# Simple maximization problem with binary variables

I tried to solve an integer-linear optimization problem but failed. I reduced the failed example to the following:

FindMaximum[{x + y, Element[x , {0, 1}], Element[y , {0, 1}]}, {x, y}]


I got the following error:

FindMaximum::elemc: Unable to resolve the domain or region membership condition x\[Element]{0,1}.


I get the same error when using NMaximize instead of FindMaximum.

What am I doing wrong?

• does NMaximize[{x + y, 0<=x<=1,0<=y<=1}, {x, y}, Integers] work? – kglr May 25 '18 at 11:17
• also FindMaximum[{x + y,x<=1,y<=1, Element[{x,y},Integers]}, {x, y}] – kglr May 25 '18 at 11:21
• @kglr yes, it works! Thanks. – Erel Segal-Halevi May 25 '18 at 11:22
• Voting to close because I think the "elemc" message and the FindMaximum function page hint why OP's command does not work. Although, I might be wrong... – Anton Antonov May 25 '18 at 13:05
• In Mathematica, and unlike in mathematics, {1,2} is not a set, but a list. – AccidentalFourierTransform May 25 '18 at 13:44

NMaximize[{x + y, 0<=x<=1,0<=y<=1}, {x, y}, Integers] (* or *)