home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / math / stat / 2406 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  15.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!ra!mimsy!ingber
  2. From: ingber@umiacs.umd.edu (Lester Ingber)
  3. Newsgroups: sci.math.stat
  4. Subject: Very Fast Simulated Reannealing code available for beta testing
  5. Message-ID: <62271@mimsy.umd.edu>
  6. Date: 23 Nov 92 04:54:50 GMT
  7. Sender: news@mimsy.umd.edu
  8. Organization: UMIACS, University of Maryland, College Park, MD 20742
  9. Lines: 367
  10.  
  11.  
  12.            VERY FAST SIMULATED REANNEALING (VFSR) (C)
  13.  
  14.              Lester Ingber ingber@alumni.caltech.edu
  15.                                and
  16.               Bruce Rosen rosen@ringer.cs.utsa.edu
  17.  
  18. 1.  License and Availability
  19.  
  20.  
  21. 1.1.  GNU Copyleft License
  22.  
  23.      This  Very  Fast  Simulated Reannealing (VFSR) code is being
  24. made available under a GNU COPYING-LIB "copyleft" license, and is
  25. owned  jointly  by Lester Ingber and Bruce Rosen[1].  Please read
  26. the copy of this license contained in this directory.
  27.  
  28. 1.2.  NETLIB Electronic Availability of VFSR
  29.  
  30.      You can obtain our code  from  NETLIB.   This  can  be  done
  31. interactively, or you can obtain it by electronic mail request.
  32.  
  33. 1.2.1.  Interactive
  34.  
  35.      From your local machine login to research.att.com:
  36.         local% ftp research.att.com
  37.         Name (research.att.com:your_login_name): netlib
  38.         Password: [type in your_login_name or anything]
  39.         ftp> cd opt
  40.         ftp> binary
  41.         ftp> get vfsr.Z
  42.         ftp> quit
  43. After  `uncompress  vfsr.Z'  read  the  header of vfsr for simple
  44. directions on obtaining your source files.  For example, on  most
  45. machines, after `sh vfsr' they will reside in a VFSR directory.
  46.  
  47. 1.2.2.  Electronic Mail Request
  48.  
  49.      Send the following one-line electronic mail request
  50.         send vfsr from opt
  51.         [For general NETLIB info, just use: send index]
  52. to one of the NETLIB sites:
  53.         netlib@research.att.com (AT&T Bell Labs, NJ, USA)
  54.         [most recent version]
  55.         netlib@ornl.gov         (Oak Ridge Natl Lab, TN, USA)
  56.         netlib@ukc.ac.uk        (U Kent, UK)
  57.         netlib@nac.no           (Oslo, Norway)
  58.         netlib@cs.uow.edu.au    (U Wollongong, NSW, Australia)
  59.  
  60. 2.  Background and Context
  61.  
  62.      VFSR  was  developed  in  1987 to deal with the necessity of
  63. performing adaptive global optimization on multivariate nonlinear
  64. stochastic  systems[2].   VFSR was recoded and applied to several
  65. complex systems, in combat analysis[3],  finance[4],  and  neuro-
  66. science[5].   A  comparison  has  shown  VFSR to be superior to a
  67. standard genetic algorithm simulation on a suite of standard test
  68. problems[6],  and  VFSR  has  been  examined  in the context of a
  69. review of methods of simulated annealing[7].  A project comparing
  70. standard  Boltzmann  annealing  with "fast" Cauchy annealing with
  71. VFSR has concluded that VFSR is a superior algorithm[8].  A paper
  72. has  indicated how this technique can be enhanced by combining it
  73. with some other powerful algorithms[9].
  74.  
  75. 2.1.  Efficiency Versus Necessity
  76.  
  77.      VFSR is not necessarily an "efficient" code.   For  example,
  78. if  you know that your cost function to be optimized is something
  79. close to a parabola, then a simple gradient Newton search  method
  80. most  likely  would  be faster than VFSR.  VFSR is believed to be
  81. faster and more robust than other simulated annealing  techniques
  82. for  most  complex problems with multiple local optima; again, be
  83. careful to note that some problems  are  best  treated  by  other
  84. algorithms.   If you do not know much about the structure of your
  85. system, and especially if it has  complex  constraints,  and  you
  86. need  to  search for a global optimum, then we heartily recommend
  87. our VFSR code to you.
  88.  
  89. 2.2.  Outline of Use
  90.  
  91.      Set up the VFSR interface: Your program  should  be  divided
  92. into two basic modules.  (1) The user calling procedure, contain-
  93. ing the cost function to be minimized (or  its  negative  if  you
  94. require  a  global  maximum),  here  is  contained  in user.c and
  95. user.h.  (2) The VFSR optimization procedure, here  is  contained
  96. in  vfsr.c  and  vfsr.h.   Furthermore, there are some options to
  97. explore in the Makefile.  We assume there will  be  no  confusion
  98. over  the standard uses of the term "parameter" in different con-
  99. texts, e.g., as an element passed by a subroutine or as a  physi-
  100. cal coefficient in a cost function.
  101.  
  102.      In VFSR/TESTS we have included some user_out files from some
  103. sample runs, containing timed runs  on  a  Sun4c/4.1.3  (SPARC-2)
  104. using    compilers    cc,   acc   and   gcc-2.3.1,   and   on   a
  105. Dec5100/Ultrix-4.2 using compilers cc and gcc-2.2.2.  No  attempt
  106. was  made  to optimize the use of any of these compilers, so that
  107. the runs do not really signify any testing of these compilers  or
  108. architectures;  rather  they  are  meant to be used as a guide to
  109. determine what you might expect on your own machine.
  110.  
  111. 3.  Makefile
  112.  
  113.      This file was generated using `make doc'.  The Makefile con-
  114. tains  some options for formatting this file differently, includ-
  115. ing the PostScript version README.ps and the text version README.
  116.  
  117.      Since  complex  problems  by  their  nature  are often quite
  118. unique, it is unlikely that our default parameters are just right
  119. for  your problem.  However, our experience has shown that if you
  120. a priori do not have any reason to determine your own parameters,
  121. then  you might do just fine using our defaults, and we recommend
  122. using them as a first-order guess.  Most of our defaults  can  be
  123. changed  simply  by uncommenting lines in the Makefile.  Remember
  124. to recompile the entire code every time you change  any  options.
  125. Depending  on  how you integrate VFSR into your own user modules,
  126. you may wish to modify this Makefile or  at  least  use  some  of
  127. these options in your own compilation procedures.
  128.  
  129.      Read  through  all the options in the Makefile.  As the com-
  130. ments therein suggest, it may be necessary to change some of them
  131. on  some  systems.   Here are just a couple of examples you might
  132. consider:
  133.  
  134. 3.1.  SMALL_FLOAT
  135.  
  136.      For example, on one  convex  running  our  test  problem  in
  137. user.c  the  SMALL_FLOAT  default  was  too  small  and  the code
  138. crashed.  A larger value was found to give reasonable results.
  139.  
  140.      The reason is that the fat tail  of  VFSR,  associated  with
  141. high  parameter temperatures, is very important for searching the
  142. breadth of the ranges especially in the initial stages of search.
  143. However,  the  parameter temperatures require small values at the
  144. final stages of the search to  converge  to  the  best  solution,
  145. albeit  this is reached very quickly given the exponential sched-
  146. ule proven in the referenced publications to be permissible  with
  147. VFSR.   Note  that  our  test problem in user.c is a particularly
  148. nasty one, with 1E20 local minima and requiring  VFSR  to  search
  149. over  many  orders  of magnitude of the cost function before cor-
  150. rectly finding the global minimum.
  151.  
  152.      In VFSR/TESTS We  have  included  vfsr_out  files  comparing
  153. results   using   SMALL_FLOAT=1.0E-16,  SMALL_FLOAT=1.0E-18  (the
  154. default),  and  SMALL_FLOAT=1.0E-20.   Although  the  same  final
  155. results were achieved, the intermediate calculations differ some-
  156. what.
  157.  
  158. 3.2.  HAVE_ANSI
  159.  
  160.      As another example, setting HAVE_ANSI=FALSE will permit  you
  161. to  use  an older K&R C compiler.  This option can be used if you
  162. do  not  have  an   ANSI   compiler,   overriding   the   default
  163. HAVE_ANSI=TRUE.
  164.  
  165. 4.  User Module
  166.  
  167.      We  have  set  up this module as user.c and user.h.  You may
  168. wish to combine them into one file, or you may wish  to  use  our
  169. VFSR  module  as  one component of a library required for a large
  170. project.
  171.  
  172. 4.1.  int main(int argc, char **argv)
  173.  
  174.      In main, set up your initializations and calling  statements
  175. to vfsr.  In the files user.c and user.h, we have provided a sam-
  176. ple program, as well as a sample cost function  for  your  conve-
  177. nience.   If you do not intend to pass parameters into main, then
  178. you can just declare it as main() without the argc and argv argu-
  179. ments.
  180.  
  181. 4.2.  void user_initialize_parameters()
  182.  
  183.      Before calling vfsr, the user must allocate storage and ini-
  184. tialize some of the passed parameters.   A  sample  procedure  is
  185. provided  as a template.  In this procedure the user should allo-
  186. cate storage for the passed arrays and  define  the  minimum  and
  187. maximum  values.   Below, we detail all the parameters which must
  188. be initialized.  If your arrays are of size 1, still use them  as
  189. arrays as described in user.c.
  190.  
  191. 4.3.  double user_cost_function(double *x, int *valid_flag)
  192.  
  193.      You  can  give any name to user_cost_function as long as you
  194. pass this name to vfsr.  x (or whatever name you pass to vfsr) is
  195. an array of doubles representing a set of parameters to evaluate,
  196. and valid_flag (or whatever name you pass to vfsr) is the address
  197. of  an integer.  In user_cost_function, *valid_flag should be set
  198. to FALSE (0) if the parameters violate a set of user defined con-
  199. straints  (e.g.,  as  defined by a set of boundary conditions) or
  200. TRUE  (1)  if  the  parameters  represent  a  valid  state.    If
  201. *valid_flag is FALSE, no acceptance test will be attempted, and a
  202. new set of trial parameters  will  be  generated.   The  function
  203. returns a real value which VFSR will minimize.
  204.  
  205. 4.4.  double user_random_generator()
  206.  
  207.      A  random number generator function must be passed next.  It
  208. may be as simple as one of  the  UNIX  random  number  generators
  209. (e.g.  drand48),  or  may be user defined, but it should return a
  210. real value within [0,1) and not take  any  parameters.   We  have
  211. provided  a good random number generator, randflt, and its auxil-
  212. iary routines with the code in the file user module.
  213.  
  214. 4.5.  void initialize_rng()
  215.  
  216.      Most random number generators should be "warmed-up" by call-
  217. ing a set of dummy random numbers.
  218.  
  219. 4.6.  void print_time(char *message)
  220.  
  221.      As  a convenience, we have included this subroutine, and its
  222. auxiliary routine aux_print_time, to keep track of the time spent
  223. during  optimization.   It  takes  as its only parameter a string
  224. which  will  be  printed.   We   have   given   an   example   in
  225. user_cost_function  to  illustrate  how  print_time may be called
  226. periodically   every   set   number   of   calls   by    defining
  227. PRINT_FREQUENCY in user.h.
  228.  
  229. 4.7.
  230. vfsr(
  231.      user_cost_function,
  232.      user_random_generator,
  233.      number_parameters,
  234.      parameter_type,
  235.      parameter_initial_final,
  236.      final_cost,
  237.      parameter_minimum,
  238.      parameter_maximum,
  239.      tangents,
  240.      curvature);
  241.  
  242.      This is the form of the call to vfsr from user.c.
  243.  
  244. 4.8.
  245. void vfsr(
  246.      double (*user_cost_function) (),
  247.      double (*user_random_generator) (),
  248.      int number_parameters,
  249.      int *parameter_type,
  250.      double *parameter_initial_final,
  251.      double final_cost,
  252.      double *parameter_minimum,
  253.      double *parameter_maximum,
  254.      double *tangents,
  255.      double *curvature)
  256.  
  257.      This is how vfsr is defined in the VFSR module, contained in
  258. vfsr.c and vfsr.h.  Each parameter is described below as it  must
  259. be passed to this module from the user module.
  260.  
  261. 4.8.1.  double (*user_cost_function) ()
  262.  
  263.      The  parameter (*user_cost_function*) () is a pointer to the
  264. cost function that you defined in your user module.
  265.  
  266. 4.8.2.  double (*user_random_generator) ()
  267.  
  268.      As discussed above, a pointer to the random number generator
  269. function, defined in the user module, must be passed next.
  270.  
  271. 4.8.3.  int number_parameters
  272.  
  273.      An  integer containing the dimensionality of the state space
  274. is passed next.  Each of the arrays that follow are to be of  the
  275. size number_parameters.
  276.  
  277. 4.8.4.  int *parameter_type
  278.  
  279.      This  integer  array  is  passed next.  Each element of this
  280. array (each flag) is either REAL_TYPE (0) (indicating the parame-
  281. ter  is a real value) or INTEGER_TYPE (1) (indicating the parame-
  282. ter can take on only integer values).
  283.  
  284. 4.8.5.  double *parameter_initial_final
  285.  
  286.      Next, an array of doubles is passed.  Initially, this  array
  287. holds  the  set  of  starting parameters which should satisfy any
  288. constraints or boundary conditions. Upon  return  from  the  VFSR
  289. procedure,  the  array  will  contain  the best set of parameters
  290. found by vfsr to minimize the user's cost  function.   Experience
  291. shows  that  any guesses within the acceptable ranges should suf-
  292. fice, since initially the system is at high annealing temperature
  293. and VFSR samples the breadth of the ranges.
  294.  
  295. 4.8.6.  double final_cost
  296.  
  297.      This  double should be defined in the calling program.  Upon
  298. return from the vfsr call, it will  be  the  minimum  cost  value
  299. found by vfsr.
  300.  
  301. 4.8.7.  double *parameter_minimum
  302.  
  303.  
  304. 4.8.8.  double *parameter_maximum
  305.  
  306.      These  two  arrays  of doubles should also be passed.  Since
  307. VFSR works only on bounded search  spaces,  these  arrays  should
  308. contain the minimum and maximum values each parameter can attain.
  309. If you aren't sure, try a factor of 10 or 100 times  any  reason-
  310. able  values.   The  exponential  temperature  annealing schedule
  311. should quickly sharpen the search  down  to  the  most  important
  312. region.
  313.  
  314. 4.8.9.  double *tangents
  315.  
  316.  
  317. 4.8.10.  double *curvature
  318.  
  319.      These  two  arrays  of  doubles  should  be passed last.  On
  320. return from vfsr, for real parameters, they contain the first and
  321. second  derivatives  of  the  cost  function  with respect to its
  322. parameters.  These can be useful for  determining  the  value  of
  323. your  fit.  In this implementation of VFSR, the tangents are used
  324. to determine the relative reannealing among parameters.
  325.  
  326. 5.  Bug Reports
  327.  
  328.      While we do not have time to help you solve your own  appli-
  329. cations,  we  do  want  VFSR  to be helpful to a large community.
  330. Therefore, we welcome your bug reports and constructive critiques
  331. regarding our code.  "Flames" will be rapidly quenched.
  332.  
  333.  
  334. References
  335.  
  336. 1.   L.  Ingber  and  B. Rosen, "vfsr," Very Fast Simulated Rean-
  337.      nealing (VFSR) Source Code, NETLIB Electronic  Ftp  Archive,
  338.      netlib@research.att.com (1992).
  339.  
  340. 2.   L.  Ingber,  "Very fast simulated re-annealing," Mathl. Com-
  341.      put. Modelling, 8, 12, pp. 967-973 (1989).
  342.  
  343. 3.   L. Ingber, H. Fujio, and M.F. Wehner, "Mathematical compari-
  344.      son of combat computer models to exercise data," Mathl. Com-
  345.      put. Modelling, 1, 15, pp. 65-90 (1991).
  346.  
  347. 4.   L. Ingber, "Statistical mechanical aids to calculating  term
  348.      structure  models,"  Phys.  Rev.  A,  12,  42, pp. 7057-7064
  349.      (1990).
  350.  
  351. 5.   L. Ingber, "Statistical mechanics  of  neocortical  interac-
  352.      tions:  A  scaling  paradigm applied to electroencephalogra-
  353.      phy," Phys. Rev. A, 6, 44, pp. 4017-4060 (1991).
  354.  
  355. 6.   L. Ingber and B. Rosen, "Genetic algorithms  and  very  fast
  356.      simulated  reannealing:  A  comparison," Mathl. Comput. Mod-
  357.      elling, 11, 16, pp. 87-100 (1992).
  358.  
  359. 7.   L. Ingber, "Simulated annealing:  Practice  versus  theory,"
  360.      Statistics Comput., p. (to be published) (1993).
  361.  
  362. 8.   B. Rosen, "Function optimization based on advanced simulated
  363.      annealing," Report, University of  Texas,  San  Antonio,  TX
  364.      (1992).
  365.  
  366. 9.   L. Ingber, "Generic mesoscopic neural networks based on sta-
  367.      tistical mechanics of neocortical interactions," Phys.  Rev.
  368.      A, 4, 45, pp. R2183-R2186 (1992).
  369.  
  370. [*]  Some  (p)reprints  can  be  obtained  via anonymous ftp from
  371.      ftp.umiacs.umd.edu [128.8.120.23] in the  pub/ingber  direc-
  372.      tory.
  373.  
  374. -- 
  375.   |  Prof. Lester Ingber               ingber@alumni.caltech.edu  |
  376.   |  P.O. Box 857                                                 |
  377.   |  McLean, VA 22101       703-848-1859 = [10ATT]0-700-L-INGBER  |
  378.