negmas.common¶
Common data-structures and classes used by all other modules.
This module does not import anything from the library except during type checking
- negmas.common.AgentMechanismInterface[source]¶
A depricated alias for
NegotiatorMechanismInterface
- class negmas.common.MechanismState(running: bool = False, waiting: bool = False, started: bool = False, step: int = 0, time: float = 0.0, relative_time: float = 0.0, broken: bool = False, timedout: bool = False, agreement: tuple | None = None, results: tuple | OutcomeSpace | tuple[tuple] | None = None, n_negotiators: int = 0, has_error: bool = False, error_details: str = '', erred_negotiator: str = '', erred_agent: str = '')[source]¶
Bases:
objectEncapsulates the mechanism state at any point
- agreement: tuple | None[source]¶
Agreement at the end of the negotiation (it is always None until an agreement is reached).
- n_negotiators: int[source]¶
Number of agents currently in the negotiation. Notice that this may change over time if the mechanism supports dynamic entry
- relative_time: float[source]¶
A number in the period [0, 1] giving the relative time of the negotiation. Relative time is calculated as
max(step/n_steps, time/time_limit).
- class negmas.common.NegotiatorInfo(name: str, id: str, type: str)[source]¶
Bases:
objectKeeps information about a negotiator. Mostly for use with controllers.
- class negmas.common.NegotiatorMechanismInterface(id: str, n_outcomes: int | float, outcome_space: OutcomeSpace, time_limit: float, pend: float, pend_per_second: float, step_time_limit: float, negotiator_time_limit: float, n_steps: int | None, dynamic_entry: bool, max_n_negotiators: int | None, _mechanism: Mechanism, annotation: dict[str, Any]=<class 'dict'>)[source]¶
Bases:
objectAll information of a negotiation visible to negotiators.
- annotation: dict[str, Any][source]¶
An arbitrary annotation as a
dict[str, Any]that is always available for all negotiators
- property cartesian_outcome_space: CartesianOutcomeSpace[source]¶
Returns the
outcome_spaceas aCartesianOutcomeSpaceor raises aValueErrorif that was not possible.Remarks:
Useful for negotiators that only work with
CartesianOutcomeSpaces (i.e.GeniusNegotiator)
- discrete_outcome_space(levels: int = 5, max_cardinality: int = 10000000000) DiscreteOutcomeSpace[source]¶
Returns a stable discrete version of the given outcome-space
- discrete_outcomes(max_cardinality: int | float = inf) Iterable[tuple][source]¶
A discrete set of outcomes that spans the outcome space
- dynamic_entry: bool[source]¶
Whether it is allowed for negotiators to enter/leave the negotiation after it starts
- property estimated_n_steps: int[source]¶
Return an estimate of the number of steps for this negotiation.
- property estimated_time_limit: float[source]¶
Return an estimate of the number of seconds for this negotiation.
- genius_id(id: str | None) str | None[source]¶
Gets the Genius ID corresponding to the given negotiator if known otherwise its normal ID
- property genius_negotiator_ids: list[str][source]¶
Gets the Java IDs of all negotiators (if the negotiator is not a GeniusNegotiator, its normal ID is returned)
- max_n_negotiators: int | None[source]¶
Maximum allowed number of negotiators in the session. None indicates no limit
- n_steps: int | None[source]¶
The allowed number of steps for this negotiation. None indicates infinity
- negotiator_index(source: str) int[source]¶
Returns the negotiator index for the given negotiator. Raises an exception if not found
- negotiator_time_limit: float[source]¶
The time limit in seconds to wait for negotiator responses of this negotiation session. None indicates infinity
- outcome_space: OutcomeSpace[source]¶
Negotiation agenda as as an
OutcomeSpaceobject. The most common type isCartesianOutcomeSpacewhich represents the cartesian product of a list of issues
- property outcomes: Iterable[tuple] | None[source]¶
All outcomes for discrete outcome spaces or None for continuous outcome spaces. See
discrete_outcomes
- property participants: list[NegotiatorInfo][source]¶
Participants.
- Returns:
The result.
- Return type:
- pend: float[source]¶
The probability that the negotiation times out at every step. Must be less than one. If <= 0, it is ignored
- pend_per_second: float[source]¶
The probability that the negotiation times out every second. Must be less than one. If <= 0, it is ignored
- random_outcomes(n: int = 1) list[tuple][source]¶
A set of random outcomes from the outcome-space of this negotiation
- property requirements: dict[source]¶
The protocol requirements
- Returns:
A dict of str/Any pairs giving the requirements
- property state: MechanismState[source]¶
Access the current state of the mechanism.
Remarks:
Whenever a method receives a
AgentMechanismInterfaceobject, it can always access the current state of the protocol by accessing this property.
- step_time_limit: float[source]¶
The time limit in seconds for each step of ;this negotiation session. None indicates infinity
- class negmas.common.PreferencesChange(type: PreferencesChangeType = PreferencesChangeType.General, data: Any = None)[source]¶
Bases:
objectPreferencesChange implementation.
- class negmas.common.PreferencesChangeType(*values)[source]¶
Bases:
EnumThe type of change in preferences.
Remarks:
Returned from
changesproperty ofPreferencesto help the owner of the preferences in deciding what to do with the change.Received by the
on_preferences_changedmethod ofRationalentities to inform them about a change in preferences.Note that the
Rationalentity needs to callchangesexplicitly and call its ownon_preferences_changedto handle changes that happen without assignment to negmas.preferences of theRationalentity.If the negmas.preferences of the
Rationalagent are changed through assignment, itson_preferences_changedwill be called with the appropriatePreferencesChangelist.
- class negmas.common.TraceElement(time, relative_time, step, negotiator, offer, responses, state)[source]¶
Bases:
tupleAn element of the trace returned by
full_tracerepresenting the history of the negotiation
- negmas.common.Value[source]¶
A value in NegMAS can either be crisp ( float ) or probabilistic (
Distribution)alias of
Distribution|float