Clear Filters
Clear Filters

How to write this small optimisation problem?

2 views (last 30 days)
The rough sketch of the problem is:
find the maximum value of F(x,y,z)
s.t. Amin<=x<=Amax Bmin<=y<=Bmax Cmin<=z<=Cmax x,y,z belong to Real set
my approach was: I fixed z=z0. x, y are column vectors with different step sizes going from their minimum to maximum value. F is the matrix of all the different values of x,y. max(F(:)) gives me the max value. Good for two variables.
But when I have three varying variables x,y,z, I am confused how to approach it. I need to find the maximum value Fmax as well as the values of x,y,z, when F=Fmax. Trying this for a day. I do not know optimisation. Any help how to begin writing this code?

Accepted Answer

Alan Weiss
Alan Weiss on 20 Jun 2013
Edited: Alan Weiss on 20 Jun 2013
If you have Optimization Toolbox, use fmincon on -F(x,y,z) = -F(t), where t = [x,y,z]. If you just want to make a grid of points and look at the maximum on the grid:
xgrid = linspace(Amin,Amax); % gives 100 values, change if you like
ygrid = linspace(Bmin,Bmax);
zgrid = linspace(Cmin,Cmax);
% biggrid = ndgrid(xgrid,ygrid,zgrid); % for a vectorized F
% Fvals = F(biggrid); % this works is F is vectorized. Otherwise:
Fvals = zeros(100,100,100);
for x = 1:100
for y = 1:100
for z = 1:100
Fvals(x,y,z) = F(xgrid(x),ygrid(y),zgrid(z));
end
end
end
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!