Optimisation: minimise function while maximising a design variable
9 次查看(过去 30 天)
显示 更早的评论
I am trying to perform an optimisation of a function that contains 2 design variables, R and L. The aim of the optimisation is to minimise the function, however I know that there are more than one combination of the design variables that will give this minimum. What I want is the design variables for the minimum solution but where R is at its maximum possible.
I have tried using fmincon with limited success, however the initial conditions determine which of the design variable combinations are given as the optimal solution. I have also looked into the global optimisation toolbox, which is helpful for finding the global minimum but I can't work out how to use for my problem where there are multiple of the same value minimum.
Is there a way of doing this built into MATLAB? The only other thing I was thinking to try is to do multiple fmincon optimisations at different initial conditions and output the one with highest R. However this would take a lot longer to process and maybe wouldnt be guaranteed to find the maximum R?
Any help/ suggestions would be much appreciated
2 个评论
Max
2021-9-26
编辑:Max
2021-9-26
You could try to substract R to the objective function:
O'-->O(R,L)-R.
It's often a good idea to do multiple starting points. fmincon is a gradient based local method so it might not converge to the most optimal solution if the landscape is not favourable.
It might be usefull to think also what is a succesful result (ie O<a, R>b)...
You can save time by running the code in parallel.
回答(2 个)
Alan Weiss
2021-9-26
Perhaps you can change the optimization in a nearly unnoticeable way that would bias solutions to have large values of R, like this (you can change 1e-8 to a value that suits you):
function y = myfun(x)
R = x(1);
L = x(2);
% Include y (objective) calculation here.
% Then:
y = y - 1e-8*R; % Bias to large value of R
end
Alan Weiss
MATLAB mathematical toolbox documentation
2 个评论
Matt J
2021-9-29
编辑:Matt J
2021-9-29
By subtracting a multiple of R, you make x with small values of R incur higher cost. As you increase the multiplicative weight, priority will be placed on maximizing R and less priority on minimizing L. You want to choose the weight to achieve some acceptable compromise.
Matt J
2021-9-29
编辑:Matt J
2021-9-29
Another approach would be to first minimize L with fmincon.
[x0,L0]=fmincon(@(x) L(x),x00,____) %Problem (A)
Then, maximize R subject to a nonlinear equality constraint L(x)=L0,
x=fmincon( @(x) -R(x),x0,____, @(x)nonlcon(x,L0)) %Problem(B)
function [c,ceq]=nonlcon(x,L0)
c=[];
ceq=L(x)-L0;
end
Note that this will only do anything meaningful if Problem (A) has a continuuum of solutions in the neighborhood of x0. You cannot use fmincon to maximize R(x) reliably over a discontiguous set of feasible solutions x.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!