From: John Adeosun on
Hello Everyone,

I want to use NMinimize to solve an optimization problem. In essence, I'm
trying to numerically minimize the "sum of a square of errors" for two
lists, aa and bb (earlier generated lists of n elements or points), using
the below syntax:

NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2, {i, n}], {y> 0}}, y,
Method -> "DifferentialEvolution"]
This does not yield the intended result of, say, {minimumvalue, y->10.012}.
I have been getting an expression (unevaluated "result" ) with a warning
message such as:

NMinimize::nnum : The function value {336.381} is not a number at {y}=
{0.063703}. More...

I then clicked on 'More' for help. I got the below message from the help
browser:

"General::nnum

function::nnum: The function value `3` is not a number at `2` = `1`.

Notes for this message have not yet been added."

Has anyone experienced this before? Is anything wrong with my syntax above?

Thanks in advance for your useful insight.

John.






From: Chris Chiasson on
Maybe you should provide the expression for aa, bb, and n. Also, in
regular least squares curve fitting, there is no restriction on the
parameter space (no restriction on y).

In[1]:=
aa=Table[Random[],{20}]

Out[1]=
{0.303766,0.14977,0.225405,0.0994793,0.358193,0.137617,0.305444,0.0196565,0.\
418029,0.386865,0.416273,0.492426,0.207767,0.486231,0.426445,0.370501,0.\
191603,0.921002,0.481863,0.353564}

In[2]:=
bb=Table[y Random[],{20}]

Out[2]=
{0.227101 y,0.239582 y,0.0272011 y,0.286646 y,0.923335 y,0.0898122 y,
0.801797 y,0.187167 y,0.565142 y,0.952195 y,0.496352 y,0.16751 y,0.147113 y,
0.56533 y,0.0800794 y,0.675084 y,0.939346 y,0.0790994 y,0.653634 y,
0.304583 y}

In[3]:=
NMinimize[{Plus@@Table[(aa[[i]]-bb[[i]])^2,{i,Length(a)aa}],{y>0}},y,
Method\[Rule]"DifferentialEvolution"]

Out[3]=
{1.46278,{y\[Rule]0.530985}}



On 9/21/06, John Adeosun <jtadeosun(a)yahoo.com> wrote:
> Hello Everyone,
>
> I want to use NMinimize to solve an optimization problem. In essence, I'm
> trying to numerically minimize the "sum of a square of errors" for two
> lists, aa and bb (earlier generated lists of n elements or points), using
> the below syntax:
>
> NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2, {i, n}], {y> 0}}, y,
> Method -> "DifferentialEvolution"]
> This does not yield the intended result of, say, {minimumvalue, y->10.012}.
> I have been getting an expression (unevaluated "result" ) with a warning
> message such as:
>
> NMinimize::nnum : The function value {336.381} is not a number at {y}=
> {0.063703}. More...
>
> I then clicked on 'More' for help. I got the below message from the help
> browser:
>
> "General::nnum
>
> function::nnum: The function value `3` is not a number at `2` = `1`.
>
> Notes for this message have not yet been added."
>
> Has anyone experienced this before? Is anything wrong with my syntax above?
>
> Thanks in advance for your useful insight.
>
> John.
>
>
>
>
>
>
>


--
http://chris.chiasson.name/

From: Jens-Peer Kuska on
Hi,

regardless of the fact that your input is
nonsense, because
your objective function does not depend on y at
all
With[{n = 4},
aa = Table[Random[], {n}];
bb = Table[Random[], {n}];
NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2,
{i, n}], {y > 0}}, y,
Method -> "DifferentialEvolution"]
]

work fine for me and I assume, that you hide some
facts to prevent
us from answer your question.

Regards
Jens

