1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections and no cover texts. A copy of the license is
included in the section entitled "GNU Free Documentation License". -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Scientific Library – Reference Manual: Simulated Annealing functions</title>
<meta name="description" content="GNU Scientific Library – Reference Manual: Simulated Annealing functions">
<meta name="keywords" content="GNU Scientific Library – Reference Manual: Simulated Annealing functions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-Index.html#Function-Index" rel="index" title="Function Index">
<link href="Simulated-Annealing.html#Simulated-Annealing" rel="up" title="Simulated Annealing">
<link href="Examples-with-Simulated-Annealing.html#Examples-with-Simulated-Annealing" rel="next" title="Examples with Simulated Annealing">
<link href="Simulated-Annealing-algorithm.html#Simulated-Annealing-algorithm" rel="previous" title="Simulated Annealing algorithm">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Simulated-Annealing-functions"></a>
<div class="header">
<p>
Next: <a href="Examples-with-Simulated-Annealing.html#Examples-with-Simulated-Annealing" accesskey="n" rel="next">Examples with Simulated Annealing</a>, Previous: <a href="Simulated-Annealing-algorithm.html#Simulated-Annealing-algorithm" accesskey="p" rel="previous">Simulated Annealing algorithm</a>, Up: <a href="Simulated-Annealing.html#Simulated-Annealing" accesskey="u" rel="up">Simulated Annealing</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Simulated-Annealing-functions-1"></a>
<h3 class="section">25.2 Simulated Annealing functions</h3>
<dl>
<dt><a name="index-gsl_005fsiman_005fsolve"></a>Function: <em>void</em> <strong>gsl_siman_solve</strong> <em>(const gsl_rng * <var>r</var>, void * <var>x0_p</var>, gsl_siman_Efunc_t <var>Ef</var>, gsl_siman_step_t <var>take_step</var>, gsl_siman_metric_t <var>distance</var>, gsl_siman_print_t <var>print_position</var>, gsl_siman_copy_t <var>copyfunc</var>, gsl_siman_copy_construct_t <var>copy_constructor</var>, gsl_siman_destroy_t <var>destructor</var>, size_t <var>element_size</var>, gsl_siman_params_t <var>params</var>)</em></dt>
<dd>
<p>This function performs a simulated annealing search through a given
space. The space is specified by providing the functions <var>Ef</var> and
<var>distance</var>. The simulated annealing steps are generated using the
random number generator <var>r</var> and the function <var>take_step</var>.
</p>
<p>The starting configuration of the system should be given by <var>x0_p</var>.
The routine offers two modes for updating configurations, a fixed-size
mode and a variable-size mode. In the fixed-size mode the configuration
is stored as a single block of memory of size <var>element_size</var>.
Copies of this configuration are created, copied and destroyed
internally using the standard library functions <code>malloc</code>,
<code>memcpy</code> and <code>free</code>. The function pointers <var>copyfunc</var>,
<var>copy_constructor</var> and <var>destructor</var> should be null pointers in
fixed-size mode. In the variable-size mode the functions
<var>copyfunc</var>, <var>copy_constructor</var> and <var>destructor</var> are used to
create, copy and destroy configurations internally. The variable
<var>element_size</var> should be zero in the variable-size mode.
</p>
<p>The <var>params</var> structure (described below) controls the run by
providing the temperature schedule and other tunable parameters to the
algorithm.
</p>
<p>On exit the best result achieved during the search is placed in
<code>*<var>x0_p</var></code>. If the annealing process has been successful this
should be a good approximation to the optimal point in the space.
</p>
<p>If the function pointer <var>print_position</var> is not null, a debugging
log will be printed to <code>stdout</code> with the following columns:
</p>
<div class="example">
<pre class="example">#-iter #-evals temperature position energy best_energy
</pre></div>
<p>and the output of the function <var>print_position</var> itself. If
<var>print_position</var> is null then no information is printed.
</p></dd></dl>
<p>The simulated annealing routines require several user-specified
functions to define the configuration space and energy function. The
prototypes for these functions are given below.
</p>
<dl>
<dt><a name="index-gsl_005fsiman_005fEfunc_005ft"></a>Data Type: <strong>gsl_siman_Efunc_t</strong></dt>
<dd><p>This function type should return the energy of a configuration <var>xp</var>.
</p>
<div class="example">
<pre class="example">double (*gsl_siman_Efunc_t) (void *xp)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fstep_005ft"></a>Data Type: <strong>gsl_siman_step_t</strong></dt>
<dd><p>This function type should modify the configuration <var>xp</var> using a random step
taken from the generator <var>r</var>, up to a maximum distance of
<var>step_size</var>.
</p>
<div class="example">
<pre class="example">void (*gsl_siman_step_t) (const gsl_rng *r, void *xp,
double step_size)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fmetric_005ft"></a>Data Type: <strong>gsl_siman_metric_t</strong></dt>
<dd><p>This function type should return the distance between two configurations
<var>xp</var> and <var>yp</var>.
</p>
<div class="example">
<pre class="example">double (*gsl_siman_metric_t) (void *xp, void *yp)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fprint_005ft"></a>Data Type: <strong>gsl_siman_print_t</strong></dt>
<dd><p>This function type should print the contents of the configuration <var>xp</var>.
</p>
<div class="example">
<pre class="example">void (*gsl_siman_print_t) (void *xp)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fcopy_005ft"></a>Data Type: <strong>gsl_siman_copy_t</strong></dt>
<dd><p>This function type should copy the configuration <var>source</var> into <var>dest</var>.
</p>
<div class="example">
<pre class="example">void (*gsl_siman_copy_t) (void *source, void *dest)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fcopy_005fconstruct_005ft"></a>Data Type: <strong>gsl_siman_copy_construct_t</strong></dt>
<dd><p>This function type should create a new copy of the configuration <var>xp</var>.
</p>
<div class="example">
<pre class="example">void * (*gsl_siman_copy_construct_t) (void *xp)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fdestroy_005ft"></a>Data Type: <strong>gsl_siman_destroy_t</strong></dt>
<dd><p>This function type should destroy the configuration <var>xp</var>, freeing its
memory.
</p>
<div class="example">
<pre class="example">void (*gsl_siman_destroy_t) (void *xp)
</pre></div>
</dd></dl>
<dl>
<dt><a name="index-gsl_005fsiman_005fparams_005ft"></a>Data Type: <strong>gsl_siman_params_t</strong></dt>
<dd><p>These are the parameters that control a run of <code>gsl_siman_solve</code>.
This structure contains all the information needed to control the
search, beyond the energy function, the step function and the initial
guess.
</p>
<dl compact="compact">
<dt><code>int n_tries</code></dt>
<dd><p>The number of points to try for each step.
</p>
</dd>
<dt><code>int iters_fixed_T</code></dt>
<dd><p>The number of iterations at each temperature.
</p>
</dd>
<dt><code>double step_size</code></dt>
<dd><p>The maximum step size in the random walk.
</p>
</dd>
<dt><code>double k, t_initial, mu_t, t_min</code></dt>
<dd><p>The parameters of the Boltzmann distribution and cooling schedule.
</p></dd>
</dl>
</dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Examples-with-Simulated-Annealing.html#Examples-with-Simulated-Annealing" accesskey="n" rel="next">Examples with Simulated Annealing</a>, Previous: <a href="Simulated-Annealing-algorithm.html#Simulated-Annealing-algorithm" accesskey="p" rel="previous">Simulated Annealing algorithm</a>, Up: <a href="Simulated-Annealing.html#Simulated-Annealing" accesskey="u" rel="up">Simulated Annealing</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|