Parameters

pyhopper.float(lb=None, ub=None, init=None, log=False, precision=None, shape=None, mutation_fn=None, seeding_fn=None)

Creates a new floating point parameter

Parameters
  • lb (Optional[Union[int, float, numpy.ndarray]]) – Lower bound of the parameter. If both lb and ub are None, this parameter will be unbounded (usually not recommended).

  • ub (Optional[Union[int, float, numpy.ndarray]]) – Upper bound of the parameter. If None, the lb argument will be used as upper bound with a lower bound of 0.

  • init (Optional[Union[int, float, numpy.ndarray]]) – Initial value of the parameter. If None it will be randomly sampled

  • shape (Optional[Union[int, Tuple]]) – For NumPy array type parameters, this argument must be set to a tuple containing the shape of the np.ndarray

  • log (bool) – Whether to use logarithmic or linearly scaling of the parameter. Defaults to False which searches the space linearly. If True, a logarithmic scaling is applied to the search space of this variable

  • precision (Optional[int]) – Rounds the values to the specified significant digits. Defaults to None meaning that no rounding is applied

  • mutation_fn (Optional[function]) – Setting this argument to a callable overwrites the default local sampling strategy. The callback gets called with the value of the the current best solution as argument and returns a mutated value

  • seeding_fn (Optional[function]) – Setting this argument to a callable overwrites the default random seeding strategy

Return type

pyhopper.parameters.FloatParameter

import pyhopper

pyhopper.float(0,1) #  Bounded by 0 and 1
pyhopper.float(1)   #  Implicitly bounded by 0 and 1
pyhopper.float()    #  Unbounded
pyhopper.int(lb=None, ub=None, init=None, multiple_of=None, power_of=None, shape=None, seeding_fn=None, mutation_fn=None)

Creates a new integer parameter

Parameters
  • lb (Optional[Union[int, float, numpy.ndarray]]) – Lower bound of the parameter.

  • ub (Optional[Union[int, float, numpy.ndarray]]) – Upper bound of the parameter. If None, the lb argument will be used as upper bound with a lower bound of 0.

  • init (Optional[Union[int, float, numpy.ndarray]]) – Initial value of the parameter. If None it will be randomly sampled

  • multiple_of (Optional[int]) – Setting this value to a positive integer enforces the sampled values of this parameter to be a mulitple of multiple_of.

  • shape (Optional[Union[int, Tuple]]) – For NumPy array type parameters, this argument must be set to a tuple containing the shape of the np.ndarray

  • mutation_fn (Optional[callable]) – Setting this argument to a callable overwrites the default local sampling strategy. The callback gets called with the value of the the current best solution as argument and returns a mutated value

  • seeding_fn (Optional[callable]) – Setting this argument to a callable overwrites the default random seeding strategy

  • power_of (Optional[int]) –

Returns

Return type

pyhopper.parameters.IntParameter

pyhopper.choice(options, init=None, is_ordinal=False, mutation_fn=None, seeding_fn=None)

Creates a new choice parameter

Parameters
  • options (list) – List containing the possible values of this parameter

  • init (Optional[Any]) – Initial value of the parameter. If None it will be randomly sampled.

  • is_ordinal (bool) – Flag indicating whether two neighboring list items ordered or not. If True, in the local sampling stage list items neighboring the current best value will be preferred. For sets with a natural ordering it is recommended to set this flag to True.

  • mutation_fn (Optional[function]) – Setting this argument to a callable overwrites the default local sampling strategy. The callback gets called with the value of the the current best solution as argument and returns a mutated value

  • seeding_fn (Optional[function]) – Setting this argument to a callable overwrites the default random seeding strategy

Returns

Return type

pyhopper.parameters.ChoiceParameter

pyhopper.custom(seeding_fn=None, mutation_fn=None, init=None)
Parameters
  • seeding_fn (Optional[callable]) –

  • mutation_fn (Optional[callable]) –

  • init (Optional[Any]) –

Return type

pyhopper.parameters.CustomParameter

class pyhopper.Parameter(init=None)[source]