示例#1
0
    def __init__(self,
                 start=[],
                 directions=[],
                 start_step_size=1.0,
                 stop_step_size=1e-10,
                 scaling_factor=0.5,
                 up_scaling_factor=1,
                 max_iter=inf,
                 max_bound=[],
                 min_bound=[],
                 red_pars=[],
                 parallelization={},
                 **kwargs):
        ParameterOptimizationBase.__init__(self, **kwargs)
        # extract parallelization dict for subflow handler
        SubflowHandler.__init__(self, parallelization)

        dim = len(self.variables)
        if start != []:
            x_opt = self.get_vector(start)
        else:
            x_opt = ones(dim)
            self._log("No starting vector given. Vector of all ones taken.",
                      level=logging.CRITICAL)

        if directions == []:
            directions = list(vstack((identity(dim), -identity(dim))))
            self._log("No search directions given! Using unit directions.",
                      level=logging.WARNING)
        directions = [tuple(d) for d in directions]
        # delete duplicates
        directions = list(set(directions))

        max_bound = self.get_vector(
            max_bound) if max_bound != [] else inf * ones(dim)
        min_bound = self.get_vector(
            min_bound) if min_bound != [] else -inf * ones(dim)

        assert((x_opt < max_bound).all() and (x_opt > min_bound).all()), \
                                                  "Starting point is not valid!"
        # copy all params which will be changed during processing
        init_params = {
            "x_opt": x_opt,
            "directions": directions,
            "step_size": start_step_size
        }
        self.set_permanent_attributes(x_opt=x_opt,
                                      directions=directions,
                                      step_size=start_step_size,
                                      stop_step_size=stop_step_size,
                                      scaling_factor=scaling_factor,
                                      up_scaling_factor=up_scaling_factor,
                                      max_iter=max_iter,
                                      min_bound=min_bound,
                                      max_bound=max_bound,
                                      init_params=init_params)
 def __init__(self, start=[], directions=[], start_step_size=1.0, 
              stop_step_size=1e-10, scaling_factor=0.5, up_scaling_factor=1, 
              max_iter=inf, max_bound=[], min_bound=[], red_pars=[],
              parallelization={},
              **kwargs):
     ParameterOptimizationBase.__init__(self, **kwargs)
     # extract parallelization dict for subflow handler
     SubflowHandler.__init__(self, parallelization)
                         
     dim = len(self.variables)
     if start != []:
         x_opt = self.get_vector(start)  
     else:
         x_opt = ones(dim)
         self._log("No starting vector given. Vector of all ones taken.",
                                                    level = logging.CRITICAL)
     
     if directions == []: 
         directions = list(vstack((identity(dim),-identity(dim)))) 
         self._log("No search directions given! Using unit directions.",
                                                     level = logging.WARNING)
     directions = [tuple(d) for d in directions]
     # delete duplicates
     directions = list(set(directions))
     
     max_bound = self.get_vector(max_bound) if max_bound != [] else inf*ones(dim)
     min_bound = self.get_vector(min_bound) if min_bound != [] else -inf*ones(dim)
     
     assert((x_opt < max_bound).all() and (x_opt > min_bound).all()), \
                                               "Starting point is not valid!"
     # copy all params which will be changed during processing
     init_params = {"x_opt": x_opt, "directions": directions, 
                    "step_size": start_step_size}
     self.set_permanent_attributes(x_opt = x_opt,
                                   directions = directions,
                                   step_size = start_step_size,
                                   stop_step_size = stop_step_size,
                                   scaling_factor = scaling_factor,
                                   up_scaling_factor = up_scaling_factor,
                                   max_iter = max_iter,
                                   min_bound = min_bound, 
                                   max_bound = max_bound,
                                   init_params = init_params)
 def __init__(self, ranges, parallelization={}, **kwargs):
     ParameterOptimizationBase.__init__(self, **kwargs)
     # extract parallelization dict for subflow handler
     SubflowHandler.__init__(self, **parallelization)
     self.set_permanent_attributes(grid=self.search_grid(ranges))
示例#4
0
 def __init__(self, ranges, *args, **kwargs):
     ParameterOptimizationBase.__init__(self, *args, **kwargs)
     # extract parallelization dict for subflow handler
     SubflowHandler.__init__(self, **kwargs.get('parallelization', {}))
     self.set_permanent_attributes(grid=self.search_grid(ranges))
示例#5
0
 def __init__(self, ranges=None, grid=None, *args, **kwargs):
     ParameterOptimizationBase.__init__(self, *args, **kwargs)
     # extract parallelization dict for subflow handler
     SubflowHandler.__init__(self, **kwargs.get('parallelization',{}))
     self.set_permanent_attributes(
         grid=self.search_grid(ranges) if ranges is not None else grid)