dynare/matlab/doc/asamin.html

364 lines
20 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of asamin</title>
<meta name="keywords" content="asamin">
<meta name="description" content="ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt; <a href="index.html">.</a> &gt; asamin.m</div>
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for .&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
<h1>asamin
&nbsp;&nbsp;<img src="../{MEXTYPE}.png" alt="Windows" border="0" title="Windows"></h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>This is a script file. </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)
ASAMIN is a matlab gateway function to Lester Ingber's Adaptive
Simulated Annealing (ASA)
Copyright (c) 1999-2001 Shinichi Sakata. All Rights Reserved.
$Id: asamin.m,v 1.1.2.1 2004/03/27 14:41:06 michel Exp $
Usage:
asamin ('set')
lists the current value of each option.
asamin ('set', opt_name)
shows the current value of the option given by a character string
opt_name; e.g.,
asamin ('set', 'seed')
asamin ('set', opt_name, opt_value)
set the value opt_value to the option opt_name; e.g.,
asamin ('set', 'seed', 654342)
asamin ('set', 'asa_out_file', 'example.log')
The valid options in these commands are:
rand_seed
test_in_cost_func
use_rejected_cost
asa_out_file
limit_acceptances
limit_generated
limit_invalid
accepted_to_generated_ratio
cost_precision
maximum_cost_repeat
number_cost_samples
temperature_ratio_scale
cost_parameter_scale
temperature_anneal_scale
include_integer_parameters
user_initial_parameters
sequential_parameters
initial_parameter_temperature
acceptance_frequency_modulus
generated_frequency_modulus
reanneal_cost
reanneal_parameters
delta_x
rand_seed is the seed of the random number generation in ASA.
If test_in_cost_func is set to zero, the cost function should
simply return the value of the objective function. When
test_in_cost_func is set to one, asamin () calls the cost
function with a threshold value as well as the parameter
value. The cost function needs to judge if the value of the cost
function exceeds the threshold as well as compute the value of
the cost function when asamin () requires. (See COST FUNCTION
below for details.)
All other items but use_rejected_cost belong to structure
USER_OPTIONS in ASA. See ASA_README in the ASA package for
details. The default value of use_rejected_cost is zero. If you
set this option to one, ASA uses the current cost value to
compute certain indices, even if the current state is rejected by
the user cost function, provided that the current cost value is
lower than the cost value of the past best state. (See COST
FUNCTION below about the user cost function.)
asamin ('reset')
resets all option values to the hard-coded default values.
[fstar,xstar,grad,hessian,state] = ...
asamin ('minimize', func, xinit, xmin, xmax, xtype,...
parm1, parm2, ...)
minimizes the cost function func (also see COST FUNCTION below).
The argument xinit specifies the initial value of the arguments
of the cost function. Each element of the vectors xmin and xmax
specify the lower and upper bounds of the corresponding
argument. The vector xtype indicates the types of the
arguments. If xtype(i) is -1 if the i'th argument is real;
xtype(i) is 1 if the i'th argument is integer. If this argument
should be ignored in reannealing, multiply the corresponding
element of xtype by 2 so that the element is 2 or -2. All
parameters following xtype are optional and simply passed to the
cost function each time the cost function is called.
This way of calling asamin returns the following values:
fstar
The value of the objective function at xstar.
xstar
The argument vector at the exit from the ASA routine. If things go
well, xstar should be the minimizer of &quot;func&quot;.
grad
The gradient of &quot;func&quot; at xstar.
hessian
The Hessian of &quot;func&quot; at xstar.
state
The vector containing the information on the exit state.
state(1) is the exit_code, and state(2) is the cost flag. See
ASA_README for details.
COST FUNCTION
If test_in_cost_func is set to zero, asamin () calls the &quot;cost
function&quot; (say, cost_func) with one argument, say x (the real cost
function is evaluated at this point). Cost_func is expected to
return the value of the objective function and cost_flag, the
latter of which must be zero if any constraint (if any) is
violated; otherwise one.
When test_in_cost_func is equal to one, asamin () calls the &quot;cost
function&quot; (say, cost_func) with three arguments, say, x (at which
the real cost function is evaluated), critical_cost_value, and
no_test_flag. Asamin expects cost_func to return three scalar
values, say, cost_value, cost_flag, and user_acceptance_flag in the
following manner.
1. The function cost_func first checks if x satisfies the
constraints of the minimization problem. If any of the
constraints is not satisfied, cost_func sets zero to cost_flag
and return. (user_acceptance_flag and cost_value will not be used
by asamin () in this case.) If all constraints are satisfied, set
one to cost_flag, and proceed to the next step.
2. If asamin () calls cost_func with no_test_flag==1, cost_func
must compute the value of the cost function, set it to cost_value
and return. When no_test_flag==0, cost_func is expected to judge
if the value of the cost function is greater than
critical_cost_value. If the value of the cost function is found
greater than critical_cost_value, cost_func must set zero to
user_acceptance_flag and return. (asamin () will not use
cost_value in this case.) On the other hand, if the value of the
cost function is found no greater than critical_cost_value,
cost_func must compute the cost function at x, set it to
cost_value, and set one to user_acceptance_flag.
Remark: To understand the usefulness of test_in_cost_func == 1,
note that it is sometimes easier to check if the value of the cost
function is greater than critical_cost_value than compute the value
of the cost function. For example, suppose that the cost function g
is implicitly defined by an equation f(g(x),x)=0, where f is
strictly increasing in the first argument, and evaluation of g(x)
is computationally expensive (e.g., requiring an iterative method
to find a solution to f(y,x)=0). But we can easily show that
f(critical_cost_value,x) &lt; 0 if and only if g(x) &gt;
critical_cost_value. We can judge if g(x) &gt; critical_cost_value by
computing f(critical_cost_value,x). The value of g(x) is not
necessary.</pre></div>
<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
<!-- crossreference -->
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">% ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)</span>
0002 <span class="comment">%</span>
0003 <span class="comment">% ASAMIN is a matlab gateway function to Lester Ingber's Adaptive</span>
0004 <span class="comment">% Simulated Annealing (ASA)</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% Copyright (c) 1999-2001 Shinichi Sakata. All Rights Reserved.</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% $Id: asamin.m,v 1.1.2.1 2004/03/27 14:41:06 michel Exp $</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% Usage:</span>
0011 <span class="comment">%</span>
0012 <span class="comment">% asamin ('set')</span>
0013 <span class="comment">%</span>
0014 <span class="comment">% lists the current value of each option.</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% asamin ('set', opt_name)</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% shows the current value of the option given by a character string</span>
0019 <span class="comment">% opt_name; e.g.,</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% asamin ('set', 'seed')</span>
0022 <span class="comment">%</span>
0023 <span class="comment">% asamin ('set', opt_name, opt_value)</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% set the value opt_value to the option opt_name; e.g.,</span>
0026 <span class="comment">%</span>
0027 <span class="comment">% asamin ('set', 'seed', 654342)</span>
0028 <span class="comment">% asamin ('set', 'asa_out_file', 'example.log')</span>
0029 <span class="comment">%</span>
0030 <span class="comment">% The valid options in these commands are:</span>
0031 <span class="comment">%</span>
0032 <span class="comment">% rand_seed</span>
0033 <span class="comment">% test_in_cost_func</span>
0034 <span class="comment">% use_rejected_cost</span>
0035 <span class="comment">% asa_out_file</span>
0036 <span class="comment">% limit_acceptances</span>
0037 <span class="comment">% limit_generated</span>
0038 <span class="comment">% limit_invalid</span>
0039 <span class="comment">% accepted_to_generated_ratio</span>
0040 <span class="comment">% cost_precision</span>
0041 <span class="comment">% maximum_cost_repeat</span>
0042 <span class="comment">% number_cost_samples</span>
0043 <span class="comment">% temperature_ratio_scale</span>
0044 <span class="comment">% cost_parameter_scale</span>
0045 <span class="comment">% temperature_anneal_scale</span>
0046 <span class="comment">% include_integer_parameters</span>
0047 <span class="comment">% user_initial_parameters</span>
0048 <span class="comment">% sequential_parameters</span>
0049 <span class="comment">% initial_parameter_temperature</span>
0050 <span class="comment">% acceptance_frequency_modulus</span>
0051 <span class="comment">% generated_frequency_modulus</span>
0052 <span class="comment">% reanneal_cost</span>
0053 <span class="comment">% reanneal_parameters</span>
0054 <span class="comment">% delta_x</span>
0055 <span class="comment">%</span>
0056 <span class="comment">% rand_seed is the seed of the random number generation in ASA.</span>
0057 <span class="comment">%</span>
0058 <span class="comment">% If test_in_cost_func is set to zero, the cost function should</span>
0059 <span class="comment">% simply return the value of the objective function. When</span>
0060 <span class="comment">% test_in_cost_func is set to one, asamin () calls the cost</span>
0061 <span class="comment">% function with a threshold value as well as the parameter</span>
0062 <span class="comment">% value. The cost function needs to judge if the value of the cost</span>
0063 <span class="comment">% function exceeds the threshold as well as compute the value of</span>
0064 <span class="comment">% the cost function when asamin () requires. (See COST FUNCTION</span>
0065 <span class="comment">% below for details.)</span>
0066 <span class="comment">%</span>
0067 <span class="comment">% All other items but use_rejected_cost belong to structure</span>
0068 <span class="comment">% USER_OPTIONS in ASA. See ASA_README in the ASA package for</span>
0069 <span class="comment">% details. The default value of use_rejected_cost is zero. If you</span>
0070 <span class="comment">% set this option to one, ASA uses the current cost value to</span>
0071 <span class="comment">% compute certain indices, even if the current state is rejected by</span>
0072 <span class="comment">% the user cost function, provided that the current cost value is</span>
0073 <span class="comment">% lower than the cost value of the past best state. (See COST</span>
0074 <span class="comment">% FUNCTION below about the user cost function.)</span>
0075 <span class="comment">%</span>
0076 <span class="comment">% asamin ('reset')</span>
0077 <span class="comment">% resets all option values to the hard-coded default values.</span>
0078 <span class="comment">%</span>
0079 <span class="comment">% [fstar,xstar,grad,hessian,state] = ...</span>
0080 <span class="comment">% asamin ('minimize', func, xinit, xmin, xmax, xtype,...</span>
0081 <span class="comment">% parm1, parm2, ...)</span>
0082 <span class="comment">%</span>
0083 <span class="comment">% minimizes the cost function func (also see COST FUNCTION below).</span>
0084 <span class="comment">% The argument xinit specifies the initial value of the arguments</span>
0085 <span class="comment">% of the cost function. Each element of the vectors xmin and xmax</span>
0086 <span class="comment">% specify the lower and upper bounds of the corresponding</span>
0087 <span class="comment">% argument. The vector xtype indicates the types of the</span>
0088 <span class="comment">% arguments. If xtype(i) is -1 if the i'th argument is real;</span>
0089 <span class="comment">% xtype(i) is 1 if the i'th argument is integer. If this argument</span>
0090 <span class="comment">% should be ignored in reannealing, multiply the corresponding</span>
0091 <span class="comment">% element of xtype by 2 so that the element is 2 or -2. All</span>
0092 <span class="comment">% parameters following xtype are optional and simply passed to the</span>
0093 <span class="comment">% cost function each time the cost function is called.</span>
0094 <span class="comment">%</span>
0095 <span class="comment">% This way of calling asamin returns the following values:</span>
0096 <span class="comment">%</span>
0097 <span class="comment">% fstar</span>
0098 <span class="comment">% The value of the objective function at xstar.</span>
0099 <span class="comment">% xstar</span>
0100 <span class="comment">% The argument vector at the exit from the ASA routine. If things go</span>
0101 <span class="comment">% well, xstar should be the minimizer of &quot;func&quot;.</span>
0102 <span class="comment">% grad</span>
0103 <span class="comment">% The gradient of &quot;func&quot; at xstar.</span>
0104 <span class="comment">% hessian</span>
0105 <span class="comment">% The Hessian of &quot;func&quot; at xstar.</span>
0106 <span class="comment">% state</span>
0107 <span class="comment">% The vector containing the information on the exit state.</span>
0108 <span class="comment">% state(1) is the exit_code, and state(2) is the cost flag. See</span>
0109 <span class="comment">% ASA_README for details.</span>
0110 <span class="comment">%</span>
0111 <span class="comment">%</span>
0112 <span class="comment">%</span>
0113 <span class="comment">% COST FUNCTION</span>
0114 <span class="comment">%</span>
0115 <span class="comment">% If test_in_cost_func is set to zero, asamin () calls the &quot;cost</span>
0116 <span class="comment">% function&quot; (say, cost_func) with one argument, say x (the real cost</span>
0117 <span class="comment">% function is evaluated at this point). Cost_func is expected to</span>
0118 <span class="comment">% return the value of the objective function and cost_flag, the</span>
0119 <span class="comment">% latter of which must be zero if any constraint (if any) is</span>
0120 <span class="comment">% violated; otherwise one.</span>
0121 <span class="comment">%</span>
0122 <span class="comment">% When test_in_cost_func is equal to one, asamin () calls the &quot;cost</span>
0123 <span class="comment">% function&quot; (say, cost_func) with three arguments, say, x (at which</span>
0124 <span class="comment">% the real cost function is evaluated), critical_cost_value, and</span>
0125 <span class="comment">% no_test_flag. Asamin expects cost_func to return three scalar</span>
0126 <span class="comment">% values, say, cost_value, cost_flag, and user_acceptance_flag in the</span>
0127 <span class="comment">% following manner.</span>
0128 <span class="comment">%</span>
0129 <span class="comment">% 1. The function cost_func first checks if x satisfies the</span>
0130 <span class="comment">% constraints of the minimization problem. If any of the</span>
0131 <span class="comment">% constraints is not satisfied, cost_func sets zero to cost_flag</span>
0132 <span class="comment">% and return. (user_acceptance_flag and cost_value will not be used</span>
0133 <span class="comment">% by asamin () in this case.) If all constraints are satisfied, set</span>
0134 <span class="comment">% one to cost_flag, and proceed to the next step.</span>
0135 <span class="comment">%</span>
0136 <span class="comment">% 2. If asamin () calls cost_func with no_test_flag==1, cost_func</span>
0137 <span class="comment">% must compute the value of the cost function, set it to cost_value</span>
0138 <span class="comment">% and return. When no_test_flag==0, cost_func is expected to judge</span>
0139 <span class="comment">% if the value of the cost function is greater than</span>
0140 <span class="comment">% critical_cost_value. If the value of the cost function is found</span>
0141 <span class="comment">% greater than critical_cost_value, cost_func must set zero to</span>
0142 <span class="comment">% user_acceptance_flag and return. (asamin () will not use</span>
0143 <span class="comment">% cost_value in this case.) On the other hand, if the value of the</span>
0144 <span class="comment">% cost function is found no greater than critical_cost_value,</span>
0145 <span class="comment">% cost_func must compute the cost function at x, set it to</span>
0146 <span class="comment">% cost_value, and set one to user_acceptance_flag.</span>
0147 <span class="comment">%</span>
0148 <span class="comment">% Remark: To understand the usefulness of test_in_cost_func == 1,</span>
0149 <span class="comment">% note that it is sometimes easier to check if the value of the cost</span>
0150 <span class="comment">% function is greater than critical_cost_value than compute the value</span>
0151 <span class="comment">% of the cost function. For example, suppose that the cost function g</span>
0152 <span class="comment">% is implicitly defined by an equation f(g(x),x)=0, where f is</span>
0153 <span class="comment">% strictly increasing in the first argument, and evaluation of g(x)</span>
0154 <span class="comment">% is computationally expensive (e.g., requiring an iterative method</span>
0155 <span class="comment">% to find a solution to f(y,x)=0). But we can easily show that</span>
0156 <span class="comment">% f(critical_cost_value,x) &lt; 0 if and only if g(x) &gt;</span>
0157 <span class="comment">% critical_cost_value. We can judge if g(x) &gt; critical_cost_value by</span>
0158 <span class="comment">% computing f(critical_cost_value,x). The value of g(x) is not</span>
0159 <span class="comment">% necessary.</span>
0160 <span class="comment">%</span></pre></div>
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>