linted iestimation.py
@@ -11,6 +11,8 @@ import numpy as np # Numerical Python
from time import time # Used to time execution
from copy import deepcopy # For replicating complex objects
from scipy.optimize import fmin, fmin_powell # Minimizers
+import warnings
+
def minimizeNelderMead(objectiveFunction, parameter_guess, verbose=False, **kwargs):
'''
@@ -47,6 +49,7 @@ def minimizeNelderMead(objectiveFunction, parameter_guess, verbose=False, **kwar
warnflag = OUTPUT[4] # warnflag : int
# 1 : Maximum number of function evaluations made.
# 2 : Maximum number of iterations reached.
+
# Check that optimization succeeded:
if warnflag != 0:
warnings.warn("Minimization failed! xopt=" + str(xopt) + ', fopt=' + str(fopt) +
@@ -95,9 +98,11 @@ def minimizePowell(objectiveFunction, parameter_guess, verbose=False):
warnflag = OUTPUT[5] # warnflag : int
# 1 : Maximum number of function evaluations made.
# 2 : Maximum number of iterations reached.
+
# Check that optimization succeeded:
if warnflag != 0:
- warnings.warn("Minimization failed! xopt=" + str(xopt) + ', fopt=' + str(fopt) + ', direc=' + str(direc) + ', optiter=' + str(optiter) +', funcalls=' + str(funcalls) +', warnflag=' + str(warnflag))
+ warnings.warn("Minimization failed! xopt=" + str(xopt) + ', fopt=' + str(fopt) + ', direc=' + str(direc) +
+ ', optiter=' + str(optiter) + ', funcalls=' + str(funcalls) + ', warnflag=' + str(warnflag))
# Display and return the results:
if verbose:
@@ -148,5 +153,6 @@ def main():
print("To see some examples of its functions in actions, check out an application")
print("like /SolvingMicroDSOPs/StructEstimation or /cstwMPC/cstwMPC.")
+
if __name__ == '__main__':
main()
