Negotiator

class negmas.negotiators.Negotiator(name: str = None, ufun: Optional[UtilityFunction] = None, parent: Controller = None, owner: Agent = None, id: str = None)[source]

Bases: negmas.common.Rational, negmas.events.Notifiable, abc.ABC

Abstract negotiation agent. Base class for all negotiators

Parameters

name

Negotiator name. If not given it is assigned by the system (unique 16 characters).

Returns:

bool: True if participating in the given negotiation (or any negotiation if it was None)

Remarks:

Attributes Summary

ami

capabilities

Agent capabilities

owner

Returns the owner agent of the negotiator

parent

Returns the parent controller

utility_function

The utility function attached to that object

Methods Summary

add_capabilities(capabilities)

Adds named capabilities to the agent.

before_death(cntxt)

Called whenever the parent is about to kill this negotiator.

cancel([reason])

A method that may be called by a mechanism to make the negotiator cancel whatever it is currently processing.

is_acceptable_as_agreement(outcome)

Whether the given outcome is acceptable as a final agreement of a negotiation.

isin(negotiation_id)

Is that agent participating in the given negotiation? Tests if the agent is participating in the given negotiation.

join(ami, state, *[, ufun, role])

Called by the mechanism when the agent is about to enter a negotiation.

on_leave(state)

A call back called after leaving a negotiation.

on_mechanism_error(state)

A call back called whenever an error happens in the mechanism.

on_negotiation_end(state)

A call back called at each negotiation end

on_negotiation_start(state)

A call back called at each negotiation start

on_notification(notification, notifier)

Called whenever the agent receives a notification

on_round_end(state)

A call back called at each negotiation round end

on_round_start(state)

A call back called at each negotiation round start

on_ufun_changed()

Called to inform the agent that its ufun has changed.

Attributes Documentation

ami
capabilities

Agent capabilities

owner

Returns the owner agent of the negotiator

parent

Returns the parent controller

utility_function

The utility function attached to that object

Methods Documentation

add_capabilities(capabilities: dict)None[source]

Adds named capabilities to the agent.

Parameters

capabilities – The capabilities to be added as a dict

Returns

None

Remarks:

It is the responsibility of the caller to be really capable of added capabilities.

before_death(cntxt: Dict[str, Any])bool[source]

Called whenever the parent is about to kill this negotiator. It should return False if the negotiator does not want to be killed but the controller can still force-kill it

cancel(reason=None)None[source]

A method that may be called by a mechanism to make the negotiator cancel whatever it is currently processing.

Negotiators can just ignore this message (default behavior) but if there is a way to actually cancel work, it should be implemented here to improve the responsiveness of the negotiator.

is_acceptable_as_agreement(outcome: Outcome)bool[source]

Whether the given outcome is acceptable as a final agreement of a negotiation.

The default behavior is to reject only if a reserved value is defined for the agent and is known to be higher than the utility of the outcome.

isin(negotiation_id: Optional[str])bool[source]

Is that agent participating in the given negotiation? Tests if the agent is participating in the given negotiation.

Parameters

negotiation_id (Optional[str]) – The negotiation ID tested. If None, it means ANY negotiation

Returns

True if participating in the given negotiation (or any

negotiation if it was None)

Return type

bool

join(ami: negmas.common.AgentMechanismInterface, state: negmas.common.MechanismState, *, ufun: Optional[UtilityFunction] = None, role: str = 'agent')bool[source]

Called by the mechanism when the agent is about to enter a negotiation. It can prevent the agent from entering

Parameters
Returns

bool indicating whether or not the agent accepts to enter. If False is returned it will not enter the negotiation

on_leave(state: negmas.common.MechanismState)None[source]

A call back called after leaving a negotiation.

Parameters

stateMechanismState giving current state of the negotiation.

Remarks:
  • MUST call the baseclass on_leave using super () if you are going to override this.

  • The default behavior is to do nothing.

  • Override this to hook some action

on_mechanism_error(state: negmas.common.MechanismState)None[source]

A call back called whenever an error happens in the mechanism. The error and its explanation are accessible in state

Parameters

stateMechanismState giving current state of the negotiation.

Remarks:
  • The default behavior is to do nothing.

  • Override this to hook some action

on_negotiation_end(state: negmas.common.MechanismState)None[source]

A call back called at each negotiation end

Parameters

stateMechanismState or one of its descendants giving the state at which the negotiation ended.

Remarks:
on_negotiation_start(state: negmas.common.MechanismState)None[source]

A call back called at each negotiation start

Parameters

stateMechanismState giving current state of the negotiation.

Remarks:

  • You MUST call the super() version of this function either before or after your code when you are overriding it.

  • on_negotiation_start and on_negotiation_end will always be called once for every agent.

on_notification(notification: negmas.events.Notification, notifier: str)[source]

Called whenever the agent receives a notification

Parameters
  • notification – The notification!!

  • notifier – The notifier!!

Returns

None

Remarks:

  • You MUST call the super() version of this function either before or after your code when you are overriding it.

on_round_end(state: negmas.common.MechanismState)None[source]

A call back called at each negotiation round end

Parameters

stateMechanismState giving current state of the negotiation.

Remarks:
  • The default behavior is to do nothing.

  • Override this to hook some action

on_round_start(state: negmas.common.MechanismState)None[source]

A call back called at each negotiation round start

Parameters

stateMechanismState giving current state of the negotiation.

Remarks:
  • The default behavior is to do nothing.

  • Override this to hook some action.

on_ufun_changed()[source]

Called to inform the agent that its ufun has changed.

Remarks:

  • You MUST call the super() version of this function either before or after your code when you are overriding it.