LinDiscountedUFun

class negmas.utilities.LinDiscountedUFun(ufun: negmas.utilities.UtilityFunction, ami: negmas.common.AgentMechanismInterface, cost: Optional[float] = None, factor: Union[str, Callable[[negmas.common.AgentMechanismInterface], float]] = 'current_step', power: float = 1.0, name=None, reserved_value: Union[negmas.helpers.Distribution, float] = - inf, dynamic_reservation=True, outcome_type: Optional[Type] = None, id=None)[source]

Bases: negmas.utilities.UtilityFunction

A utility function with linear discounting based on some factor of the negotiation

Parameters
  • ufun – The utility function that is being discounted

  • cost – discount factor

  • factor – str -> The name of the AgentMechanismInterface variable based on which discounting operate

  • -> must receive a mechanism info object and returns a float representing the factor (callable) –

  • power – A power to raise the total cost to before discounting it from the utility_function value

Attributes Summary

ami

base_type

Returns the utility_function base type ignoring discounting and similar wrappings.

outcome_type

type

Returns the utility_function type.

Methods Summary

eval(offer)

Calculate the utility value for a given outcome.

from_dict(d)

random(issues[, reserved_value, normalized, …])

Generates a random ufun of the given type

to_dict()

xml(issues)

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

Attributes Documentation

ami
base_type
outcome_type
type

Methods Documentation

eval(offer: Union[negmas.outcomes.OutcomeType, Tuple[Union[int, float, str, list]], Dict[Union[int, str], Union[int, float, str, list]]])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: Dict[str, Any])[source]
classmethod random(issues, reserved_value=(0.0, 1.0), normalized=True, cost_range=(0.8, 1.0), power_range=(0.0, 1.0), base_ufun_type: Type[negmas.utilities.UtilityFunction] = 'negmas.LinearUtilityAggregationFunction', **kwargs)negmas.utilities.ExpDiscountedUFun[source]

Generates a random ufun of the given type

to_dict()Dict[str, Any][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