# I have declared “set S” and “param b {S}”. How do I write an AMPL expression for the arg min of b[i] — that is, the s in S such that b[s] equals the minimum of b[i] over al

There’s no specific arg min operator in AMPL. However, proceeding directly from the definition, you can define the arg min explicitly by a set expression like

``````{s in S: b[s] = min {i in S} b[i]}
``````

This expression gives a subset of `S` , however, containing all of the members of `S` that achieve the minimum. To get just one member representing the arg min, you can define this to be an ordered set,

``````set b_argmin ordered := {s in S: b[s] = min {i in S} b[i]};
``````

Then `first(b_argmin)` is guaranteed to be one member of `S` that minimizes `b[i]` .

As an alternative, you can use AMPL’s `for` and `if` commands to write a script that loops over `S` to compute the arg min explicitly:

``````param bmin;
param imin symbolic in S;
let bmin := Infinity;
for {i in S} {
if b[i] < bmin then {
let bmin := b[i];
let imin := i; } }
``````

In general this is a slower alternative than defining `b_argmin` as above. It admits a greater variety of generalizations in complex cases, however.