# ArgMin over intervals and discrete sets

I was playing with ArgMin but I'm not sure how to use it for constrained optimization.

For example,

ArgMin[x^2, x]


returns 0 as expected, but,

ArgMin[x^2, x ∈ Interval[{1, 2}]]


gives the error

ArgMin::objfs: The objective function {Subscript[x, 1]^2} should be scalar-valued.

I know it works using,

ArgMin[{x^2, x <= 2, x >= 1}, x]


but what's the point of intervals if you can't use them as sets/domains? Even more puzzling, it seems that it does not handle finite sets,

P = {-2, -1, 1, 2};
ArgMin[x, x ∈ P]


gives the error

ArgMin::ivar: x ∈ {-2, -1, 1, 2} is not a valid variable.

Anyone has an idea why ArgMin does not seem to handle those simple cases?

• As already noted, a list of numbers is not a valid domain that can be fed to Element[]. Nevertheless, try this: With[{P = {-2, -1, 1, 2}}, ArgMin[{x, AnyTrue[P, EqualTo[x]]}, x]]. Dec 2 '19 at 21:18

Clear["Global*"]

ArgMin[x^2, x ∈ Interval[{1, 2}]]

(* ArgMin::objfs: The objective function {Subscript[x, 1]^2} should be scalar-valued.

ArgMin[x^2, x ∈ Interval[{1, 2}]] *)


The subscript in the error message indicates that it was expecting a vector. Use

ArgMin[x^2, {x} ∈ Interval[{1, 2}]]

(* 1 *)


For the second example,

P = {-2, -1, 1, 2};

RegionQ[P]

(* False *)


P is not a region. Define a region

reg = ImplicitRegion[Or @@ Thread[var == P], var];


Then

ArgMin[x, {x} ∈ reg]

(* -2 *)

• Nice all this works! I get the set {x} instead of x, but could you explain a little the definition of a region you wrote? This seemed very esoteric to me, especially to just use a set as a region, it should be more straightforward, shouldn't it? Dec 1 '19 at 21:38
• Read the documentation for ImplicitRegion Dec 1 '19 at 21:53
• Sure, also the documentation of Thread and @@. I understand the construction now, but shouldn't there be a more straightforward way than using an implicit region with writing out explicitly var==-2 || var==-1... ? For example, I feel this should have worked but it does not: reg = ImplicitRegion[MemberQ[P, var], var] Dec 1 '19 at 22:04
• @OlivierMassicot - Issues on how it should work you'll have to take up with Wolfram Dec 1 '19 at 22:11
• It does not work because ImplicitRegion[MemberQ[P, var], var] evaluates to EmptyRegion since MemberQ[{-2, -1, 1, 2}, var] evaluates to False`, i.e., it cannot have a symbolic value. The logical expressions can return symbolic expressions. Dec 1 '19 at 22:58