#. :ref:`Examples with the "ObservationSimulationComparisonTest" check<section_ref_algorithm_ObservationSimulationComparisonTest_examples>`
#. :ref:`Examples with the "ParallelFunctionTest" check<section_ref_algorithm_ParallelFunctionTest_examples>`
+Dedicated tasks or study oriented cases uses
+--------------------------------------------
+
+#. :ref:`Examples with the "MeasurementsOptimalPositioningTask" case<section_ref_algorithm_MeasurementsOptimalPositioningTask_examples>`
+
Advanced uses
-------------
.. ------------------------------------ ..
.. _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`
--- /dev/null
+# -*- 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()
--- /dev/null
+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]
+
--- /dev/null
+.. 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.
--- /dev/null
+# -*- 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()
--- /dev/null
+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.]]
+
--- /dev/null
+.. 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.
#. :ref:`Exemples de vérification avec "ObservationSimulationComparisonTest"<section_ref_algorithm_ObservationSimulationComparisonTest_examples>`
#. :ref:`Exemples de vérification avec "ParallelFunctionTest"<section_ref_algorithm_ParallelFunctionTest_examples>`
+Utilisations d'algorithmes orientés tâches ou études dédiées
+------------------------------------------------------------
+
+#. :ref:`Exemples de vérification avec "MeasurementsOptimalPositioningTask"<section_ref_algorithm_MeasurementsOptimalPositioningTask_examples>`
+
Utilisations avancées
---------------------
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:
.. ------------------------------------ ..
.. _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`
--- /dev/null
+# -*- 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()
--- /dev/null
+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]
+
--- /dev/null
+.. 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.
--- /dev/null
+# -*- 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()
--- /dev/null
+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.]]
+
--- /dev/null
+.. 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.
# 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)