How to let fminsearch only search over integers?
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tom Gerard
le 28 Avr 2016
Réponse apportée : Walter Roberson
le 28 Avr 2016
c = cvpartition(200,'KFold',10);
minfn = @(z)kfoldLoss(fitcsvm(cdata,grp,'CVPartition',c,...
'KernelFunction','rbf','BoxConstraint',exp(z(2)),...
'KernelScale',exp(z(1))));
opts = optimset('TolX',5e-4,'TolFun',5e-4);
[searchmin fval] = fminsearch(minfn,randn(2,1),opts)
The minimization is over two parameters.
Now I would like to minimize a third parameter, but this parameter can only take positive integer values, i.e. 1,2,3,...
How can I tell fminsearch to only consider positive integers?
Second, if my third parameter gets initialized to 10 but it actual best value is 100, does fminsearch converge fast in such cases?
1 commentaire
Torsten
le 28 Avr 2016
fminsearch can not handle constraints that a certain variable to be optimized is an integer. Choose a reasonable range for this parameter (say 1,2,3,4,...,100), run fmincon with this parameter set to 1,2,3,4,5... 100 (thus 100 times) and choose the case out of the 100 results where "minfn" is minimal.
Best wishes
Torsten.
Réponse acceptée
Walter Roberson
le 28 Avr 2016
fminsearch does not handle constraints of any kind.
You can use floor(abs()) of the parameter in your calculation.
fminsearch is not necessarily going to converge quickly for any particular parameter. A lot depends upon how "bumpy" the function is (because of local minima) and how "flat" the function is (very flat functions can take a lot of time to converge because the step might need to be very large in that parameter, and yet might need to be very small in some other parameter.)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!