pg.floatv

Accessible via pg.floatv, pg.float_value, pg.hyper.floatv, pg.hyper.float_value.

floatv(min_value, max_value, scale=None, *, name=None, hints=None)[source]

A continuous value within a range.

Example:

# A continuous value within [0.0, 1.0]
v = pg.floatv(0.0, 1.0)

See also: :rtype: Any

Note

Under symbolic mode (by default), pg.floatv returns a pg.hyper.Float object. Under dynamic evaluate mode, which is called under the context of pg.hyper.DynamicEvaluationContext or pg.hyper.DynamicEvaluationContext, it evaluates to a concrete candidate value.

Parameters:
  • min_value – Minimum acceptable value (inclusive).

  • max_value – Maximum acceptable value (inclusive).

  • scale

    An optional string as the scale of the range. Supported values are None, ‘linear’, ‘log’, and ‘rlog’. If None, the feasible space is unscaled. If linear, the feasible space is mapped to [0, 1] linearly. If log, the feasible space is mapped to [0, 1] logarithmically with

    formula x -> log(x / min) / log(max / min).

    If rlog, the feasible space is mapped to [0, 1] “reverse”

    logarithmically, resulting in values close to max_value spread out more than the points near the min_value, with formula: x -> 1.0 - log((max + min - x) / min) / log (max / min).

    min_value must be positive if scale is not None. Also, it depends on the search algorithm to decide whether this information is used or not.

  • name – A name that can be used to identify a decision point in the search space. This is needed when the code to instantiate the same hyper primitive may be called multiple times under a pg.DynamicEvaluationContext.collect context or a pg.DynamicEvaluationContext.apply context.

  • hints – An optional value which acts as a hint for the controller.

Returns:

In symbolic mode, this function returns a Float. In dynamic evaluate mode, this function returns a float value that is no less than the min_value and no greater than the max_value. If evaluated under an pg.DynamicEvaluationContext.apply scope, this function will return a chosen float value from the controller decisions. If evaluated under a pg.DynamicEvaluationContext.collect scope, it will return min_value.