I have a function $f(x,y,z)$ I want to find the minimum/maximum of the function with some constraints like
$$0 < x < C_1$$ $$0 < y+z <C_2$$
where $C_1$ and $C_2$ are some integer constants.
Right now the function that I have is $ax + by + cz\;$ ($a,$ $b$ and $c$ are constants). But is there a generic way to do this in Matlab.
You can use
linprog(help page has good examples):So
f = [a; b; c]lb = []ub = []Aeq = []beq = []We need to setup the constraints in a matrix format $A{\mathbf x} \le b -\epsilon$. Separate $0 < x < c$ into $-x < 0,$ and $x < c,$ etc. Subtract
epsto $-x < 0 -\epsilon,$ etc. So $$ \begin{pmatrix} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 1 & 1 \\ 0 & -1 & -1 \end{pmatrix} \begin{pmatrix} x \\ y \\ z \end{pmatrix} \le \begin{pmatrix} c_1 -\epsilon \\ 0 -\epsilon \\ c_2 -\epsilon \\ 0 -\epsilon \end{pmatrix} $$ Now, we can invoke:linprog.