Re: Mathematica in conjunction with outside program; NMinimize fails.
- To: mathgroup at smc.vnet.net
- Subject: [mg98977] Re: Mathematica in conjunction with outside program; NMinimize fails.
- From: kamilfirst at gmail.com
- Date: Thu, 23 Apr 2009 06:41:56 -0400 (EDT)
- References: <gsivfv$9dj$1@smc.vnet.net>
On Apr 21, 4:11 am, Andreas Pape <ap... at binghamton.edu> 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 ir=
relevant)
> This function (successfully) runs the out=
side 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 e=
rror:
>
> NetLogo`Private`NetLogo::"compilerExcepti=
on" : "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 funct=
ion 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 wa=
y with:
> NMaximize, FindMaximum, FindMimimum, etc.
>
> Thank you.
>
> Sincerely,
> Andreas Duus Pape
Hi, I am facing the same problem. It complains but it seems it give
answer at the end if you do not abort it.
regards,
kamil