Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Problem with NMaximize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90034] Re: Problem with NMaximize
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 27 Jun 2008 06:14:04 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g3vkvi$kio$1@smc.vnet.net>

Ramiro Barrantes-Reynolds wrote:

<snip>

> {res, data} =
>    Reap[NMaximize[{logLikelihood[{{5, 5, 0, 0}, {3, 1, 0, 1}}, {33, 83,
>          11, 14}, S,
>        a, {l1, l2, l3, l4}, {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
>         t11, t12}], l1 > 0, l2 > 0, l3 > 0, l4 > 0, t1 > 0, t2 > 0,
>       t3 > 0, t4 > 0, t5 > 0, t6 > 0, t7 > 0, t8 > 0, t9 > 0, t10 > 0,
>       t11 > 0, t12 > 0,
>       t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11 + t12 ==
>        1}, {a, l1, l2, l3, l4, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
>        t11, t12},
>      EvaluationMonitor :>
>       Sow[{a, {l1, l2, l3, l4}, {t1, t2, t3, t4, t5, t6, t7, t8, t9,
>          t10, t11, t12}}]]];

The code is not complete since you did not post the definition of the 
function logLikelihood[...]

> NMaximize::nrnum: The function value 28.2245-6.28319 I is not a real \
> number at {a,l1,l2,l3,l4,t1,t10,t11,t12,t2,<<7>>} = \
> {1.,2.,2.,<<6>>,0.0799689,<<7>>}. >>

Nevertheless, by reading this above error message I bet that your 
function is called with symbolic arguments (i.e. non-numeric arguments). 
The following should help to correctly defined your function so it will 
be called by NMaximize only when all its arguments are numeric values.

"How do I write a function which evaluates only when the argument is a 
number?"

http://support.wolfram.com/mathematica/kernel/features/evalwhennumber.html

Regards,
-- Jean-Marc


  • Prev by Date: Re: Bug of Units-package in combination with DynamicModule
  • Next by Date: Re: Re: Local extrema of a function of two variables
  • Previous by thread: Problem with NMaximize
  • Next by thread: Re: Problem with NMaximize