Find values of x that minimize f(x) = –x1x2x3,starting at the point x = [10;10;10],subject to the constraints:
0 ≤ x1 +2x2 + 2x3 ≤72.
- Write a file that returns a scalar value f ofthe objective function evaluated at x:
function f = myfun(x)f = -x(1) * x(2) * x(3); - Rewrite the constraints as both less than or equalto a constant,
–x1–2x2–2x3 ≤0
x1 + 2x2 +2x3≤ 72 - Since both constraints are linear, formulate themas the matrix inequality A·x ≤ b,where
A = [-1 -2 -2; ... 1 2 2];b = [0;72]; - Supply a starting point and invoke an optimizationroutine:
x0 = [10;10;10]; % Starting guess at the solution[x,fval] = fmincon(@myfun,x0,A,b);