optunity.solvers.Sobol module¶
-
class
optunity.solvers.Sobol.
Sobol
(num_evals, seed=None, skip=None, **kwargs)[source]¶ Bases:
optunity.solvers.util.Solver
Please refer to Sobol sequences for details on this algorithm.
Initializes a Sobol sequence solver.
Parameters: - num_evals (int) – number of evaluations to use
- skip (int or None) – the number of initial elements of the sequence to skip, if None a random skip is generated
- kwargs ({'name': [lb, ub], ..}) – box constraints for each hyperparameter
The search space is rescaled to the unit hypercube before the solving process begins.
-
static
bitwise_xor
(a, b)[source]¶ Returns the bitwise_xor of a and b as a bitstring.
Parameters: - a (int) – first number
- b (int) – second number
>>> Sobol.bitwise_xor(13, 17) 28 >>> Sobol.bitwise_xor(31, 5) 26
-
bounds
¶
-
desc_brief
= 'sample the search space using a Sobol sequence'¶
-
desc_full
= ['Generates a Sobol sequence of points to sample in the search space.', '', 'A Sobol sequence is a low discrepancy quasirandom sequence,', 'specifically designed to cover the search space evenly.', '', 'Details are available at: http://en.wikipedia.org/wiki/Sobol_sequence', 'This sampling method should be preferred over sampling uniformly at random.']¶
-
static
i4_bit_hi1
(n)[source]¶ Returns the position of the high 1 bit base 2 in an integer.
Parameters: n (int) – the integer to be measured Returns: (int) the number of bits base 2 This was taken from http://people.sc.fsu.edu/~jburkardt/py_src/sobol/sobol.html Licensing:
This code is distributed under the MIT license.- Modified:
- 22 February 2011
- Author:
- Original MATLAB version by John Burkardt. PYTHON version by Corrado Chisari
-
static
i4_bit_lo0
(n)[source]¶ Returns the position of the low 0 bit base 2 in an integer.
Parameters: n (int) – the integer to be measured Returns: (int) the number of bits base 2 This was taken from http://people.sc.fsu.edu/~jburkardt/py_src/sobol/sobol.html Licensing:
This code is distributed under the MIT license.- Modified:
- 22 February 2011
- Author:
- Original MATLAB version by John Burkardt. PYTHON version by Corrado Chisari
-
static
i4_sobol
(dim_num, seed)[source]¶ Generates a new quasi-random Sobol vector with each call.
Parameters: - dim_num (int) – number of dimensions of the Sobol vector
- seed (int) – the seed to use to generate the Sobol vector
Returns: the next quasirandom vector and the next seed to use
This was taken from http://people.sc.fsu.edu/~jburkardt/py_src/sobol/sobol.html Licensing:
This code is distributed under the MIT license.- Modified:
- 22 February 2011
- Author:
- Original MATLAB version by John Burkardt. PYTHON version by Corrado Chisari
-
static
i4_sobol_generate
(m, n, skip)[source]¶ Generates a Sobol sequence.
Parameters: - m (int) – the number of dimensions (our implementation supports up to 40)
- n (int) – the length of the sequence to generate
- skip (int) – the number of initial elements in the sequence to skip
Returns: a list of length n containing m-dimensional points of the Sobol sequence
-
maximize
(f, pmap=<built-in function map>)¶ Maximizes f.
Parameters: - f (callable) – the objective function
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
minimize
(f, pmap=<built-in function map>)¶ Minimizes
f
.Parameters: - f (callable) – the objective function
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
name
= 'sobol'¶
-
num_evals
¶
-
optimize
(f, maximize=True, pmap=<built-in function map>)[source]¶ Optimizes
f
.Parameters: - f (callable) – the objective function
- maximize (boolean) – do we want to maximizes?
- pmap (callable) – the map() function to use
Returns: - the arguments which optimize
f
- an optional solver report, can be None
-
skip
¶
-
static
suggest_from_box
(num_evals, **kwargs)[source]¶ Create a configuration for a Sobol solver.
Parameters: - num_evals (int) – number of permitted function evaluations
- kwargs ({'param': [lb, ub], ..}) – box constraints
Verify that we can effectively make a solver from box.
>>> s = Sobol.suggest_from_box(30, x=[0, 1], y=[-1, 0], z=[-1, 1]) >>> solver = Sobol(**s)