# How to use fmincon for multivariable optimisation of a cost function with different levels of sensitivity to different variables?

6 views (last 30 days)
Samuele Gould on 12 Jul 2021
Commented: Samuele Gould on 14 Jul 2021
Dear all,
In short I would like to know if it is possible to define the DiffMinChange option in fmincon so that in a multivariable optimisation different DiffMinChange options are used for the different variables? And if so how this should be implemented.
A more complete explanation:
I am simulating a 6 degree of freedom system, where each degree of freedom is characterised by a single variable. These variables determine the motion in each degree of freedom. I am trying to optimise the variables so that a predicted motion in each direction matches the measure motion in the corrisponding direction. To do this I have been using fmincon to optimise the variables by minimising the cost function, which I have defines as the sum of the squared error (measured-predicted motion).
Until now I have been optimising a single variable at a time and changing the DiffMinChange option to help guide the step size fmincon used to find the optimal solution. Doing this I was able to drastically reduce the number of iterations. I am now trying to optimise all 6 variables simultaneously, however the cost function is highly sensitive to certain variables while much less sensitive to others. Therefore I am trying to implement different DiffMinChange values for different variables so that I can encourage fmincon to take larger steps for the variables which do not affect the cost function rapidly and small steps for the variables which have a large effect on the cost function. Is it possible to specify different DiffMinChange values for the different variables or would I need to consider a different optimisation function?
I have tried to assign a 1x6 matrix to DiffMinChange (in the same way you assign a matrix of variables to be optimised) but this does not work as DiffMinChange requires a real non-negative scalar.
Thanks,
Samuele

Alan Weiss on 13 Jul 2021
Usually you should not use DiffMinChange. The more recent version of the option is FiniteDifferenceStepSize. That option accepts a vector value. You might also consider changing the FiniteDifferenceType option to 'central' to obtain more accurate estimates.
You probably know that these options only affect the solver in terms of estimating the gradient by finite differences. They do not directly control the step sizes that fmincon takes.
Finally, I hope that you are using optimoptions to set your options. If not, please change your code.
Alan Weiss
MATLAB mathematical toolbox documentation
Samuele Gould on 14 Jul 2021
Thanks for the helpful suggestions. This has started to give the variation in the step sizes I was looking for. I suspect now with some tunning of the vector I assign to the FiniteDifferenceStepSize I'll be able to get suitable gradient estimates for each variable.

R2020b

### Community Treasure Hunt

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

Start Hunting!