Salome HOME
Documentation update for DFO
[modules/adao.git] / doc / en / ref_algorithm_ParticleSwarmOptimization.rst
1 ..
2    Copyright (C) 2008-2017 EDF R&D
3
4    This file is part of SALOME ADAO module.
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20    See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22    Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
23
24 .. index:: single: ParticleSwarmOptimization
25 .. _section_ref_algorithm_ParticleSwarmOptimization:
26
27 Calculation algorithm "*ParticleSwarmOptimization*"
28 ---------------------------------------------------
29
30 Description
31 +++++++++++
32
33 This algorithm realizes an estimation of the state of a dynamic system by
34 minimization of a cost function :math:`J` by using a particle swarm. It is a
35 method that doesn't use the derivatives of the cost function. It fall in the
36 same category than the :ref:`section_ref_algorithm_DerivativeFreeOptimization`.
37
38 This is an optimization method allowing for global minimum search of a general
39 error function :math:`J` of type :math:`L^1`, :math:`L^2` or :math:`L^{\infty}`,
40 with or without weights. The default error function is the augmented weighted
41 least squares function, classicaly used in data assimilation.
42
43 Optional and required commands
44 ++++++++++++++++++++++++++++++
45
46 .. index:: single: AlgorithmParameters
47 .. index:: single: Background
48 .. index:: single: BackgroundError
49 .. index:: single: Observation
50 .. index:: single: ObservationError
51 .. index:: single: ObservationOperator
52 .. index:: single: MaximumNumberOfSteps
53 .. index:: single: MaximumNumberOfFunctionEvaluations
54 .. index:: single: NumberOfInsects
55 .. index:: single: SwarmVelocity
56 .. index:: single: GroupRecallRate
57 .. index:: single: QualityCriterion
58 .. index:: single: BoxBounds
59 .. index:: single: SetSeed
60 .. index:: single: StoreSupplementaryCalculations
61
62 The general required commands, available in the editing user interface, are the
63 following:
64
65   Background
66     *Required command*. This indicates the background or initial vector used,
67     previously noted as :math:`\mathbf{x}^b`. Its value is defined as a
68     "*Vector*" or a *VectorSerie*" type object.
69
70   BackgroundError
71     *Required command*. This indicates the background error covariance matrix,
72     previously noted as :math:`\mathbf{B}`. Its value is defined as a "*Matrix*"
73     type object, a "*ScalarSparseMatrix*" type object, or a
74     "*DiagonalSparseMatrix*" type object.
75
76   Observation
77     *Required command*. This indicates the observation vector used for data
78     assimilation or optimization, previously noted as :math:`\mathbf{y}^o`. It
79     is defined as a "*Vector*" or a *VectorSerie* type object.
80
81   ObservationError
82     *Required command*. This indicates the observation error covariance matrix,
83     previously noted as :math:`\mathbf{R}`. It is defined as a "*Matrix*" type
84     object, a "*ScalarSparseMatrix*" type object, or a "*DiagonalSparseMatrix*"
85     type object.
86
87   ObservationOperator
88     *Required command*. This indicates the observation operator, previously
89     noted :math:`H`, which transforms the input parameters :math:`\mathbf{x}` to
90     results :math:`\mathbf{y}` to be compared to observations
91     :math:`\mathbf{y}^o`. Its value is defined as a "*Function*" type object or
92     a "*Matrix*" type one. In the case of "*Function*" type, different
93     functional forms can be used, as described in the section
94     :ref:`section_ref_operator_requirements`. If there is some control :math:`U`
95     included in the observation, the operator has to be applied to a pair
96     :math:`(X,U)`.
97
98 The general optional commands, available in the editing user interface, are
99 indicated in :ref:`section_ref_assimilation_keywords`. Moreover, the parameters
100 of the command "*AlgorithmParameters*" allows to choose the specific options,
101 described hereafter, of the algorithm. See
102 :ref:`section_ref_options_Algorithm_Parameters` for the good use of this
103 command.
104
105 The options of the algorithm are the following:
106
107   MaximumNumberOfSteps
108     This key indicates the maximum number of iterations allowed for iterative
109     optimization. The default is 50, which is an arbitrary limit. It is then
110     recommended to adapt this parameter to the needs on real problems.
111
112     Example : ``{"MaximumNumberOfSteps":100}``
113
114   MaximumNumberOfFunctionEvaluations
115     This key indicates the maximum number of evaluation of the cost function to
116     be optimized. The default is 15000, which is an arbitrary limit. It is then
117     recommended to adapt this parameter to the needs on real problems. For some
118     optimizers, the effective number of function evaluations can be slightly
119     different of the limit due to algorithm internal control requirements.
120
121     Example : ``{"MaximumNumberOfFunctionEvaluations":50}``
122
123   NumberOfInsects
124     This key indicates the number of insects or particles in the swarm. The
125     default is 100, which is a usual default for this algorithm.
126
127     Example : ``{"NumberOfInsects":100}``
128
129   SwarmVelocity
130     This key indicates the part of the insect velocity which is imposed by the 
131     swarm. It is a positive floating point value. The default value is 1.
132
133     Example : ``{"SwarmVelocity":1.}``
134
135   GroupRecallRate
136     This key indicates the recall rate at the best swarm insect. It is a
137     floating point value between 0 and 1. The default value is 0.5.
138
139     Example : ``{"GroupRecallRate":0.5}``
140
141   QualityCriterion
142     This key indicates the quality criterion, minimized to find the optimal
143     state estimate. The default is the usual data assimilation criterion named
144     "DA", the augmented weighted least squares. The possible criteria has to be
145     in the following list, where the equivalent names are indicated by the sign
146     "=": ["AugmentedWeightedLeastSquares"="AWLS"="DA",
147     "WeightedLeastSquares"="WLS", "LeastSquares"="LS"="L2",
148     "AbsoluteValue"="L1", "MaximumError"="ME"].
149
150     Example : ``{"QualityCriterion":"DA"}``
151
152   BoxBounds
153     This key allows to define upper and lower bounds for *increments* on every
154     state variable being optimized (and not on state variables themselves).
155     Bounds have to be given by a list of list of pairs of lower/upper bounds for
156     each increment on variable, with extreme values every time there is no bound
157     (``None`` is not allowed when there is no bound). This key is required and
158     there is no default values.
159
160     Example : ``{"BoxBounds":[[-0.5,0.5], [0.01,2.], [0.,1.e99], [-1.e99,1.e99]]}``
161
162   SetSeed
163     This key allow to give an integer in order to fix the seed of the random
164     generator used to generate the ensemble. A convenient value is for example
165     1000. By default, the seed is left uninitialized, and so use the default
166     initialization from the computer.
167
168     Example : ``{"SetSeed":1000}``
169
170   StoreSupplementaryCalculations
171     This list indicates the names of the supplementary variables that can be
172     available at the end of the algorithm. It involves potentially costly
173     calculations or memory consumptions. The default is a void list, none of
174     these variables being calculated and stored by default. The possible names
175     are in the following list: ["BMA", "CostFunctionJ", "CostFunctionJb",
176     "CostFunctionJo", "CurrentState", "OMA", "OMB", "Innovation",
177     "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState",
178     "SimulatedObservationAtOptimum"].
179
180     Example : ``{"StoreSupplementaryCalculations":["BMA", "Innovation"]}``
181
182 Information and variables available at the end of the algorithm
183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
184
185 At the output, after executing the algorithm, there are variables and
186 information originating from the calculation. The description of
187 :ref:`section_ref_output_variables` show the way to obtain them by the method
188 named ``get`` of the variable "*ADD*" of the post-processing. The input
189 variables, available to the user at the output in order to facilitate the
190 writing of post-processing procedures, are described in the
191 :ref:`subsection_r_o_v_Inventaire`.
192
193 The unconditional outputs of the algorithm are the following:
194
195   Analysis
196     *List of vectors*. Each element is an optimal state :math:`\mathbf{x}*` in
197     optimization or an analysis :math:`\mathbf{x}^a` in data assimilation.
198
199     Example : ``Xa = ADD.get("Analysis")[-1]``
200
201   CostFunctionJ
202     *List of values*. Each element is a value of the error function :math:`J`.
203
204     Example : ``J = ADD.get("CostFunctionJ")[:]``
205
206   CostFunctionJb
207     *List of values*. Each element is a value of the error function :math:`J^b`,
208     that is of the background difference part.
209
210     Example : ``Jb = ADD.get("CostFunctionJb")[:]``
211
212   CostFunctionJo
213     *List of values*. Each element is a value of the error function :math:`J^o`,
214     that is of the observation difference part.
215
216     Example : ``Jo = ADD.get("CostFunctionJo")[:]``
217
218 The conditional outputs of the algorithm are the following:
219
220   BMA
221     *List of vectors*. Each element is a vector of difference between the
222     background and the optimal state.
223
224     Example : ``bma = ADD.get("BMA")[-1]``
225
226   CurrentState
227     *List of vectors*. Each element is a usual state vector used during the
228     optimization algorithm procedure.
229
230     Example : ``Xs = ADD.get("CurrentState")[:]``
231
232   Innovation
233     *List of vectors*. Each element is an innovation vector, which is in static
234     the difference between the optimal and the background, and in dynamic the
235     evolution increment.
236
237     Example : ``d = ADD.get("Innovation")[-1]``
238
239   OMA
240     *List of vectors*. Each element is a vector of difference between the
241     observation and the optimal state in the observation space.
242
243     Example : ``oma = ADD.get("OMA")[-1]``
244
245   OMB
246     *List of vectors*. Each element is a vector of difference between the
247     observation and the background state in the observation space.
248
249     Example : ``omb = ADD.get("OMB")[-1]``
250
251   SimulatedObservationAtBackground
252     *List of vectors*. Each element is a vector of observation simulated from
253     the background :math:`\mathbf{x}^b`.
254
255     Example : ``hxb = ADD.get("SimulatedObservationAtBackground")[-1]``
256
257   SimulatedObservationAtCurrentState
258     *List of vectors*. Each element is an observed vector at the current state,
259     that is, in the observation space.
260
261     Example : ``Ys = ADD.get("SimulatedObservationAtCurrentState")[-1]``
262
263   SimulatedObservationAtOptimum
264     *List of vectors*. Each element is a vector of observation simulated from
265     the analysis or optimal state :math:`\mathbf{x}^a`.
266
267     Example : ``hxa = ADD.get("SimulatedObservationAtOptimum")[-1]``
268
269 See also
270 ++++++++
271
272 References to other sections:
273   - :ref:`section_ref_algorithm_DerivativeFreeOptimization`
274
275 Bibliographical references:
276   - [WikipediaPSO]_