Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8449
| From | Sam Takoy <sam.takoy@yahoo.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Baffled by FindMinimum |
| Date | 2012-02-10 10:57 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jh2t6j$o9$1@smc.vnet.net> (permalink) |
Hi,
Please take a look at this simple code.
ObjectiveFunction[p_] := Module[{},
Print["Why is this p: ", p];
(p[[3]] - 1)^2 + Norm[p]]
p0 = {1, 2, 2, 1, 2};
FindMinimum[ObjectiveFunction[xx], {xx, {1, 2, 3, 2, 1, 2}}]
If you run it, you will find that ObjectiveFunction is called with the
argument "xx" rather than the numerical vector. How come?
Also, judging by the lack of the Print statement firing,
ObjectiveFunction is not called again. Yet, it eventually (after
complaining of understandable errors) produces the correct answer.
What's going on here? I would expect if to be called repeated in the
course of numerical minimization. I'm completely baffled by what's
going on here.
Here's the output:
During evaluation of In[377]:= Why is this p: xx
During evaluation of In[377]:= Part::partd: Part specification xx[[3]]
is longer than depth of object. >>
During evaluation of In[377]:= Part::partd: Part specification xx[[3]]
is longer than depth of object. >>
Out[380]= {0.75, {xx -> {-5.48284*10^-9, -7.29576*10^-9,
0.5, -7.02789*10^-9, -5.48284*10^-9, -7.02789*10^-9}}}
Many thanks in advance,
Sam
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Baffled by FindMinimum Sam Takoy <sam.takoy@yahoo.com> - 2012-02-10 10:57 +0000 Re: Baffled by FindMinimum David Skulsky <edskulsky@gmail.com> - 2012-02-11 20:49 +0000
csiph-web