Optimisation: minimise function while maximising a design variable

14 views (last 30 days)
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 Comments
Max
Max on 26 Sep 2021
Edited: Max on 26 Sep 2021
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.
hugo c
hugo c on 29 Sep 2021
Thats sounds great, I will give it a go with a few different starting points and see any changes. Could you just explain a bit more about the effect subtracting R from the objective function and how that would work?

Sign in to comment.

Answers (2)

Alan Weiss
Alan Weiss on 26 Sep 2021
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 Comments
hugo c
hugo c on 29 Sep 2021
Thanks alot Alan, as I have replied to the comment above, would you mind explaining a bit more about how subtracting the R from the objective function works? I dont quite understand how that would bias for a large R. I will give it a go anyway in the meantime and see how it goes!
Matt J
Matt J on 29 Sep 2021
Edited: Matt J on 29 Sep 2021
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.

Sign in to comment.


Matt J
Matt J on 29 Sep 2021
Edited: Matt J on 29 Sep 2021
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.

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!