Example #1
0
def quadratic_optimization(M,
                           b,
                           Ds=[],
                           hypers=[],
                           maxiter=None,
                           tol=1e-6,
                           min_alpha_step=1e-10,
                           **kwargs):
    """
    Use scikits.optimization to perform least-square inversion.
    """
    from scikits.optimization import step, line_search, criterion, optimizer

    if maxiter is None:
        maxiter = M.shape[0]
    model = QuadraticModel(M, b, Ds, hypers)
    mystep = step.PRPConjugateGradientStep()
    mylinesearch = QuadraticOptimalStep(M, b, Ds, hypers)
    #mylinesearch = line_search.QuadraticInterpolationSearch(
    #    min_alpha_step=min_alpha_step,alpha_step = 1e-4)
    mycriterion = criterion.criterion(gtol=tol, iterations_max=maxiter)
    myoptimizer = VerboseStandardOptimizer(function=model,
                                           step=mystep,
                                           line_search=mylinesearch,
                                           criterion=mycriterion,
                                           x0=np.zeros(M.shape[1]))
    return myoptimizer.optimize()
Example #2
0
def huber_optimization(M,
                       b,
                       Ds=[],
                       hypers=[],
                       maxiter=None,
                       tol=1e-6,
                       min_alpha_step=1e-10,
                       **kwargs):
    """
    Use scikits.optimization to perform least-square inversion.
    """
    from scikits.optimization import step, line_search, criterion, optimizer

    if maxiter is None:
        maxiter = M.shape[0]
    model = HuberModel(M, b, Ds, hypers, **kwargs)
    mystep = step.PRPConjugateGradientStep()
    mylinesearch = BacktrackingFromOptimal(M, b, Ds, hypers)
    mycriterion = criterion.criterion(ftol=tol, iterations_max=maxiter)
    myoptimizer = VerboseStandardOptimizer(function=model,
                                           step=mystep,
                                           line_search=mylinesearch,
                                           criterion=mycriterion,
                                           x0=np.zeros(M.shape[1]))
    return myoptimizer.optimize()
def start_optimization():
  startPoint = np.empty((3, 2), np.float)
  startPoint[:,0] = 1.
  startPoint[:,1] = 0.
  startPoint[1,0] -= .1
  startPoint[2,1] += .1
  recorder = Recorder()
  optimi = optimizer.PolytopeOptimizer(function = Rosenbrock(), criterion = criterion.criterion(ftol = .01, iterations_max=50), x0 = startPoint, record=recorder)

  print optimi.optimize()
Example #4
0
def huber_optimization(M, b, Ds=[], hypers=[], maxiter=None, tol=1e-6,
                           min_alpha_step=1e-10, **kwargs):
    """
    Use scikits.optimization to perform least-square inversion.
    """
    from scikits.optimization import step, line_search, criterion, optimizer

    if maxiter is None:
        maxiter = M.shape[0]
    model = HuberModel(M, b, Ds, hypers, **kwargs)
    mystep = step.PRPConjugateGradientStep()
    mylinesearch = BacktrackingFromOptimal(M, b, Ds, hypers)
    mycriterion = criterion.criterion(ftol=tol, iterations_max=maxiter)
    myoptimizer = VerboseStandardOptimizer(function=model,
                                              step=mystep,
                                              line_search=mylinesearch,
                                              criterion=mycriterion,
                                              x0 = np.zeros(M.shape[1]))
    return myoptimizer.optimize()
Example #5
0
def quadratic_optimization(M, b, Ds=[], hypers=[], maxiter=None, tol=1e-6,
                           min_alpha_step=1e-10, **kwargs):
    """
    Use scikits.optimization to perform least-square inversion.
    """
    from scikits.optimization import step, line_search, criterion, optimizer
    
    if maxiter is None:
        maxiter = M.shape[0]
    model = QuadraticModel(M, b, Ds, hypers)
    mystep = step.PRPConjugateGradientStep()
    mylinesearch = QuadraticOptimalStep(M, b, Ds, hypers)
    #mylinesearch = line_search.QuadraticInterpolationSearch(
    #    min_alpha_step=min_alpha_step,alpha_step = 1e-4)
    mycriterion = criterion.criterion(gtol=tol, iterations_max=maxiter)
    myoptimizer = VerboseStandardOptimizer(function=model,
                                              step=mystep,
                                              line_search=mylinesearch,
                                              criterion=mycriterion,
                                              x0 = np.zeros(M.shape[1]))
    return myoptimizer.optimize()
Example #6
0
"""
Use the optimization scikits to define a set of optimizer and models
using LinearOperators.
"""
import numpy as np
from copy import copy
from scikits.optimization import step, line_search, criterion, optimizer
from scikits.optimization.optimizer import StandardOptimizer
import criterions
import norms

# defaults
default_step = step.PRPConjugateGradientStep()
default_line_search = line_search.QuadraticInterpolationSearch(0)
default_stop_criterion = criterion.criterion()


# a class wrapping StandardOptimizer
class Optimizer(object):
    def __init__(self,
                 criterion,
                 x0=None,
                 step=default_step,
                 line_search=default_line_search,
                 stop_criterion=default_stop_criterion):
        self.criterion = criterion
        self.n_variables = criterion.n_variables
        self.step = step
        self.line_search = line_search
        self.stop_criterion = stop_criterion
        self.first_guess()
Example #7
0
"""
Use the optimization scikits to define a set of optimizer and models
using LinearOperators.
"""
import numpy as np
from copy import copy
from scikits.optimization import step, line_search, criterion, optimizer
from scikits.optimization.optimizer import StandardOptimizer
import criterions
import norms

# defaults
default_step = step.PRPConjugateGradientStep()
default_line_search = line_search.QuadraticInterpolationSearch(0)
default_stop_criterion = criterion.criterion()

# a class wrapping StandardOptimizer
class Optimizer(object):
    def __init__(self, criterion,
                 x0=None,
                 step=default_step,
                 line_search=default_line_search,
                 stop_criterion=default_stop_criterion):
        self.criterion = criterion
        self.n_variables = criterion.n_variables
        self.step = step
        self.line_search = line_search
        self.stop_criterion = stop_criterion
        self.first_guess()
        self.optimizer = StandardOptimizer(function=self.criterion,
                                           step=self.step,