MathGroup Archive 2010

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

Search the Archive

Re: Desperate due to NMinimize

  • To: mathgroup at
  • Subject: [mg114674] Re: Desperate due to NMinimize
  • From: Bob Hanlon <hanlonr at>
  • Date: Sun, 12 Dec 2010 05:46:31 -0500 (EST)

Restrict dd to numeric arguments

dd[x_?NumericQ] := (
   Export["test.dat", x^2];
   Import["test.dat"])[[1, 1]]

Bob Hanlon

---- toxic topas <toxictopas at> wrote: 

I am working with Mathematica 7. I want to use NMinimize to find the
minimum of a function that is calculated by an external program. It is
called by Run with some arguments and it writes the result into a
file. I then use Import to read the value. Such a situation can be
mimicked by:

dd[x_]:=(Export["test.dat",x^2];Import["test.dat"])[[1, 1]]

If you give the function dd a value it returns the result correctly
(and writes a file). But NMinimize does not specify a value for x but
tries to evaluate the expression generally for a global x. I tried
everything that I could possibly think of using HoldAll, Unevaluated,
With[{x=x},], ... Nothing worked.

Is there anybody that can help me?

  • Prev by Date: Re: Numbering a chapter starting in number n?
  • Next by Date: front end bug?
  • Previous by thread: Desperate due to NMinimize
  • Next by thread: Re: Desperate due to NMinimize