How to write this small optimisation problem?
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Alan Weiss
2013-6-20
编辑:Alan Weiss
2013-6-20
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
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!