
Writing your own optimization method for use in Sherpa
------------------------------------------------------

Unlike user models, there is only one way to write your own
optimization methof in Sherpa, and that is to use the
ascfitUserSearchMethod interface.

The directory method/ contains an example of how to do this. Note that
you must also provide routines for the ascfitUserModel and
ascfitUserStatFunction interfaces, otherwise the dynamic library will
not be loaded by Sherpa. In the example we use dummy routines for
these interfaces.

The file method.c contains the user-defined routine:

  ascfitusersearchmethod_

The body of this routines should be changed to match your needs (the
routine name and argument list must not be changed).

To build and use the example (run from within the method/ directory):

a)  ./configure

This creates a link to the correct Makefile.

b)  make

(or 'make -f Makefile.<os>' if step a has not been run)

This compiles the code and creates the libascfitUser.so shared library
(libascfitUser.dylib on OS-X).

d)  add the current directory to the start of the library path

On Solaris and Linux

  setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH

On OS-X

  setenv DYLD_LIBRARY_PATH `pwd`:$DYLD_LIBRARY_PATH

The directory containing the libascfitUser.so/dylib file must be
placed at the start of this list, otherwise Sherpa will use the
default library from the CIAO distribution rather than your own
version. To check this try on Solaris or Linux

  ldd `which sherpa` | grep ascfitUser
        libascfitUser.so => <pwd>/libascfitUser.so

which should report the current working directory rather than the CIAO
installation firectory for the library. The 'otool -L' command can be
used on OS-X, but it does not seem to report the directory location in
the same manner as ldd.

e)  start Sherpa

The directory contains a simple test script (test.shp) which can be
loaded into Sherpa by saying

  sherpa> use test.shp

Note that the example search method is provided for educative purposes
and must not be used for scientific analysis.
