comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » CONSTRAINED_MIN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: constrained_min [message #24448 is a reply to message #12813] Wed, 28 March 2001 14:28 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Glenn Newnham <gnewnham@ses.curtin.edu.au> writes:

> I'm using constrained_min to find model parameter values which minimise
> the difference between modelled and measured data. The measured data is
> contained in various ascii files.
>
> At present my program opens the ascii file within the function to be
> minimised. this slows processing because the file is opened and closed
> every time constrained_min tries a new parameter set.
>
> Is there a way to read in these variables in the main program and make
> them global or to pass them to the function within the constrained_min
> command?

First suggestion: this is indeed a place for common blocks. It's
ugly, but that's because constrained_min doesn't provide a way for you
to get auxiliary data into your function (ie, by using _EXTRA, or a
private parameter).

At command line:
common mydata, x, y, err
read_data, x, y, err

In function:
function doodad, p
common mydata, x, y, err
; .. compute function value ...
return, f
end

However, I have a second suggestion: You sound like you may doing
least squares curve fitting. This is really a quite specialized
application which is accomplished by CURVEFIT (IDL library) and MPFIT
(available from my web page). If you need to satisfy simple bounding
constraints, then MPFIT is probably a good choice for you. Not only
is it a quite robust algorithm, but it also allows you to set
parameter constraints. It may be as simple as:

fit_params = mpfitfun('DOODAD', x, y, err, start_params)

and can be customized from there.

I've recently updated another program TNMIN, available from the same
web page. This function does more sophisticated function minimization
and also allows you to pass private data such as data values using the
FUNCTARGS keyword. It's overkill for curve fitting though.

Good luck,
Craig
Web page: http://cow.physics.wisc.edu/~craigm/idl/idl.html
(under Fitting and Tutorial)


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Drawing an arrow
Next Topic: Optimized IDL machines and license question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Tue Apr 14 09:27:38 PDT 2026

Total time taken to generate the page: 1.12010 seconds