# Optimisation: minimise function while maximising a design variable

3 views (last 30 days)
hugo c on 26 Sep 2021
Edited: Matt J on 29 Sep 2021
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 CommentsShowHide 1 older comment
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?

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 CommentsShowHide 1 older comment
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.

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.