MathGroup Archive 2008

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

Search the Archive

Re: Re: Plot vs NMaximize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94445] Re: [mg94414] Re: Plot vs NMaximize
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Sun, 14 Dec 2008 07:33:30 -0500 (EST)
  • References: <ghqk1q$16j$1@smc.vnet.net> <200812121155.GAA27987@smc.vnet.net>

Nikolaus Rath wrote:
> Bill Rowe <readnews at sbcglobal.net> writes:
>> On 12/10/08 at 4:47 AM, Nikolaus at rath.org (Nikolaus Rath) wrote:
>>
>>> Bill Rowe <readnews at sbcglobal.net> writes:
>>>> An effective way to use NMaximize, is to first Plot the function
>>>> and use that plot to specify the search range to be used with
>>>> NMaximize (at least for the 1-D problem).
>>> I fully agree. But my question is: why doesn't NMaximize do this
>>> automatically? It seems like a very sensible thing to do.
>> Quite simply with existing technology there is no practical way to
>> do this. In essence, you are asking for an automated algorithm for
>> finding a global maximum. That is a very tough problem.
> 
> No, you misunderstood me. I am asking for NMaximize to first sample
> the function the same way plot does, and then take into account this
> information when continuing with the currently used algorithms.
> 
> There was already code posted here that demonstrated this for simply
> setting the starting position of NMaximize based on Plot[].
> 
> So why isn't such code inserted into NMaxmize directly? Of course even
> with this additional step NMaximize may fail to find the global
> maximum, but it will certainly work better in many cases and I don't
> see any cases where it would be detrimental.
> 
>> You can somewhat approximate what plot does with NMaximize by
>> choosing a different method for the maximization. The methods
>> RandomSearch, DifferentialEvolution and SimulatedAnnealing all
>> generate random samples in your coordinate space then process those
>> sample points to find a maximum or minimum. You can get more details
>> on these methods in the tutorial
> 
> But even with these methods, there are cases where Plot[] performs
> better (I tried this for an interpolated function, so unfortunately I
> cannot post it here).
> 
>> Also, note the process of using Plot to find a maximum isn't without
>> issues as well.
> 
> Yes. Therefore I'm asking for NMaximize to *take into account* the
> information from Plot[], not to use Plot[] as a substitute for
> NMaximize.
> 
> 
> Best,
> 
>    -Nikolaus

This is, in rudimentary form, already present in the "RandomSearch" 
method. For the example posted a few days ago, one might do:

f[x_] := Sin[2 \[Pi] x] + 10 Sin[(2 \[Pi] x)/30]

NMaximize[{f[x], x >= 0 && x < 50}, x,
  Method -> {"RandomSearch", "SearchPoints" -> 25}]

One way this is different from usage of Plot is that the latter might do 
adaptive sampling; it hence has some limited capability of homing in on 
"bad" areas, when they are at all visible to the initial sampling. But 
it is still generally advantageous to use NMaximize as above, for 
several reasons.

(1) It cam be used in dimensions higher than 3.

(2) It has some other capabilities to home in on bad regions. This 
arises from use of local optimization to move from the initial sampled 
points.

(3) It has a more robust variant (simulated annealing):

NMaximize[{f[x], x >= 0 && x < 50}, x,
  Method -> {"SimulatedAnnealing", "SearchPoints" -> 25}]

This too will allow one to locate bad regions in a way that is "adaptive".

While I am not certain, I suspect the local adaptiveness of NMaximize, 
with the above methods, might in general surpass that of Plot. Both tend 
to be based on rate-of-change and curvature-like assessments. But my 
guess is Plot will not try as hard, nor use them as accurately, because 
it's charter is primarily to draw, and not to locate optima.

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: Re: Manipulate question
  • Next by Date: Re: Plot vs NMaximize
  • Previous by thread: Re: Plot vs NMaximize
  • Next by thread: Re: Plot vs NMaximize