from daCore import BasicObjects, PlatformInfo
from daCore.NumericObjects import ApplyBounds, ForceNumericBounds
from daCore.PlatformInfo import vfloat
+lpi = PlatformInfo.PlatformInfo()
# ==============================================================================
class ElementaryAlgorithm(BasicObjects.Algorithm):
"NonLocalOptimization",
"DerivativeFree",
"ParallelFree",
+ "ConvergenceOnBoth",
),
)
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
#
- if not PlatformInfo.has_nlopt and not self._parameters["Minimizer"] in ["COBYLA", "POWELL", "SIMPLEX"]:
+ if not lpi.has_nlopt and not self._parameters["Minimizer"] in ["COBYLA", "POWELL", "SIMPLEX"]:
logging.warning(
"%s Minimization by SIMPLEX is forced because %s "%(self._name, self._parameters["Minimizer"]) + \
"is unavailable (COBYLA, POWELL are also available)")
full_output = True,
disp = self._parameters["optdisp"],
)
- elif self._parameters["Minimizer"] == "COBYLA" and not PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "COBYLA" and not lpi.has_nlopt:
def make_constraints(bounds):
constraints = []
for (i, (a, b)) in enumerate(bounds):
catol = 2. * self._parameters["StateVariationTolerance"],
disp = self._parameters["optdisp"],
)
- elif self._parameters["Minimizer"] == "COBYLA" and PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "COBYLA" and lpi.has_nlopt:
import nlopt
opt = nlopt.opt(nlopt.LN_COBYLA, Xini.size)
print("%s: optimal state: %s"%(opt.get_algorithm_name(), Minimum))
print("%s: minimum of J: %s"%(opt.get_algorithm_name(), opt.last_optimum_value()))
print("%s: return code: %i"%(opt.get_algorithm_name(), opt.last_optimize_result()))
- elif self._parameters["Minimizer"] == "SIMPLEX" and not PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "SIMPLEX" and not lpi.has_nlopt:
Minimum, J_optimal, niter, nfeval, rc = scipy.optimize.fmin(
func = CostFunction,
x0 = Xini,
full_output = True,
disp = self._parameters["optdisp"],
)
- elif self._parameters["Minimizer"] == "SIMPLEX" and PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "SIMPLEX" and lpi.has_nlopt:
import nlopt
opt = nlopt.opt(nlopt.LN_NELDERMEAD, Xini.size)
print("%s: optimal state: %s"%(opt.get_algorithm_name(), Minimum))
print("%s: minimum of J: %s"%(opt.get_algorithm_name(), opt.last_optimum_value()))
print("%s: return code: %i"%(opt.get_algorithm_name(), opt.last_optimize_result()))
- elif self._parameters["Minimizer"] == "BOBYQA" and PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "BOBYQA" and lpi.has_nlopt:
import nlopt
opt = nlopt.opt(nlopt.LN_BOBYQA, Xini.size)
print("%s: optimal state: %s"%(opt.get_algorithm_name(), Minimum))
print("%s: minimum of J: %s"%(opt.get_algorithm_name(), opt.last_optimum_value()))
print("%s: return code: %i"%(opt.get_algorithm_name(), opt.last_optimize_result()))
- elif self._parameters["Minimizer"] == "NEWUOA" and PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "NEWUOA" and lpi.has_nlopt:
import nlopt
opt = nlopt.opt(nlopt.LN_NEWUOA, Xini.size)
print("%s: optimal state: %s"%(opt.get_algorithm_name(), Minimum))
print("%s: minimum of J: %s"%(opt.get_algorithm_name(), opt.last_optimum_value()))
print("%s: return code: %i"%(opt.get_algorithm_name(), opt.last_optimize_result()))
- elif self._parameters["Minimizer"] == "SUBPLEX" and PlatformInfo.has_nlopt:
+ elif self._parameters["Minimizer"] == "SUBPLEX" and lpi.has_nlopt:
import nlopt
opt = nlopt.opt(nlopt.LN_SBPLX, Xini.size)