MathGroup Archive 2009

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

Search the Archive

Re: Mathematica in conjunction with outside program; NMinimize fails.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98947] Re: Mathematica in conjunction with outside program; NMinimize fails.
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 22 Apr 2009 05:13:38 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <gsivfv$9dj$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

no the definition is not irrelevant. You just define

SingleModelRun[ parametervalue_?NumericQ ] := ....(definition irrelevant)

and better you write a MathLink program to do the calculation.

Regards
   Jens

Andreas Pape wrote:
> 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: Help with Speeding up a For loop
  • Next by Date: Re: Getting the height and width of controls?
  • Previous by thread: Re: Mathematica in conjunction with outside program; NMinimize fails.
  • Next by thread: Re: Mathematica in conjunction with outside program; NMinimize fails.