Re: Problem with NMinimize
- To: mathgroup at smc.vnet.net
- Subject: [mg119162] Re: Problem with NMinimize
- From: Themis Matsoukas <tmatsoukas at me.com>
- Date: Mon, 23 May 2011 06:27:17 -0400 (EDT)
Hi Dimos, Define fob without ?NumericQ. For example: nmax = 5; thist = RandomReal[100, nmax]; t1 = RandomReal[100, nmax]; t2 = RandomReal[100, nmax]; t3 = RandomReal[100, nmax]; t4 = RandomReal[100, nmax]; fob[w1_, w2_, w3_, w4_, c_, pow_] := (w1*(c + t1)^pow + w2*(c + t2)^pow + w3*(c + t3)^pow + w4*(c + t4)^pow)^(1/pow) - c; results = NMinimize[{Abs[ 1000*(Mean[thist] - Mean[fob[w1, w2, w3, w4, c, pow]])^2 + Total[(thist - fob[w1, w2, w3, w4, c, pow])^2]/Length[thist]], w1 + w2 + w3 + w4 == 1 && 0 < w1 < 1 && 0 < w2 < 1, 0 < w3 < 1 && 0 < w4 < 1 && 0 < c, 0 < pow}, {w1, w2, w3, w4, c, pow}] {1197.03, {w1 -> 0.81389, w2 -> 1.91257*10^-10, w3 -> 0.122859, w4 -> 0.0632512, c -> 6.82525*10^-7, pow -> 1.98958*10^-8}} Themis