Coding problem in pattern search optimization algorithm
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
i tried to use pattern search algorithm to find the minimum of a rather simple function of two variables. While running an error occures saying: "Operands to the || and && operators must be convertible to logical scalar values."
I was able to track the error down to line 94 in psAugConverged.m file, where it says "if ~isempty(infMessage) && strmatch('optimlib:optimfcnchk',infMessage)", which is causing the error. Sadly I cannot change this, bacause I do not have permission to change those files.
Is this a bug, can this be changed, and is there a way I can use the algorithm?
Best regards
Thomas
0 commentaires
Réponses (2)
John D'Errico
le 7 Fév 2020
Your objective function needs to return a SCALAR value for any set of inputs. That is, you cannot minimize two (or more) independent objectives at once.
So this is NOT a problem of needing to change the code for patternsearch. If you got that error, it suggests that you have made a mistake. Your function returns more than one result for a set of inputs.
A common mistake that new users make is they want to use a tool like this as a regression tool, perhaps fitting a curve or line to a set of data. You cannot do that, at least not directly. What you need to do in that case is to compute ONE objective, thus reducing hte problem to a scalar result. This is why tools operate on the sum of squares of residuals.
0 commentaires
Thomas Ewald
le 7 Fév 2020
3 commentaires
Orcan Maktal
le 3 Juin 2021
Modifié(e) : Orcan Maktal
le 3 Juin 2021
Could you solve your problem? Because I have the same issue, it iterates and fails with that error. I am optimizing an ODE, for such cases, it is normal that I have NaN.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!