]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Improvement of bounds treatment for DFO
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 5 Apr 2017 10:31:06 +0000 (12:31 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 5 Apr 2017 10:31:06 +0000 (12:31 +0200)
src/daComposant/daAlgorithms/DerivativeFreeOptimization.py

index 221d4efe659465ee7181b385939197dd9c90dd23..e9d9a5f0a33f4e2f491183f866ae77d6ea4ce4c6 100644 (file)
@@ -213,9 +213,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 return CostFunction(_Xx, self._parameters["QualityCriterion"])
             opt.set_min_objective(_f)
             if self._parameters["Bounds"] is not None:
-                lub = numpy.array(self._parameters["Bounds"]).reshape((Xini.size,2))
-                lb = lub[:,0]
-                ub = lub[:,1]
+                lub = numpy.array(self._parameters["Bounds"],dtype=float).reshape((Xini.size,2))
+                lb = lub[:,0] ; lb[numpy.isnan(lb)] = -float('inf')
+                ub = lub[:,1] ; ub[numpy.isnan(ub)] = +float('inf')
                 if self._parameters["optdisp"]:
                     print("%s: upper bounds %s"%(opt.get_algorithm_name(),ub))
                     print("%s: lower bounds %s"%(opt.get_algorithm_name(),lb))
@@ -249,9 +249,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 return CostFunction(_Xx, self._parameters["QualityCriterion"])
             opt.set_min_objective(_f)
             if self._parameters["Bounds"] is not None:
-                lub = numpy.array(self._parameters["Bounds"]).reshape((Xini.size,2))
-                lb = lub[:,0]
-                ub = lub[:,1]
+                lub = numpy.array(self._parameters["Bounds"],dtype=float).reshape((Xini.size,2))
+                lb = lub[:,0] ; lb[numpy.isnan(lb)] = -float('inf')
+                ub = lub[:,1] ; ub[numpy.isnan(ub)] = +float('inf')
                 if self._parameters["optdisp"]:
                     print("%s: upper bounds %s"%(opt.get_algorithm_name(),ub))
                     print("%s: lower bounds %s"%(opt.get_algorithm_name(),lb))
@@ -273,9 +273,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 return CostFunction(_Xx, self._parameters["QualityCriterion"])
             opt.set_min_objective(_f)
             if self._parameters["Bounds"] is not None:
-                lub = numpy.array(self._parameters["Bounds"]).reshape((Xini.size,2))
-                lb = lub[:,0]
-                ub = lub[:,1]
+                lub = numpy.array(self._parameters["Bounds"],dtype=float).reshape((Xini.size,2))
+                lb = lub[:,0] ; lb[numpy.isnan(lb)] = -float('inf')
+                ub = lub[:,1] ; ub[numpy.isnan(ub)] = +float('inf')
                 if self._parameters["optdisp"]:
                     print("%s: upper bounds %s"%(opt.get_algorithm_name(),ub))
                     print("%s: lower bounds %s"%(opt.get_algorithm_name(),lb))
@@ -297,9 +297,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 return CostFunction(_Xx, self._parameters["QualityCriterion"])
             opt.set_min_objective(_f)
             if self._parameters["Bounds"] is not None:
-                lub = numpy.array(self._parameters["Bounds"]).reshape((Xini.size,2))
-                lb = lub[:,0]
-                ub = lub[:,1]
+                lub = numpy.array(self._parameters["Bounds"],dtype=float).reshape((Xini.size,2))
+                lb = lub[:,0] ; lb[numpy.isnan(lb)] = -float('inf')
+                ub = lub[:,1] ; ub[numpy.isnan(ub)] = +float('inf')
                 if self._parameters["optdisp"]:
                     print("%s: upper bounds %s"%(opt.get_algorithm_name(),ub))
                     print("%s: lower bounds %s"%(opt.get_algorithm_name(),lb))
@@ -321,9 +321,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 return CostFunction(_Xx, self._parameters["QualityCriterion"])
             opt.set_min_objective(_f)
             if self._parameters["Bounds"] is not None:
-                lub = numpy.array(self._parameters["Bounds"]).reshape((Xini.size,2))
-                lb = lub[:,0]
-                ub = lub[:,1]
+                lub = numpy.array(self._parameters["Bounds"],dtype=float).reshape((Xini.size,2))
+                lb = lub[:,0] ; lb[numpy.isnan(lb)] = -float('inf')
+                ub = lub[:,1] ; ub[numpy.isnan(ub)] = +float('inf')
                 if self._parameters["optdisp"]:
                     print("%s: upper bounds %s"%(opt.get_algorithm_name(),ub))
                     print("%s: lower bounds %s"%(opt.get_algorithm_name(),lb))