# List of constraints in Minimize

I'm seeking a technique to automate a list of constraints in Mathematica. A sample piece of code is given below; it's designed to take a 3D cube [0, 1]^3, sample 5 points uniformly randomly from this cube, scale + translate them to [-1, 1]^3, and use them in 5 constraints in the optimization problem "Minimize". I've hardcoded the constraints for the moment:

dimuncertset = 3; numsamples = 5;
sampinposcube =
RandomVariate[UniformDistribution[dimuncertset], numsamples];
sampincube =
2*sampinposcube + ConstantArray[-1, {numsamples, dimuncertset}];
res = FindMinimum[{t,
t >= x Norm[sampincube[[1]], Infinity] -
Norm[sampincube[[1]], Infinity]^2 &&
t >= x Norm[sampincube[[2]], Infinity] -
Norm[sampincube[[2]], Infinity]^2 &&
t >= x Norm[sampincube[[3]], Infinity] -
Norm[sampincube[[3]], Infinity]^2 &&
t >= x Norm[sampincube[[4]], Infinity] -
Norm[sampincube[[4]], Infinity]^2 &&
t >= x Norm[sampincube[[5]], Infinity] -
Norm[sampincube[[5]], Infinity]^2, - 10 <= t <= 10,
0 <= x <= 1}, {t, x}]

Any pointer will be appreciated.

• Why not just Minimize the function from which the samples were obtained? In any case, please explain your problem more clearly. May 16 '21 at 17:39
• @bbgodfrey: Sorry for being unclear. The problem goes by the name scenario approach' to robust optimization. When \min_{x\in X} \max_{y\in Y} f(x, y) proves to be too difficult due to the inner max, one samples Y finitely many times independently according to some distribution, and solves \min_{x\in X} \max_{i=1, \ldots, N} f(x, y_i). The idea is that if N is large enough, then the two problems have values that are 'close' in some probabilistic sense. May 17 '21 at 15:09
• @bbgodfrey: (cont'd) The original problem can be translated into a semi-infinite program that looks like \min{c(x) | g(x, y) \le 0 for all y in Y}. (Note that this is not an exact translation.) Again, if Y is large (uncountable, e.g., an interval), then one samples finitely many elements from Y and solves \min{c(x) | g(x, y_i) \le 0 for all i = 1, \ldots, N}, which is a "scenario" program. The idea is if N is large enough, the values of the two programs are 'close' in some probabilistic sense. May 17 '21 at 15:12
• (cont'd): I was trying to automate the sampling of the constraints. Bob Hanlon's response was spot on, it solved the problem. May 17 '21 at 15:13

\$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)

Clear["Global*"]

SeedRandom[1234];

dimuncertset = 3;
numsamples = 5;
sampinposcube =
RandomVariate[UniformDistribution[dimuncertset], numsamples];
sampincube =
2*sampinposcube + ConstantArray[-1, {numsamples, dimuncertset}];

Define a helper function

f[t_, x_] = t >= x Norm[#, Infinity] - Norm[#, Infinity]^2 &;

Then for any number of samples

res = FindMinimum[{t, Sequence @@ (f[t, x] /@ sampincube),
-10 <= t <= 10, 0 <= x <= 1}, {t, x}]

(* {-0.259388, {t -> -0.259388, x -> 0.}} *)
• Thank you so much! May 17 '21 at 4:27