Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

Desperate due to NMinimize

7 просмотров
Перейти к первому непрочитанному сообщению

toxic topas

не прочитано,
11 дек. 2010 г., 01:53:5111.12.2010
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]]
NMinimize[dd[x],x]

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?

Nasser M. Abbasi

не прочитано,
12 дек. 2010 г., 05:40:2212.12.2010


In[1]:= Remove["Global`*"]
dd[x_?NumericQ]:=(Export["test.dat",x^2];Import["test.dat"])[[1,1]]
Chop@NMinimize[dd[x],x]

Out[3]= {0,{x->5.905900171355918*10^-7}}
In[4]:= NMinimize[x^2,x]
Out[4]= {0.,{x->0.}}

--Nasser

Bob Hanlon

не прочитано,
12 дек. 2010 г., 05:46:1812.12.2010
Restrict dd to numeric arguments

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


Import["test.dat"])[[1, 1]]


Bob Hanlon

---- toxic topas <toxic...@googlemail.com> wrote:

=============

0 новых сообщений