NonlinearHyperRectangleUtilityFunction

class negmas.utilities.NonlinearHyperRectangleUtilityFunction(hypervolumes: Iterable[Mapping[Union[int, str], Union[int, float, str, List[int], List[float], List[str], Tuple[int, int], Tuple[float, float], List[Tuple[Union[int, float], Union[int, float]]]]]], mappings: List[Union[Callable[[Union[negmas.outcomes.OutcomeType, Tuple[Union[int, float, str, list]], Dict[Union[int, str], Union[int, float, str, list]], int, str, float]], Union[negmas.helpers.Distribution, float]], Mapping[Union[Sequence, Mapping, int, str, float], Union[negmas.helpers.Distribution, float]]]], f: Callable[[List[Union[negmas.helpers.Distribution, float]]], Union[negmas.helpers.Distribution, float]], name: Optional[str] = None, reserved_value: Union[negmas.helpers.Distribution, float] = - inf, ami: Optional[negmas.common.AgentMechanismInterface] = None, outcome_type: Optional[Type] = None, id=None)[source]

Bases: negmas.utilities.UtilityFunction

A utility function defined as a set of outcome_ranges.

Parameters

Methods Summary

eval(offer)

Calculate the utility value for a given outcome.

from_dict(d)

to_dict()

xml(issues)

Converts the function into a well formed XML string preferrably in GENIUS format.

Methods Documentation

eval(offer: Optional[Union[negmas.outcomes.OutcomeType, Tuple[Union[int, float, str, list]], Dict[Union[int, str], Union[int, float, str, list]]]])Optional[Union[negmas.helpers.Distribution, float]][source]

Calculate the utility value for a given outcome.

Parameters

offer – The offer to be evaluated.

Returns

The utility_function value which may be a distribution.

If None it means the utility_function value cannot be calculated.

Return type

UtilityValue

Remarks:
  • You cannot return None from overriden eval() functions but raise an exception (ValueError) if it was not possible to calculate the UtilityValue.

  • Typehint the return type as a UtilityValue instead of a float for the benefit of inspection code.

  • Return the reserved value if the offer was None

  • NEVER call the baseclass using super() when overriding this method. Calling super will lead to an infinite loop.

  • The default implementation assumes that is_better is defined and uses it to do the evaluation. Note that the default implementation of is_better does assume that eval is defined and uses it. This means that failing to define both leads to an infinite loop.

classmethod from_dict(d)[source]
to_dict()[source]
xml(issues: List[negmas.outcomes.Issue])str[source]

Converts the function into a well formed XML string preferrably in GENIUS format.

If the output has with </objective> then discount factor and reserved value should also be included If the output has </utility_space> it will not be appended in to_xml_str