# What is wrong with my ArgMin expression?

I need to find the minimum of a function $mj_1^2+mj_2^2$ where my $mj$ are constrained.

I wrote this expression:

ArgMin[
{mj1^2 + mj2^2, mj1 == (M1 + 1)*p1, p1 ∈ Integers,
mj2 == (M2 + 1)*p2, p2 ∈ Integers,
MemberQ[{mj1, mj2} , couplesm]}, {mj1, mj2}]


Indeed, my mj's must be multiples of Mj + 1, and they musn't be part of a list given by couplesm.

When I evaluate it, I get the following message;

ArgMin::infeas: There are no values of {mj1, mj2} for which the constraints False are satisfied and the objective function mj1^2 + mj2^2 is real valued.

I even added p1 and p2 to the variables of minimization, but it still didn't work.

How can I find the minimum of: $mj_1^2+mj_2^2$, where $mj_i$ is a multiple of $M_i+1$ and where the pairs $(mj_1,mj_2)$ can't be inside of the list couplesm?

### Edit

I wrote the following and the code still doesn't work.

couplesm = {{0, 0}}


{{0, 0}}

ArgMin[
{mj1^2 + mj2^2,
IntegerQ[mj1/(M1 + 1)], IntegerQ[mj2/(M1 + 1)],
mj1 ∈ Integers, mj2 ∈ Integers,
Sequence @@ Table[{mj1, mj2} != couplesm[[i]], {i, 1, Length[couplesm]}]},
{mj1, mj2}]


ArgMin::infeas: There are no values of {mj1,mj2} for which the constraints False are satisfied and the objective function mj1^2+mj2^2 is real valued.

{Indeterminate, Indeterminate}

• What are the definitions of p1, p2 and couples? – m_goldberg Jun 28 '17 at 17:35
• $p_1$ and $p_2$ are just positive integers. They are here to symbolise the fact that I want $mji$ to be a multiple of $Mi+1$. couplesm is a list of couples like this : {{a,b},{c,d},{e,f}}. I don't want (mj1,mj2) to be an element of this list. To take an example you can take couplesm={{0,0}} to start with – StarBucK Jun 28 '17 at 17:38
• The arguments of ArgMin are evaluated first. Evaluate MemberQ[{mj1, mj2} , couplesm] to see where the False in the error message comes from. – Michael E2 Jun 28 '17 at 17:38
• I don't understand. I can't evaluate it first as mj1 and mj2 are changed by Argmin. They don't have a value outside of this function ? – StarBucK Jun 28 '17 at 17:39
• "I can't evaluate it first as mj1 and mj2 are changed by Argmin." -- Actually, Mathematica evaluates it first, before passing the result False to ArgMin[]. Therefore ArgMin[] never has a chance to change mj1 or mj2 or see whether the pair of values are a member of couplesm. You need a function like memQ[x1_Integer, x2_Integer] := MemberQ[{x1, x2}, couplesm]., and then replace MemberQ[{mj1, mj2} , couplesm] with memQ[{mj1, mj2}]. – Michael E2 Jun 28 '17 at 19:34

Maybe this?

couplesm = {{0, 0}, {3, 0}};

Block[{M1 = 2, mj1 = (M1 + 1) m1, mj2 = (M1 + 1) m2},
ArgMin[
{mj1^2 + mj2^2,
AllTrue[couplesm, {mj1, mj2} != # &]},
{m1, m2},
Integers]
]
(*  {-1, 0}  *)


In general, avoid functions that end in Q, such as IntegerQ and MemberQ, in constructing equations and constraints for solvers. Almost all of them evaluate to True or False immediately, that is, before values are substituted for the variables. If, for some reason, you need to use one, you need to construct a wrapper function that will evaluate the Q function only after the variables have been given numeric values (using ?NumericQ).

• Are the m1 ∈ Integers and m2 ∈ Integers necessary when you're setting the domain to be Integers? – aardvark2012 Jun 29 '17 at 6:08
• @aardvark2012 No, I meant to get rid of them. Thanks for pointing it out. – Michael E2 Jun 29 '17 at 14:03