opposition_level
- negmas.preferences.opposition_level(ufuns: Sequence[UtilityFunction], max_utils: float | tuple[float | int, ...] | list[float | int] = 1.0, outcomes: int | Sequence[Outcome] | None = None, issues: Sequence[Issue] | None = None, max_tests: int = 10000) float[source]
Finds the opposition level of the two ufuns defined as the minimum distance to outcome (1, 1)
- Parameters:
ufuns – A list of utility functions to use.
max_utils – A list of maximum utility value for each ufun (or a single number if they are equal).
outcomes – A list of outcomes (should be the complete issue space) or an integer giving the number of outcomes. In the later case, ufuns should expect a tuple of a single integer.
issues – The issues (only used if outcomes is None).
max_tests – The maximum number of outcomes to use. Only used if issues is given and has more outcomes than this value.
Examples
Opposition level of the same ufun repeated is always 0
>>> from negmas.preferences.crisp.mapping import MappingUtilityFunction >>> from negmas.preferences.ops import opposition_level >>> u1, u2 = lambda x: x[0], lambda x: x[0] >>> opposition_level([u1, u2], outcomes=10, max_utils=9) 0.0
Opposition level of two ufuns that are zero-sum
>>> u1, u2 = ( ... MappingUtilityFunction(lambda x: x[0]), ... MappingUtilityFunction(lambda x: 9 - x[0]), ... ) >>> opposition_level([u1, u2], outcomes=10, max_utils=9) 0.7114582486036499