negmas.sao¶
Implements Stacked Alternating Offers (SAO) mechanism and basic negotiators.
- class negmas.sao.ACCombi(offering_strategy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyThe ACcombi acceptance condition of Baarslag et al. (2012/2013), used by the Nice Tit for Tat agent.
ACcombi combines ACnext with a time-based fallback:
ACnext: accept the opponent’s offer if it is at least as good as the offer the bidding strategy was planning to propose next, i.e.
a * u(opp_offer) + b >= u(my_next_offer). The rationale is that if the opponent’s offer beats our own next planned offer, we have effectively reached a consensus and should accept.ACtime: when time is running out (
relative_time >= t), accept the offer rather than risk a breakdown — there is no expected improvement in the little time left.
Accepts if either condition holds.
- Parameters:
offering_strategy – The offering policy used to determine our next planned offer (its result is cached per step, so calling it here does not duplicate the work done when we later propose).
a – Scaling factor on the opponent-offer utility (default
1.0).b – Offset added to the scaled opponent-offer utility (default
0.0).t – Relative-time threshold for the ACtime fallback (default
0.99).
- Remarks:
If the offering strategy cannot produce a next offer, any rational offer (at or above the reserved value) is accepted.
AI Generated (ACcombi acceptance condition for the Nice Tit for Tat agent).
- offering_strategy: OfferingPolicy[source]¶
- class negmas.sao.ACConst(th: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts outcomes with utilities above the given threshold
- class negmas.sao.ACLast(alpha: float = 1.0, beta: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyImplements the AClast acceptance strategy based on our last offer.
Accepts $omega$ if $lpha u(my-next-offer) + eta > u(omega)$
- class negmas.sao.ACLastFractionReceived(fraction: float = 1.0, alpha: float = 1.0, beta: float = 0.0, op: Callable[[list[float]], float] = <built-in function max>, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts $omega$ if $lpha u(my-next-offer) + eta > f(u( ext{utils of offers received in the given fraction of time}))$
- class negmas.sao.ACLastKReceived(k: int = 0, alpha: float = 1.0, beta: float = 0.0, op: Callable[[list[float]], float] = <built-in function max>, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts $omega$ if $lpha u(my-next-offer) + eta > f(u( ext{utils of offers received in the last k steps))$
- after_join(nmi) None[source]¶
Initialize the sliding window buffer for tracking recent offer utilities.
- class negmas.sao.ACNext(offering_strategy: OfferingPolicy, alpha: float = 1.0, beta: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyImplements the ACnext acceptance strategy based on our next offer.
Accepts $omega$ if $lpha u(my-next-offer) + eta > u(omega)$
- offering_strategy: OfferingPolicy[source]¶
- class negmas.sao.ACTime(tau: float, rational: bool = True, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyImplements the ACtime acceptance strategy based on our next offer.
Accepts if the relative time is greater than or equal to tau
- class negmas.sao.AcceptAbove(limit: float, above_reserve: bool = True, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts outcomes with utilities in the given top
limitfraction above reserve/minimum (based onabove_resrve).- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Handle preference updates (no action needed for threshold-based acceptance).
- class negmas.sao.AcceptAnyRational(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts any rational outcome.
- class negmas.sao.AcceptAround(relative_time: float = 1.0, eps: float = 0.001, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts around the given relative time (i.e. eps from it)
- class negmas.sao.AcceptBest(best_util: float = inf, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts Only the best outcome.
- Remarks:
If the best possible utility cannot be found, nothing will be accepted
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Handle preference updates (no action needed for best-only acceptance).
- class negmas.sao.AcceptBetterRational(accepted: dict[str, Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccept first rational outcomes and then accept only outcomes better than the all accepted so far.
- class negmas.sao.AcceptBetween(min: float, max: float = 1.0, rational: bool = True, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts in the given range of relative times.
- class negmas.sao.AcceptImmediately(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts immediately anything
- class negmas.sao.AcceptNotWorseRational(accepted: dict[str, Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccept any outcome not worse than the best so far.
- class negmas.sao.AcceptTop(fraction: float = 0.0, k: int = 1, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts outcomes that are in the given top fraction or top
k. If neither is given it reverts to accepting the best outcome only.- Remarks:
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Reinitialize the utility inverter when preferences change significantly.
- class negmas.sao.AcceptancePolicy(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GBComponentAcceptance policy implementation.
- respond(state: GBState, offer: Outcome | None, source: str | None) ResponseType | ExtendedResponseType[source]¶
Called to respond to an offer. This is the method that should be overriden to provide an acceptance strategy.
- Parameters:
state – a
GBStategiving current state of the negotiation.offer – offer being tested
- Returns:
The response to the offer
- Return type:
- Remarks:
The default implementation never ends the negotiation
The default implementation asks the negotiator to
propose`() and accepts the `offerif its utility was at least as good as the offer that it would have proposed (and above the reserved value).
- class negmas.sao.AdditiveFirstFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.AdditiveLastOfferFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.AdditiveParetoFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.AdditivePartnerOffersOrientedSelector(*args, u_weight: float = 0.6, **kwargs)[source]¶
Bases:
PartnerOffersOrientedSelectorOrients offes toward the set of past opponent offers.
The score of an offer is the product of its utility to self and its distance to opponent’s past offers after normalization
- class negmas.sao.AllAcceptanceStrategies(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcensusAcceptancePolicyAccept only if all children accept, end only if all of them end, otherwise reject
- decide(indices: list[int], responses: list[ResponseType]) ResponseType | ExtendedResponseType[source]¶
Return first non-accept response, or accept if all strategies accepted.
- Parameters:
indices – Indices of strategies whose responses were saved.
responses – The saved responses from those strategies.
- Returns:
ACCEPT_OFFER if all accepted, otherwise the first reject/end response.
- filter(indx: int, response: ResponseType) FilterResult[source]¶
Stop early on reject/end; continue collecting accepts for unanimous decision.
- Parameters:
indx – Index of the strategy in the strategies list.
response – The response returned by the strategy at this index.
- Returns:
FilterResult indicating whether to continue and whether to save this response.
- class negmas.sao.AnyAcceptancePolicy(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcensusAcceptancePolicyAccept any children accept, end or reject only if all of them end or reject
- decide(indices: list[int], responses: list[ResponseType]) ResponseType | ExtendedResponseType[source]¶
Accept if any strategy accepted, reject only if all rejected.
- Parameters:
indices – Indices of strategies whose responses were saved.
responses – The saved responses from those strategies.
- Returns:
ACCEPT_OFFER if any accepted, REJECT_OFFER if all rejected.
- filter(indx: int, response: ResponseType) FilterResult[source]¶
Stop early on accept/end; continue collecting rejects to find any acceptor.
- Parameters:
indx – Index of the strategy in the strategies list.
response – The response returned by the strategy at this index.
- Returns:
FilterResult indicating whether to continue and whether to save this response.
- class negmas.sao.AspirationNegotiator(*args, max_aspiration=1.0, aspiration_type: Literal['boulware'] | Literal['conceder'] | Literal['linear'] | float = 'boulware', stochastic=False, presort: bool = True, tolerance: float = 0.001, ufun_inverter: type[InverseUFun] | None = None, **kwargs)[source]¶
Bases:
TimeBasedConcedingNegotiatorA time-based conceding negotiator with a simplified interface.
This is the most commonly used negotiator in the library. It concedes over time according to a polynomial aspiration curve (boulware / linear / conceder, or a custom exponent) and uses an
InverseUFunto find outcomes within the current aspiration band.- Parameters:
max_aspiration (float) – The aspiration level (relative utility in
[0, 1]) to use for the first offer (and first acceptance decision). Defaults to1.0(start at the best outcome).aspiration_type (str | float) – The polynomial aspiration curve type. Pass a string (
"boulware"for slow concession,"linear"for constant-rate concession,"conceder"for fast concession) or a real-valued exponent. Defaults to"boulware".stochastic (bool) – If
False(default), the negotiator proposes the outcome with the lowest utility still within its aspiration band (i.e. just above the aspiration level) viaworst_in. IfTrue, it proposes a random in-range outcome viaone_in.presort (bool) – If
True(default), aDefaultInverseUtilityFunction(i.e.AdaptiveInverseUtilityFunction) is used, which presorts outcomes for exactO(log n)lookups on small/medium spaces and falls back to BIDS for large additive spaces. IfFalse, no inverter is used and the negotiator cannot propose (it will always fall back to the best outcome).tolerance (float) – A tolerance used for sampling outcomes near the aspiration level (passed as
epsto the inverter). Defaults to0.001.ufun_inverter (type[InverseUFun] | None) – An optional
InverseUFuntype to use for inverting the utility function. If given, it overrides thepresortdefault. Seenegmas.preferences.inv_ufunfor the full list of available inverters and their trade-offs.**kwargs – Forwarded to
TimeBasedConcedingNegotiator(e.g.name,ufun,parent,owner).
- Remarks:
This class provides a simpler interface to
TimeBasedConcedingNegotiatorwith less control over the accepting curve and offer selector. For more control, useTimeBasedConcedingNegotiatororTimeBasedNegotiatordirectly.proposenever returnsNonemid-negotiation: if the inverter finds no outcome in the aspiration range (e.g. for strict inverters likeBruteForceInverseUtilityFunction, or when the aspiration band is empty), it falls back to the best outcome rather than breaking the SAO mechanism.
- class negmas.sao.BestOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
OfferOrientedSelectorSelects the offer nearest the partner’s best offer for me so far
- class negmas.sao.BestOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
FirstOfferOrientedTBNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on their utility value and how near they are to the partner’s past offer with the highest utility for me
- class negmas.sao.BestOfferSelector(*args, **kwargs)[source]¶
Bases:
OfferSelectorSelects the outcome with the highest utility value.
- class negmas.sao.BoulwareTBNegotiator(*args, **kwargs)[source]¶
Bases:
TimeBasedConcedingNegotiatorA time-based negotiator that concedes sub-linearly (boulware).
Uses a
PolyAspirationcurve with exponent 4 ("boulware") andstochastic=False(proposes the worst outcome within the aspiration band).
- class negmas.sao.CABNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorConceding Accepting Better Strategy (optimal, complete, but not an equilibirum)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.CABOfferingPolicy(next_indx: int = 0, sorter: InverseUFun | None = None, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyCABOffering policy implementation.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Initializes the outcome sorter on significant preference changes.
- sorter: InverseUFun | None[source]¶
- class negmas.sao.CANNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorConceding Accepting Not Worse Strategy (optimal, complete, but not an equilibirum)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.CARNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorConceding Accepting Rational Strategy (neither complete nor an equilibrium)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.CandidateEliminationModel(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UFunModelOrdinal opponent model via candidate elimination (survey §5.3.4).
Candidate elimination [8,9] is an inductive-learning algorithm that assumes only that the opponent’s preferences do not change during the negotiation. Each offer the opponent sends is a positive instance (its values are acceptable to the opponent); each of our own offers that the opponent rejects (i.e. counters instead of accepting) is a negative instance (something in it is unacceptable).
A full version space over whole offers is exponential, so — as the survey notes such models “only learn part of the relationships” — this is a per-issue rendition: for each issue it keeps the set of values seen in the opponent’s offers (acceptable) and the set seen only in rejected offers of ours (suspect). The estimated ordinal utility of an offer is the mean per-issue score, where a value is scored
1if confirmed acceptable,0if only ever seen in a rejected offer, and0.5if not yet seen (the general-boundary default: unseen values may still be acceptable).Negatives are derived automatically: whenever the opponent makes a new offer, our most recent proposal is treated as rejected. They can also be supplied explicitly via
note_rejected().- Remarks:
This is an ordinal model — the values it returns rank outcomes but are not calibrated cardinal utilities.
Returns
0.5for every outcome until some evidence is gathered.
AI Generated (candidate-elimination acceptable-offer model).
- after_proposing(state: GBState, offer: Outcome | ExtendedOutcome | None, dest=None)[source]¶
Remember our own proposal so a later opponent offer marks it rejected.
- before_responding(state, offer: Outcome | None, source: str | None = None)[source]¶
Learn from the opponent offer we are about to respond to.
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Eval normalized (the model already returns values in
[0, 1]).
- note_rejected(offer: Outcome) None[source]¶
Record
offeras a negative (rejected-by-opponent) instance.
- on_partner_proposal(state, partner_id: str, offer: Outcome) None[source]¶
Learn from a partner proposal (only with
enable_callbacks).
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Set up the issue list and register the model.
- class negmas.sao.ConcederTBNegotiator(*args, **kwargs)[source]¶
Bases:
TimeBasedConcedingNegotiatorA time-based negotiator that concedes super-linearly (conceder).
Uses a
PolyAspirationcurve with exponent 0.25 ("conceder") andstochastic=False.
- class negmas.sao.ConcensusAcceptancePolicy(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicy,ABCAccepts based on concensus of multiple strategies
- abstractmethod decide(indices: list[int], responses: list[ResponseType | ExtendedResponseType]) ResponseType | ExtendedResponseType[source]¶
Called to make a final decision given the decisions of the strategies with indices
indices(seefilterfor filtering rules)
- filter(indx: int, response: ResponseType | ExtendedResponseType) FilterResult[source]¶
Called with the decision of each strategy in order.
- Remarks:
Two decisions need to be made:
Should we continue trying other strategies
Should we save this result.
- on_negotiation_start(state) None[source]¶
Initialize child strategies with the negotiator reference at negotiation start.
- strategies: list[AcceptancePolicy][source]¶
- class negmas.sao.ConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicy,ABCOffers based on concensus of multiple strategies
- abstractmethod decide(indices: list[int], responses: list[Outcome | ExtendedOutcome | None]) Outcome | ExtendedOutcome | None[source]¶
Called to make a final decsision given the decisions of the stratgeis with indices
indices(seefilterfor filtering rules)
- filter(indx: int, offer: Outcome | ExtendedOutcome | None) FilterResult[source]¶
Called with the decision of each strategy in order.
- Remarks:
Two decisions need to be made:
Should we continue trying other strategies
Should we save this result.
- strategies: list[OfferingPolicy][source]¶
- class negmas.sao.ConcessionRatioUFunModel(above_reserve: bool = True, levels: int = 10, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
_SequentialWeightUFunModelIssue weights from concession ratios — Niemann & Lang [143] (survey §5.3.1).
For each issue a concession ratio
c_iis the fraction of consecutive offer pairs in which the opponent changed that issue’s value. The more an issue is conceded on, the less important it is assumed to be, so the issue weight isw_i = 1 - c_i(then normalized across issues). Per-issue value utilities are estimated from offer frequency.- Remarks:
The survey’s method updates a Bayesian posterior over weight hypotheses; here
1 - c_iis used directly as a deterministic maximum-likelihood rendition (no explicit posterior), which keeps the model domain-agnostic and online.Returns utilities already normalized to
[0, 1]; a neutral0.5before any offer is observed.
AI Generated (Niemann & Lang concession-ratio issue weights).
- class negmas.sao.ConcessionRecommender(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GBComponentDecides the level of concession to use
- class negmas.sao.ControlledSAONegotiator(preferences: Preferences | None = None, ufun: BaseUtilityFunction | None = None, name: str | None = None, parent: Controller | None = None, owner: Agent | None = None, id: str | None = None, type_name: str | None = None, can_propose: bool = True, **kwargs)[source]¶
Bases:
SAOPRNegotiator,ControlledNegotiatorA negotiator that acts as an end point to a parent Controller.
This negotiator simply calls its controler for everything.
- join(nmi, state, *, preferences=None, ufun=None, role: str = 'negotiator') bool[source]¶
Joins a negotiation.
Remarks:
This method first gets permission from the parent controller by calling
before_joinon it and confirming the result isTrue, it then joins the negotiation and callsafter_joinof the controller to inform it that joining is completed if joining was successful.
- propose(state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Calls parent controller
- respond(state, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Calls parent controller
- class negmas.sao.EndImmediately(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyEnds negotiation immediately regardless of the offer.
- class negmas.sao.FastMiCRONegotiator(*args, accept_same: bool = True, forced_concession_time: float = 0.95, min_time_before_skipping: float = 0.1, min_offers_before_skipping: int = 5, expected_offers_rounding: float = 0.5, **kwargs)[source]¶
Bases:
MAPNegotiatorRational Concession Negotiator that can skip outcomes so as to traverse the whole outcome list before the deadline.
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.accept_same – Accept an offer equal in utility to our own next offer.
forced_concession_time – Relative time after which concession is allowed even if we already sent more offers than we received.
min_time_before_skipping – Skipping is disabled before this relative time.
min_offers_before_skipping – Skipping is disabled until this many offers have been sent.
expected_offers_rounding – Added before truncating the estimated number of remaining offers (
0.5rounds to nearest).offering – A ready
FastMiCROOfferingPolicyto use instead of building one from the arguments above (which are then ignored).acceptance – A ready
AcceptancePolicyto use instead ofMiCROAcceptancePolicy.
- class negmas.sao.FirstOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
OfferOrientedSelectorSelects the offer nearest the partner’s first offer
- class negmas.sao.FirstOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
OfferOrientedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on their utility value and how near they are to the partner’s first offer
- class negmas.sao.FrequencyLinearUFunModel(above_reserve: bool = True, levels: int = 10, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UFunModelA frequency-based opponent model that assumes the opponent’s utility function is `LinearAdditiveUtilityFunction` (a weighted sum of per-issue value utilities) — the assumption used by the Bayesian opponent model of Hindriks & Tykhonov (2008), and hence the default opponent model for the Nice Tit for Tat agent.
It estimates the opponent’s preference for an issue value from how often the opponent has offered that value (values offered more frequently are assumed more preferred) and combines issues with learned weights: an issue whose offered-value distribution is more concentrated receives a higher weight (
weight = 1 - normalized_entropyof the value counts). The estimated utility is the weighted sum of the per-issue value scores — a linear-additive aggregation.The model is updated from every offer the negotiator responds to (
before_responding) and, when the mechanism enables callbacks, fromon_partner_proposal.- Parameters:
above_reserve – Kept for interface compatibility with
ZeroSumModel.levels – Number of grid values used to discretize continuous issues (so they contribute frequency counts instead of being ignored).
- Remarks:
Continuous issues are discretized to
levelsgrid values (viaIssue.to_discrete); offered values are snapped to the nearest grid value for counting. Already-discrete issues are used as-is.Returns utilities in
[0, 1](already normalized).Before any opponent offer is observed, returns a neutral
0.5for every outcome (so a Nice Tit for Tat offering strategy falls back to mirroring until the model has learned).
AI Generated (linear-additive frequency opponent model).
- before_responding(state, offer: Outcome | None, source: str | None = None)[source]¶
Learn from the offer the negotiator is about to respond to.
- Parameters:
state – Current state.
offer – The partner’s offer being responded to.
source – Source identifier.
- eval(offer: Outcome) Value[source]¶
Estimate the opponent’s (normalized) utility of
offer.- Parameters:
offer – Offer being considered.
- Returns:
A value in
[0, 1].
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Eval normalized (the model already returns values in
[0, 1]).- Parameters:
offer – Offer being considered.
above_reserve – Unused (kept for interface compatibility).
expected_limits – Unused (kept for interface compatibility).
- Returns:
A value in
[0, 1].
- on_partner_proposal(state, partner_id: str, offer: Outcome) None[source]¶
Learn from a partner proposal (only called with
enable_callbacks).- Parameters:
state – State when the offer was proposed.
partner_id – The ID of the agent who proposed.
offer – The proposal.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
On preferences changed.
- Parameters:
changes – Changes.
- class negmas.sao.FrequencyUFunModel(above_reserve: bool = True, levels: int = 10, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UFunModelA frequency-based opponent model that makes no assumption about the form of the opponent’s utility function (use this when the opponent’s ufun is not known to be linear-additive).
It counts how often the opponent has offered each complete outcome and estimates the opponent’s utility of an outcome as its offer frequency normalized by the maximum observed frequency. Outcomes never offered score
0. Before any offer is observed, every outcome scores a neutral0.5.The model is updated from every offer the negotiator responds to (
before_responding) and, when the mechanism enables callbacks, fromon_partner_proposal.- Remarks:
Returns utilities in
[0, 1](already normalized).Sparse: only outcomes actually offered get a positive score, so this model is best suited to small/discrete outcome spaces. For larger spaces with an additive opponent ufun, prefer
FrequencyLinearUFunModel.
AI Generated (frequency-based opponent model).
- before_responding(state, offer: Outcome | None, source: str | None = None)[source]¶
Learn from the offer the negotiator is about to respond to.
- Parameters:
state – Current state.
offer – The partner’s offer being responded to.
source – Source identifier.
- eval(offer: Outcome) Value[source]¶
Estimate the opponent’s (normalized) utility of
offer.- Parameters:
offer – Offer being considered.
- Returns:
A value in
[0, 1].
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Eval normalized (the model already returns values in
[0, 1]).- Parameters:
offer – Offer being considered.
above_reserve – Unused (kept for interface compatibility).
expected_limits – Unused (kept for interface compatibility).
- Returns:
A value in
[0, 1].
- on_partner_proposal(state, partner_id: str, offer: Outcome) None[source]¶
Learn from a partner proposal (only called with
enable_callbacks).- Parameters:
state – State when the offer was proposed.
partner_id – The ID of the agent who proposed.
offer – The proposal.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Register the model and set up discretized issues.
- Parameters:
changes – Changes.
- class negmas.sao.GACCombi(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.99, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Combi acceptance strategy from Genius.
Combines AC_Next and AC_Time: accepts if either condition is met.
- Accepts if:
(a * u(opponent_offer) + b >= u(my_next_offer)) OR (time >= t)
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
a – Scaling factor for opponent’s offer utility (default 1.0).
b – Offset added to scaled opponent utility (default 0.0).
t – Time threshold for acceptance (default 0.99).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Combi
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiAvg(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiAvg acceptance strategy from Genius.
Combines AC_Next with average-based acceptance in the end game.
Before time t: acts like AC_Next. After time t: accepts if opponent’s offer >= average of opponent’s offers in window.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which average-based acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiAvg
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiBestAvg(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiBestAvg acceptance strategy from Genius.
Combines AC_Next with best-average-based acceptance.
Before time t: acts like AC_Next. After time t: accepts if opponent’s offer >= average of offers better than current offer.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which best-average acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiBestAvg
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiBestAvgDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiBestAvgDiscounted acceptance strategy from Genius.
Like AC_CombiBestAvg but applies time discount to utilities.
Before time t: acts like AC_Next. After time t: accepts if discounted opponent offer >= discounted avg of better offers.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which best-average acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiBestAvgDiscounted
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiMax(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiMax acceptance strategy from Genius.
Combines AC_Next with maximum-based acceptance.
Before time t: acts like AC_Next. After time t: accepts if opponent’s offer >= max of all previous opponent offers.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which max-based acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiMax
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiMaxInWindow(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiMaxInWindow acceptance strategy from Genius.
Combines AC_Next with a time-window-based acceptance criterion.
Before time t: acts like AC_Next only. After time t: accepts if opponent’s offer is >= best offer seen in remaining time window.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which window-based acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiMaxInWindow
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiMaxInWindowDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiMaxInWindowDiscounted acceptance strategy from Genius.
Like AC_CombiMaxInWindow but applies time discount to utilities.
Before time t: acts like AC_Next. After time t: accepts if discounted offer >= discounted best in window.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which window-based acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiMaxInWindowDiscounted
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiProb(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiProb acceptance strategy from Genius.
Probability-based acceptance that combines AC_Next with probabilistic acceptance based on the expected utility of waiting.
Before time t: acts like AC_Next. After time t: accepts with probability based on how good the offer is relative to expected future offers.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which probabilistic acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiProb
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiProbDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiProbDiscounted acceptance strategy from Genius.
Like AC_CombiProb but applies time discount to utilities.
Before time t: acts like AC_Next. After time t: probabilistic acceptance with discounted utilities.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which probabilistic acceptance kicks in (default 0.98).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiProbDiscounted
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiV2(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.99, decay: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiV2 acceptance strategy from Genius.
A variant of AC_Combi that uses a different combination logic. Accepts if the opponent’s offer utility exceeds a time-dependent threshold based on both the next offer utility and a decay factor.
Before time t: acts like AC_Next. After time t: accepts if opponent’s offer >= next offer utility * decay.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
a – Scaling factor for opponent’s offer utility (default 1.0).
b – Offset added to scaled opponent utility (default 0.0).
t – Time threshold (default 0.99).
decay – Decay factor applied after time threshold (default 0.9).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiV2
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiV3(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.95, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiV3 acceptance strategy from Genius.
A variant of AC_Combi that uses linear interpolation between AC_Next threshold and reserved value based on time.
The acceptance threshold decreases linearly from next offer utility to reserved value as time progresses past threshold t.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
a – Scaling factor for opponent’s offer utility (default 1.0).
b – Offset added to scaled opponent utility (default 0.0).
t – Time threshold when interpolation begins (default 0.95).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiV3
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACCombiV4(offering_policy: OfferingPolicy, t: float = 0.98, w: float = 0.5, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_CombiV4 acceptance strategy from Genius.
A variant of AC_Combi that combines AC_Next with a weighted combination of max and average opponent offers in the end game.
Before time t: acts like AC_Next. After time t: accepts if opponent’s offer >= weighted combo of max and avg.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
t – Time threshold after which combined strategy kicks in (default 0.98).
w – Weight for max utility (1-w used for avg utility) (default 0.5).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_CombiV4
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACConst(c: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Const acceptance strategy from Genius.
Accepts an offer if its utility exceeds a constant threshold.
- Parameters:
c – Constant threshold. Accept if utility > c (default 0.9).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Const
- class negmas.sao.GACConstDiscounted(c: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_ConstDiscounted acceptance strategy from Genius.
Accepts an offer if its discounted utility exceeds a constant threshold. Takes time discount into account.
- Parameters:
c – Constant threshold. Accept if discounted utility > c (default 0.9).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_ConstDiscounted
- class negmas.sao.GACFalse(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_False acceptance strategy from Genius.
Never accepts any offer. Useful for debugging and testing.
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_False
- class negmas.sao.GACGap(c: float = 0.01, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Gap acceptance strategy from Genius.
- Accepts an offer if:
u(opponent_offer) + c >= u(my_previous_offer)
A restricted version of AC_Previous with a=1 and configurable gap.
- Parameters:
c – Gap constant added to opponent utility (default 0.01).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Gap
- class negmas.sao.GACNext(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Next acceptance strategy from Genius.
- Accepts an offer if:
a * u(opponent_offer) + b >= u(my_next_offer)
- where:
u(opponent_offer): Utility of the opponent’s current offer
u(my_next_offer): Utility of the offer we would make next
a: Scaling factor (default 1.0)
b: Offset factor (default 0.0)
With default parameters (a=1, b=0), this accepts if the opponent’s offer is at least as good as what we would offer next.
- Parameters:
offering_policy – The offering strategy used to determine my next offer.
a – Scaling factor for opponent’s offer utility (default 1.0).
b – Offset added to scaled opponent utility (default 0.0).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Next
- offering_policy: OfferingPolicy[source]¶
- class negmas.sao.GACPrevious(a: float = 1.0, b: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Previous acceptance strategy from Genius.
- Accepts an offer if:
a * u(opponent_offer) + b >= u(my_previous_offer)
Similar to AC_Next but compares against our previous offer instead of next.
- Parameters:
a – Scaling factor for opponent’s offer utility (default 1.0).
b – Offset added to scaled opponent utility (default 0.0).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Previous
- class negmas.sao.GACTime(t: float = 0.99, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_Time acceptance strategy from Genius.
Accepts any offer after a certain time threshold has passed.
- Parameters:
t – Time threshold (0 to 1). Accept any offer when time > t (default 0.99).
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_Time
- class negmas.sao.GACTrue(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusAcceptancePolicyAC_True acceptance strategy from Genius.
Always accepts any offer. Useful for debugging and testing.
Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_True
- class negmas.sao.GAgentXFrequencyModel(decay_ratio: float = 0.5, learning_rate: float = 0.25, default_value: int = 1, issue_weights: dict[int, float] = NOTHING, value_counts: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelAgentX frequency-based opponent model from Genius.
From AgentX (ANAC 2015). An advanced frequency model that uses both value frequencies and issue weight learning based on bid patterns.
Tracks issue weights by observing which issues change less frequently, and uses exponential smoothing for weight updates.
- Parameters:
learning_rate – Learning rate for weight updates (default 0.25).
default_value – Default value for unseen issue values (default 1).
Transcompiled from: negotiator.boaframework.opponentmodel.AgentXFrequencyModel
- decay_ratio: float[source]¶
Fraction of
learning_rateused to shrink the weight of an issue whose value changed between two consecutive opponent bids.
- eval(offer: Outcome | None) Value[source]¶
Evaluate opponent utility.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update model based on opponent’s offer.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- class negmas.sao.GBayesianModel(n_hypotheses: int = 10, rationality: float = 5.0, initial_value_util: float = 0.5, issue_weight_hypotheses: list[dict[int, float]] = NOTHING, hypothesis_probs: list[float] = NOTHING, value_utils: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelBayesian opponent model from Genius.
Uses Bayesian inference to update beliefs about opponent’s utility function based on their bids. Maintains probability distributions over possible opponent preferences and updates them using Bayes’ rule.
This is a simplified version that assumes the opponent is rational and only offers bids above some threshold.
- Parameters:
n_hypotheses – Number of hypotheses to consider (default 10).
rationality – Assumed opponent rationality - higher values assume opponent is more likely to make utility-maximizing bids (default 5.0).
Transcompiled from: negotiator.boaframework.opponentmodel.BayesianModel
- eval(offer: Outcome | None) Value[source]¶
Evaluate opponent utility as weighted average over hypotheses.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- initial_value_util: float[source]¶
Utility assigned to an issue value before anything is learned about it.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update hypothesis probabilities using Bayes’ rule.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- class negmas.sao.GBoulwareOffering(utility_band_tolerance: float = 0.01, e: float = 0.2, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyBoulware offering strategy - a time-dependent strategy with e < 1.
Concedes slowly at first, then faster as deadline approaches. This is a convenience wrapper around GTimeDependentOffering.
- Parameters:
e – Concession exponent (default 0.2, typical Boulware value).
k – Offset constant (default 0).
Transcompiled from: negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering with e < 1
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the delegate time-dependent offering strategy.
- class negmas.sao.GChoosingAllBids(utility_band_tolerance: float = 0.01, all_outcomes: list[Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyChoosingAllBids offering strategy from Genius.
Iterates through all possible bids in the domain, offering each one in sequence. Useful for exhaustive exploration or testing.
When all bids have been offered, it restarts from the beginning.
Transcompiled from: negotiator.boaframework.offeringstrategy.other.ChoosingAllBids
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the list of all outcomes.
- class negmas.sao.GConcederOffering(utility_band_tolerance: float = 0.01, e: float = 2.0, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyConceder offering strategy - a time-dependent strategy with e > 1.
Concedes quickly at first, then slows down as deadline approaches. This is a convenience wrapper around GTimeDependentOffering.
- Parameters:
e – Concession exponent (default 2.0, typical Conceder value).
k – Offset constant (default 0).
Transcompiled from: negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering with e > 1
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the delegate time-dependent offering strategy.
- class negmas.sao.GDefaultModel(utility: float = 0.5, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelDefault opponent model from Genius.
A no-op model that doesn’t learn from opponent behavior and assumes uniform preferences. Always returns 0.5 utility for any outcome.
Useful as a baseline or placeholder when no opponent modeling is needed.
Transcompiled from: negotiator.boaframework.opponentmodel.DefaultModel
- eval(offer: Outcome | None) Value[source]¶
Return the constant
utilityfor any outcome.- Parameters:
offer – The outcome to evaluate.
- Returns:
Always returns
self.utility.
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
No-op - this model doesn’t learn from offers.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
No-op - this model doesn’t adapt.
- class negmas.sao.GHardHeadedFrequencyModel(learning_coef: float = 0.2, learning_value_addition: int = 1, default_value: int = 1, issue_weights: dict[int, float] = NOTHING, value_weights: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelHard-Headed Frequency-based opponent model from Genius.
This model estimates the opponent’s utility function by tracking which issues remain unchanged between consecutive opponent bids. Issues that don’t change are assumed to be more important to the opponent.
The model works by: 1. Tracking bid frequencies for each issue value 2. When an issue value stays the same between consecutive bids,
increasing its weight (the opponent likely cares about that issue)
Computing opponent utility as a weighted sum of issue value frequencies
- Parameters:
learning_coef – Learning coefficient controlling how fast weights adapt. Higher values mean faster adaptation (default 0.2).
learning_value_addition – Value added to unchanged issue weights (default 1).
default_value – Default value for unseen issue values (default 1).
Transcompiled from: negotiator.boaframework.opponentmodel.HardHeadedFrequencyModel
- eval(offer: Outcome | None) Value[source]¶
Evaluate the estimated opponent utility for an outcome.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Evaluate normalized opponent utility.
- Parameters:
offer – The outcome to evaluate.
above_reserve – Whether to normalize above reserve value.
expected_limits – Whether to use expected limits.
- Returns:
Normalized opponent utility (0 to 1).
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update the model based on the opponent’s offer.
- Parameters:
state – Current negotiation state.
partner_id – ID of the partner who made the offer.
offer – The opponent’s offer.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- Parameters:
changes – List of preference changes.
- class negmas.sao.GHardlinerOffering(utility_band_tolerance: float = 0.01, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyHardliner offering strategy - always offers the best outcome.
Never concedes - always offers the maximum utility outcome. This is equivalent to time-dependent with e = 0.
Transcompiled from: negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering with e = 0
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the inverse utility function.
- class negmas.sao.GLinearOffering(utility_band_tolerance: float = 0.01, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyLinear offering strategy - a time-dependent strategy with e = 1.
Concedes at a constant rate throughout negotiation. This is a convenience wrapper around GTimeDependentOffering.
- Parameters:
k – Offset constant (default 0).
Transcompiled from: negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering with e = 1
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the delegate time-dependent offering strategy.
- class negmas.sao.GNashFrequencyModel(unchanged_issue_weight_addition: float = 0.1, default_value: int = 1, issue_weights: dict[int, float] = NOTHING, value_counts: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelNash frequency-based opponent model from Genius.
A frequency model that aims to estimate outcomes close to the Nash bargaining solution by combining opponent utility estimates with our own utility.
Uses frequency-based opponent modeling but biases toward Pareto-efficient outcomes by considering the product of utilities.
- Parameters:
default_value – Default value for unseen issue values (default 1).
Transcompiled from: negotiator.boaframework.opponentmodel.NashFrequencyModel
- eval(offer: Outcome | None) Value[source]¶
Evaluate opponent utility with Nash-optimal bias.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update model based on opponent’s offer.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- class negmas.sao.GOppositeModel(no_information_utility: float = 0.5, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelOpposite opponent model from Genius.
Assumes the opponent has exactly opposite preferences - what’s good for us is bad for them and vice versa. Returns 1 - our_utility.
This is a pessimistic assumption useful for competitive scenarios.
Transcompiled from: negotiator.boaframework.opponentmodel.OppositeModel
- eval(offer: Outcome | None) Value[source]¶
Return opposite utility (1 - our utility).
- Parameters:
offer – The outcome to evaluate.
- Returns:
1 - our_utility for the outcome.
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized opposite utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
No-op - this model uses our utility function inversely.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
No special initialization needed.
- class negmas.sao.GRandomOffering(utility_band_tolerance: float = 0.01, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyRandom offering strategy from Genius.
This strategy offers random bids from the outcome space, completely ignoring utility. Also known as “Zero Intelligence” or “Random Walker”.
This is useful for: - Debugging and testing - Creating baseline comparisons - Simulating unpredictable opponents
Transcompiled from: negotiator.boaframework.offeringstrategy.other.Random_Offering
- class negmas.sao.GScalableBayesianModel(learning_rate: float = 0.1, initial_value_util: float = 0.5, decay_ratio: float = 0.1, issue_weights: dict[int, float] = NOTHING, value_utils: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelScalable Bayesian opponent model from Genius.
A Bayesian model optimized for large outcome spaces. Uses a more efficient representation that scales better with domain size.
Instead of maintaining full hypothesis distributions, it tracks sufficient statistics and uses approximate inference.
- Parameters:
learning_rate – Rate of belief updates (default 0.1).
Transcompiled from: negotiator.boaframework.opponentmodel.ScalableBayesianModel
- decay_ratio: float[source]¶
Fraction of
learning_rateused to decay the values the opponent did not offer.
- eval(offer: Outcome | None) Value[source]¶
Evaluate opponent utility.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- initial_value_util: float[source]¶
Utility assigned to an issue value before anything is learned about it.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update beliefs using online learning.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- class negmas.sao.GSmithFrequencyModel(default_value: int = 1, value_counts: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelSmith frequency-based opponent model from Genius.
From AgentSmith (ANAC 2010). Similar to HardHeadedFrequencyModel but with a simpler weight update mechanism based purely on value frequencies.
The model tracks how often each value appears in opponent bids and assumes higher frequency = higher importance.
- Parameters:
default_value – Default value for unseen issue values (default 1).
Transcompiled from: negotiator.boaframework.opponentmodel.SmithFrequencyModel
- eval(offer: Outcome | None) Value[source]¶
Evaluate opponent utility based on value frequencies.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Estimated opponent utility (0 to 1).
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Update value frequencies based on opponent’s offer.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset the model when preferences change.
- class negmas.sao.GTimeDependentOffering(utility_band_tolerance: float = 0.01, e: float = 0.2, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOfferingPolicyTime-dependent offering strategy from Genius.
This strategy offers bids based on a time-dependent target utility curve. The curve is controlled by the concession exponent
e: - e = 0: Hardliner (never concedes) - e < 1: Boulware (concedes slowly, faster near deadline) - e = 1: Linear - e > 1: Conceder (concedes quickly at start)- The target utility at time t is computed as:
f(t) = k + (1 - k) * t^(1/e) target(t) = Pmin + (Pmax - Pmin) * (1 - f(t))
- where:
k: Offset constant (default 0)
e: Concession exponent (default 0.2 for Boulware)
Pmin: Minimum utility (reserved value)
Pmax: Maximum utility (best outcome utility)
- Parameters:
e – Concession exponent. Controls the shape of the concession curve.
k – Offset constant for the time function (default 0).
Transcompiled from: negotiator.boaframework.offeringstrategy.other.TimeDependent_Offering
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Initialize the inverse utility function for finding outcomes by utility.
- Parameters:
changes – List of preference changes.
- class negmas.sao.GUniformModel(outcome_utils: dict[tuple, float] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GeniusOpponentModelUniform opponent model from Genius.
Assumes the opponent values all outcomes equally - returns uniform random utility values. Each outcome gets a consistent random value.
Transcompiled from: negotiator.boaframework.opponentmodel.UniformModel
- eval(offer: Outcome | None) Value[source]¶
Return a random but consistent utility for the outcome.
- Parameters:
offer – The outcome to evaluate.
- Returns:
Random utility value in [0, 1], consistent for same outcome.
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Return normalized utility.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
No-op - this model uses random values.
- on_preferences_changed(changes: list[PreferencesChange]) None[source]¶
Reset cached utilities when preferences change.
- class negmas.sao.GeniusAcceptancePolicy(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyBase class for Genius acceptance policies.
- class negmas.sao.GeniusOfferingPolicy(utility_band_tolerance: float = 0.01, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyBase class for Genius offering policies.
Holds the search knobs shared by (almost) every transcompiled Genius offering strategy, so they can be tuned uniformly.
- Parameters:
utility_band_tolerance – Slack added on each side of the target utility when asking the inverter for an outcome, i.e. the policy searches
[target - tol, pmax + tol]. Defaults to0.01.
- class negmas.sao.GeniusOpponentModel(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GBComponent,BaseUtilityFunctionBase class for Genius opponent models.
This base class provides helper methods for updating the negotiator’s private_info with learned opponent utility function estimates.
- class negmas.sao.HybridNegotiator(*args, alpha: float = 1.0, beta: float = 0.0, initial_utility: float = nan, concession_ratio: float = nan, final_utility: float = nan, empathy_score: float = nan, auto_initial_utility: float = 1.0, auto_concession_ratio: float = 0.75, auto_empathy_score: float = 0.5, domain_size_cap: int = 100000, final_utility_ladder: tuple[tuple[float, float], ...] = ((450, 0.8), (1500, 0.775), (4500, 0.75), (18000, 0.725), (33000, 0.7)), final_utility_floor: float = 0.675, behavior_min_offers: int = 2, enumeration_levels: int = 10, enumeration_max_cardinality: int = 1000000, frac_time_based: dict[int, tuple[float, ...]] | None = None, above_only: bool = False, **kwargs)[source]¶
Bases:
MAPNegotiatorA negotiator mixing a time-based (Bezier) concession curve with a behaviour-based reaction to the opponent, accepting via ACnext.
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.alpha – ACnext utility scale (see
ACNext).beta – ACnext utility offset (see
ACNext).initial_utility – Bezier control point at
t=0.NaNmeans auto (seeHybridOfferingPolicy).concession_ratio – Middle Bezier control point.
NaNmeans auto.final_utility – Bezier control point at
t=1.NaNmeans auto (derived from the domain size).empathy_score – How strongly the opponent’s concession moves our target.
NaNmeans auto.auto_initial_utility –
initial_utilityused in auto mode.auto_concession_ratio –
concession_ratioused in auto mode.auto_empathy_score –
empathy_scoreused in auto mode.domain_size_cap – Domain cardinality is clipped to this before consulting
final_utility_ladder.final_utility_ladder – Ordered
(max_domain_size, final_utility)pairs used to derivefinal_utilityin auto mode.final_utility_floor –
final_utilityin auto mode for domains larger than every ladder threshold.behavior_min_offers – Offers to receive before mixing in the behaviour-based component.
enumeration_levels – Discretization levels for continuous outcome spaces.
enumeration_max_cardinality – Max outcomes enumerated for continuous outcome spaces.
frac_time_based – Window weights over the opponent’s recent utility differences.
above_only – Only consider outcomes at or above the target utility.
offering – A ready
HybridOfferingPolicyto use instead of building one from the arguments above (which are then ignored).acceptance – A ready
AcceptancePolicyto use instead ofACNext.
- Remarks:
Every hyperparameter of
HybridOfferingPolicyis reachable here, so the negotiator can be tuned without constructing components by hand.
- class negmas.sao.HybridOfferingPolicy(initial_utility: float = nan, concession_ratio: float = nan, final_utility: float = nan, empathy_score: float = nan, auto_initial_utility: float = 1.0, auto_concession_ratio: float = 0.75, auto_empathy_score: float = 0.5, domain_size_cap: int = 100000, final_utility_ladder: tuple[tuple[float, float], ...] = ((450, 0.8), (1500, 0.775), (4500, 0.75), (18000, 0.725), (33000, 0.7)), final_utility_floor: float = 0.675, behavior_min_offers: int = 2, enumeration_levels: int = 10, enumeration_max_cardinality: int = 1000000, frac_time_based: dict[int, tuple[float, ...]] = NOTHING, above_only: bool = False, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyHybridOffering policy implementation.
Combines a time-based (quadratic Bezier) concession curve with a behaviour-based reaction to the opponent’s concessions.
- Parameters:
initial_utility – Bezier control point at
t=0.NaN(default) means auto: useauto_initial_utility.concession_ratio – Middle Bezier control point.
NaN(default) means auto: useauto_concession_ratio.final_utility – Bezier control point at
t=1.NaN(default) means auto: derive it from the domain size usingfinal_utility_ladder/final_utility_floor. Whether given or derived, it is always floored at the reserved value.empathy_score – How strongly the opponent’s concession moves our target in
behaviour_based.NaN(default) means auto: useauto_empathy_score.auto_initial_utility – Value used for
initial_utilityin auto mode.auto_concession_ratio – Value used for
concession_ratioin auto mode.auto_empathy_score – Value used for
empathy_scorein auto mode.domain_size_cap – Domain cardinality is clipped to this before consulting
final_utility_ladder.final_utility_ladder – Ordered
(max_domain_size, final_utility)pairs. The first pair whosemax_domain_sizeexceeds the (clipped) domain size suppliesfinal_utilityin auto mode.final_utility_floor –
final_utilityused in auto mode when the domain is larger than every threshold infinal_utility_ladder.behavior_min_offers – Minimum number of offers received before the behaviour-based component is mixed in (pure time-based before that).
enumeration_levels –
levelsused to discretize a continuous outcome space when enumerating candidate outcomes.enumeration_max_cardinality –
max_cardinalityused when enumerating a continuous outcome space.frac_time_based – Window weights (keyed by window length) applied to the opponent’s recent utility differences in
behaviour_based.above_only – Only consider outcomes at or above the target utility.
- behaviour_based(t: float) float[source]¶
Computes target utility based on opponent’s concession patterns.
- Parameters:
t – Normalized negotiation time in [0, 1].
- Returns:
The target utility value adjusted by opponent behavior.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Records partner’s offer and its utility for behavior-based strategy.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Recalculates parameters and outcome utilities when preferences change.
- class negmas.sao.KDEWeightUFunModel(above_reserve: bool = True, levels: int = 10, threshold: float = 0.1, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
_SequentialWeightUFunModelIssue weights via kernel density estimation — Coehoorn & Jennings [50].
The most-established issue-weight method in the survey (§5.3.1). For each issue it collects the sequence of normalized distances between sequential offers and fits a Gaussian kernel density estimate (
scipy.stats.gaussian_kde) to that distance distribution. An issue whose distances concentrate near zero (the opponent barely moves it) is important, so the issue weight is the KDE probability mass in[0, threshold]— i.e.P(distance <= threshold)— then normalized across issues. Per-issue value utilities are estimated from offer frequency.- Parameters:
threshold – The distance below which a move counts as “held” when integrating the KDE (a fraction of the normalized
[0, 1]range).
- Remarks:
The survey’s full method maps distance to weight using a database of previous negotiations; this is a domain-agnostic online rendition that estimates the distance distribution from the running negotiation.
Falls back to the mean-distance estimate
1 - mean_distanceper issue until there are enough distinct distance samples to fit a KDE.Returns utilities already normalized to
[0, 1].
AI Generated (Coehoorn & Jennings KDE issue weights).
- class negmas.sao.KindConcessionRecommender(kindness: float = 0.0, punish: float = True, initial_concession: float = 0.0, must_concede: bool = True, inverter: UtilityInverter | None = None, no_concession_step: int = 0, kindness_start_step: int = 3, min_concession_eps: float = 1e-12, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcessionRecommenderA simple recommender that does one small concession first then a tit-for-tat response
- Parameters:
kindness – A fraction of the utility range to concede everytime no matter what.
punish – If True, the partner will be punished by pushing our lower utility limit up if the concession (or its expectation) was negative
initial_concession – The amount of concession to do in the first step
must_concede – If
Truethe agent is guaranteed to concede in the first stepinverter – Used only if
must_concedeisTrueto determine the lowest level of concession possibleno_concession_step – Steps at or below this index get zero concession (the agent does not concede on its very first call).
kindness_start_step – From this step onward the recommendation is simply the partner’s concession plus
kindness(theinitial_concession/must_concedelogic no longer applies).min_concession_eps – Numerical slack added to the smallest representable utility gap when
must_concedeforces a minimal concession.
- inverter: UtilityInverter | None[source]¶
- set_inverter(inverter: UtilityInverter | None) None[source]¶
Set inverter.
- Parameters:
inverter – Inverter.
- set_negotiator(negotiator: GBNegotiator) None[source]¶
Set negotiator.
- Parameters:
negotiator – Negotiator.
- class negmas.sao.LastOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
OfferOrientedSelectorSelects the offer nearest the partner’s last offer
- class negmas.sao.LastOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
FirstOfferOrientedTBNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on their utility value and how near they are to the partner’s last offer
- class negmas.sao.LimitedOutcomesAcceptancePolicy(prob: dict[Outcome, float] | float | None, p_ending: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAccepts from a list of predefined outcomes
- Remarks:
- classmethod from_outcome_list(outcomes: list[Outcome], prob: list[float] | float = 1.0, p_ending: float = 0.0)[source]¶
Create policy from a list of outcomes with their acceptance probabilities.
- Parameters:
outcomes – The list of acceptable outcomes.
prob – Acceptance probability for each outcome (single value or per-outcome list).
p_ending – Probability of ending negotiation on each call.
- class negmas.sao.LimitedOutcomesAcceptor(acceptable_outcomes: list[tuple] | None = None, acceptance_probabilities: list[float] | None = None, p_ending=0.0, preferences=None, ufun=None, **kwargs)[source]¶
Bases:
MAPNegotiator,GBNegotiatorA negotiation agent that uses a fixed set of outcomes in a single negotiation.
- Remarks:
The ufun inputs to the constructor and join are ignored. A ufun will be generated that gives a utility equal to the probability of choosing a given outcome.
- class negmas.sao.LimitedOutcomesNegotiator(acceptable_outcomes: list[tuple] | None = None, acceptance_probabilities: float | list[float] | None = None, proposable_outcomes: list[tuple] | None = None, p_ending=0.0, p_no_response=0.0, default_acceptance_probability: float = 0.5, preferences=None, ufun=None, **kwargs)[source]¶
Bases:
MAPNegotiatorA negotiation agent that uses a fixed set of outcomes in a single negotiation.
- Parameters:
acceptable_outcomes – the set of acceptable outcomes. If None then it is assumed to be all the outcomes of the negotiation.
acceptance_probabilities – probability of accepting each acceptable outcome. If None then it is assumed to be unity.
proposable_outcomes – the set of outcomes from which the agent is allowed to propose. If None, then it is the same as acceptable outcomes with nonzero probability
p_no_response – probability of refusing to respond to offers
p_ending – probability of ending negotiation
default_acceptance_probability – acceptance probability used when neither
acceptable_outcomesnoracceptance_probabilitiesis given.
- Remarks:
The ufun inputs to the constructor and join are ignored. A ufun will be generated that gives a utility equal to the probability of choosing a given outcome.
If
proposable_outcomesis passed as None, it is considered the same asacceptable_outcomes
- class negmas.sao.LimitedOutcomesOfferingPolicy(outcomes: list[Outcome] | None, prob: list[float] | None = None, p_ending: float = 0.0, prob_sum_tolerance: float = 0.999, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyOffers from a given list of outcomes
- class negmas.sao.LinearTBNegotiator(*args, **kwargs)[source]¶
Bases:
TimeBasedConcedingNegotiatorA time-based negotiator that concedes linearly.
Uses a
PolyAspirationcurve with exponent 1 ("linear") andstochastic=False.
- class negmas.sao.LuceProfileClassifierModel(profiles: list[BaseUtilityFunction] = NOTHING, use_map: bool = False, max_outcomes: int = 10000, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UFunModelClassifies the opponent among candidate profiles via Luce numbers.
The model is given a finite set of candidate opponent utility functions (
profiles). Following Lin et al. [123,124], a rational opponent using profiletis assumed to offer outcomeowith probability proportional to its Luce numberL_t(o) = u_t(o) / Σ_{o'} u_t(o')— the outcome’s utility divided by the sum of utilities over the outcome space. Each observed opponent offer therefore updates a Bayesian posterior over the candidate profiles (accumulated in log-space for numerical stability).The estimated opponent utility of an outcome is the posterior-weighted average of the candidate utilities (or, if
use_mapis set, the utility under the single most-probable profile — the choice the survey describes).- Parameters:
profiles – The candidate opponent utility functions to classify among.
use_map – If
True, evaluate using only the maximum-a-posteriori profile; otherwise use the posterior-weighted average of all profiles.max_outcomes – Cap on the number of outcomes sampled to compute the Luce denominators (for large/continuous spaces).
- Remarks:
The Luce denominators and combination use each candidate’s normalized utility (
eval_normalized), so utilities are non-negative and comparable across profiles.Before any offer is observed the posterior is uniform, so
evalreturns the plain average of the candidate utilities.
AI Generated (Lin et al. Luce-number classifier).
- before_responding(state, offer: Outcome | None, source: str | None = None)[source]¶
Learn from the offer the negotiator is about to respond to.
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Eval normalized (the model already returns values in
[0, 1]).
- on_partner_proposal(state, partner_id: str, offer: Outcome) None[source]¶
Learn from a partner proposal (only with
enable_callbacks).
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Compute Luce denominators and initialize a uniform log-posterior.
- profiles: list[BaseUtilityFunction][source]¶
- class negmas.sao.MeanMetaNegotiator(*args, negotiators: Iterable[SAOPRNegotiator] | None = None, negotiator_types: Iterable[type[SAOPRNegotiator]] | None = None, negotiator_params: Iterable[dict[str, Any]] | None = None, negotiator_names: Iterable[str] | None = None, initial_epsilon: float = 0.05, epsilon_step: float = 0.1, max_cardinality: int = 10000, **kwargs)[source]¶
Bases:
SAOAggMetaNegotiatorAn SAO meta-negotiator that samples outcomes around the mean utility of sub-negotiator proposals.
This negotiator collects proposals from all sub-negotiators, computes the mean utility of those proposals, and tries to sample an outcome with utility close to the mean. If no outcome is found within a small epsilon around the mean, it progressively expands the search range until it covers the full min/max range of sub-negotiator proposals.
For response aggregation, it uses majority voting among sub-negotiators.
- Parameters:
negotiators – An iterable of
SAONegotiatorinstances to manage. Mutually exclusive withnegotiator_types.negotiator_types – An iterable of
SAONegotiatortypes to instantiate. Mutually exclusive with negmas.negotiators.negotiator_params – Optional iterable of parameter dicts for each negotiator type. Only used with
negotiator_types.negotiator_names – Optional names for the negotiators.
initial_epsilon – Initial utility range around the mean to search. Defaults to 0.05.
epsilon_step – How much to expand the range on each iteration. Defaults to 0.1.
max_cardinality – Maximum number of outcomes to sample when searching. Defaults to 10000.
*args – Additional positional arguments passed to the base class.
**kwargs – Additional keyword arguments passed to the base class.
Example
>>> from negmas.sao.negotiators import ( ... MeanMetaNegotiator, ... BoulwareTBNegotiator, ... ConcederTBNegotiator, ... ) >>> from negmas.sao import SAOMechanism >>> from negmas.preferences import LinearAdditiveUtilityFunction as U >>> from negmas.outcomes import make_issue, make_os >>> >>> issues = [make_issue(10, "price")] >>> os = make_os(issues) >>> ufun1 = U.random(os, reserved_value=0.0) >>> ufun2 = U.random(os, reserved_value=0.0) >>> >>> # Create a mean meta-negotiator with diverse strategies >>> meta = MeanMetaNegotiator( ... negotiator_types=[BoulwareTBNegotiator, ConcederTBNegotiator], ... ufun=ufun1, ... ) >>> opponent = ConcederTBNegotiator(ufun=ufun2) >>> >>> mechanism = SAOMechanism(issues=issues, n_steps=50) >>> _ = mechanism.add(meta) >>> _ = mechanism.add(opponent) >>> result = mechanism.run() >>> result.running False
- aggregate_proposals(state: SAOState, proposals: list[tuple[SAOPRNegotiator, tuple | ExtendedOutcome | None]], dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Aggregate proposals by sampling an outcome near the mean utility.
Computes the mean utility of sub-negotiator proposals and tries to find an outcome within a small epsilon around the mean. If not found, progressively expands the search range up to the full min/max range.
- Parameters:
state – The current SAO state.
proposals – List of (negotiator, proposal) tuples from sub-negotiators.
dest – The destination partner ID (if applicable).
- Returns:
An outcome near the mean utility of sub-negotiator proposals, or None if no valid outcome can be found.
- aggregate_responses(state: SAOState, responses: list[tuple[SAOPRNegotiator, ResponseType]], offer: tuple | None, source: str | None = None) ResponseType[source]¶
Aggregate responses using majority voting.
- Parameters:
state – The current SAO state.
responses – List of (negotiator, response) tuples from sub-negotiators.
offer – The offer being responded to.
source – The source partner ID (if applicable).
- Returns:
The most common response among sub-negotiators.
- class negmas.sao.MedianOfferSelector(*args, **kwargs)[source]¶
Bases:
OfferSelectorSelects the outcome with the median utility value.
- class negmas.sao.MiCRONegotiator(*args, accept_same: bool = True, **kwargs)[source]¶
Bases:
MAPNegotiatorRational Concession Negotiator
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.accept_same – Accept an offer equal in utility to our own next offer.
offering – A ready
MiCROOfferingPolicyto use instead of the default.acceptance – A ready
AcceptancePolicyto use instead ofMiCROAcceptancePolicy.
- class negmas.sao.MiCROOfferingPolicy(next_indx: int = 0, sorter: InverseUFun | None = None, received: set[Outcome] = NOTHING, sent: set[Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyMiCROOffering policy implementation.
- best_offer_so_far() Outcome | ExtendedOutcome | None[source]¶
Returns the highest-utility outcome offered so far, or None if none sent.
- next_offer() Outcome | ExtendedOutcome | None[source]¶
Returns the next outcome to offer based on current concession level.
- on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]¶
Records the partner’s offer to track concession balance.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Reinitializes the sorter and resets offer tracking on significant preference changes.
- sample_sent() Outcome | ExtendedOutcome | None[source]¶
Returns a random outcome from previously sent offers, or None if empty.
- sorter: InverseUFun | None[source]¶
- negmas.sao.Model[source]¶
alias of
GBComponent
- class negmas.sao.MultiplicativeFirstFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.MultiplicativeLastOfferFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.MultiplicativeParetoFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based negotiator that selectes outcomes from the list allowed by the current utility level based on a weighted sum of their normalized utilities and distances to previous offers
- class negmas.sao.MultiplicativePartnerOffersOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]¶
Bases:
PartnerOffersOrientedSelectorOrients offes toward the set of past opponent offers.
The score of an offer is the product of its utility to self and its distance to opponent’s past offers after normalization
- class negmas.sao.MyBestConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UtilBasedConcensusOfferingPolicyOffers my best outcome from the list of stratgies (different strategy every time).
- class negmas.sao.MyWorstConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UtilBasedConcensusOfferingPolicyOffers my worst outcome from the list of stratgies (different strategy every time) based on outcome utilities
- class negmas.sao.NaiveTitForTatNegotiator(*args, kindness=0.0, punish=False, initial_concession: float | Literal['min'] = 'min', rank_only: bool = False, stochastic: bool = False, must_concede: bool = True, no_concession_step: int = 0, kindness_start_step: int = 3, min_concession_eps: float = 1e-12, **kwargs)[source]¶
Bases:
MAPNegotiatorImplements a naive tit-for-tat strategy that does not depend on the availability of an opponent model.
The negotiator mirrors the opponent’s concession: if the opponent’s last offer was better for this negotiator than the one before it, the negotiator considers that the opponent has conceded by the difference and concedes a matching amount (adjusted by
kindness). This implicitly assumes a zero-sum situation (no opponent model is kept).- Parameters:
name – Negotiator name.
preferences – Negotiator preferences (deprecated; use
ufun).ufun – Negotiator utility function (overrides
preferences).parent – A controller that manages this negotiator.
kindness (float) – How ‘kind’ the agent is.
0.0is standard tit-for-tat. Positive values make the negotiator concede faster; negative values make it concede slower. Defaults to0.0.stochastic (bool) – If
True, offers are randomized within the band determined by the current concession (which reflects the opponent’s concession). IfFalse(default), the worst outcome in the band is proposed. Defaults toFalse.punish (bool) – If
True, the agent punishes a partner who does not concede by requiring higher utilities. Defaults toFalse.initial_concession (float | str) – How much the agent should concede at the beginning, in utility units. Can be a non-negative float or the string
"min"(treated as0.0— minimum concession). Defaults to"min".rank_only (bool) – If
True, only the relative ranks of outcomes (not their actual utilities) are used for inversion. Defaults toFalse.must_concede (bool) – If
True(default) the negotiator is guaranteed to make a (minimal) concession on its second call. Forwarded toKindConcessionRecommender.no_concession_step (int) – Steps at or below this index get zero concession. Forwarded to
KindConcessionRecommender.kindness_start_step (int) – From this step onward the recommendation is simply the partner’s concession plus
kindness. Forwarded toKindConcessionRecommender.min_concession_eps (float) – Numerical slack added to the smallest representable utility gap when
must_concedeforces a minimal concession. Forwarded toKindConcessionRecommender.**kwargs – Forwarded to
MAPNegotiator.
- Remarks:
This negotiator does not keep an opponent model. It thinks only in terms of changes in its own utility. If the opponent’s last offer was better for the negotiator compared with the one before it, it considers that the opponent has conceded by the difference. This means that it implicitly assumes a zero-sum situation.
- class negmas.sao.NegotiatorAcceptancePolicy(acceptor: GBNegotiator, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyUses a negotiator as an offering strategy
- acceptor: GBNegotiator[source]¶
- class negmas.sao.NegotiatorOfferingPolicy(*, negotiator: GBNegotiator | None = None, proposer: GBNegotiator)[source]¶
Bases:
OfferingPolicyUses a negotiator as an offering strategy
- proposer: GBNegotiator[source]¶
- class negmas.sao.NiceNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorOffers and accepts anything.
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides prefrences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.NiceTitForTatNegotiator(*args, opponent_model: UFunModel | None = None, opponent_model_type: type | None = None, target: str = 'nash', sample_size: int = 100, max_cardinality: int = 10000, nash_refresh: int = 1, stochastic: bool = False, levels: int = 20, nash_min: float = 0.5, nash_multiplier_base: float = 1.4, nash_multiplier_gap_weight: float = 0.6, default_nash_utility: float = 0.7, discount_bonus_base: float = 0.5, discount_bonus_weight: float = 0.4, big_domain_cardinality: float = 3000, bonus_start_time: float = 0.91, bonus_start_time_big_domain: float = 0.85, bonus_ramp_rate: float = 20.0, pareto_sampler_type: type | None = None, a: float = 1.0, b: float = 0.0, t: float = 0.98, **kwargs)[source]¶
Bases:
MAPNegotiatorThe Nice Tit for Tat agent (Baarslag, Hindriks & Jonker, 2013).
A MAP negotiator combining the
NiceTitForTatOfferingPolicybidding strategy (reciprocate in the agent’s own utility while aiming for a bargaining-solution point, and make offers attractive to the opponent) with theACCombiacceptance condition (accept when the opponent’s offer beats our next planned offer, or when time is running out).The opponent model is the one piece the bidding strategy depends on. It is accessed through the standard
opponent_ufunproperty (read by the offering policy viaself.negotiator.opponent_ufun), populated automatically from the model passed here. You can either:pass a ready opponent model as
opponent_model(anyUFunModel, e.g. a learnedFrequencyLinearUFunModel, an oraclePeekingOpponentModelfor tests, or aZeroSumModel), orpass an opponent-model type as
opponent_model_type(aUFunModelsubclass), constructed with no required args, orpass neither and use the default:
FrequencyLinearUFunModel— a frequency-based learner assuming a linear-additive opponent ufun, the same assumption as the Bayesian opponent model of Hindriks & Tykhonov (2008) used in the paper. UseFrequencyUFunModelinstead when the opponent’s ufun is not known to be linear-additive.
- Parameters:
opponent_model – A ready
UFunModelto use as the opponent model. Takes precedence overopponent_model_type.opponent_model_type – A
UFunModelsubclass to instantiate as the default opponent model. Defaults toFrequencyLinearUFunModel.target – Bargaining solution the offering strategy aims for — one of
"nash"(default),"kalai","kalai_smorodinsky"/"ks","max_welfare","max_relative_welfare". Forwarded toNiceTitForTatOfferingPolicy.sample_size – Forwarded to
NiceTitForTatOfferingPolicy.max_cardinality – Forwarded to
NiceTitForTatOfferingPolicy.nash_refresh – Forwarded to
NiceTitForTatOfferingPolicy.stochastic – Forwarded to
NiceTitForTatOfferingPolicy.levels – Forwarded to
NiceTitForTatOfferingPolicy.nash_min – Forwarded to
NiceTitForTatOfferingPolicy.nash_multiplier_base
nash_multiplier_gap_weight
default_nash_utility
:param : :param discount_bonus_base: :param discount_bonus_weight: :param big_domain_cardinality: :param : :param bonus_start_time: The Baarslag reference constants of the bidding strategy, forwarded
to
NiceTitForTatOfferingPolicy. Defaults reproduce the paper.- Parameters:
bonus_start_time_big_domain – The Baarslag reference constants of the bidding strategy, forwarded to
NiceTitForTatOfferingPolicy. Defaults reproduce the paper.bonus_ramp_rate – The Baarslag reference constants of the bidding strategy, forwarded to
NiceTitForTatOfferingPolicy. Defaults reproduce the paper.pareto_sampler_type – The
ParetoSamplerimplementation used by the offering policy for the opponent-attractive trade-off query.None(default) uses the offering policy’s own default (DefaultParetoSampler/AdaptiveParetoSampler— exact brute-force on small spaces, a scalable backend on large ones). Pass a specific type (e.g.IPSParetoSampler) to override.a – ACcombi parameters (forwarded to
ACCombi).b – ACcombi parameters (forwarded to
ACCombi).t – ACcombi parameters (forwarded to
ACCombi).
- Remarks:
Exposes
opponent_model(theUFunModelin use) as a property.The offering policy degrades to naive tit-for-tat if the opponent model is unavailable or uninformative.
AI Generated (Nice Tit for Tat MAP negotiator, after Baarslag et al. 2013).
- class negmas.sao.NiceTitForTatOfferingPolicy(sample_size: int = 100, max_cardinality: int = 10000, nash_refresh: int = 1, stochastic: bool = False, target: str = 'nash', levels: int = 20, nash_min: float = 0.5, pareto_sampler_type: type[ParetoSampler] = <class 'negmas.preferences.pareto_sampler.adaptive.AdaptiveParetoSampler'>, nash_multiplier_base: float = 1.4, nash_multiplier_gap_weight: float = 0.6, default_nash_utility: float = 0.7, discount_bonus_base: float = 0.5, discount_bonus_weight: float = 0.4, big_domain_cardinality: float = 3000, bonus_start_time: float = 0.91, bonus_start_time_big_domain: float = 0.85, bonus_ramp_rate: float = 20.0, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyThe bidding (offering) strategy of the Nice Tit for Tat agent (Baarslag, Hindriks & Jonker, 2013, “A Tit for Tat Negotiation Strategy for Real-Time Bilateral Negotiations”).
The strategy reciprocates in the agent’s own utility (the opponent’s utility is unknown and any model of it is unreliable, so we measure the opponent’s concession as the change in our utility of the opponent’s successive offers) and aims for a bargaining solution point of the scenario rather than naively mirroring the opponent’s raw concession (naive mirroring settles for ~0.5 utility and misses win-win deals). By default the target is the Nash bargaining point (as in the paper); other solution concepts can be selected with
target(see below):This follows the algorithm of the reference Genius implementation (Baarslag’s
NiceTitForTat), working entirely in the agent’s normalized[0, 1]utility:Cooperate first. Initially the agent offers its best outcome (it never defects first).
Estimate ``my_nash``. Using the opponent model (
negotiator.opponent_ufun) and the calculators innegmas.preferences.ops, estimate the chosen bargaining solution and take the agent’s own utilityp_meat it. Scale it by a multiplier that depends on how far the opponent started from the agent (1.4 - 0.6 * initial_gap) and floor it: for the Nash target atnash_min(0.5by default, as in the reference); for other targets only at the reserved value.Reciprocate the opponent’s observed concession. Measure the opponent’s concession in the agent’s own utility as
max_offered_to_me - first_offered_to_me(how far the best bid it has offered us has moved from its starting bid — directly observed, not model-estimated) and express it as a fraction of the way tomy_nash. The agent concedes the same fraction of its own gap from1down tomy_nash:target = 1 - factor * (1 - my_nash). Then a concession bonus (a small constant baseline from the discount factor plus a ramp near the deadline) pulls the target the rest of the way towardmy_nash— this is what lets a mirror match concede and agree instead of deadlocking at maximum utility.Make the offer attractive to the opponent. Among the outcomes in the agent’s acceptable utility band
[target, 1], pick the one the opponent model rates highest — the trade-off queryargmax_{u_me >= target} u_opp, answered by aParetoSampler(pareto_sampler_type) built on the normalized agent ufun with the opponent model as the opponent ufun (viaufun.make_pareto_sampler, cached and re-initialized as the same model instance learns). If the sampler cannot answer (no result, or its additivity requirements are not met), the policy falls back to inverting the normalized ufun over the band. Finally, if the best bid the opponent has already offered us is worth at least as much to us as our planned bid, we offer that bid instead (the reference’smakeAppropriate), so consensus forms as soon as the opponent’s standing offer beats our plan.
The opponent model is accessed through
self.negotiator.opponent_ufun(aUFunModel), which may be provided to the negotiator or left to a default (seeNiceTitForTatNegotiator).AI Generated (implementation of the Baarslag 2013 Nice Tit for Tat bidding strategy for negmas).
- Parameters:
sample_size – Maximum number of outcomes to sample from the utility band when selecting the opponent-attractive offer.
max_cardinality – Maximum number of outcomes to enumerate/sample when estimating the bargaining point.
nash_refresh – Re-estimate the bargaining point every this many rounds (1 = every round, reflecting an opponent model that keeps learning).
stochastic – If
Trueand no opponent model is available, pick a random in-band outcome instead of the worst-in-band one.target – The bargaining solution to aim for. One of
"nash"(default, Nash bargaining),"kalai"(Kalai egalitarian),"kalai_smorodinsky"/"ks"(Kalai-Smorodinsky),"max_welfare"(utilitarian / max sum of utilities), or"max_relative_welfare"(max sum of relative gains). Selected via the corresponding calculator innegmas.preferences.ops.nash_min – Lower clamp on the estimated
my_nashtarget utility, applied only for the"nash"target (the reference agent never asks for less than0.5). For other solution concepts the target is floored at the reserved value instead, so a legitimately lowerp_meis not inflated.pareto_sampler_type – The
ParetoSamplerimplementation used for step iv (the opponent-attractive trade-off query). Defaults toDefaultParetoSampler(AdaptiveParetoSampler), which uses the exactBruteForceParetoSampleron small outcome spaces and a scalable backend on large ones. Pass a specific sampler type (e.g.BruteForceParetoSampler, orIPSParetoSamplerfor very large additive domains) to override. The sampler is queried each round viabest_for_opponentwith the opponent model as the opponent ufun; if it cannot answer the query the policy falls back to the inverter path.
- Remarks:
Requires the negotiator to expose
opponent_ufun(aUFunModelorNone). When it isNonethe policy degrades to naive tit-for-tat.
- before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]¶
Remember the opponent’s offers and update the offer-history stats.
Tracks, in the agent’s own normalized utility, the utility of the opponent’s first bid (the reference point for its concession) and the running maximum utility it has offered us (a ratchet), plus the bid that achieved it (used to avoid overshooting — see
makeAppropriatein the reference).
- pareto_sampler_type: type[ParetoSampler][source]¶
- class negmas.sao.NoneOfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyAlways offers
Nonewhich means it never gets an agreement.
- class negmas.sao.OSMeanMetaNegotiator(*args, negotiators: Iterable[SAOPRNegotiator] | None = None, negotiator_types: Iterable[type[SAOPRNegotiator]] | None = None, negotiator_params: Iterable[dict[str, Any]] | None = None, negotiator_names: Iterable[str] | None = None, share_ufun: bool = True, share_nmi: bool = True, **kwargs)[source]¶
Bases:
SAOAggMetaNegotiatorAn SAO meta-negotiator that aggregates proposals by averaging in outcome space.
Unlike
MeanMetaNegotiatorwhich works in utility space, this negotiator works directly in the outcome space by averaging issue values from sub-negotiator proposals.For numeric issues (integers, floats), it computes the mean value across all sub-negotiator proposals and finds/generates an outcome with values near that mean. For non-numeric issues (categorical), it samples from the values proposed by sub-negotiators.
For response aggregation, it uses majority voting among sub-negotiators.
- Parameters:
negotiators – An iterable of
SAONegotiatorinstances to manage. Mutually exclusive withnegotiator_types.negotiator_types – An iterable of
SAONegotiatortypes to instantiate. Mutually exclusive with negmas.negotiators.negotiator_params – Optional iterable of parameter dicts for each negotiator type. Only used with
negotiator_types.negotiator_names – Optional names for the negotiators.
*args – Additional positional arguments passed to the base class.
**kwargs – Additional keyword arguments passed to the base class.
- Remarks:
For continuous issues, the mean value is used directly.
For discrete numeric issues (integers), the mean is rounded to the nearest valid value within the issue’s range.
For categorical issues, a value is randomly sampled from those proposed by the sub-negotiators.
Example
>>> from negmas.sao.negotiators import ( ... OSMeanMetaNegotiator, ... BoulwareTBNegotiator, ... ConcederTBNegotiator, ... ) >>> from negmas.sao import SAOMechanism >>> from negmas.preferences import LinearAdditiveUtilityFunction as U >>> from negmas.outcomes import make_issue, make_os >>> >>> issues = [make_issue(10, "price"), make_issue(5, "quantity")] >>> os = make_os(issues) >>> ufun1 = U.random(os, reserved_value=0.0) >>> ufun2 = U.random(os, reserved_value=0.0) >>> >>> # Create an outcome-space mean meta-negotiator >>> meta = OSMeanMetaNegotiator( ... negotiator_types=[BoulwareTBNegotiator, ConcederTBNegotiator], ... ufun=ufun1, ... ) >>> opponent = ConcederTBNegotiator(ufun=ufun2) >>> >>> mechanism = SAOMechanism(issues=issues, n_steps=50) >>> _ = mechanism.add(meta) >>> _ = mechanism.add(opponent) >>> result = mechanism.run() >>> result.running False
- aggregate_proposals(state: SAOState, proposals: list[tuple[SAOPRNegotiator, tuple | ExtendedOutcome | None]], dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Aggregate proposals by averaging issue values in outcome space.
For numeric issues, computes the mean and finds/generates a valid value. For non-numeric issues, samples from the values proposed by sub-negotiators.
- Parameters:
state – The current SAO state.
proposals – List of (negotiator, proposal) tuples from sub-negotiators.
dest – The destination partner ID (if applicable).
- Returns:
An outcome with averaged issue values, or None if no valid proposals.
- aggregate_responses(state: SAOState, responses: list[tuple[SAOPRNegotiator, ResponseType]], offer: tuple | None, source: str | None = None) ResponseType[source]¶
Aggregate responses using majority voting.
- Parameters:
state – The current SAO state.
responses – List of (negotiator, response) tuples from sub-negotiators.
offer – The offer being responded to.
source – The source partner ID (if applicable).
- Returns:
The most common response among sub-negotiators.
- class negmas.sao.OfferBest(best: Outcome | None = None, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyOffers Only the best outcome.
- Remarks:
You can pass the best outcome if you know it as
bestotherwise it will find it.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Finds and caches the best outcome when preferences change.
- class negmas.sao.OfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]¶
Bases:
OfferSelectorSelects the nearest outcome to the pivot outcome which is updated before responding
- class negmas.sao.OfferSelector(*args, **kwargs)[source]¶
Bases:
OfferSelectorProtocol,GBComponentCan select the best offer in some sense from a list of offers based on an inverter
- class negmas.sao.OfferSelectorProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolCan select the best offer in some sense from a list of offers based on an inverter
- class negmas.sao.OfferTop(fraction: float = 0.0, k: int = 1, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyOffers outcomes that are in the given top fraction or top
k. If neither is given it reverts to only offering the best outcome- Remarks:
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Computes the set of top outcomes based on fraction and k constraints.
- class negmas.sao.OfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GBComponentOffering policy implementation.
- propose(state: GBState, dest: str | None = None) Outcome | ExtendedOutcome | None[source]¶
Propose an offer or None to refuse.
- Parameters:
state –
GBStategiving current state of the negotiation.dest – the thread in which I am supposed to offer.
- Returns:
The outcome being proposed or None to refuse to propose
- Remarks:
Caches results for the same thread and step. If called multiple times for the same thread and step, it will do the computations only once.
Caching is useful when the acceptance strategy calls the offering strategy
- class negmas.sao.OutcomeSetOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]¶
Bases:
OfferSelectorSelects the nearest outcome to a set of pivot outcomes which is updated before responding
- abstractmethod calculate_scores(outcomes: Sequence[Outcome], pivots: list[Outcome], state: GBState) Sequence[tuple[float, Outcome]][source]¶
Compute a score for each outcome based on its relation to the pivot outcomes.
- Parameters:
outcomes – The candidate outcomes to score.
pivots – Reference outcomes used for distance calculations.
state – The current negotiation state.
- Returns:
Sequence of (score, outcome) tuples for ranking.
- class negmas.sao.PartnerOffersOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]¶
Bases:
OutcomeSetOrientedSelectorOrients offes toward the set of past opponent offers
- negmas.sao.ProposalPolicy[source]¶
alias of
OfferingPolicy
- class negmas.sao.RandomAcceptancePolicy(p_acceptance: float = 0.15, p_rejection: float = 0.25, p_ending: float = 0.1, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyResponds randomly with configurable probabilities for accept, reject, end, or no response.
- class negmas.sao.RandomAlwaysAcceptingNegotiator(p_acceptance=0.15, p_rejection=0.75, p_ending=0.1, can_propose=True, accept_around=1.0, eps=0.001, **kwargs)[source]¶
Bases:
MAPNegotiatorRandomAlwaysAccepting negotiator.
- class negmas.sao.RandomConcensusOfferingPolicy(strategies: list[OfferingPolicy], prob: list[float] | None = None, prob_sum_tolerance: float = 0.999, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcensusOfferingPolicyOffers a random response from the list of strategies (different strategy every time).
- decide(indices: list[int], responses: list[Outcome | ExtendedOutcome | None]) Outcome | ExtendedOutcome | None[source]¶
Randomly selects an outcome from responses using probability weights.
- Parameters:
indices – Indices of strategies that passed the filter.
responses – Outcomes proposed by the filtered strategies.
- Returns:
A randomly selected outcome based on probability distribution.
- class negmas.sao.RandomNegotiator(p_acceptance=0.15, p_rejection=0.75, p_ending=0.1, can_propose=True, **kwargs)[source]¶
Bases:
MAPNegotiatorA negotiation agent that responds randomly in a single negotiation.
- Parameters:
p_acceptance – Probability of accepting an offer
p_rejection – Probability of rejecting an offer
p_ending – Probability of ending the negotiation at any round
can_propose – Whether the agent can propose or not
**kwargs – Passed to the GBNegotiator
Remarks:
If p_acceptance + p_rejection + p_ending < 1, the rest is the probability of no-response.
- class negmas.sao.RandomOfferSelector(*args, **kwargs)[source]¶
Bases:
OfferSelectorSelects a random outcome from the candidate set.
- class negmas.sao.RandomOfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyOffers random outcomes from the negotiation outcome space.
- class negmas.sao.RangeMetaNegotiator(*args, negotiators: Iterable[SAOPRNegotiator] | None = None, negotiator_types: Iterable[type[SAOPRNegotiator]] | None = None, negotiator_params: Iterable[dict[str, Any]] | None = None, negotiator_names: Iterable[str] | None = None, max_cardinality: int = 10000, **kwargs)[source]¶
Bases:
SAOAggMetaNegotiatorAn SAO meta-negotiator that samples outcomes within the utility range of sub-negotiator proposals.
This negotiator collects proposals from all sub-negotiators, computes their utilities, and samples an outcome from the outcome space that falls within the min/max utility range defined by those proposals.
For response aggregation, it uses majority voting among sub-negotiators.
- Parameters:
negotiators – An iterable of
SAONegotiatorinstances to manage. Mutually exclusive withnegotiator_types.negotiator_types – An iterable of
SAONegotiatortypes to instantiate. Mutually exclusive with negmas.negotiators.negotiator_params – Optional iterable of parameter dicts for each negotiator type. Only used with
negotiator_types.negotiator_names – Optional names for the negotiators.
max_cardinality – Maximum number of outcomes to sample when searching for outcomes in the utility range. Defaults to 10000.
*args – Additional positional arguments passed to the base class.
**kwargs – Additional keyword arguments passed to the base class.
Example
>>> from negmas.sao.negotiators import ( ... RangeMetaNegotiator, ... BoulwareTBNegotiator, ... ConcederTBNegotiator, ... ) >>> from negmas.sao import SAOMechanism >>> from negmas.preferences import LinearAdditiveUtilityFunction as U >>> from negmas.outcomes import make_issue, make_os >>> >>> issues = [make_issue(10, "price")] >>> os = make_os(issues) >>> ufun1 = U.random(os, reserved_value=0.0) >>> ufun2 = U.random(os, reserved_value=0.0) >>> >>> # Create a range meta-negotiator with diverse strategies >>> meta = RangeMetaNegotiator( ... negotiator_types=[BoulwareTBNegotiator, ConcederTBNegotiator], ... ufun=ufun1, ... ) >>> opponent = ConcederTBNegotiator(ufun=ufun2) >>> >>> mechanism = SAOMechanism(issues=issues, n_steps=50) >>> _ = mechanism.add(meta) >>> _ = mechanism.add(opponent) >>> result = mechanism.run() >>> result.running False
- aggregate_proposals(state: SAOState, proposals: list[tuple[SAOPRNegotiator, tuple | ExtendedOutcome | None]], dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Aggregate proposals by sampling an outcome within the utility range.
Computes the utility of each sub-negotiator’s proposal, finds the min/max utility range, and samples an outcome from the outcome space that falls within this range.
- Parameters:
state – The current SAO state.
proposals – List of (negotiator, proposal) tuples from sub-negotiators.
dest – The destination partner ID (if applicable).
- Returns:
An outcome within the utility range of sub-negotiator proposals, or None if no valid outcome can be found.
- aggregate_responses(state: SAOState, responses: list[tuple[SAOPRNegotiator, ResponseType]], offer: tuple | None, source: str | None = None) ResponseType[source]¶
Aggregate responses using majority voting.
- Parameters:
state – The current SAO state.
responses – List of (negotiator, response) tuples from sub-negotiators.
offer – The offer being responded to.
source – The source partner ID (if applicable).
- Returns:
The most common response among sub-negotiators.
- class negmas.sao.RejectAlways(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyRejects everything
- class negmas.sao.ResponseType(*values)[source]¶
Bases:
IntEnumPossible responses to offers during negotiation.
- class negmas.sao.SAOAggMetaNegotiator(*args, negotiators: Iterable[SAOPRNegotiator] | None = None, negotiator_types: Iterable[type[SAOPRNegotiator]] | None = None, negotiator_params: Iterable[dict[str, Any]] | None = None, negotiator_names: Iterable[str] | None = None, share_ufun: bool = True, share_nmi: bool = True, **kwargs)[source]¶
Bases:
SAOMetaNegotiatorAn SAO meta-negotiator that aggregates proposals and responses from sub-negotiators.
This class collects proposals and responses from all sub-negotiators and uses abstract aggregation methods to combine them into a single proposal or response.
Subclasses must implement
aggregate_proposalsandaggregate_responsesto define how proposals and responses from sub-negotiators are combined.- Parameters:
negotiators – An iterable of
SAONegotiatorinstances to manage. Mutually exclusive withnegotiator_types.negotiator_types – An iterable of
SAONegotiatortypes to instantiate. Mutually exclusive with negmas.negotiators.negotiator_params – Optional iterable of parameter dicts for each negotiator type. Only used with
negotiator_types.negotiator_names – Optional names for the negotiators.
share_ufun – If True (default), sub-negotiators will share the parent’s ufun.
share_nmi – If True (default), sub-negotiators will receive the parent’s NMI on join.
*args – Additional positional arguments passed to the base class.
**kwargs – Additional keyword arguments passed to the base class.
- Remarks:
Example
>>> from negmas.sao.negotiators import ( ... SAOAggMetaNegotiator, ... BoulwareTBNegotiator, ... ) >>> from negmas.sao import SAOMechanism >>> from negmas.preferences import LinearAdditiveUtilityFunction as U >>> from negmas.outcomes import make_issue >>> >>> class MajorityVoteNegotiator(SAOAggMetaNegotiator): ... def aggregate_proposals(self, state, proposals, dest=None): ... for neg, proposal in proposals: ... if proposal is not None: ... return proposal ... return None ... ... def aggregate_responses(self, state, responses, offer, source=None): ... accept_count = sum( ... 1 for _, r in responses if r == ResponseType.ACCEPT_OFFER ... ) ... if accept_count > len(responses) / 2: ... return ResponseType.ACCEPT_OFFER ... return ResponseType.REJECT_OFFER
- abstractmethod aggregate_proposals(state: SAOState, proposals: list[tuple[SAOPRNegotiator, tuple | ExtendedOutcome | None]], dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Aggregate proposals from all sub-negotiators into a single proposal.
- Parameters:
state – The current SAO state.
proposals – List of (negotiator, proposal) tuples from sub-negotiators.
dest – The destination partner ID (if applicable).
- Returns:
The aggregated proposal, or None to refuse to propose.
- abstractmethod aggregate_responses(state: SAOState, responses: list[tuple[SAOPRNegotiator, ResponseType]], offer: tuple | None, source: str | None = None) ResponseType[source]¶
Aggregate responses from all sub-negotiators into a single response.
- Parameters:
state – The current SAO state.
responses – List of (negotiator, response) tuples from sub-negotiators.
offer – The offer being responded to.
source – The source partner ID (if applicable).
- Returns:
The aggregated response.
- class negmas.sao.SAOCallNegotiator(*args, **kwargs)[source]¶
Bases:
SAOPRNegotiator,ABCAn SAO negotiator implemented by overriding __call__ to return a counter offer.
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The utility function of the negotiator (overrides preferences if given)
owner – The
Agentthat owns the negotiator.
Remarks:
See also
- propose(state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generate proposal by calling the negotiator and extracting the outcome.
- Parameters:
state – Current SAO state with step counter and previous offers
dest – Destination negotiator ID (None broadcasts to all)
- Returns:
Cached or freshly generated proposal
- Return type:
Outcome | ExtendedOutcome | None
- respond(state: SAOState, source: str | None = None) ResponseType[source]¶
Generate response by calling negotiator and extracting response type.
- Parameters:
state – Current SAO state including the offer to respond to
source – Negotiator ID who made the offer (None if unknown)
- Returns:
Response action (ACCEPT_OFFER, REJECT_OFFER, or END_NEGOTIATION)
- Return type:
- class negmas.sao.SAOController(default_negotiator_type=<class 'negmas.sao.negotiators.controlled.ControlledSAONegotiator'>, preferences=None, ufun=None, **kwargs)[source]¶
Bases:
Controller[SAONMI,SAOState,ControlledSAONegotiator]A controller that can manage multiple negotiators taking full or partial control from them.
- Parameters:
default_negotiator_type – Default type to use when creating negotiators using this controller. The default type is
ControlledSAONegotiatorwhich passes full control to the controller.default_negotiator_params – Default paramters to pass to the default controller.
auto_kill – Automatically kill the negotiator once its negotiation session is ended.
name – Controller name
preferences – The preferences of the controller.
ufun – The ufun of the controller (overrides negmas.preferences).
- after_join(negotiator_id, *args, ufun=None, preferences=None, **kwargs) None[source]¶
Called by children negotiators after joining a negotiation to inform the controller
- Parameters:
negotiator_id – The negotiator ID
nmi (SAONMI) – The negotiation.
state (SAOState) – The current state of the negotiation
ufun (UtilityFunction) – The ufun function to use before any discounting.
role (str) – role of the agent.
- before_join(negotiator_id: str, nmi: SAONMI, state: SAOState, *, preferences: Preferences | None = None, role: str = 'negotiator') bool[source]¶
Called by children negotiators to get permission to join negotiations
- Parameters:
negotiator_id – The negotiator ID
nmi (SAONMI) – The negotiation.
state (SAOState) – The current state of the negotiation
ufun (UtilityFunction) – The ufun function to use before any discounting.
role (str) – role of the agent.
- Returns:
True if the negotiator is allowed to join the negotiation otherwise False
- create_negotiator(negotiator_type=None, name: str | None = None, cntxt: Any = None, **kwargs)[source]¶
Creates a new negotiator managed by this controller.
- propose(negotiator_id: str, state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generates a proposal for the given negotiator.
- respond(negotiator_id: str, state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Generates a response for the given negotiator.
- class negmas.sao.SAOMechanism(dynamic_entry=False, extra_callbacks=True, end_on_no_response=True, avoid_ultimatum=False, check_offers=False, enforce_issue_types=False, cast_offers=False, offering_is_accepting=True, allow_offering_just_rejected_outcome=True, allow_none_with_data=True, allow_negotiators_to_leave=True, name: str | None = None, max_wait: int = 9223372036854775807, sync_calls: bool = False, initial_state: SAOState | None = None, one_offer_per_step: bool = False, **kwargs)[source]¶
Bases:
Mechanism[SAONMI,SAOState,SAOResponse,SAOPRNegotiator|GBNegotiator]A generalized Stacked Alternating Offers Protocol mechanism.
This mechanism extends the classic SAO protocol with several advanced features:
Dynamic Entry/Exit: Negotiators can join after the negotiation starts (
dynamic_entry=True) and can leave gracefully usingResponseType.LEAVEwithout forcing the negotiation to end (allow_negotiators_to_leave=True).Per-Negotiator Limits: Each negotiator can have individual time and step limits, enabling asymmetric negotiation scenarios.
Text-Based Communication: Negotiators can send messages or explanations alongside offers using the
datafield and can even send messages that do not contain any offers as long as they include some text or data (allow_none_with_data=True).Flexible Response Types: Beyond ACCEPT/REJECT/END, negotiators can WAIT (pause their turn) or LEAVE (exit gracefully).
Callbacks: Negotiators receive notifications when others join (
on_negotiator_entered) or leave (on_negotiator_left) and on the most important events including partner offers, rounds start and end, etc.
- Parameters:
outcome_space – The negotiation agenda
issues – A list of issues defining the outcome-space of the negotiation
outcomes – A list of outcomes defining the outcome-space of the negotiation
n_steps – The maximum number of negotiation rounds (see
time_limit)time_limit – The maximum wall-time allowed for the negotiation (see
n_steps)step_time_limit – The maximum wall-time allowed for a single negotiation round.
max_n_agents – The maximum number of negotiators allowed to join the negotiation.
dynamic_entry – Whether it is allowed for negotiators to join the negotiation after it starts
cache_outcomes – If true, the mechanism will catch negmas.outcomes and a discrete version (
discrete_outcomes) that can be accessed by any negotiator through their NMIs.max_cardinality – Maximum number or outcomes to use when discretizing the outcome-space
annotation – A key-value mapping to keep around. Accessible through the NMI but not used by the mechanism.
end_on_no_response – End the negotiation if any negotiator returns NO_RESPONSE from
respond/counteror returns REJECT_OFFER then refuses to give an offer (by returningNonefromproposee/`counter).enable_callbacks – Enable callbacks like on_round_start, etc. Note that on_negotiation_end is always received by the negotiators no matter what is the setting for this parameter.
check_offers – If true, offers are checked to see if they are valid for the negotiation outcome-space and if not the offer is considered None which is the same as refusing to offer (NO_RESPONSE).
enforce_issue_types – If True, the type of each issue is enforced depending on the value of
cast_offerscast_offers – If true, each issue value is cast using the issue’s type otherwise an incorrect type will be considered an invalid offer. See
check_offers. Only used ifenforce_issue_typesignore_negotiator_exceptions – just silently ignore negotiator exceptions and consider them no-responses.
offering_is_accepting – Offering an outcome implies accepting it. If not, the agent who proposed an offer will be asked to respond to it after all other agents.
allow_none_with_data – If True (default), a negotiator can respond with REJECT_OFFER and outcome=None as long as there is associated data (e.g., text). This allows negotiators to send messages or explanations without making a concrete offer. The negotiation will continue rather than breaking.
allow_negotiators_to_leave – If True (default), a LEAVE response removes the negotiator but remaining negotiators continue if 2+ remain. If fewer than 2 remain after leaving, the negotiation ends unless
dynamic_entry=True(allowing new negotiators to join). If False, LEAVE is treated exactly like END_NEGOTIATION (breaks the negotiation).sync_calls – If given, calls to negotiators will be synchronized. This will not enforce timeouts on single calls which means that a negotiator in an infinite loop will hog the CPU. By default calls are done using a different thread that is killed when the timeout passes. This may, but is not guaranteed to, resolve this issue at the expense of slower negotiations and harder debugging
name – Name of the mechanisms
**kwargs – Extra parameters passed directly to the
Mechanismconstructor
Remarks:
One and only one of
outcome_space,issues, negmas.outcomes can be givenIf both
n_stepsandtime_limitare passed, the negotiation ends when either of the limits is reached.Negotiations may take longer than
time_limitbecause negotiators are not interrupted while they are executing theirrespondorproposemethods.
Events:
negotiator_exception: Data=(negotiator, exception) raised whenever a negotiator raises an exception if ignore_negotiator_exceptions is set to True.
- add(negotiator: SAONegotiator | GBNegotiator, *, preferences: Preferences | None = None, role: str | None = None, **kwargs) bool | None[source]¶
Add a negotiator to this mechanism.
- Parameters:
negotiator – The negotiator instance to add.
preferences – Optional preferences to assign to the negotiator.
role – Optional role identifier for the negotiator.
**kwargs – Additional keyword arguments passed to the parent add method.
- Returns:
True if successfully added, False if rejected, None if pending.
- property agreement_partners: list[SAOPRNegotiator | GBNegotiator][source]¶
Returns negotiators who are part of the final agreement.
This is the same as
participating_negotiators- it includes all negotiators who haven’t left the negotiation. If there’s an agreement, these are the parties to that agreement.- Returns:
List of negotiator objects who participated in the final outcome.
- property atomic_steps: bool[source]¶
Is every step corresponding to a single action by a single negotiator
- property extended_trace: list[tuple[int, str, tuple]][source]¶
Returns the negotiation history as a list of step/negotiator/offer tuples
- following_negotiators() list[str][source]¶
Returns a list of ids for all negotiators in the order they are to be run in the next calls to step()
- property full_trace: list[TraceElement][source]¶
Returns the negotiation history as a list of relative_time/step/negotiator/offer tuples
- property full_trace_with_utils: list[tuple][source]¶
Returns the full trace and the utility of the negotiators at each step.
- full_trace_with_utils_df(ufun_names: str | list[str] = 'id') pd.DataFrame[source]¶
Returns the full trace and the utility of the negotiators at each step.
- Parameters:
ufun_names – How to name utility columns. “id” (default) uses negotiator IDs for consistency with the ‘negotiator’ field in trace entries. “name” uses negotiator names. Can also be a list of custom names.
- property n_participating: int[source]¶
Number of negotiators still participating (not left).
- Returns:
Count of active negotiators.
- negotiator_full_trace(negotiator_id: str) list[tuple[float, float, int, tuple, str, str | None, dict[str, Any] | None]][source]¶
Returns the (time/relative-time/step/outcome/response/text/data) given by a negotiator (in order)
- negotiator_offers(negotiator_id: str) list[tuple][source]¶
Returns the offers given by a negotiator (in order)
- next_negotitor_ids() list[str][source]¶
Returns a list of negotiator IDs in the order they are to be run in the next call to step()
- property participating_negotiators: list[SAOPRNegotiator | GBNegotiator][source]¶
Returns negotiators still participating (those who haven’t left).
Unlike negmas.negotiators, this excludes any negotiator that has returned a LEAVE response. The original negotiator list and indices remain unchanged to avoid breaking any saved references.
- Returns:
List of negotiator objects still active in the negotiation.
- plot(plotting_negotiators: tuple[int, int] | tuple[str, str] = (0, 1), save_fig: bool = False, path: str | None = None, fig_name: str | None = None, ignore_none_offers: bool = True, with_lines: bool = True, show_agreement: bool = False, show_pareto_distance: bool = True, show_nash_distance: bool = True, show_kalai_distance: bool = True, show_ks_distance: bool = True, show_max_welfare_distance: bool = True, show_max_relative_welfare_distance: bool = False, show_end_reason: bool = True, show_last_negotiator: bool = True, show_annotations: bool = False, show_reserved: bool = True, show_total_time=True, show_relative_time=True, show_n_steps=True, colors: list | None = None, markers: list[str] | None = None, colormap: str = 'jet', ylimits: tuple[float, float] | None = None, common_legend: bool = True, xdim: str = 'relative_time', only2d: bool = False, no2d: bool = False, fast: bool = False, simple_offers_view: bool = False, mark_offers_view: bool = True, mark_pareto_points: bool = True, mark_all_outcomes: bool = True, mark_nash_points: bool = True, mark_kalai_points: bool = True, mark_ks_points: bool = True, mark_max_welfare_points: bool = True, show: bool = True, **kwargs)[source]¶
Visualize the negotiation run showing offers and utilities in 2D space.
- Parameters:
plotting_negotiators – Indices or IDs of two negotiators whose utilities form the axes.
save_fig – Whether to save the figure to disk.
path – Directory path for saving the figure.
fig_name – Filename for the saved figure.
ignore_none_offers – Whether to skip None offers in the plot.
with_lines – Whether to connect offers with lines showing progression.
show_agreement – Whether to highlight the final agreement point.
show_pareto_distance – Whether to display distance to Pareto frontier.
show_nash_distance – Whether to display distance to Nash solution.
show_kalai_distance – Whether to display distance to Kalai-Smorodinsky solution.
show_ks_distance – Whether to display distance to KS point.
show_max_welfare_distance – Whether to display distance to max welfare point.
show_max_relative_welfare_distance – Whether to display distance to max relative welfare.
show_end_reason – Whether to annotate why the negotiation ended.
show_last_negotiator – Whether to show the last negotiator who acted.
show_annotations – Whether to show offer annotations on the plot.
show_reserved – Whether to show reservation values.
show_total_time – Whether to display total negotiation time.
show_relative_time – Whether to display relative time progress.
show_n_steps – Whether to display the number of steps.
colors – Custom color list for negotiators.
markers – Custom marker list for negotiators.
colormap – Matplotlib colormap name for coloring offers.
ylimits – Y-axis limits as (min, max) tuple.
common_legend – Whether to use a shared legend for all subplots.
xdim – Dimension for x-axis (“relative_time”, “step”, etc.).
only2d – Whether to show only the 2D utility space plot.
no2d – Whether to skip the 2D utility space plot.
fast – Whether to use faster but less detailed rendering.
simple_offers_view – Whether to use simplified offer visualization.
mark_offers_view – Whether to mark offers in the utility space view.
mark_pareto_points – Whether to mark Pareto optimal points.
mark_all_outcomes – Whether to mark all possible outcomes.
mark_nash_points – Whether to mark Nash bargaining solution.
mark_kalai_points – Whether to mark Kalai-Smorodinsky solution.
mark_ks_points – Whether to mark KS points.
mark_max_welfare_points – Whether to mark maximum welfare points.
show – Whether to display the figure immediately.
**kwargs – Additional arguments passed to the plotting function.
- class negmas.sao.SAOMetaNegotiator(*args, negotiators: Iterable[SAOPRNegotiator] | None = None, negotiator_types: Iterable[type[SAOPRNegotiator]] | None = None, negotiator_params: Iterable[dict[str, Any]] | None = None, negotiator_names: Iterable[str] | None = None, share_ufun: bool = True, share_nmi: bool = True, **kwargs)[source]¶
Bases:
MetaNegotiator,SAOPRNegotiatorAbstract base class for SAO meta-negotiators that manage multiple SAONegotiator instances.
This class provides the infrastructure for managing sub-negotiators in SAO protocols, including lifecycle callback forwarding, NMI/ufun sharing, and proper joining.
Subclasses must implement
proposeandrespondto define how the meta-negotiator behaves. This is straightforward - just decide how to use your sub-negotiators.- Parameters:
negotiators – An iterable of
SAONegotiatorinstances to manage. Mutually exclusive withnegotiator_types.negotiator_types – An iterable of
SAONegotiatortypes to instantiate. Mutually exclusive with negmas.negotiators.negotiator_params – Optional iterable of parameter dicts for each negotiator type. Only used with
negotiator_types.negotiator_names – Optional names for the negotiators.
share_ufun – If True (default), sub-negotiators will share the parent’s ufun.
share_nmi – If True (default), sub-negotiators will receive the parent’s NMI on join.
*args – Additional positional arguments passed to the base class.
**kwargs – Additional keyword arguments passed to the base class.
- Remarks:
All lifecycle callbacks are delegated to all sub-negotiators.
Subclasses can implement any strategy: delegation to a single negotiator, aggregation of multiple negotiators, or custom logic that uses sub-negotiators for advice/context only.
You can either pass negmas.negotiators (instances) OR
negotiator_types(classes to instantiate). If usingnegotiator_types, you can optionally providenegotiator_params(parameter dicts).
Example
A simple passthrough meta-negotiator that delegates to its first sub-negotiator:
class PassthroughMeta(SAOMetaNegotiator): def propose(self, state, dest=None): return self._negotiators[0].propose(state, dest=dest) def respond(self, state, source=None): return self._negotiators[0].respond(state, source=source)
Creating with negotiator types instead of instances:
meta = MeanMetaNegotiator( negotiator_types=[BoulwareTBNegotiator, ConcederTBNegotiator], negotiator_params=[{"name": "boulware"}, {"name": "conceder"}], )
See also
- SAOAggMetaNegotiator: Implementation that aggregates proposals/responses
from multiple sub-negotiators.
- join(nmi: NegotiatorMechanismInterface, state: MechanismState, *, preferences: Preferences | None = None, ufun: BaseUtilityFunction | None = None, role: str = 'negotiator') bool[source]¶
Join a negotiation and have sub-negotiators join too.
- Parameters:
nmi – The negotiator-mechanism interface.
state – The current mechanism state.
preferences – Optional preferences for this negotiator.
ufun – Optional utility function (overrides preferences).
role – The role in the negotiation.
- Returns:
True if successfully joined, False otherwise.
- on_leave(state: MechanismState) None[source]¶
Notify all sub-negotiators that we’re leaving the negotiation.
- on_mechanism_error(state: MechanismState) None[source]¶
Notify all sub-negotiators of a mechanism error.
- on_negotiation_end(state: MechanismState) None[source]¶
Notify all sub-negotiators that negotiation has ended.
- on_negotiation_start(state: MechanismState) None[source]¶
Notify all sub-negotiators that negotiation has started.
- on_negotiator_didnot_enter(negotiator_id: str, state: MechanismState) None[source]¶
Notify all sub-negotiators that a negotiator failed to enter the negotiation.
- on_negotiator_entered(negotiator_id: str, state: MechanismState) None[source]¶
Notify all sub-negotiators that a new negotiator entered the negotiation.
- on_negotiator_left(negotiator_id: str, state: MechanismState) None[source]¶
Notify all sub-negotiators that a negotiator left the negotiation.
- on_round_end(state: MechanismState) None[source]¶
Notify all sub-negotiators that a round has ended.
- on_round_start(state: MechanismState) None[source]¶
Notify all sub-negotiators that a round has started.
- abstractmethod propose(state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generate a proposal for the negotiation.
Subclasses must implement this method to define how proposals are generated. This could involve delegating to a single sub-negotiator, aggregating proposals from multiple sub-negotiators, or using custom logic.
- Parameters:
state – The current SAO state.
dest – The destination partner ID (if applicable).
- Returns:
The proposal, or None to refuse to propose.
- abstractmethod respond(state: SAOState, source: str | None = None) ResponseType[source]¶
Respond to an offer in the negotiation.
Subclasses must implement this method to define how responses are generated. This could involve delegating to a single sub-negotiator, aggregating responses from multiple sub-negotiators, or using custom logic.
- Parameters:
state – The current SAO state.
source – The source partner ID.
- Returns:
The response to the current offer.
- property sao_negotiators: tuple[SAOPRNegotiator, ...][source]¶
Return the tuple of SAO sub-negotiators.
- Returns:
A tuple of all SAO sub-negotiators.
- class negmas.sao.SAOMetaNegotiatorController(*args, meta_negotiator: GBNegotiator | None = None, **kwargs)[source]¶
Bases:
SAOControllerControls multiple negotiations using a single
metanegotiator.- Parameters:
meta_negotiator (-) – The negotiator used for controlling all negotiations.
Remarks:
The controller will use the meta-negotiator to handle all negotiations by first setting its NMI to the current negotiation then calling the appropriate method in the meta negotiator.
If no meta-negotiator is given, an
AspirationNegotiatorwill be created and used (with default parameters).The meta-negotiator should not internally store information between calls to
proposeandrespondabout the negotiation because it will be called to propose and respond in multiple negotiations. TheAspirationNegotiatorcan be used butSimpleTitForTatNegotiatorcannot as it stores the past offer.
- propose(negotiator_id: str, state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Uses the meta negotiator to propose
- respond(negotiator_id: str, state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Uses the meta negotiator to respond
- class negmas.sao.SAONMI(id: str, n_outcomes: int | float, outcome_space: OutcomeSpace, shared_time_limit: float, shared_n_steps: int | None, private_time_limit: float, private_n_steps: int | None, pend: float, pend_per_second: float, step_time_limit: float, negotiator_time_limit: float, dynamic_entry: bool, max_n_negotiators: int | None, _mechanism: Mechanism, annotation: dict[str, Any] = NOTHING, end_on_no_response: bool = True, one_offer_per_step: bool = False, offering_is_accepting: bool = True, allow_none_with_data: bool = True, allow_negotiators_to_leave: bool = True)[source]¶
Bases:
NegotiatorMechanismInterfaceThe
NegotiatorMechanismInterfaceof SAO- allow_negotiators_to_leave: bool[source]¶
If true, negotiators can leave using LEAVE response without ending the negotiation for others
- allow_none_with_data: bool[source]¶
If true, a negotiator can offer None with associated data (e.g., text) without breaking the negotiation
- property extended_trace: list[tuple[int, str, Outcome]][source]¶
Returns the negotiation history as a list of step, negotiator, offer tuples
- property full_trace: list[TraceElement][source]¶
Returns the negotiation history as a list of relative_time/step/negotiator/offer tuples
- property full_trace_with_utils: list[tuple][source]¶
Returns the full trace and the utility of the negotiators at each step.
- full_trace_with_utils_df(ufun_names: str | list[str] = 'id') pd.DataFrame[source]¶
Returns the full trace and the utility of the negotiators at each step.
- Parameters:
ufun_names – How to name utility columns. “id” (default) uses negotiator IDs for consistency with the ‘negotiator’ field in trace entries. “name” uses negotiator names. Can also be a list of custom names.
- negotiator_full_trace(negotiator_id: str) list[tuple[float, float, int, Outcome, str, str | None, dict[str, Any] | None]][source]¶
Returns the (time/relative-time/step/outcome/response/text/data) given by a negotiator (in order)
- negotiator_offers(negotiator_id: str) list[Outcome][source]¶
Get all offers made by a specific negotiator.
- offering_is_accepting: bool[source]¶
If true, offering is considered an acceptance of that offer which means that the offerer need not accept the offer again to make it an agreement
- one_offer_per_step: bool[source]¶
If true, a step should be atomic with only one action from one negotiator
- negmas.sao.SAONegotiator[source]¶
alias of
SAOPRNegotiator
- class negmas.sao.SAOPRNegotiator(preferences: Preferences | None = None, ufun: BaseUtilityFunction | None = None, name: str | None = None, parent: Controller | None = None, owner: Agent | None = None, id: str | None = None, type_name: str | None = None, can_propose: bool = True, **kwargs)[source]¶
Bases:
GBNegotiator[SAONMI,SAOState]Base class for all SAO negotiators. Implemented by implementing propose() and respond() methods.
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The utility function of the negotiator (overrides preferences if given)
owner – The
Agentthat owns the negotiator.
Remarks:
The only method that must be implemented by any SAONegotiator is
propose.The default
respondmethod, accepts offers with a utility value no less than whateverproposereturns with the same mechanism state.A default implementation of respond() is provided which simply accepts any offer better than the last offer I gave or the next one I would have given in the current state.
See also
- on_notification(notification: Notification, notifier: str)[source]¶
Called whenever a notification is received
- Parameters:
notification – The notification
notifier – The notifier entity
Remarks:
The default implementation only responds to end_negotiation by ending the negotiation
- abstractmethod propose(state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generate a proposal (offer) for the current negotiation state.
- Parameters:
state – Current SAO negotiation state including step, offers, and responses
dest – Target negotiator ID to send proposal to (None for all)
- Returns:
Proposed outcome, or None to end negotiation
- Return type:
Outcome | ExtendedOutcome | None
- propose_(state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
The method directly called by the mechanism (through
counter) to ask for a proposal- Parameters:
state – The mechanism state
dest – the destination (can be ignored in AOP, SAOP, MAOP)
- Returns:
An outcome to offer or None to refuse to offer
Remarks:
Depending on the
SAOMechanismsettings, refusing to offer may be interpreted as ending the negotiationThe negotiator will only receive this call if it has the ‘propose’ capability.
- respond(state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Called to respond to an offer. This is the method that should be overriden to provide an acceptance strategy.
- Parameters:
state – a
SAOStategiving current state of the negotiation.source – The ID of the negotiator that gave this offer
- Returns:
The response to the offer
- Return type:
Remarks:
The default implementation never ends the negotiation
The default implementation asks the negotiator to
propose`() and accepts the `offerif its utility was at least as good as the offer that it would have proposed (and above the reserved value).The current offer to respond to can be accessed through
state.current_offer
- respond_(state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
The method to be called directly by the mechanism (through
counter) to respond to an offer.- Parameters:
state – a
SAOStategiving current state of the negotiation.source – The ID of the negotiator that gave the offer.
- Returns:
The response to the offer. Possible values are:
- NO_RESPONSE: refuse to offer. Depending on the mechanism settings this may be interpreted as ending
the negotiation.
ACCEPT_OFFER: Accepting the offer.
- REJECT_OFFER: Rejecting the offer. The negotiator will be given the chance to counter this
offer through a call of
propose_later if this was not the last offer to be evaluated by the mechanism.
END_NEGOTIATION: End the negotiation
WAIT: Instructs the mechanism to wait for this negotiator more. It may lead to cycles so use with care.
- Return type:
Remarks:
The default implementation never ends the negotiation except if an earler end_negotiation notification is sent to the negotiator
The default implementation asks the negotiator to
propose`() and accepts the `offerif its utility was at least as good as the offer that it would have proposed (and above the reserved value).
- negmas.sao.SAOProtocol[source]¶
alias of
SAOMechanism
- class negmas.sao.SAORandomController(*args, p_acceptance: float = 0.1, **kwargs)[source]¶
Bases:
SAOControllerA controller that returns random offers.
- Parameters:
p_acceptance – The probability of accepting an offer.
- propose(negotiator_id: str, state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generates a random proposal for the given negotiator.
- respond(negotiator_id: str, state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Generates a random response for the given negotiator.
- class negmas.sao.SAORandomSyncController(*args, p_acceptance=0.15, p_rejection=0.85, p_ending=0.0, **kwargs)[source]¶
Bases:
SAOSyncControllerA sync controller that returns random offers. (See
SAOSyncController).- Parameters:
p_acceptance – The probability that an offer will be accepted
p_rejection – The probability that an offer will be rejected
p_ending – The probability of ending the negotiation at any negotiation round.
Remarks:
If probability of acceptance, rejection and ending sum to less than 1.0, the agent will return NO_RESPONSE with the remaining probability. Depending on the settings of the
SAOMechanismthis may be treated as ending the negotiation.
- make_response() ResponseType | ExtendedResponseType[source]¶
Generates a random response based on configured probabilities.
- class negmas.sao.SAOResponse(response: ResponseType = ResponseType.NO_RESPONSE, outcome: Outcome | None = None, data: dict[str, Any] | None = None)[source]¶
Bases:
MechanismActionA response to an offer given by a negotiator in the alternating offers protocol.
This class encapsulates both the response decision and an optional offer, along with any additional data (such as text explanations).
Example
Creating a simple response:
>>> from negmas.sao.common import SAOResponse >>> from negmas.gb.common import ResponseType >>> response = SAOResponse(ResponseType.REJECT_OFFER, (5, 10)) >>> response.response <ResponseType.REJECT_OFFER: 1>
Creating a response from extended types with text:
>>> from negmas.outcomes.common import ExtendedOutcome >>> from negmas.gb.common import ExtendedResponseType >>> ext_response = ExtendedResponseType( ... ResponseType.REJECT_OFFER, ... data={"text": "Price too high"} ... ) >>> ext_offer = ExtendedOutcome( ... outcome=(5, 10), ... data={"text": "Counter offer"} ... ) >>> combined = SAOResponse.from_extended(ext_response, ext_offer) >>> "Price too high" in combined.data["text"] True
To customize how text is combined when both response and offer have text, subclass SAOResponse and override the
text_combinerclass method.- classmethod from_extended(response: ResponseType | ExtendedResponseType, offer: Outcome | ExtendedOutcome | None) SAOResponse[source]¶
Create SAOResponse from extended response and offer types.
- Parameters:
response – The response, either ResponseType or ExtendedResponseType.
offer – The offer, either Outcome, ExtendedOutcome, or None.
- Returns:
SAOResponse with merged data from both response and offer.
- Remarks:
If both response and offer have data with the same key, the keys are renamed with “_response” and “_offer” postfixes respectively.
If “text” exists in only one of them, it is copied normally.
If “text” exists in both, the
text_combinerclass method is used to combine them.To customize text combination, subclass SAOResponse and override
text_combiner.
- response: ResponseType[source]¶
- classmethod text_combiner(response_text: str, offer_text: str) str[source]¶
Combine text from response and offer.
Override this method in subclasses to customize text combination behavior.
- Parameters:
response_text – Text from the response.
offer_text – Text from the offer.
- Returns:
Combined text string.
- class negmas.sao.SAOSingleAgreementAspirationController(*args, max_aspiration: float = 1.0, aspiration_type: Literal['boulware', 'conceder', 'linear'] | int | float = 'boulware', **kwargs)[source]¶
Bases:
SAOSingleAgreementControllerA
SAOSingleAgreementControllerthat uses aspiration level to decide what to accept and what to propose.- Parameters:
preferences – The utility function to use for ALL negotiations
max_aspiration – The maximum aspiration level to start with
aspiration_type – The aspiration type/ exponent
Remarks:
This controller will get at most one agreement. It uses a concession strategy controlled by
max_aspirationandaspiration_typeas in theAspirationNegotiatorfor all negotiations.The partner who gives the best proposal will receive an offer that is guaranteed to have a utility value (for the controller) above the current aspiration level.
The controller uses a single ufun for all negotiations. This implies that all negotiations should have the same outcome space (i.e. the same issues).
- is_acceptable(offer: tuple, source: str, state: SAOState)[source]¶
Checks if offer utility meets current aspiration level.
- class negmas.sao.SAOSingleAgreementController(*args, strict=False, **kwargs)[source]¶
Bases:
SAOSyncController,ABCA synchronized controller that tries to get no more than one agreeement.
This controller manages a set of negotiations from which only a single one – at most – is likely to result in an agreement. An example of a case in which it is useful is an agent negotiating to buy a car from multiple suppliers. It needs a single car at most but it wants the best one from all of those suppliers. To guarentee a single agreement, pass strict=True
The general algorithm for this controller is something like this:
Receive offers from all partners.
Find the best offer among them by calling the abstract
best_offermethod.Check if this best offer is acceptable using the abstract
is_acceptablemethod.If the best offer is acceptable, accept it and end all other negotiations.
If the best offer is still not acceptable, then all offers are rejected and with the partner who sent it receiving the result of
best_outcomewhile the rest of the partners receive the result ofmake_outcome.
The default behavior of
best_outcomeis to return the outcome with maximum utility.The default behavior of
make_outcomeis to return the best offer received in this round if it is valid for the respective negotiation and the result ofbest_outcomeotherwise.
- Parameters:
strict – If True the controller is guaranteed to get a single agreement but it will have to send no-response repeatedly so there is a higher chance of never getting an agreement when two of those controllers negotiate with each other
- after_join(negotiator_id, *args, ufun=None, preferences=None, **kwargs) None[source]¶
Stores best outcome for the negotiator after joining.
- abstractmethod best_offer(offers: dict[str, tuple]) str | None[source]¶
Return the ID of the negotiator with the best offer
- Parameters:
offers – A mapping from negotiator ID to the offer it received
- Returns:
The ID of the negotiator with best offer. Ties should be broken. Return None only if there is no way to calculate the best offer.
- best_outcome(negotiator: str, state: SAOState | None = None) tuple | None[source]¶
The best outcome for the negotiation
negotiatorengages in given thestate.- Parameters:
negotiator – The negotiator for which the best outcome is to be found
state – If given, the state of the negotiation. If None, should return the absolute best outcome
- Returns:
The outcome with maximum utility.
Remarks:
The default implementation, just returns the best outcome for this negotiation without considering the
stateor returns None if it is not possible to find this best outcome.If the negotiator defines a ufun, it is used otherwise the ufun defined for the controller if used (if any)
- counter_all(offers: dict[str, tuple | None], states: dict[str, SAOState]) dict[str, SAOResponse][source]¶
Counters all responses
- Parameters:
offers – A dictionary mapping partner ID to offer
states – A dictionary mapping partner ID to mechanism state
- Returns:
A dictionary mapping partner ID to a response
Remarks:
The agent will counter all offers by either ending all negotiations except one which is accepted or by rejecting all offers and countering them using the
make_offermethod.
- first_proposals() dict[str, tuple | None][source]¶
Generates first proposals, selecting one random partner in strict mode.
- abstractmethod is_acceptable(offer: tuple, source: str, state: SAOState) bool[source]¶
Should decide if the given offer is acceptable
- Parameters:
offer – The offer being tested
source – The ID of the negotiator that received this offer
state – The state of the negotiation handled by that negotiator
Remarks:
If True is returned, this offer will be accepted and all other negotiations will be ended.
- abstractmethod is_better(a: tuple | None, b: tuple | None, negotiator: str, state: SAOState) bool[source]¶
Compares two outcomes of the same negotiation
- Parameters:
a – Outcome
b – Outcome
negotiator – The negotiator for which the comparison is to be made
state – Current state of the negotiation
- Returns:
True if utility(a) > utility(b)
- make_offer(negotiator: str, state: SAOState, best_offer: tuple | None, best_from: str | None) tuple | None[source]¶
Generate an offer for the given partner
- Parameters:
negotiator – The ID of the negotiator for who an offer is to be made.
state – The mechanism state of this partner
best_offer – The best offer received in this round. None means that no known best offers.
best_from – The ID of the negotiator that received the best offer
- Returns:
The outcome to be offered to
negotiator(None means no-offer)
Remarks:
Default behavior is to offer everyone
best_offerif available otherwise, it returns no offers (None). Thebest_fromnegotiator will be sending the result ofbest_outcome.
- on_negotiation_end(negotiator_id: str, state: SAOState) None[source]¶
Handles negotiation end, ending all negotiations if agreement was reached.
- response_to_best_offer(negotiator: str, state: SAOState, offer: tuple) tuple | None[source]¶
Return a response to the partner from which the best current offer was received
- Parameters:
negotiator – The negotiator from which the best offer was received
state – The state of the corresponding negotiation
offer – The best offer received at this round.
- Returns:
The offer to be sent back to
negotiator
- class negmas.sao.SAOSingleAgreementRandomController(*args, p_acceptance=0.1, **kwargs)[source]¶
Bases:
SAOSingleAgreementControllerA single agreement controller that uses a random negotiation strategy.
- Parameters:
p_acceptance – The probability that an offer is accepted
- best_offer(offers: dict[str, tuple]) str | None[source]¶
Returns a random negotiator as having the best offer.
- class negmas.sao.SAOState(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: Outcome | None = None, results: Outcome | OutcomeSpace | tuple[Outcome] | None = None, n_negotiators: int = 0, has_error: bool = False, error_details: str = '', erred_negotiator: str = '', erred_agent: str = '', threads: dict[str, ThreadState] = NOTHING, last_thread: str = '', left_negotiators: set[str] = NOTHING, current_offer: Outcome | None = None, current_proposer: str | None = None, current_proposer_agent: str | None = None, n_acceptances: int = 0, new_offers: list[tuple[str, Outcome | None]] = NOTHING, new_offerer_agents: list[str | None] = NOTHING, last_negotiator: str | None = None, current_data: dict[str, Any] | None = None, new_data: list[tuple[str, dict[str, Any] | None]] = NOTHING)[source]¶
Bases:
GBStateThe
MechanismStateof SAO
- class negmas.sao.SAOSyncController(*args, global_ufun=None, **kwargs)[source]¶
Bases:
SAOControllerA controller that can manage multiple negotiators synchronously.
- Parameters:
global_ufun – If true, the controller assumes that the ufun is only defined globally for the complete set of negotiations
Remarks:
The controller waits for an offer from each one of its negotiators before deciding what to do.
Loops may happen if multiple controllers of this type negotiate with each other. For example controller A is negotiating with B, C, while B is also negotiating with C. These loops are broken by the
SAOMechanismby forcing some controllers to respond before they have all of the offers. In this case,counter_allwill receive offers from one or more negotiators but not all of them.
- abstractmethod counter_all(offers: dict[str, tuple | None], states: dict[str, SAOState]) dict[str, SAOResponse][source]¶
Calculate a response to all offers from all negotiators (negotiator ID is the key).
- Parameters:
offers – Maps negotiator IDs to offers
states – Maps negotiator IDs to offers AT the time the offers were made.
Remarks:
The response type CANNOT be WAIT.
If the system determines that a loop is formed, the agent may receive this call for a subset of negotiations not all of them.
- first_offer(negotiator_id: str) tuple | None[source]¶
Finds the first offer for this given negotiator. By default it will be the best offer
- Parameters:
negotiator_id – The ID of the negotiator
- Returns:
The first offer to use.
Remarks:
Default behavior is to use the ufun defined for the controller if any then try the ufun defined for the negotiator. If neither exists, the first offer will be None.
- first_proposals() dict[str, tuple | None][source]¶
Gets a set of proposals to use for initializing the negotiation.
- is_clean() bool[source]¶
Checks that the agent has no negotiators and that all its intermediate data-structures are reset
- on_negotiation_end(negotiator_id: str, state: SAOState) None[source]¶
Handles negotiation end by resetting internal state for the negotiator.
- propose(negotiator_id: str, state: SAOState, dest: str | None = None) tuple | ExtendedOutcome | None[source]¶
Generates a synchronized proposal for the given negotiator.
- reset()[source]¶
Clears all cached offers, responses, and proposals to prepare for new negotiations.
- respond(negotiator_id: str, state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Generates a synchronized response for the given negotiator.
- negmas.sao.SimpleTitForTatNegotiator[source]¶
alias of
NaiveTitForTatNegotiator
- class negmas.sao.TFTAcceptancePolicy(partner_ufun: UFunModel, recommender: ConcessionRecommender, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
AcceptancePolicyAn acceptance strategy that concedes as much as the partner (or more)
- recommender: ConcessionRecommender[source]¶
- class negmas.sao.TFTOfferingPolicy(partner_ufun: UFunModel, recommender: ConcessionRecommender, stochastic: bool = False, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyAn acceptance strategy that concedes as much as the partner (or more)
- before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]¶
Stores the partner’s latest offer for concession calculation.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Propagates preference changes to the partner utility model.
- recommender: ConcessionRecommender[source]¶
- class negmas.sao.TimeBasedConcedingNegotiator(*args, offering_curve: Aspiration | Literal['boulware'] | Literal['conceder'] | Literal['linear'] | float = 'boulware', accepting_curve: Aspiration | Literal['boulware'] | Literal['conceder'] | Literal['linear'] | float | None = None, starting_utility: float = 1.0, **kwargs)[source]¶
Bases:
TimeBasedNegotiatorA time-based conceding negotiator using an
Aspirationcurve.This is the main entry point for aspiration-based time-only negotiators. It accepts an
Aspirationcurve (or a string/float shorthand) for both offering and accepting, plus astarting_utilitythat controls the first offer’s utility level.- Parameters:
offering_curve (Aspiration | str | float) – An
Aspirationcurve (or"boulware"/"linear"/"conceder"or a float exponent) controlling how fast the negotiator concedes when offering. Defaults to"boulware"(slow concession).accepting_curve (Aspiration | str | float | None) – An
Aspirationcurve (or string/float) controlling the acceptance threshold. IfNoneor falsy, the offering curve is reused.starting_utility (float) – The relative utility (in
[0, 1]) at which the first offer is made. Only used whenoffering_curveis a string/float (not a pre-builtAspirationobject). Defaults to1.0(start at the best outcome).**kwargs – Forwarded to
TimeBasedNegotiator(e.g.stochastic,ufun_inverter,eps,offer_selector).
- Remarks:
BoulwareTBNegotiator,LinearTBNegotiator, andConcederTBNegotiatorare convenience subclasses that fixoffering_curveto"boulware","linear", and"conceder"respectively (withstochastic=False).AspirationNegotiatoris a simplified interface to this class withpresortandtoleranceparameters.
- class negmas.sao.TimeBasedNegotiator(*args, offering_curve: TimeCurve | Literal['boulware'] | Literal['conceder'] | Literal['linear'] | float = 'boulware', accepting_curve: TimeCurve | Literal['boulware'] | Literal['conceder'] | Literal['linear'] | float | None = None, offer_selector: OfferSelector | None = None, **kwargs)[source]¶
Bases:
UtilBasedNegotiatorA time-based negotiation strategy that concedes independently of the offers received during the negotiation.
The negotiator maintains two concession curves: an offering curve that controls the utility range of its own proposals, and an accepting curve that controls the utility range of offers it will accept. Both are
TimeCurveobjects mapping relative timet ∈ [0, 1]to a utility range. At each step, the negotiator asks the inverter for an outcome within the offering curve’s range (forpropose) or checks whether the opponent’s offer falls within the accepting curve’s range (forrespond).- Parameters:
offering_curve (TimeCurve | str | float) – A
TimeCurve(or a string"boulware"/"linear"/"conceder"or a float exponent) used to sample outcomes when offering. Defaults to"boulware".accepting_curve (TimeCurve | str | float | None) – A
TimeCurve(or string/float as above) used to decide the utility range to accept. IfNone, the offering curve is reused (same range for offering and accepting).offer_selector (OfferSelector | None) – See
UtilBasedNegotiator.**kwargs – Forwarded to
UtilBasedNegotiator(e.g.stochastic,ufun_inverter,eps,rank_only,max_cardinality).
- Remarks:
This negotiator is time-only: it never reacts to the opponent’s offers (except accepting/rejecting them). For opponent-aware behavior, use
NaiveTitForTatNegotiatoror theOfferOrientedTBNegotiatorfamily.
- class negmas.sao.TimeBasedOfferingPolicy(curve: PolyAspiration = NOTHING, stochastic: bool = False, sorter: InverseUFun | None = None, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyTimeBasedOffering policy implementation.
- curve: PolyAspiration[source]¶
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Initializes the outcome sorter when preferences are set or changed.
Handles different change types appropriately: - Initialization/General: Initialize the sorter (warn if already initialized) - Scale/ReservedValue/ReservedOutcome: Ignored (don’t affect outcome ordering)
- sorter: InverseUFun | None[source]¶
- class negmas.sao.TopFractionNegotiator(min_utility=0.95, top_fraction=0.05, best_first=True, can_propose=True, **kwargs)[source]¶
Bases:
MAPNegotiatorOffers and accepts only one of the top outcomes for the negotiator.
- Parameters:
name – Negotiator name
parent – Parent controller if any
can_propose – If
Falsethe negotiator will never propose but can only acceptpreferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides preferences)
min_utility – The minimum utility to offer or accept
top_fraction – The fraction of the outcomes (ordered decreasingly by utility) to offer or accept
best_first – Guarantee offering will non-increasing in terms of utility value
probabilistic_offering – Offer randomly from the outcomes selected based on
top_fractionandmin_utilityowner – The
Agentthat owns the negotiator.
- class negmas.sao.ToughNegotiator(can_propose=True, **kwargs)[source]¶
Bases:
MAPNegotiatorAccepts and proposes only the top offer (i.e. the one with highest utility).
- Parameters:
- Remarks:
If there are multiple outcome with the same maximum utility, only one of them will be used.
- class negmas.sao.TraceElement(time, relative_time, step, negotiator, offer, responses, state, text, data)[source]¶
Bases:
tuple
- class negmas.sao.UFunModel(*, negotiator: GBNegotiator | None = None)[source]¶
Bases:
GBComponent,BaseUtilityFunctionA
SAOComponentthat can model the opponent’s utility function.Classes implementing this ufun-model, must implement the abstract
eval()method to return the utility value of an outcome. They can use any callbacks available toSAOComponentto update the model.A
UFunModelis a full stand-in for a `BaseUtilityFunction`: anywhere a ufun is accepted (e.g.pareto_frontier, the bargaining-solution calculators innegmas.preferences.ops, or aParetoSampler) aUFunModelcan be passed without errors. Concrete subclasses are typically declared with@defineand therefore skipBaseUtilityFunction.__init__, so the state it would have set up (_invalid_value,_constraints,_reserved_valueand the caches) is initialised here in__attrs_post_init__instead.AI supported (made into a full ufun stand-in for use as an opponent model).
- property outcome_space[source]¶
The outcome space the model is defined over.
A
UFunModelmodels the opponent over the same outcomes the agent cares about, so its outcome space is the negotiator’s ufun outcome space. Exposing it (rather than leaving it unset, as the@definesubclasses do by skippingBaseUtilityFunction.__init__) lets the model be used wherever a ufun is expected — e.g.minmax,pareto_frontier, and the bargaining-solution calculators all readoutcome_space.
- class negmas.sao.UnanimousConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcensusOfferingPolicyOffers only if all offering strategies gave exactly the same outcome
- decide(indices: list[int], responses: list[Outcome | ExtendedOutcome | None]) Outcome | ExtendedOutcome | None[source]¶
Returns the outcome only if all strategies agree, otherwise None.
- Parameters:
indices – Indices of strategies that passed the filter.
responses – Outcomes proposed by the filtered strategies.
- Returns:
The unanimous outcome, or None if strategies disagree.
- class negmas.sao.UtilBasedConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
ConcensusOfferingPolicy,ABCOffers from the list of stratgies (different strategy every time) based on outcome utilities
- decide(indices: list[int], responses: list[Outcome | ExtendedOutcome | None]) Outcome | ExtendedOutcome | None[source]¶
Selects an outcome based on utility values using the decide_util method.
- Parameters:
indices – Indices of strategies that passed the filter.
responses – Outcomes proposed by the filtered strategies.
- Returns:
The outcome selected by the utility-based decision rule.
- class negmas.sao.UtilBasedNegotiator(*args, stochastic: bool = False, rank_only: bool = False, ufun_inverter: Callable[[BaseUtilityFunction], InverseUFun] | None = None, offer_selector: OfferSelector | None = None, max_cardinality: int = 10000000, eps: float = 0.0001, **kwargs)[source]¶
Bases:
GBNegotiatorA negotiator that bases its decisions on the utility value of outcomes only.
It uses an
InverseUFun(via theUtilityInvertercomponent) to find outcomes with utilities in a desired range, and an optionalOfferSelectorto pick among multiple candidate outcomes.- Parameters:
stochastic (bool) – If
False(default), the inverter’sworst_inis used so the negotiator proposes the outcome with the lowest utility still within its aspiration band (i.e. just above the aspiration level). IfTrue,one_inis used so a random in-range outcome is proposed.rank_only (bool) – If
True, only the relative ranks of outcomes (not their actual utilities) are used for inversion. This maps all equal-utility outcomes to the same rank, which can be useful for non-stationary or noisy ufuns.ufun_inverter (Callable[[BaseUtilityFunction], InverseUFun] | None) – A factory that constructs an
InverseUFunfrom the negotiator’s utility function. IfNone, aDefaultInverseUtilityFunction(i.e.AdaptiveInverseUtilityFunction) is used.offer_selector (OfferSelector | None) – A callable that selects one outcome from a sequence of candidates given the current state. If
NoneandstochasticisTrue, a random candidate is chosen. IfNoneandstochasticisFalse,worst_inis used directly (no selection needed).max_cardinality (int) – The number of outcomes at which the default inverter may switch away from exact presorting to a scalable approximation. Used only if
ufun_inverterisNone.eps (float) – A tolerance around the utility range used when sampling outcomes (passed to the inverter).
- Remarks:
proposerecovers from aNoneinverter result (which would otherwise break the SAO mechanism) by falling back to the best outcome. This matters for strict inverters (e.g.BruteForceInverseUtilityFunction) whose aspiration range contains no outcome, and as a safety net when a clamping inverter’s fallbacks are exhausted.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
On preferences changed.
- Parameters:
changes – Changes.
- propose(state, dest: str | None = None)[source]¶
Propose.
Recovers from a
Noneproposal (which would otherwise break the SAO mechanism — seenegmas.sao.mechanism) by falling back to the best outcome. This is important when the inverter is strict (e.g.BruteForceInverseUtilityFunction) and the requested aspiration range contains no outcome: the negotiator would rather offer its best outcome than break the negotiation.- Parameters:
state – Current state.
dest – Dest.
- respond(state, source: str | None = None) ResponseType | ExtendedResponseType[source]¶
Respond.
- Parameters:
state – Current state.
source – Source identifier.
- Returns:
The result.
- Return type:
- class negmas.sao.UtilityBasedOutcomeSetRecommender(rank_only: bool = False, ufun_inverter: Callable[[BaseUtilityFunction], InverseUFun] | None = None, max_cardinality: int | float = inf, eps: float = 0.0001, inversion_method: Literal['min', 'max', 'one', 'some', 'all'] = 'some')[source]¶
Bases:
GBComponentRecommends a set of outcome appropriate for proposal
- before_proposing(state: GBState, dest: str | None = None)[source]¶
Ensures the inverter is initialized before making a proposal.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Rebuilds the inverse utility function when preferences change.
- scale_utilities(urange: tuple[float, ...]) tuple[float, ...][source]¶
Scales given utilities to the range of the ufun.
Remarks:
Assumes that the input utilities are in the range [0-1] no matter what is the range of the ufun.
Subtracts the
tolerancefrom the first and adds it to the last utility value which slightly enlarges the range to account for small rounding errors
- set_negotiator(negotiator: GBNegotiator) None[source]¶
Attaches this component to a negotiator and resets internal state.
- class negmas.sao.UtilityInverter(*args, offer_selector: OfferSelectorProtocol | Literal['min'] | Literal['max'] | None = None, **kwargs)[source]¶
Bases:
GBComponentA component that can recommend an outcome based on utility
- before_proposing(state: GBState, dest: str | None = None)[source]¶
Prepares the recommender before making a proposal.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Forwards preference changes to the underlying recommender.
- set_negotiator(negotiator: GBNegotiator) None[source]¶
Attaches this component and its recommender to a negotiator.
- class negmas.sao.ValueDifferenceUFunModel(above_reserve: bool = True, levels: int = 10, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
_SequentialWeightUFunModelIssue weights from value-difference magnitudes — Carbonneau & Vahidov [37].
Unlike
ConcessionRatioUFunModel, which only counts whether an issue’s value changed, this model uses the magnitude of the change between two sequential offers, normalized by the issue’s range (survey §5.3.1). For a numeric issue the per-step difference is|v_t - v_{t-1}| / range_i; for a categorical issue it is a0/1indicator. The running mean normalized differenced_igives the issue weightw_i = 1 - d_i(then normalized). Per-issue value utilities are estimated from offer frequency.- Remarks:
Larger (normalized) moves on an issue ⇒ more concession ⇒ lower weight.
Returns utilities already normalized to
[0, 1]; a neutral0.5before any offer is observed.
AI Generated (Carbonneau & Vahidov value-difference issue weights).
- class negmas.sao.WABNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorWasting Accepting Better (neither complete nor an equilibrium)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides preferences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.WANNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorWasting Accepting Any (an equilibrium but not complete)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides preferences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.WARNegotiator(*args, **kwargs)[source]¶
Bases:
MAPNegotiatorWasting Accepting Any (an equilibrium but not complete)
- Parameters:
name – Negotiator name
parent – Parent controller if any
preferences – The preferences of the negotiator
ufun – The ufun of the negotiator (overrides preferences)
owner – The
Agentthat owns the negotiator.
- class negmas.sao.WAROfferingPolicy(next_indx: int = 0, sorter: InverseUFun | None = None, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
OfferingPolicyWAROffering policy implementation.
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
Initializes outcome sorter and irrational offer tracking on preference changes.
- sorter: InverseUFun | None[source]¶
- class negmas.sao.WorstOfferSelector(*args, **kwargs)[source]¶
Bases:
OfferSelectorSelects the outcome with the lowest utility value.
- class negmas.sao.ZeroSumModel(above_reserve: bool = True, rank_only: bool = False, *, negotiator: GBNegotiator | None = None)[source]¶
Bases:
UFunModelAssumes a zero-sum negotiation (i.e. $u_o$ = $-u_s$ )
Remarks:
Because some negotiators do not work well with negative ufun values, we return (max - u(w)) instead of (- u(w))
- eval(offer: Outcome) Value[source]¶
Eval.
- Parameters:
offer – Offer being considered.
- Returns:
The result.
- Return type:
- eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]¶
Eval normalized.
- Parameters:
offer – Offer being considered.
above_reserve – Above reserve.
expected_limits – Expected limits.
- Returns:
The result.
- Return type:
- on_preferences_changed(changes: list[PreferencesChange])[source]¶
On preferences changed.
- Parameters:
changes – Changes.
- negmas.sao.all_negotiator_types() list[type[SAONegotiator]][source]¶
Returns all the negotiator types defined in negmas.sao.negotiators