Timeline for NMinimize error: Nearest::neard:
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:55 | history | edited | CommunityBot |
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
|
|
May 14, 2015 at 14:54 | comment | added | Kurt | Thank you Michael E2!! Really helps! I did take a look at your linked tutorial and found many useful things. I got the NMinimize working now and playing around with the Methods. | |
May 12, 2015 at 20:08 | comment | added | Michael E2 |
If you're having trouble finding the minimum, you could consult the tutorial I linked in my last comment under the main question. Another method or increasing "MaxIterations" may help. Your graph looks ragged. You can monitor the process with Block[{Optimization`NMinimizeDump`dbPrint = Print}, NMinimize[…]] , but do it in its own notebook and be prepared for tons and tons of output. If you do it on f or g in my previous comment, look for "Entering KKT" to see where the derivative comes into play.
|
|
May 12, 2015 at 20:02 | comment | added | Michael E2 |
More of a hint than an explanation: First ClearAll[f, g]; f[x_?NumericQ] := x^2; g[x_] := x^2 . Then consider NMinimize[f[x], x] vs. NMinimize[g[x], x] . Now f[x] evaluates to f[x] - nothing happens because NumericQ[x] is False . This is the standard Mathematica evaluation and has nothing to with NMinimize . But f[2] yields 4 . OTOH, g[x] evaluates to the symbolic expression x^2 . Execute the the NMinimize commands and you get different answers, because NMinimize has to use a finite difference approximation for f'[x] . See the links in the linked Q above for more.
|
|
May 12, 2015 at 18:23 | vote | accept | Kurt | ||
May 12, 2015 at 18:21 | comment | added | Kurt |
Thank you @Michael E2, it works just as you say in the first part of your answer. I am still having trouble finding the minimum with actual values but thats another story. The ?NumberQ as pattern in the definition of the function buffles me, because somehow NMinimize "notices" and prevents evaluation, but it does not with a more simple function like x^2.
|
|
May 12, 2015 at 17:32 | history | edited | Michael E2 | CC BY-SA 3.0 |
Added addendum
|
May 12, 2015 at 16:54 | history | answered | Michael E2 | CC BY-SA 3.0 |