L2L 1.0.0-beta documentation
  • Table Of Contents
      • Optimizer using Grid Search
        • GridSearchOptimizer
        • GridSearchParameters
  • previous
  • next
  • modules
  • index
  • API Reference
  • Optimizers
  • Show Source

Table of Contents

  • Quickstart
  • Overview
  • API Reference
    • Optimizees
    • Optimizers
      • Optimizer Base Module
      • Implemented Examples
        • Optimizer using Cross Entropy
        • Optimizer using FACE
        • Optimizer using Gradient Descent
        • Optimizer using Grid Search
          • GridSearchOptimizer
          • GridSearchParameters
        • Optimizer using Evolutionary Algorithm
        • Optimizer using Simulated Annealing
        • Optimizer using Evolution Strategies
        • Optimizer using Natural Evolution Strategies
    • Simulation control
    • Logging Tools
    • Other module functions
  • L2L Experiments
  • Indices and tables

Previous topic

Optimizer using Gradient Descent

Next topic

Optimizer using Evolutionary Algorithm

This Page

  • Show Source

Quick search

Enter search terms or a module, class or function name.

Optimizer using Grid Search¶

GridSearchOptimizer¶

class l2l.optimizers.gridsearch.optimizer.GridSearchOptimizer(traj, optimizee_create_individual, optimizee_fitness_weights, parameters, optimizee_bounding_func=None)[source]¶

Bases: l2l.optimizers.optimizer.Optimizer

This class implements a basic grid search optimizer. It runs the optimizee on a given grid of parameter values and returns the best fitness found. moreover, this can also simply be used to run a grid search and process the results stored in the traj in any manner desired.

Notes regarding what it does -

  1. This algorithm does not do any kind of adaptive searching and thus the concept of generations does not apply per se. That said, it is currently implemented as a series of runs in a single generation. All of these runs are declared in the constructor itself. The Optimizer.post_process() function simply prints the individual with the maximal fitness.
  2. This algorithm doesnt make use of self.eval_pop and Optimizer._expand_trajectory() simply because the cartesian product can be used more efficiently directly. (Imagine having to split a dict of 10000 parameter combinations into 10000 small Individual-Dict`s and storing into eval_pop only to join them and call `traj.f_expand() in Optimizer._expand_trajectory())
Parameters:
  • traj (Trajectory) – Use this trajectory to store the parameters of the specific runs. The parameters should be initialized based on the values in parameters
  • optimizee_create_individual – A function which when called returns one instance of parameter (or “individual”)
  • optimizee_fitness_weights – The weights which should be multiplied with the fitness returned from the Optimizee – one for each element of the fitness (fitness can be multi-dimensional). If some element is negative, the Optimizer minimizes that element of fitness instead of maximizing. By default, the Optimizer maximizes all fitness dimensions.
  • parameters – An instance of GridSearchParameters
g = None¶

The current generation number

eval_pop = None¶

The population (i.e. list of individuals) to be evaluated at the next iteration

post_process(traj, fitnesses_results)[source]¶

In this optimizer, the post_proces function merely returns the best individual out of the grid and does not expand the trajectory. It also stores any relevant results

end(traj)[source]¶

Run any code required to clean-up, print final individuals etc.

GridSearchParameters¶

class l2l.optimizers.gridsearch.optimizer.GridSearchParameters¶

Bases: tuple

Parameters:param_grid (dict) –

This is the data structure specifying the grid over which to search. This should be a dictionary as follows:

optimizee_param_grid['param_name'] = (lower_bound, higher_bound, n_steps)

Where the interval [lower_bound, upper_bound] is divided into n_steps intervals thereby providing n_steps + 1 points for the grid.

Note that there must be as many keys as there are in the Individual-Dict returned by the function Optimizee.create_individual(). Also, if any of the parameters of the individuals is an array, then the above grid specification applies to each element of the array.

param_grid¶
  • L2L 1.0.0-beta documentation
  • previous
  • next
  • modules
  • index
  • API Reference
  • Optimizers
  • top
© Copyright 2017, Anand Subramoney. Created using Sphinx 1.8.1.