AI-SimulatedAnnealing
view release on metacpan or search on metacpan
lib/AI/SimulatedAnnealing.htm view on Meta::CPAN
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AI::SimulatedAnnealing – optimize a list of numbers
according to a specified cost function.</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link href="mailto:" rev="made"/>
</head>
<body style="background-color: white">
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#prerequisites">PREREQUISITES</a></li>
<li><a href="#methods">METHODS</a></li>
<li><a href="#author">AUTHOR</a></li>
<li><a href="#copyright_and_license">COPYRIGHT AND LICENSE</a></li>
</ul>
<hr/>
<h1><a name="name">NAME</a></h1>
<p>AI::SimulatedAnnealing – optimize a list of numbers according
to a specified cost function.</p>
<hr/>
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">AI::SimulatedAnnealing</span><span class="operator">;</span>
</pre>
<pre>
<span class="variable">$optimized_list</span> <span class="operator">=</span> <span class="variable">anneal</span><span class="operator">(</span><span class="variable">$number_specs</span><span class="operator">,</span> <span class="variable">$cost...
</pre>
<hr/>
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module provides a single public function, <a
href="#anneal"><code>anneal()</code></a>, that optimizes a list of
numbers according to a specified cost function.</p>
<p>Each number to be optimized has a lower bound, an upper bound, and a
precision, where the precision is an integer in the range 0–4
that specifies the number of decimal places to which all instances of
the number will be rounded. The upper bound must be greater than the
lower bound but not greater than 10 to the power of
<code>(4 - p)</code>, where <code>p</code> is the precision.
The lower bound must be not less than <code>-1</code> times the result
of taking 10 to the power of <code>(4 - p)</code>.</p>
<p>A bound that has a higher degree of precision than that specified for
the number to which the bound applies is rounded inward (that is,
downward for an upper bound and upward for a lower bound) to the
nearest instance of the specified precision.</p>
<p>The attributes of a number (bounds and precision) are encapsulated
within a number specification, which is a reference to a hash
containing <code>"LowerBound"</code>,
<code>"UpperBound"</code>, and
<code>"Precision"</code> fields.</p>
<p>The <a href="#anneal"><code>anneal()</code></a> function takes a
reference to an array of number specifications, a cost function, and a
positive integer specifying the number of randomization cycles per
temperature to perform. The <code>anneal()</code> function returns a
reference to an array having the same length as the array of number
specifications. The returned list represents the optimal list of
numbers matching the specified attributes, where "optimal"
means producing the lowest cost.</p>
<p>The cost function must take a reference to an array of numbers that
match the number specifications. The function must return a single
number representing a cost to be minimized.</p>
<p>In order to work efficiently with the varying precisions, the
<code>anneal()</code> function converts each bound to an integer by
multiplying it by 10 to the power of the precision; then the function
performs the temperature reductions and randomization cycles (which
include tests performed via calls to the cost function) on integers in
the resulting ranges. When passing an integer to the cost function or
( run in 0.805 second using v1.01-cache-2.11-cpan-d8267643d1d )