From: Jean-Philippe ARGAUD Date: Thu, 28 Sep 2023 08:55:18 +0000 (+0200) Subject: Documentation update for MOP with examples X-Git-Tag: V9_12_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2cf2c774be7d69dd949e946cc10aaaf9a1b7dfc;p=modules%2Fadao.git Documentation update for MOP with examples --- diff --git a/doc/en/examples.rst b/doc/en/examples.rst index 114af16..0387e83 100644 --- a/doc/en/examples.rst +++ b/doc/en/examples.rst @@ -60,6 +60,11 @@ Checking algorithms uses #. :ref:`Examples with the "ObservationSimulationComparisonTest" check` #. :ref:`Examples with the "ParallelFunctionTest" check` +Dedicated tasks or study oriented cases uses +-------------------------------------------- + +#. :ref:`Examples with the "MeasurementsOptimalPositioningTask" case` + Advanced uses ------------- diff --git a/doc/en/images/irm_determination.png b/doc/en/images/irm_determination.png index d531169..e961574 100644 Binary files a/doc/en/images/irm_determination.png and b/doc/en/images/irm_determination.png differ diff --git a/doc/en/images/mop_determination.png b/doc/en/images/mop_determination.png index 65bcd73..3aab4c7 100644 Binary files a/doc/en/images/mop_determination.png and b/doc/en/images/mop_determination.png differ diff --git a/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst b/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst index e68f61c..a798b9e 100644 --- a/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst +++ b/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst @@ -174,6 +174,29 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. _section_ref_algorithm_MeasurementsOptimalPositioningTask_examples: +.. include:: snippets/Header2Algo09.rst + +.. --------- .. +.. include:: scripts/simple_MeasurementsOptimalPositioningTask1.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask1.py + +.. include:: snippets/Header2Algo10.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask1.res + :language: none + +.. --------- .. +.. include:: scripts/simple_MeasurementsOptimalPositioningTask2.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask2.py + +.. include:: snippets/Header2Algo10.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask2.res + :language: none + +.. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst - :ref:`section_ref_algorithm_FunctionTest` diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.py b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.py new file mode 100644 index 0000000..2612cab --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# +from numpy import array, arange +# +dimension = 7 +# +print("Defining a set of artificial physical fields") +print("--------------------------------------------") +Ensemble = array( [i+arange(dimension) for i in range(7)] ).T +print("- Dimension of physical field space....................: %i"%dimension) +print("- Number of physical field vectors.....................: %i"%Ensemble.shape[1]) +print("- Collection of physical fields (one per column)") +print(Ensemble) +print() +# +print("Search for optimal measurement positions") +print("-------------------------------------------") +from adao import adaoBuilder +case = adaoBuilder.New() +case.setAlgorithmParameters( + Algorithm = 'MeasurementsOptimalPositioningTask', + Parameters = { + "EnsembleOfSnapshots":Ensemble, + "MaximumNumberOfLocations":3, + "ErrorNorm":"L2", + } +) +case.execute() +print("- ADAO calculation performed") +print() +# +print("Optimal positioning of measures") +print("-------------------------------") +op = case.get("OptimalPoints")[-1] +print("- Number of optimal measurement positions..............: %i"%op.size) +print("- Optimal measurement positions, numbered by default...: %s"%op) +print() diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.res b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.res new file mode 100644 index 0000000..25b1e36 --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.res @@ -0,0 +1,22 @@ +Defining a set of artificial physical fields +-------------------------------------------- +- Dimension of physical field space....................: 7 +- Number of physical field vectors.....................: 7 +- Collection of physical fields (one per column) +[[ 0 1 2 3 4 5 6] + [ 1 2 3 4 5 6 7] + [ 2 3 4 5 6 7 8] + [ 3 4 5 6 7 8 9] + [ 4 5 6 7 8 9 10] + [ 5 6 7 8 9 10 11] + [ 6 7 8 9 10 11 12]] + +Search for optimal measurement positions +------------------------------------------- +- ADAO calculation performed + +Optimal positioning of measures +------------------------------- +- Number of optimal measurement positions..............: 2 +- Optimal measurement positions, numbered by default...: [6 0] + diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.rst b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.rst new file mode 100644 index 0000000..eab4572 --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask1.rst @@ -0,0 +1,10 @@ +.. index:: single: MeasurementsOptimalPositioningTask (exemple) + +First example +............. + +This example describes the implementation of a search for **optimal measurement +positioning**. To illustrate, we construct a very simple artificial collection +of physical fields (generated here so as to exist in a vector space of +dimension 2). The default ADAO search then easily yields 2 optimal positions +for the measurements, as illustrated by the display at the end of the script. diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.py b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.py new file mode 100644 index 0000000..a6420ad --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# +from numpy import array, arange +# +dimension = 7 +# +print("Defining a set of artificial physical fields") +print("--------------------------------------------") +Ensemble = array( [i+arange(dimension) for i in range(7)] ).T +print("- Dimension of physical field space....................: %i"%dimension) +print("- Number of physical field vectors.....................: %i"%Ensemble.shape[1]) +print("- Collection of physical fields (one per column)") +print(Ensemble) +print() +# +print("Search for optimal measurement positions") +print("-------------------------------------------") +from adao import adaoBuilder +case = adaoBuilder.New() +case.setAlgorithmParameters( + Algorithm = 'MeasurementsOptimalPositioningTask', + Parameters = { + "EnsembleOfSnapshots":Ensemble, + "MaximumNumberOfLocations":3, + "ErrorNorm":"L2", + "StoreSupplementaryCalculations":[ + "ReducedBasis", + "Residus", + ], + } +) +case.execute() +print("- ADAO calculation performed") +print() +# +print("Optimal positioning of measures") +print("-------------------------------") +op = case.get("OptimalPoints")[-1] +print("- Number of optimal measurement positions..............: %i"%op.size) +print("- Optimal measurement positions, numbered by default...: %s"%op) +print() +# +print("Reduced representation and error information") +print("--------------------------------------------") +rb = case.get("ReducedBasis")[-1] +print("- Number of vectors of the reduced basis...............: %i"%rb.shape[1]) +print("- Reduced basis vectors (one per column)\n") +print(rb) +rs = case.get("Residus")[-1] +print("- Ordered residuals of reconstruction error\n ",rs) +print() +a0, a1 = 7, -2.5 +print("- Elementary example of second field reconstruction") +print(" as a linear combination of the two base vectors,") +print(" with the respective coefficients %.1f and %.1f:"%(a0,a1)) +print( a0*rb[:,0] + a1*rb[:,1]) +print() diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.res b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.res new file mode 100644 index 0000000..bb4706a --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.res @@ -0,0 +1,48 @@ +Defining a set of artificial physical fields +-------------------------------------------- +- Dimension of physical field space....................: 7 +- Number of physical field vectors.....................: 7 +- Collection of physical fields (one per column) +[[ 0 1 2 3 4 5 6] + [ 1 2 3 4 5 6 7] + [ 2 3 4 5 6 7 8] + [ 3 4 5 6 7 8 9] + [ 4 5 6 7 8 9 10] + [ 5 6 7 8 9 10 11] + [ 6 7 8 9 10 11 12]] + +Search for optimal measurement positions +------------------------------------------- +- ADAO calculation performed + +Optimal positioning of measures +------------------------------- +- Number of optimal measurement positions..............: 2 +- Optimal measurement positions, numbered by default...: [6 0] + +Reduced representation and error information +-------------------------------------------- +- Number of vectors of the reduced basis...............: 2 +- Reduced basis vectors (one per column) + +[[ 0.5 1. ] + [ 0.58333333 0.83333333] + [ 0.66666667 0.66666667] + [ 0.75 0.5 ] + [ 0.83333333 0.33333333] + [ 0.91666667 0.16666667] + [ 1. -0. ]] +- Ordered residuals of reconstruction error + [2.43926218e+01 4.76969601e+00 2.51214793e-15] + +- Elementary example of second field reconstruction + as a linear combination of the two base vectors, + with the respective coefficients 7.0 and -2.5: +[[1.] + [2.] + [3.] + [4.] + [5.] + [6.] + [7.]] + diff --git a/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.rst b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.rst new file mode 100644 index 0000000..e65cd3b --- /dev/null +++ b/doc/en/scripts/simple_MeasurementsOptimalPositioningTask2.rst @@ -0,0 +1,14 @@ +.. index:: single: MeasurementsOptimalPositioningTask (exemple) + +Second example +.............. + +This example describes the same optimal positioning of measurements, followed +by an analysis of the **reduced representation and errors** obtained during the +search for optimal positions. + +The initial part of the script is identical to the previous one, with the same +artificial collection of physical fields and the same analysis by ADAO. We then +add the recovery of the reduced base and a very simple example of decomposition +on the reduced base, exact in this simple case, of one of the physical fields +initially provided. diff --git a/doc/fr/examples.rst b/doc/fr/examples.rst index 0471405..2cf3320 100644 --- a/doc/fr/examples.rst +++ b/doc/fr/examples.rst @@ -61,6 +61,11 @@ Utilisations d'algorithmes de vérification #. :ref:`Exemples de vérification avec "ObservationSimulationComparisonTest"` #. :ref:`Exemples de vérification avec "ParallelFunctionTest"` +Utilisations d'algorithmes orientés tâches ou études dédiées +------------------------------------------------------------ + +#. :ref:`Exemples de vérification avec "MeasurementsOptimalPositioningTask"` + Utilisations avancées --------------------- diff --git a/doc/fr/images/irm_determination.png b/doc/fr/images/irm_determination.png index 0fc73cb..e3fb340 100644 Binary files a/doc/fr/images/irm_determination.png and b/doc/fr/images/irm_determination.png differ diff --git a/doc/fr/images/mop_determination.png b/doc/fr/images/mop_determination.png index 9ce4cd0..6bf5321 100644 Binary files a/doc/fr/images/mop_determination.png and b/doc/fr/images/mop_determination.png differ diff --git a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst index 037bc68..6fe2723 100644 --- a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst +++ b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst @@ -58,8 +58,8 @@ un jeu de paramètres donné :math:`\mathbf{x}`, ou d'une observation explicite du (ou des) champ(s) complet(s) :math:`\mathbf{y}`. Pour établir la position optimale de mesures, on utilise une méthode de type -Empirical Interpolation Method (EIM [Barrault04]_), avec (variant "*lcEIM*") ou -sans contraintes (variant "*EIM*") de positionnement. +Empirical Interpolation Method (EIM [Barrault04]_), avec contraintes (variant +"*lcEIM*") ou sans contraintes (variant "*EIM*") de positionnement. Il y a deux manières d'utiliser cet algorithme: @@ -176,6 +176,29 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. _section_ref_algorithm_MeasurementsOptimalPositioningTask_examples: +.. include:: snippets/Header2Algo09.rst + +.. --------- .. +.. include:: scripts/simple_MeasurementsOptimalPositioningTask1.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask1.py + +.. include:: snippets/Header2Algo10.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask1.res + :language: none + +.. --------- .. +.. include:: scripts/simple_MeasurementsOptimalPositioningTask2.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask2.py + +.. include:: snippets/Header2Algo10.rst + +.. literalinclude:: scripts/simple_MeasurementsOptimalPositioningTask2.res + :language: none + +.. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst - :ref:`section_ref_algorithm_FunctionTest` diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.py b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.py new file mode 100644 index 0000000..39c0771 --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# +from numpy import array, arange +# +dimension = 7 +# +print("Définition d'un ensemble artificiel de champs physiques") +print("-------------------------------------------------------") +Ensemble = array( [i+arange(dimension) for i in range(7)] ).T +print("- Dimension de l'espace des champs physiques...........: %i"%dimension) +print("- Nombre de vecteurs de champs physiques...............: %i"%Ensemble.shape[1]) +print("- Collection des champs physiques (un par colonne)") +print(Ensemble) +print() +# +print("Recherche des positions optimales de mesure") +print("-------------------------------------------") +from adao import adaoBuilder +case = adaoBuilder.New() +case.setAlgorithmParameters( + Algorithm = 'MeasurementsOptimalPositioningTask', + Parameters = { + "EnsembleOfSnapshots":Ensemble, + "MaximumNumberOfLocations":3, + "ErrorNorm":"L2", + } +) +case.execute() +print("- Calcul ADAO effectué") +print() +# +print("Positions optimales de mesure") +print("-----------------------------") +op = case.get("OptimalPoints")[-1] +print("- Nombre de positions optimales de mesure..............: %i"%op.size) +print("- Positions optimales de mesure, numérotées par défaut.: %s"%op) +print() diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.res b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.res new file mode 100644 index 0000000..ff9fbd2 --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.res @@ -0,0 +1,22 @@ +Définition d'un ensemble artificiel de champs physiques +------------------------------------------------------- +- Dimension de l'espace des champs physiques...........: 7 +- Nombre de vecteurs de champs physiques...............: 7 +- Collection des champs physiques (un par colonne) +[[ 0 1 2 3 4 5 6] + [ 1 2 3 4 5 6 7] + [ 2 3 4 5 6 7 8] + [ 3 4 5 6 7 8 9] + [ 4 5 6 7 8 9 10] + [ 5 6 7 8 9 10 11] + [ 6 7 8 9 10 11 12]] + +Recherche des positions optimales de mesure +------------------------------------------- +- Calcul ADAO effectué + +Positions optimales de mesure +----------------------------- +- Nombre de positions optimales de mesure..............: 2 +- Positions optimales de mesure, numérotées par défaut.: [6 0] + diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.rst b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.rst new file mode 100644 index 0000000..590cac0 --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask1.rst @@ -0,0 +1,11 @@ +.. index:: single: MeasurementsOptimalPositioningTask (exemple) + +Premier exemple +............... + +Cet exemple décrit la mise en oeuvre d'une recherche de **positionnement +optimal de mesures**. Pour l'illustration, on construit une collection +artificielle de champs physiques très simple (engendré ici de manière à exister +dans un espace vectoriel de dimension 2). La recherche ADAO par défaut permet ensuite +d'obtenir aisément 2 positions optimales pour les mesures, comme illustré par +l'affichage en fin de script. diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.py b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.py new file mode 100644 index 0000000..8d2aaed --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# +from numpy import array, arange +# +dimension = 7 +# +print("Définition d'un ensemble artificiel de champs physiques") +print("-------------------------------------------------------") +Ensemble = array( [i+arange(dimension) for i in range(7)] ).T +print("- Dimension de l'espace des champs physiques...........: %i"%dimension) +print("- Nombre de vecteurs de champs physiques...............: %i"%Ensemble.shape[1]) +print("- Collection des champs physiques (un par colonne)") +print(Ensemble) +print() +# +print("Recherche des positions optimales de mesure") +print("-------------------------------------------") +from adao import adaoBuilder +case = adaoBuilder.New() +case.setAlgorithmParameters( + Algorithm = 'MeasurementsOptimalPositioningTask', + Parameters = { + "EnsembleOfSnapshots":Ensemble, + "MaximumNumberOfLocations":3, + "ErrorNorm":"L2", + "StoreSupplementaryCalculations":[ + "ReducedBasis", + "Residus", + ], + } +) +case.execute() +print("- Calcul ADAO effectué") +print() +# +print("Positions optimales de mesure") +print("-----------------------------") +op = case.get("OptimalPoints")[-1] +print("- Nombre de positions optimales de mesure..............: %i"%op.size) +print("- Positions optimales de mesure, numérotées par défaut.: %s"%op) +print() +# +print("Représentation réduite et informations d'erreurs") +print("------------------------------------------------") +rb = case.get("ReducedBasis")[-1] +print("- Nombre de vecteurs de la base réduite................: %i"%rb.shape[1]) +print("- Vecteurs de la base réduite (un par colonne)\n") +print(rb) +rs = case.get("Residus")[-1] +print("- Résidus ordonnés d'erreur de reconstruction\n ",rs) +print() +a0, a1 = 7, -2.5 +print("- Exemple élémentaire de reconstruction du second champ") +print(" comme combinaison linéaire des deux vecteurs de base,") +print(" avec les coefficients respectifs %.1f et %.1f :"%(a0,a1)) +print( a0*rb[:,0] + a1*rb[:,1]) +print() diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.res b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.res new file mode 100644 index 0000000..300a264 --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.res @@ -0,0 +1,48 @@ +Définition d'un ensemble artificiel de champs physiques +------------------------------------------------------- +- Dimension de l'espace des champs physiques...........: 7 +- Nombre de vecteurs de champs physiques...............: 7 +- Collection des champs physiques (un par colonne) +[[ 0 1 2 3 4 5 6] + [ 1 2 3 4 5 6 7] + [ 2 3 4 5 6 7 8] + [ 3 4 5 6 7 8 9] + [ 4 5 6 7 8 9 10] + [ 5 6 7 8 9 10 11] + [ 6 7 8 9 10 11 12]] + +Recherche des positions optimales de mesure +------------------------------------------- +- Calcul ADAO effectué + +Positions optimales de mesure +----------------------------- +- Nombre de positions optimales de mesure..............: 2 +- Positions optimales de mesure, numérotées par défaut.: [6 0] + +Représentation réduite et informations d'erreurs +------------------------------------------------ +- Nombre de vecteurs de la base réduite................: 2 +- Vecteurs de la base réduite (un par colonne) + +[[ 0.5 1. ] + [ 0.58333333 0.83333333] + [ 0.66666667 0.66666667] + [ 0.75 0.5 ] + [ 0.83333333 0.33333333] + [ 0.91666667 0.16666667] + [ 1. -0. ]] +- Résidus ordonnés d'erreur de reconstruction + [2.43926218e+01 4.76969601e+00 2.51214793e-15] + +- Exemple élémentaire de reconstruction du second champ + comme combinaison linéaire des deux vecteurs de base, + avec les coefficients respectifs 7.0 et -2.5 : +[[1.] + [2.] + [3.] + [4.] + [5.] + [6.] + [7.]] + diff --git a/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.rst b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.rst new file mode 100644 index 0000000..4f51eeb --- /dev/null +++ b/doc/fr/scripts/simple_MeasurementsOptimalPositioningTask2.rst @@ -0,0 +1,14 @@ +.. index:: single: MeasurementsOptimalPositioningTask (exemple) + +Second exemple +.............. + +Cet exemple décrit le même positionnement optimal de mesures, suivi d'une +analyse de **la représentation réduite et des erreurs** obtenues lors de la +recherche des positions optimales. + +La partie initiale du script est identique au précédent, avec la même +collection artificielle de champs physiques et la même analyse par ADAO. On +ajoute ensuite la récupération de la base réduite et un exemple très simple de +décomposition sur la base réduite, exacte dans ce cas simple, de l'un des +champs physiques initialement fournis. diff --git a/src/daComposant/daAlgorithms/Atoms/ecweim.py b/src/daComposant/daAlgorithms/Atoms/ecweim.py index b0c3525..297e8bb 100644 --- a/src/daComposant/daAlgorithms/Atoms/ecweim.py +++ b/src/daComposant/daAlgorithms/Atoms/ecweim.py @@ -115,7 +115,7 @@ def EIM_offline(selfA, EOS = None, Verbose = False): # Détermination du point et de la fonction magiques __abs_residuM = numpy.abs(__residuM) __iM = numpy.argmax(__abs_residuM) - __rhoM = __residuM / __abs_residuM[__iM] + __rhoM = __residuM / __residuM[__iM] # if __LcCsts and __iM in __ExcludedMagicPoints: __sIndices = numpy.argsort(__abs_residuM)