.. [Nelder65] Nelder J. A., Mead R., *A simplex method for function minimization*, The Computer Journal, 7, pp.308-313, 1965
+.. [NumPy20] Harris C.R. et al., *Array programming with NumPy*, Nature 585, pp.357–362, 2020, https://numpy.org/
+
.. [Powell64] Powell M. J. D., *An efficient method for finding the minimum of a function of several variables without calculating derivatives*, Computer Journal, 7(2), pp.155-162, 1964
.. [Powell94] Powell M. J. D., *A direct search optimization method that models the objective and constraint functions by linear interpolation*, in Advances in Optimization and Numerical Analysis, eds. S. Gomez and J-P Hennart, Kluwer Academic (Dordrecht), pp. 51-67, 1994
-.. [Powell98] Powell M. J. D., *Direct search algorithms for optimization calculations*, Acta Numerica 7, 287-336, 1998
+.. [Powell98] Powell M. J. D., *Direct search algorithms for optimization calculations*, Acta Numerica 7, pp.287-336, 1998
.. [Powell04] Powell M. J. D., *The NEWUOA software for unconstrained optimization without derivatives*, Proc. 40th Workshop on Large Scale Nonlinear Optimization, Erice, Italy, 2004
.. [SalomeMeca] *Salome_Meca and Code_Aster, Analysis of Structures and Thermomechanics for Studies & Research*, http://www.code-aster.org/
+.. [SciPy20] Virtanen P. et al., *SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python*, Nature Methods, 17(3), pp.261-272, 2020, https://scipy.org/
+
.. [Storn97] Storn R., Price, K., *Differential Evolution – A Simple and Efficient Heuristic for global Optimization over Continuous Spaces*, Journal of Global Optimization, 11(1), pp.341-359, 1997
.. [Tarantola87] Tarantola A., *Inverse Problem: Theory Methods for Data Fitting and Parameter Estimation*, Elsevier, 1987
.. include:: snippets/MaximumNumberOfLocations.rst
+.. include:: snippets/NameOfLocations.rst
+
.. include:: snippets/SampleAsExplicitHyperCube.rst
.. include:: snippets/SampleAsIndependantRandomVariables.rst
algorithm*"): [
"EnsembleOfSimulations",
"EnsembleOfStates",
+ "ExcludedPoints",
"OptimalPoints",
"ReducedBasis",
"Residus",
.. include:: snippets/EnsembleOfStates.rst
+.. include:: snippets/ExcludedPoints.rst
+
.. include:: snippets/OptimalPoints.rst
.. include:: snippets/ReducedBasis.rst
.. index:: single: ExcludeLocations
ExcludeLocations
- *List of integers*. This key specifies the list of points in the state vector
- excluded from the optimal search. The default value is an empty list.
- Important: the numbering of these excluded points must be identical to the
- one implicitly adopted in the states provided by the "*EnsembleOfSnapshots*"
- key.
+ *List of integers or names*. This key specifies the list of points in the
+ state vector excluded from the optimal search. The default value is an empty
+ list. The list can contain either **indices of points** (in the implicit
+ internal order of a state vector) or **names of points** (which must exist in
+ the list of position names indicated by the keyword "*NameOfLocations*" in
+ order to be excluded). By default, if the elements of the list are strings
+ that can be assimilated to indices, then these strings are indeed considered
+ as indices and not names.
+
+ Important notice: the numbering of these excluded points must be identical to
+ that adopted, implicitly and imperatively, by the variables constituting a
+ state considered arbitrarily in one-dimensional form.
Example :
- ``{"ExcludeLocations":[3, 125, 286]}``
+ ``{"ExcludeLocations":[3, 125, 286]}`` or ``{"ExcludeLocations":["Point3", "XgTaC"]}``
--- /dev/null
+.. index:: single: ExcludedPoints
+
+ExcludedPoints
+ *List of integer series*. Each element is a series, containing the indices of
+ the points excluded from the optimal search, according to the order of the
+ variables of a state vector considered arbitrarily in one-dimensional form.
+
+ Example :
+ ``mp = ADD.get("ExcludedPoints")[-1]``
Python, 3.6.5, 3.10.9
Numpy, 1.14.3, 1.24.2
Scipy, 1.1.0, 1.10.0
- MatplotLib, 2.2.2, 3.6.3
+ MatplotLib, 2.2.2, 3.7.0
GnuplotPy, 1.8, 1.8
NLopt, 2.4.2, 2.7.1
--- /dev/null
+.. index:: single: NameOfLocations
+
+NameOfLocations
+ *List of names*. This key indicates an explicit list of variable names or
+ positions, positioned as in a state vector considered arbitrarily in
+ one-dimensional form. The default value is an empty list. To be used, this
+ list must have the same length as that of a physical state.
+
+ Important notice: the order of the names is, implicitly and imperatively, the
+ same as that of the variables constituting a state considered arbitrarily in
+ one-dimensional form.
+
+ Example :
+ ``{"NameOfLocations":["Point3", "Location42", "Position125", "XgTaC"]}``
Versions of ADAO compatibility with support tools
-------------------------------------------------
+The module benefits greatly from the **Python environment** [Python]_ and the
+multiple features of this language, from the scientific calculation tools
+included in **NumPy** [NumPy20]_, **SciPy** [SciPy20]_, **NLopt** [Johnson08]_
+or in the tools that can be reached with them, and from the numerous
+capabilities of **SALOME** [Salome]_ when used in combination.
+
.. include:: snippets/ModuleValidation.rst
.. include:: snippets/ModuleCompatibility.rst
.. [Nelder65] Nelder J. A., Mead R., *A simplex method for function minimization*, The Computer Journal, 7, pp.308-313, 1965
+.. [NumPy20] Harris C.R. et al., *Array programming with NumPy*, Nature 585, pp.357–362, 2020, https://numpy.org/
+
.. [Powell64] Powell M. J. D., *An efficient method for finding the minimum of a function of several variables without calculating derivatives*, Computer Journal, 7(2), pp.155-162, 1964
.. [Powell94] Powell M. J. D., *A direct search optimization method that models the objective and constraint functions by linear interpolation*, in Advances in Optimization and Numerical Analysis, eds. S. Gomez and J-P Hennart, Kluwer Academic (Dordrecht), pp. 51-67, 1994
-.. [Powell98] Powell M. J. D., *Direct search algorithms for optimization calculations*, Acta Numerica 7, 287-336, 1998
+.. [Powell98] Powell M. J. D., *Direct search algorithms for optimization calculations*, Acta Numerica 7, pp.287-336, 1998
.. [Powell04] Powell M. J. D., *The NEWUOA software for unconstrained optimization without derivatives*, Proc. 40th Workshop on Large Scale Nonlinear Optimization, Erice, Italy, 2004
.. [SalomeMeca] *Salome_Meca et Code_Aster, Analyse des Structures et Thermomécanique pour les Etudes et la Recherche*, http://www.code-aster.org/
+.. [SciPy20] Virtanen P. et al., *SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python*, Nature Methods, 17(3), pp.261-272, 2020, https://scipy.org/
+
.. [Storn97] Storn R., Price, K., *Differential Evolution – A Simple and Efficient Heuristic for global Optimization over Continuous Spaces*, Journal of Global Optimization, 11(1), pp.341-359, 1997
.. [Tarantola87] Tarantola A., *Inverse Problem: Theory Methods for Data Fitting and Parameter Estimation*, Elsevier, 1987
.. include:: snippets/MaximumNumberOfLocations.rst
+.. include:: snippets/NameOfLocations.rst
+
.. include:: snippets/SampleAsExplicitHyperCube.rst
.. include:: snippets/SampleAsIndependantRandomVariables.rst
"*Informations et variables disponibles à la fin de l'algorithme*") : [
"EnsembleOfSimulations",
"EnsembleOfStates",
+ "ExcludedPoints",
"OptimalPoints",
"ReducedBasis",
"Residus",
.. include:: snippets/EnsembleOfStates.rst
+.. include:: snippets/ExcludedPoints.rst
+
.. include:: snippets/OptimalPoints.rst
.. include:: snippets/ReducedBasis.rst
.. index:: single: ExcludeLocations
ExcludeLocations
- *Liste d'entiers*. Cette clé indique la liste des points du vecteur d'état
- exclus de la recherche optimale. La valeur par défaut est une liste vide.
- Important : la numérotation de ces points exclus doit être identique à celle
- qui est adoptée implicitement dans les états fournis par la clé
- "*EnsembleOfSnapshots*".
+ *Liste d'entiers ou de noms*. Cette clé indique la liste des points du
+ vecteur d'état exclus de la recherche optimale. La valeur par défaut est une
+ liste vide. La liste peut contenir soit des **indices de points** (dans
+ l'ordre interne implicite d'un vecteur d'état), soit des **noms des points**
+ (qui doivent exister dans la liste des noms de positions indiquées par le
+ mot-clé "*NameOfLocations*" pour pouvoir être exclus). Par défaut, si les
+ éléments de la liste sont des chaînes de caractères assimilables à des
+ indices, alors ces chaînes sont bien considérées comme des indices et pas des
+ noms.
+
+ Rappel important : la numérotation de ces points exclus doit être identique à
+ celle qui est adoptée, implicitement et impérativement, par les variables
+ constituant un état considéré arbitrairement sous forme unidimensionnelle.
Exemple :
- ``{"ExcludeLocations":[3, 125, 286]}``
+ ``{"ExcludeLocations":[3, 125, 286]}`` ou ``{"ExcludeLocations":["Point3", "XgTaC"]}``
--- /dev/null
+.. index:: single: ExcludedPoints
+
+ExcludedPoints
+ *Liste de série d'entiers*. Chaque élément est une série, contenant les
+ indices des points exclus de la recherche optimale, selon l'ordre des
+ variables d'un vecteur d'état considéré arbitrairement sous forme
+ unidimensionnelle.
+
+ Exemple :
+ ``mp = ADD.get("ExcludedPoints")[-1]``
Python, 3.6.5, 3.10.9
Numpy, 1.14.3, 1.24.2
Scipy, 1.1.0, 1.10.0
- MatplotLib, 2.2.2, 3.6.3
+ MatplotLib, 2.2.2, 3.7.0
GnuplotPy, 1.8, 1.8
NLopt, 2.4.2, 2.7.1
--- /dev/null
+.. index:: single: NameOfLocations
+
+NameOfLocations
+ *Liste de noms*. Cette clé indique une liste explicite de noms des variables
+ ou de positions, positionnées comme dans un vecteur d'état considéré
+ arbitrairement sous forme unidimensionnelle. La valeur par défaut est une
+ liste vide. Pour être utilisée, cette liste doit avoir la même longueur que
+ celle d'un état physique.
+
+ Rappel important : l'ordre des noms est, implicitement et impérativement, le
+ même que celui des variables constituant un état considéré arbitrairement
+ sous forme unidimensionnelle.
+
+ Exemple :
+ ``{"NameOfLocations":["Point3", "Location42", "Position125", "XgTaC"]}``
Versions de compatibilité d'ADAO avec les outils support
--------------------------------------------------------
+Le module ADAO bénéficie largement de l'**environnement Python** [Python]_ et
+des nombreuses possibilités de ce langage, des outils de calcul scientifique
+inclus dans **NumPy** [NumPy20]_, **SciPy** [SciPy20]_, **NLopt** [Johnson08]_
+ou dans les outils atteignables grâce à eux, et des nombreuses capacités de
+**SALOME** [Salome]_ lorsqu'il est utilisé en association.
+
.. include:: snippets/ModuleValidation.rst
.. include:: snippets/ModuleCompatibility.rst
# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
__doc__ = """
- EIM
+ EIM & lcEIM
"""
__author__ = "Jean-Philippe ARGAUD"
import numpy
import daCore.Persistence
+from daCore.NumericObjects import FindIndexesFromNames
# ==============================================================================
def EIM_offline(selfA, EOS = None, Verbose = False):
# __EOS = numpy.asarray(EOS).T
else:
raise ValueError("EnsembleOfSnapshots has to be an array/matrix (each column being a vector) or a list/tuple (each element being a vector).")
+ __dimS, __nbmS = __EOS.shape
#
if selfA._parameters["ErrorNorm"] == "L2":
MaxNormByColumn = MaxL2NormByColumn
if __LcCsts and "ExcludeLocations" in selfA._parameters:
__ExcludedMagicPoints = selfA._parameters["ExcludeLocations"]
else:
- __ExcludedMagicPoints = []
+ __ExcludedMagicPoints = ()
+ if __LcCsts and "NameOfLocations" in selfA._parameters:
+ if isinstance(selfA._parameters["NameOfLocations"], (list, numpy.ndarray, tuple)) and len(selfA._parameters["NameOfLocations"]) == __dimS:
+ __NameOfLocations = selfA._parameters["NameOfLocations"]
+ else:
+ __NameOfLocations = ()
+ else:
+ __NameOfLocations = ()
if __LcCsts and len(__ExcludedMagicPoints) > 0:
+ __ExcludedMagicPoints = FindIndexesFromNames( __NameOfLocations, __ExcludedMagicPoints )
__ExcludedMagicPoints = numpy.ravel(numpy.asarray(__ExcludedMagicPoints, dtype=int))
__IncludedMagicPoints = numpy.setdiff1d(
numpy.arange(__EOS.shape[0]),
else:
__IncludedMagicPoints = []
#
- __dimS, __nbmS = __EOS.shape
if "MaximumNumberOfLocations" in selfA._parameters and "MaximumRBSize" in selfA._parameters:
selfA._parameters["MaximumRBSize"] = min(selfA._parameters["MaximumNumberOfLocations"],selfA._parameters["MaximumRBSize"])
elif "MaximumNumberOfLocations" in selfA._parameters:
selfA.StoredVariables["ReducedBasis"].store( __Q )
if selfA._toStore("Residus"):
selfA.StoredVariables["Residus"].store( __errors )
+ if selfA._toStore("ExcludedPoints"):
+ selfA.StoredVariables["ExcludedPoints"].store( __ExcludedMagicPoints )
#
return __mu, __I, __Q, __errors
-# Modification de la version 1.9.1
+# Modification de la version 1.9.1 et 1.10.1
"""
Functions
---------
If `jac is None` the absolute step size used for numerical
approximation of the jacobian via forward differences.
maxfun : int
- Maximum number of function evaluations.
+ Maximum number of function evaluations. Note that this function
+ may violate the limit because of evaluating gradients by numerical
+ differentiation.
maxiter : int
Maximum number of iterations.
iprint : int, optional
self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
#
#--------------------------
- # Default EKF
- #--------------------------
if self._parameters["Variant"] == "EKF":
exkf.exkf(self, Xb, Y, U, HO, EM, CM, R, B, Q)
#
#--------------------------
- # Default CEKF
elif self._parameters["Variant"] == "CEKF":
cekf.cekf(self, Xb, Y, U, HO, EM, CM, R, B, Q)
#
import numpy
from daCore import BasicObjects
-from daAlgorithms.Atoms import ecweim
-from daAlgorithms.Atoms import eosg
+from daAlgorithms.Atoms import ecweim, eosg
# ==============================================================================
class ElementaryAlgorithm(BasicObjects.Algorithm):
name = "ExcludeLocations",
default = [],
typecast = tuple,
- message = "Liste des positions exclues selon la numérotation interne d'un snapshot",
- minval = -1,
+ message = "Liste des indices ou noms de positions exclues selon l'ordre interne d'un snapshot",
+ )
+ self.defineRequiredParameter(
+ name = "NameOfLocations",
+ default = [],
+ typecast = tuple,
+ message = "Liste des noms de positions selon l'ordre interne d'un snapshot",
)
self.defineRequiredParameter(
name = "ErrorNorm",
listval = [
"EnsembleOfSimulations",
"EnsembleOfStates",
+ "ExcludedPoints",
"OptimalPoints",
"ReducedBasis",
"Residus",
self.StoredVariables["EnsembleOfSimulations"] = Persistence.OneMatrix(name = "EnsembleOfSimulations")
self.StoredVariables["EnsembleOfSnapshots"] = Persistence.OneMatrix(name = "EnsembleOfSnapshots")
self.StoredVariables["EnsembleOfStates"] = Persistence.OneMatrix(name = "EnsembleOfStates")
+ self.StoredVariables["ExcludedPoints"] = Persistence.OneVector(name = "ExcludedPoints")
self.StoredVariables["ForecastCovariance"] = Persistence.OneMatrix(name = "ForecastCovariance")
self.StoredVariables["ForecastState"] = Persistence.OneVector(name = "ForecastState")
self.StoredVariables["GradientOfCostFunctionJ"] = Persistence.OneVector(name = "GradientOfCostFunctionJ")
#
return Xa + EnsembleOfAnomalies( __EnXn )
+# ==============================================================================
+def FindIndexesFromNames( __NameOfLocations = None, __ExcludeLocations = None, ForceArray = False):
+ "Exprime les indices des noms exclus, en ignorant les absents"
+ if __ExcludeLocations is None:
+ __ExcludeIndexes = ()
+ elif isinstance(__ExcludeLocations, (list, numpy.ndarray, tuple)) and len(__ExcludeLocations)==0:
+ __ExcludeIndexes = ()
+ # ----------
+ elif __NameOfLocations is None:
+ try:
+ __ExcludeIndexes = numpy.asarray(__ExcludeLocations, dtype=int)
+ except ValueError as e:
+ if "invalid literal for int() with base 10:" in str(e):
+ raise ValueError("to exclude named locations, initial location name list can not be void and has to have the same length as one state")
+ else:
+ raise ValueError(str(e))
+ elif isinstance(__NameOfLocations, (list, numpy.ndarray, tuple)) and len(__NameOfLocations)==0:
+ try:
+ __ExcludeIndexes = numpy.asarray(__ExcludeLocations, dtype=int)
+ except ValueError as e:
+ if "invalid literal for int() with base 10:" in str(e):
+ raise ValueError("to exclude named locations, initial location name list can not be void and has to have the same length as one state")
+ else:
+ raise ValueError(str(e))
+ # ----------
+ else:
+ try:
+ __ExcludeIndexes = numpy.asarray(__ExcludeLocations, dtype=int)
+ except ValueError as e:
+ if "invalid literal for int() with base 10:" in str(e):
+ if len(__NameOfLocations) < 1.e6+1 and len(__ExcludeLocations) > 1500:
+ __Heuristic = True
+ else:
+ __Heuristic = False
+ if ForceArray or __Heuristic:
+ # Recherche par array permettant des noms invalides, peu efficace
+ __NameToIndex = dict(numpy.array((
+ __NameOfLocations,
+ range(len(__NameOfLocations))
+ )).T)
+ __ExcludeIndexes = numpy.asarray([__NameToIndex.get(k, -1) for k in __ExcludeLocations], dtype=int)
+ #
+ else:
+ # Recherche par liste permettant des noms invalides, très efficace
+ def __NameToIndex_get( cle, default = -1 ):
+ if cle in __NameOfLocations:
+ return __NameOfLocations.index(cle)
+ else:
+ return default
+ __ExcludeIndexes = numpy.asarray([__NameToIndex_get(k, -1) for k in __ExcludeLocations], dtype=int)
+ #
+ # Recherche par liste interdisant des noms invalides, mais encore un peu plus efficace
+ # __ExcludeIndexes = numpy.asarray([__NameOfLocations.index(k) for k in __ExcludeLocations], dtype=int)
+ #
+ # Ignore les noms absents
+ __ExcludeIndexes = numpy.compress(__ExcludeIndexes > -1, __ExcludeIndexes)
+ if len(__ExcludeIndexes)==0: __ExcludeIndexes = ()
+ else:
+ raise ValueError(str(e))
+ # ----------
+ return __ExcludeIndexes
+
# ==============================================================================
def BuildComplexSampleList(
__SampleAsnUplet,