MathGroup Archive 2004

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

Search the Archive

Using loops inside NMaximize

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45399] Using loops inside NMaximize
  • From: "Michael Harre" <Michael_Harre at resimac.com.au>
  • Date: Tue, 6 Jan 2004 04:16:58 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com
  • Thread-index: AcPT6Bn9hnZMriEnQOiam54UawH0GA==

I am trying to use NMaximize on a non-linear iterative function that
conceptually looks like this:
(*-------------------------------------------------------------------------*)
variables = {x1, x2, <<96>>, x99, x100};
in1[[1]] = initial value;
in2[[1]] = some other initial value;
out[ previousIn_, variable_] := a nonlinear function

f[100Variables_] := (
Do[
in1[[i+1]] = out[in1[[i]], 100variables[[i]] ];
in2[[i+1]] = out[in2[[i]], 100variables[[i]] ], {i, 1,
Length[100variables]};
   ];
Last[in1-in2] );

(*Then try and optimise for the last element produced by f*)

NMaximize[{f[variables], simple constraints}, variables]
(*-------------------------------------------------------------------------*)

Mathematica tries to compute this, but it gets progressively slower and
slower, so far it hasn't
finished one Do loop given 12 hrs to run. If I abort the program and
look at what it has already
been produced, I see that Mathematica retains the whole nested function
in an unevaluated form
(i.e. expressed in terms of the variables), which very quickly becomes
too large for my computer
to handle. If I try to evaluate f[] using actual numbers, it generates
an answer very quickly
(approx. 0.3 secs). It looks as though I need some way for NMaximize to
actually pass and
immediately evaluate trial solutions, rather than trying to expand the
entire expression before
passing trial values (at least I think that's what's happening). The
same thing happens using
FindMaximum.

Any suggestions as to how I can make this work?

Cheers, Mike.



  • Prev by Date: what's wrong about my package?
  • Next by Date: Combinatorica book out
  • Previous by thread: RE: Re: what's wrong about my package?
  • Next by thread: Combinatorica book out