Re: Forcing output in FindMinimum
- To: mathgroup@smc.vnet.net
- Subject: [mg12583] Re: Forcing output in FindMinimum
- From: "Allan Hayes" <hay@haystack.demon.cc.uk>
- Date: Mon, 25 May 1998 14:24:55 -0400
- References: <6k7d8d$1if@smc.vnet.net>
Hossein Kazemi wrote in message <6k7d8d$1if@smc.vnet.net>...
>Is there a way to force FindMinimum to give an answer even if it does
>not want to. For example, when one uses:
>
>In[1]: FindMinimum[f[x1,x2],{x1,start,min,max},{x2,start,min,max}]
>
>Mathematica may send a message that it has moved outside the range, but
>it does give the last values of x1 and x2. Is there a way to force it
>to produce the last values it used for x1 and x2.
>
>Thank you
>
>Hossein Kazemi
>Univ of Mass
>
>
Hossein,
The following is based on an earlier posting of David Withoff
In[1]:=
Clear[GetParameter]
In[2]:=
Attributes[GetParameter]= HoldAll;
In[3]:=
GetParameter[expr_, n_]:=
( Unprotect[Message];
Message[ n, p_,q___]:=Null/;{par =p;False};
Protect[Message];
Check[expr,par,n]
)
In[4]:=
GetParameter[FindMinimum[-Sin[Pi x],{x,0,0,.3}],
FindMinimum::regex]
FindMinimum::"regex":
"Reached the point 0.3` which is outside the region {{0., 0.3}}
Out[4]=
0.3
------------------------------------------------------------- Allan
Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay@haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642