[ < ] | [ > ] | [Contents] | [Index] | [ ? ] |
In the following a possible use of Miniker for optimisation is discussed.
More precisely the use of adjoint and control laws in Miniker are presented.
Optimisation isn’t the only application of these tools, but it is the most
common one. In that case the adjoint may be used to determine the gradient of a
functional to perturbations in the control laws, and an optimisation process
can use this
information to search for the optimum.
Another application of the adjoint is to compute the sensitivity of a
cost function to parameters (the ones declared in the free_parameters:
’ list.
Note that the cost function can be sensitive to probe’s variables, even if these are
uncoupled with standard variables in the forward calculations; this is the case
when minimizing a quadratic distance function between probes (from the model)
and the corresponding measurements.
The code is close transcription of the mathematical calculus described
in
http://www.lmd.jussieu.fr/ZOOM/doc/Adjoint.pdf . It essentialy reverse time and
transpose the four Jacobian matrices: states and transfers are saved in array dimensionned
with maxstep
Fortran parameter.
[ < ] | [ > ] | [Contents] | [Index] | [ ? ] |
In the proposed method, Miniker is run twice, one time forward and then backward to determine the trajectory and the adjoint model. After that the control laws are modified by a program external to Miniker. The same steps are repeated until convergence. More pecisely,
The command law h(t) is given (by an explicit law or taken from a file).
The trajectory is computed in a classical way, with the additionnal computation
of the functional to be optimised, J, prescribed with specific
f_set
macros. The states, transfers and control laws are stored.
The adjoint variable is computed from the last time T backward. The time increment is re-read as it could have changed during the forward simulation. The system is solved by using the same technics as in the forward simulation, but with a negative time step.
Now the command should be corrected. This step isn’t covered here, but, for example, minuit the optimisation tool from the CERN could be used. In order to ease such a use of Miniker, the principal program has to be compiled as a subroutine to be driven by an external program (see Calling the model code).
The functionnal J to be optimised is defined as
Where ψ is the final cost function, l is the integrand cost function and h represents the control laws variations.
The general use of the adjoint model of a system is the determination of the gradient of this J functional to be optimised, with respect to perturbations of the original conditions of the reference trajectory, that is, along its GTLS(6).
[ < ] | [ > ] | [Contents] | [Index] | [ ? ] |
Each control law is associated with one cell or transfer equation, meaning that a command associated with an equation does not appear in any other equation. It is still possible to add commands acting anywhere by defining a transfer equal to that command.
The control laws associated with states are in the ux_com(.)
array,
control laws associated with transfers are in the uy_com(.)
array.
The control laws may be prescribed even when there is no adjoint computed,
nor any optimisation, and they are used during simulation, in which case they will
act as external sources. To enable
the use of commands, the logical flag Zcommand
should be .true.
.
The command can be given either as:
Zlaw
should be set to .true.
in ‘zinit’. The sequence
‘zcmd_law’ should hold
the code filling the ux_com(.)
and uy_com(.)
arrays, as the code
from that sequence is used whenever the control laws are needed.
In that case the files ‘uxcom.data’ and ‘uycom.data’ will
be filled by the command values generated by the function along the trajectory.
For example in the Lotka-Volterra model, the parameter apar
could
be a control variable.
In that case, apar
would be defined as the variable ux_com(1)
,
and either entered as a law
in the sequence ‘zcmd_law’ , either written in the file ‘uxcom.data’
step by step. In that case, there must be a perfect corresponodence between time
of the commands and time of the run.
[ < ] | [ > ] | [Contents] | [Index] | [ ? ] |
First of all the flag zback
should be set to .true.
in order to
allow adjoint model computation:
Zback=.true.;
The two functions cout_Psi
corresponding with the final cost and
cout_l
corresponding with the integrand cost are set up with the
f_set
macros.
This macro defines the final cost function.
f
is a fortran
expression which may be function of cell state variables,
‘eta(1)’…‘eta(np)’, transfers
‘ff(1)’…‘ff(mp)’,
state control laws
‘ux_com(1)’…‘ux_com(np)’, and transfer control laws
‘uy_com(1)’…‘uy_com(mp)’.
This macro defines the integrand cost function.
f
is a fortran
expression which may be function of cell state variables,
‘eta(1)’…‘eta(np)’, transfers
‘ff(1)’…‘ff(mp)’,
state control laws
‘ux_com(1)’…‘ux_com(np)’, and transfer control laws
‘uy_com(1)’…‘uy_com(mp)’.
For example, the following code sets a cost function for the masselottes model:
! Initialisation F_set cout_Psi = eta_move(inode:1); !and f_set cout_l integrand in the functionnal F_set cout_l = 0.;
In that example the functional is reduced to the final value of the first state component. Here, the adjoint vector will correspond to the final sensitivity (at t = 0) of that component (here the first masselotte position) to a perturbation in all initial conditions(7).
The following variables are set during the backward phase, and output in the associated files:
var | file | explanation |
---|---|---|
v_adj(.) | ‘vadj.data’ | adjoint to eta(.) |
w_adj(.) | ‘wadj.data’ | adjoint to ff(.) |
wadj(mp+.) | ‘gradmuj.data’ | adjoint to ff(mp+.) |
graduej(.) | ‘gradxj.data’ | adjoint to ux_com(.) |
gradufj(.) | ‘gradyj.data’ | adjoint to uy_com(.) |
hamilton | ‘hamilton.data’ | time increment, hamiltonian, cost function increment |
[ < ] | [ > ] | [Contents] | [Index] | [ ? ] |
The sensitivity of the cost function to all the parameters given as
arguments of Free_parameters
is computed. For the
predator model the sensitivity of a cost function consisting in
the integral of the predator population with respect with
apar
an cpar
is obtained with a number of parameters
set to 2 in ‘dimetaphi’:
parameter (lp=2);
And the cost function and Free_parameters
list in ‘zinit’:
f_set cout_Psi = eta(2); f_set cout_l = eta(2); Free_parameters: apar,cpar;
apar
and cpar
also have to be given a value.
The result is output in ‘gradpj.data’.
[Contents] | [Index] | [ ? ] |
This document was generated on a sunny day using texi2html.