opposition_level
- negmas.preferences.opposition_level(ufuns, max_utils=1.0, outcomes=None, issues=None, max_tests=10000)[source]
Finds the opposition level of the two ufuns defined as the minimum distance to outcome (1, 1)
- Parameters:
ufuns (Sequence[UtilityFunction]) – A list of utility functions to use.
max_utils (float | tuple[float | int, …] | list[float | int]) – A list of maximum utility value for each ufun (or a single number if they are equal).
outcomes (int | Sequence[Outcome] | None) – 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 (Sequence[Issue] | None) – The issues (only used if outcomes is None).
max_tests (int) – The maximum number of outcomes to use. Only used if issues is given and has more outcomes than this value.
- Return type:
float
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