Re: Re: weird NMaximize behaviour

*To*: mathgroup at smc.vnet.net*Subject*: [mg92091] Re: [mg92071] Re: weird NMaximize behaviour*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Sat, 20 Sep 2008 04:55:59 -0400 (EDT)*References*: <gat9qm$ejo$1@smc.vnet.net> <200809190916.FAA15056@smc.vnet.net>

I don't think the answer can be as simple as that. Note that: Table[First[NMaximize[{(x - i)^2, -2 <= x <= 2}, {x}]] - First[NMaximize[{(x - i)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}]], {i, 0, 10}] {0., 8., 0., 0., 0., 0., 0., 0., 0., 0., 0.} Andrzej Kozlowski On 19 Sep 2008, at 18:16, dh wrote: > > > Hi Andrzej, > > We do not know what method is chosen by the default Method- > >"Automatic", > > but it seems to me that some "up hill" method is invoked. Starting at > > some point x0>1, the algorithm will then go towards larger x until > > reaching the border of the region. > > To fix this, we need to choose a method that does not simply go uphill > > but tries to find a global maximum, e.g. "SimulatedAnnealing" or > > "DifferentialEvolution". E.g. "SimulatedAnnealing" gives: > > {9.,{x->-2.,y->0.999067}} > > Daniel > > > > > > Andrzej Kozlowski wrote: > >> I have just encountered strange behaviour by NMaximize (which has >> been > >> ruining a demonstration I have been working on): > >> > >> This is fine: > >> > >> NMaximize[{(x - 1)^2, -2 <= x <= 2}, {x}] > >> {9., {x -> -2.}} > >> > >> but this definitely is not: > >> > >> NMaximize[{(x - 1)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] > >> {1., {x -> 2., y -> 0.87904}} > >> > >> The objective function s independent of y, yet NMaximize seems to go > >> off on some wild goose chase and ends up with a very poor "maximum". > >> > >> This does not happen here: > >> > >> NMaximize[{(x - 2)^2, -2 <= x <= 2}, {x}] > >> {16., {x -> -2.}} > >> > >> NMaximize[{(x - 2)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] > >> {16., {x -> -2., y -> -0.980305}} > >> > >> Kind of weird. > >> > >> Andrzej Kozlowski > >> > > > > > > -- > > > > Daniel Huber > > Metrohm Ltd. > > Oberdorfstr. 68 > > CH-9100 Herisau > > Tel. +41 71 353 8585, Fax +41 71 353 8907 > > E-Mail:<mailto:dh at metrohm.com> > > Internet:<http://www.metrohm.com> > > >

**References**:**Re: weird NMaximize behaviour***From:*dh <dh@metrohm.ch>