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?
Element[]
. Nevertheless, try this:With[{P = {-2, -1, 1, 2}}, ArgMin[{x, AnyTrue[P, EqualTo[x]]}, x]]
. $\endgroup$