"John Adeosun" <jtadeosun(a)yahoo.com> schrieb im
Newsbeitrag news:eeu01h$b83$1(a)smc.vnet.net...
| Hello Everyone,
|
| I want to use NMinimize to solve an optimization
problem. In essence, I'm
| trying to numerically minimize the "sum of a
square of errors" for two
| lists, aa and bb (earlier generated lists of n
elements or points), using
| the below syntax:
|
| NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2,
{i, n}], {y> 0}}, y,
| Method -> "DifferentialEvolution"]
| This does not yield the intended result of, say,
{minimumvalue, y->10.012}.
| I have been getting an expression (unevaluated
"result" ) with a warning
| message such as:
|
| NMinimize::nnum : The function value {336.381}
is not a number at {y}=
| {0.063703}. More...
|
| I then clicked on 'More' for help. I got the
below message from the help
| browser:
|
| "General::nnum
|
| function::nnum: The function value `3` is not a
number at `2` = `1`.
|
| Notes for this message have not yet been added."
|
| Has anyone experienced this before? Is anything
wrong with my syntax above?
|
| Thanks in advance for your useful insight.
|
| John.
|
|
|
|
|
|


From: Jean-Marc Gulliet on
John Adeosun wrote:
> Hello Everyone,
>
> I want to use NMinimize to solve an optimization problem. In essence, I'm
> trying to numerically minimize the "sum of a square of errors" for two
> lists, aa and bb (earlier generated lists of n elements or points), using
> the below syntax:
>
> NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2, {i, n}], {y> 0}}, y,
> Method -> "DifferentialEvolution"]
> This does not yield the intended result of, say, {minimumvalue, y->10.012}.
> I have been getting an expression (unevaluated "result" ) with a warning
> message such as:
>
> NMinimize::nnum : The function value {336.381} is not a number at {y}=
> {0.063703}. More...
>
> I then clicked on 'More' for help. I got the below message from the help
> browser:
>
> "General::nnum
>
> function::nnum: The function value `3` is not a number at `2` = `1`.
>
> Notes for this message have not yet been added."
>
> Has anyone experienced this before? Is anything wrong with my syntax above?

John,

The syntax above seems correct (see below). I suspect you have some
problem with your lists. Note that the second version of the code should
be more efficient (you can do vector operations).

In[1]:=
aa = Table[Random[], {10}];
bb = Table[Random[], {10}];

In[3]:=
NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2, {i, 10}], {y > 0}}, y,
Method -> "DifferentialEvolution"]

Out[3]=
{1.71356,{y\[Rule]13.0914}}

In[4]:=
NMinimize[{Plus @@ ((aa - bb)^2), {y > 0}}, y,
Method -> "DifferentialEvolution"]

Out[4]=
{1.71356,{y\[Rule]13.0914}}

In[5]:=
$Version

Out[5]=
5.2 for Microsoft Windows (June 20, 2005)

HTH,
Jean-Marc

From: p-valko on
As it is written right now, you are minimizing a list that consists of
two elements,
each of them being a list itself. NMinimize really does not know what
to do with such an object.
(Very often in Mathematica - and in any software - the error messages are
difficult to understand because they are logical only within a given
context, but the user misses the context itself, not the particulars
within the context. I think the next generation of softwares will have
some AI built-in to recognize the real root of the misunderstanding and
will offer more help. Today softwares, like Mathematica, still look like a bit
autistic persons, but soon they will have more empathy for the user. )


John Adeosun wrote:
> Hello Everyone,
>
> I want to use NMinimize to solve an optimization problem. In essence, I'm
> trying to numerically minimize the "sum of a square of errors" for two
> lists, aa and bb (earlier generated lists of n elements or points), using
> the below syntax:
>
> NMinimize[{Plus @@ Table[(aa[[i]] - bb[[i]])^2, {i, n}], {y> 0}}, y,
> Method -> "DifferentialEvolution"]
> This does not yield the intended result of, say, {minimumvalue, y->10.012}.
> I have been getting an expression (unevaluated "result" ) with a warning
> message such as:
>
> NMinimize::nnum : The function value {336.381} is not a number at {y}=
> {0.063703}. More...
>
> I then clicked on 'More' for help. I got the below message from the help
> browser:
>
> "General::nnum
>
> function::nnum: The function value `3` is not a number at `2` = `1`.
>
> Notes for this message have not yet been added."
>
> Has anyone experienced this before? Is anything wrong with my syntax above?
>
> Thanks in advance for your useful insight.
>
> John.