1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2016 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22 "Vérification d'un exemple de la documentation"
24 # ==============================================================================
27 # Construction artificielle d'un exemple de données utilisateur
28 # -------------------------------------------------------------
33 alphamin, alphamax = 0., 10.
34 betamin, betamax = 3, 13
35 gammamin, gammamax = 1.5, 15.5
38 "Fonction de simulation H pour effectuer Y=H(X)"
40 __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
41 __H = numpy.matrix("1 0 0;0 2 0;0 0 3; 1 2 3")
44 # Observations obtenues par simulation
45 # ------------------------------------
46 observations = simulation((2, 3, 4))
48 # ==============================================================================
54 # Mise en forme des entrées
55 # -------------------------
56 Xb = (alpha, beta, gamma)
64 case = adaoBuilder.New()
66 'AlgorithmParameters',
70 "MaximumNumberOfSteps":100,
71 "StoreSupplementaryCalculations":[
74 "SimulatedObservationAtOptimum",
78 case.set( 'Background', Vector = numpy.array(Xb), Stored = True )
79 case.set( 'Observation', Vector = numpy.array(observations) )
80 case.set( 'BackgroundError', ScalarSparseMatrix = 1.0e10 )
81 case.set( 'ObservationError', ScalarSparseMatrix = 1.0 )
83 'ObservationOperator',
84 OneFunction = simulation,
85 Parameters = {"DifferentialIncrement":0.0001},
87 case.set( 'Observer', Variable="CurrentState", Template="ValuePrinter" )
90 # Exploitation indépendante
91 # -------------------------
92 Xbackground = case.get("Background")
93 Xoptimum = case.get("Analysis")[-1]
94 FX_at_optimum = case.get("SimulatedObservationAtOptimum")[-1]
95 J_values = case.get("CostFunctionJ")[:]
97 print "Nombre d'itérations internes...: %i"%len(J_values)
98 print "Etat initial...................:",numpy.ravel(Xbackground)
99 print "Etat optimal...................:",numpy.ravel(Xoptimum)
100 print "Simulation à l'état optimal....:",numpy.ravel(FX_at_optimum)
103 # ==============================================================================
104 if __name__ == "__main__":
105 print '\n AUTODIAGNOSTIC \n'
106 print """Exemple de la doc :
108 Exploitation indépendante des résultats d'un cas de calcul
109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++