class_docstr: Implement the hypervolume scalarization.
  
  Given a vector of (at least two) objectives M, a unit-length vector V with
  non-negative coordinates, a slope vector A, and an offset vector B, all having
  the same dimension, the hypervolume scalarization of M is defined as:
  
  ```min_{i: V_i > 0} max(A_i * M_i + B_i, 0) / V_i.```
  
  See https://arxiv.org/abs/2006.04655 for more details.
  Note that it is recommended for the user to set A_i and B_i in such a way to
  ensure non-negativity of the transformed objectives.
class_docstr_tok: ["Implement","the","hypervolume","scalarization",".","Given","a","vector","of","(","at","least","two",")","objectives","M",",","a","unit-length","vector","V","with","non-negative","coordinates",",","a","slope","vector","A",",","and","an","offset","vector","B",",","all","having","the","same","dimension",",","the","hypervolume","scalarization","of","M","is","defined","as",":","``","`","min_","{","i",":","V_i",">","0","}","max","(","A_i","*","M_i","+","B_i",",","0",")","\/","V_i.","``","`","See","https",":","\/\/arxiv.org\/abs\/2006.04655","for","more","details",".","Note","that","it","is","recommended","for","the","user","to","set","A_i","and","B_i","in","such","a","way","to","ensure","non-negativity","of","the","transformed","objectives","."]
docstr: Initialize the HyperVolumeScalarizer.
  
  Args:
    direction: A `Sequence` representing a directional vector, which will be
      normalized to have unit length. Coordinates of the normalized direction
      whose absolute values are less than `HyperVolumeScalarizer.ALMOST_ZERO`
      will be considered zeros.
    transform_params: A `Sequence` of namedtuples
      `HyperVolumeScalarizer.PARAMS`, each containing a slope and an offset
      for transforming an objective to be non-negative.
    multi_objective_transform: A `Optional` `Callable` that takes in a
      `tf.Tensor` of multiple objective values, a `Sequence` of slopes, and a
      `Sequence` of offsets, and returns a `tf.Tensor` of transformed multiple
      objectives. If unset, the transform is defaulted to the standard
      transform multiple_objectives * slopes + offsets.
  
  Raises:
    ValueError: if `any([x < 0 for x in direction])`.
    ValueError: if the 2-norm of `direction` is less than
      `HyperVolumeScalarizer.ALMOST_ZERO`.
    ValueError: if `len(transform_params) != len(self._direction)`.
docstr_tok: ["Initialize","the","HyperVolumeScalarizer",".","Args",":","direction",":","A","`","Sequence","`","representing","a","directional","vector",",","which","will","be","normalized","to","have","unit","length",".","Coordinates","of","the","normalized","direction","whose","absolute","values","are","less","than","`","HyperVolumeScalarizer.ALMOST_ZERO","`","will","be","considered","zeros",".","transform_params",":","A","`","Sequence","`","of","namedtuples","`","HyperVolumeScalarizer.PARAMS","`",",","each","containing","a","slope","and","an","offset","for","transforming","an","objective","to","be","non-negative",".","multi_objective_transform",":","A","`","Optional","`","`","Callable","`","that","takes","in","a","`","tf.Tensor","`","of","multiple","objective","values",",","a","`","Sequence","`","of","slopes",",","and","a","`","Sequence","`","of","offsets",",","and","returns","a","`","tf.Tensor","`","of","transformed","multiple","objectives",".","If","unset",",","the","transform","is","defaulted","to","the","standard","transform","multiple_objectives","*","slopes","+","offsets",".","Raises",":","ValueError",":","if","`","any","(","[","x","<","0","for","x","in","direction","]",")","`",".","ValueError",":","if","the","2-norm","of","`","direction","`","is","less","than","`","HyperVolumeScalarizer.ALMOST_ZERO","`",".","ValueError",":","if","`","len","(","transform_params",")","!","=","len","(","self._direction",")","`","."]
code: def __init__(
      self,
      direction: Sequence[ScalarFloat],
      transform_params: Sequence[PARAMS],
      multi_objective_transform: Optional[
          Callable[
              [tf.Tensor, Sequence[ScalarFloat], Sequence[ScalarFloat]],
              tf.Tensor,
          ]
      ] = None,
  ):
      """Initialize the HyperVolumeScalarizer.
  
      Args:
        direction: A `Sequence` representing a directional vector, which will be
          normalized to have unit length. Coordinates of the normalized direction
          whose absolute values are less than `HyperVolumeScalarizer.ALMOST_ZERO`
          will be considered zeros.
        transform_params: A `Sequence` of namedtuples
          `HyperVolumeScalarizer.PARAMS`, each containing a slope and an offset
          for transforming an objective to be non-negative.
        multi_objective_transform: A `Optional` `Callable` that takes in a
          `tf.Tensor` of multiple objective values, a `Sequence` of slopes, and a
          `Sequence` of offsets, and returns a `tf.Tensor` of transformed multiple
          objectives. If unset, the transform is defaulted to the standard
          transform multiple_objectives * slopes + offsets.
  
      Raises:
        ValueError: if `any([x < 0 for x in direction])`.
        ValueError: if the 2-norm of `direction` is less than
          `HyperVolumeScalarizer.ALMOST_ZERO`.
        ValueError: if `len(transform_params) != len(self._direction)`.
      """
      if any([x < 0 for x in direction]):
          raise ValueError(
              "direction should be in the positive orthant, but has negative "
              "coordinates: [{}].".format(
                  ", ".join(map(str, direction))
              )
          )
      length = np.sqrt(sum([x * x for x in direction]))
      if length < self.ALMOST_ZERO:
          raise ValueError(
              "direction found to be a nearly-zero vector, but should not be."
          )
      self._direction = [x / length for x in direction]
      if len(transform_params) != len(self._direction):
          raise ValueError(
              "direction has {} elements but transform_params has {}.".format(
                  len(direction), len(transform_params)
              )
          )
      self._slopes, self._offsets = zip(
          *[(p.slope, p.offset) for p in transform_params]
      )
  
      if multi_objective_transform is None:
          multi_objective_transform = self._default_hv_transform
  
      self._transformer = multi_objective_transform
      super(HyperVolumeScalarizer, self).__init__(
          len(self._direction),
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import copy
  from typing import Callable, Dict, NamedTuple, Optional, Sequence, Union
  import numpy
  import six
  import tensorflow.compat.v2
label_desc: Use image node_id 1 to create a new HyperVolumeScalarizer object from inherited base classes: Scalarizer with example: obj = HyperVolumeScalarizer(direction, transform_params, multi_objective_transform)