how to set proper constraints for Nonlinear Optimisation solvers
1 view (last 30 days)
Show older comments
Hi,
I am looking forward to minimize the following function:
function f = alfafun2(alfa)
global S H LR;
f=10.^(log(S)-log(1/LR*alfa)+H*alfa);
end
the provided Data has the following dimensions:
S<474x59>
H<474x474>
LR <scalar>
alfa<474x59>
so far i use the lsqnonlin in the optimtool, because it seems it is the only one that can handle a matrix based Output. The problem that arises is, that somehow the solver seems to ignore the constraints that i give for the boundaries and the gradient. For example, the boundaries are set to [1e-7 1e-3] but the output is in [1e-4 1e-2] and the gradient, that was set to a maximum pertuberation of 1e-5 is completely ignored. Does anybody have an idea for setting the constraints more convenienlty or perhaps propose another solver that is more suitable for this problem?
Thanks for the help!
0 Comments
Accepted Answer
Alan Weiss
on 3 Aug 2012
Thank you for the question. Currently, this topic is not documented properly. I will work on it.
In fact, if you pass matrix arguments to solvers such as fmincon, the solver accepts these arguments, and internally converts the arguments to vector versions via the colon operator (so alfa gets changed internally to alfa(:)). At the end of the optimization, the solution is reshaped back to the original dimensions.
This internal conversion can cause some unexpected behavior. For example, a linear inequality constraint such as
A*alfa <= b
requires the matrix A to have as many columns as alfa(:) has rows.
For your case, you might not be aware that lower bounds must be given for each component separately. So if you want a lower bound of 1e-7 on each component, you need to give lb as 1e-7*ones(size(alfa0)).
Your question on bounding the gradient does not make sense to me. There is no built-in facility in Optimization Toolbox to bound the gradient of the objective function. Are you looking for a solution where the gradient is in a region? If so, you need to calculate separately where alfa must be in order to give the gradient that bound, and you need to put in that restriction as a constraint on alfa.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
3 Comments
Alan Weiss
on 6 Aug 2012
The objective function must evaluate to a scalar. fmincon solves minimization problems, and assumes that when you input a vector or matrix to your objective function, the result is a real scalar value.
Alan Weiss
MATLAB mathematical toolbox documentation
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!