MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Warning Message wrt NMinimize function


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


  • Prev by Date: Re: Warning Message wrt NMinimize function
  • Next by Date: Re: Extracting terms from an equation
  • Previous by thread: Re: Warning Message wrt NMinimize function
  • Next by thread: Re: Warning Message wrt NMinimize function