Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Mathematica in conjunction with outside program; NMinimize fails. Symbolic v. numeric evaluation problem?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98875] Mathematica in conjunction with outside program; NMinimize fails. Symbolic v. numeric evaluation problem?
  • From: Andreas Pape <apape at binghamton.edu>
  • Date: Mon, 20 Apr 2009 19:12:19 -0400 (EDT)

Hello mathgroup.  I am using Mathematica in conjunction with an  
outside program (Netlogo is the program.)  In a nutshell, my error is  
the following: I can call the outside program with a numeric value  
successfully, and Plot can call the outside program as one would  
expect.  However, NMinimize calls the outside program with the  
variable name, not a value, so it fails.  In short, I need to force  
NMinimize to pass a numeric value to the objective function, not a  
variable name.

More details:

I have the following functions defined in Mathematica:

	SingleModelRun[ parametervalue_ ] := ....(definition irrelevant)
		This function (successfully) runs the outside program, setting a  
parameter equal to "parametervalue" (which is some number when I call  
the function).  It returns a value from the model.

	Plot[ SingleModelRun[ x ], {x , 0, 1} ]
		Does what you expect: runs SingleModelRun for parameter values 0  
through 1, and plots the resulting return value each time.

	NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ]
		Does not work.  Returns the following error:

		NetLogo`Private`NetLogo::"compilerException" : "Nothing named  
MYVALUE has been defined"

	(Note: NetLogo is the name of the outside program.)

Which means that, oddly, NMinimize passes the *variable name*  
(myvalue) instead of the *variable value* to the function  
SingleModelRun; otherwise, there is no way the outside program would  
be aware of the variable name.

	Is there a way to force Mathematica to evaluate the function with a  
numeric value, not the variable name?  (I thought that's what "N" in  
"NMinimize" meant, but apparently not.)
	
	In case you were wondering, this fails in an identical way with:  
NMaximize, FindMaximum, FindMimimum, etc.

	Thank you.

			Sincerely,
			Andreas Duus Pape



  • Prev by Date: Re: Mathematica documentation - for newest and older versions
  • Next by Date: Re: running mathematica notebooks without interface
  • Previous by thread: Re: Help with Speeding up a For loop
  • Next by thread: Preserving Notebook Changes