negmas.gb

Implements Generalized Bargaining Protocol (GB) set of mechanisms and basic negotiators.

class negmas.gb.ACConst(th: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts outcomes with utilities above the given threshold

th: float[source]
class negmas.gb.ACLast(alpha: float = 1.0, beta: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Implements the AClast acceptance strategy based on our last offer.

Accepts $omega$ if $lpha u(my-next-offer) + eta > u(omega)$

after_proposing(state: GBState, offer: Outcome | ExtendedOutcome | None, dest: str | None = None)[source]

After proposing.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • dest – Dest.

alpha: float[source]
beta: float[source]
last_offer_util: float[source]
class negmas.gb.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: AcceptancePolicy

Accepts $omega$ if $lpha u(my-next-offer) + eta > f(u( ext{utils of offers received in the given fraction of time}))$

alpha: float[source]
before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

beta: float[source]
fraction: float[source]
op: Callable[[list[float]], float][source]
class negmas.gb.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: AcceptancePolicy

Accepts $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]

After join.

Parameters:

nmi – Nmi.

alpha: float[source]
before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

beta: float[source]
k: int[source]
op: Callable[[list[float]], float][source]
class negmas.gb.ACNext(offering_strategy: OfferingPolicy, alpha: float = 1.0, beta: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Implements the ACnext acceptance strategy based on our next offer.

Accepts $omega$ if $lpha u(my-next-offer) + eta > u(omega)$

alpha: float[source]
beta: float[source]
offering_strategy: OfferingPolicy[source]
class negmas.gb.ACTime(tau: float, rational: bool = True, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Implements the ACtime acceptance strategy based on our next offer.

Accepts if the relative time is greater than or equal to tau

rational: bool[source]
tau: float[source]
class negmas.gb.AcceptAbove(limit: float, above_reserve: bool = True, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts outcomes with utilities in the given top limit fraction above reserve/minimum (based on above_resrve ).

above_reserve: bool[source]
limit: float[source]
on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

negmas.gb.AcceptAfter[source]

alias of ACTime

class negmas.gb.AcceptAnyRational(*, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts any rational outcome.

class negmas.gb.AcceptAround(relative_time: float = 1.0, eps: float = 0.001, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts around the given relative time (i.e. eps from it)

eps: float[source]
relative_time: float[source]
class negmas.gb.AcceptBest(best_util: float = inf, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts Only the best outcome.

Remarks:
  • If the best possible utility cannot be found, nothing will be accepted

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

class negmas.gb.AcceptBetterRational(accepted: dict[str, Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accept first rational outcomes and then accept only outcomes better than the all accepted so far.

class negmas.gb.AcceptBetween(min: float, max: float = 1.0, rational: bool = True, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts in the given range of relative times.

max: float[source]
min: float[source]
rational: bool[source]
class negmas.gb.AcceptImmediately(*, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts immediately anything

class negmas.gb.AcceptNotWorseRational(accepted: dict[str, Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accept any outcome not worse than the best so far.

class negmas.gb.AcceptTop(fraction: float = 0.0, k: int = 1, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts outcomes that are in the given top fraction or top k. If neither is given it reverts to accepting the best outcome only.

Remarks:
  • The outcome-space is always discretized and the constraints fraction and k are applied to the discretized space

fraction: float[source]
k: int[source]
on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

class negmas.gb.AcceptancePolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: GBComponent

Acceptance 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 GBState giving current state of the negotiation.

  • offer – offer being tested

Returns:

The response to the offer

Return type:

ResponseType | ExtendedResponseType

Remarks:
  • The default implementation never ends the negotiation

  • The default implementation asks the negotiator to propose`() and accepts the `offer if its utility was at least as good as the offer that it would have proposed (and above the reserved value).

class negmas.gb.AdditiveFirstFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.AdditiveLastOfferFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.AdditiveParetoFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.AdditivePartnerOffersOrientedSelector(*args, u_weight: float = 0.6, **kwargs)[source]

Bases: PartnerOffersOrientedSelector

Orients 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

calculate_scores(outcomes: Sequence[Outcome], pivots: list[Outcome], state: GBState) Sequence[tuple[float, Outcome]][source]

Calculate scores.

Parameters:
  • outcomes – Outcomes.

  • pivots – Pivots.

  • state – Current state.

Returns:

The result.

Return type:

Sequence[tuple[float, Outcome]]

class negmas.gb.AllAcceptEvaluationStrategy(strategies: list[EvaluationStrategy])[source]

Bases: EvaluationStrategy

AllAcceptEvaluation strategy.

class negmas.gb.AllAcceptanceStrategies(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcensusAcceptancePolicy

Accept only if all children accept, end only if all of them end, otherwise reject

decide(indices: list[int], responses: list[ResponseType]) ResponseType | ExtendedResponseType[source]

Decide.

Parameters:
  • indices – Indices.

  • responses – Responses.

Returns:

The result.

Return type:

ResponseType

filter(indx: int, response: ResponseType) FilterResult[source]

Filter.

Parameters:
  • indx – Indx.

  • response – Response.

Returns:

The result.

Return type:

FilterResult

class negmas.gb.AllOfferingConstraints(constaints: list[OfferingConstraint])[source]

Bases: OfferingConstraint

AllOfferingConstraints implementation.

constaints: list[OfferingConstraint][source]
class negmas.gb.AnyAcceptEvaluationStrategy(strategies: list[EvaluationStrategy])[source]

Bases: EvaluationStrategy

AnyAcceptEvaluation strategy.

class negmas.gb.AnyAcceptancePolicy(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcensusAcceptancePolicy

Accept any children accept, end or reject only if all of them end or reject

decide(indices: list[int], responses: list[ResponseType]) ResponseType | ExtendedResponseType[source]

Decide.

Parameters:
  • indices – Indices.

  • responses – Responses.

Returns:

The result.

Return type:

ResponseType

filter(indx: int, response: ResponseType) FilterResult[source]

Filter.

Parameters:
  • indx – Indx.

  • response – Response.

Returns:

The result.

Return type:

FilterResult

class negmas.gb.AnyOfferingConstraint(constraints: list[OfferingConstraint])[source]

Bases: OfferingConstraint

AnyOfferingConstraint implementation.

constraints: list[OfferingConstraint][source]
class negmas.gb.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, **kwargs)[source]

Bases: TimeBasedConcedingNegotiator

Represents a time-based negotiation strategy that is independent of the offers received during the negotiation.

Parameters:
  • name – The agent name

  • preferences – The utility function to attache with the agent

  • max_aspiration – The aspiration level to use for the first offer (or first acceptance decision).

  • aspiration_type – The polynomial aspiration curve type. Here you can pass the exponent as a real value or pass a string giving one of the predefined types: linear, conceder, boulware.

  • stochastic – If True, the agent will propose outcomes with utility >= the current aspiration level not outcomes just above it.

  • can_propose – If True, the agent is allowed to propose

  • ranking – If True, the aspiration level will not be based on the utility value but the ranking of the outcome within the presorted list. It is only effective when presort is set to True

  • presort – If True, the negotiator will catch a list of outcomes, presort them and only use them for offers and responses. This is much faster then other option for general continuous utility functions but with the obvious problem of only exploring a discrete subset of the issue space (Decided by the discrete_outcomes property of the NegotiatorMechanismInterface . If the number of outcomes is very large (i.e. > 10000) and discrete, presort will be forced to be True. You can check if presorting is active in realtime by checking the “presorted” attribute.

  • tolerance – A tolerance used for sampling of outcomes when presort is set to False

  • owner – The Agent that owns the negotiator.

  • parent – The parent which should be an GBController

Remarks:

property tolerance[source]

Tolerance.

property ufun_max[source]

Ufun max.

property ufun_min[source]

Ufun min.

utility_at(t)[source]

Utility at.

Parameters:

t

class negmas.gb.BestOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: OfferOrientedSelector

Selects the offer nearest the partner’s best offer for me so far

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

class negmas.gb.BestOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: FirstOfferOrientedTBNegotiator

A 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.gb.BestOfferSelector(*args, **kwargs)[source]

Bases: OfferSelector

BestOfferSelector implementation.

class negmas.gb.BoulwareTBNegotiator(*args, **kwargs)[source]

Bases: TimeBasedConcedingNegotiator

A Boulware time-based negotiator that conceeds sub-linearly

class negmas.gb.CABNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Conceding 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 Agent that owns the negotiator.

class negmas.gb.CABOfferingPolicy(next_indx: int = 0, sorter: PresortingInverseUtilityFunction | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

CABOffering policy implementation.

next_indx: int[source]
on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

sorter: PresortingInverseUtilityFunction | None[source]
class negmas.gb.CANNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Conceding 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 Agent that owns the negotiator.

class negmas.gb.CARNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Conceding 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 Agent that owns the negotiator.

class negmas.gb.ConcederTBNegotiator(*args, **kwargs)[source]

Bases: TimeBasedConcedingNegotiator

A Boulware time-based negotiator that conceeds super-linearly

class negmas.gb.ConcensusAcceptancePolicy(strategies: list[AcceptancePolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy, ABC

Accepts 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 (see filter for 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:

    1. Should we continue trying other strategies

    2. Should we save this result.

on_negotiation_start(state) None[source]

On negotiation start.

Parameters:

state – Current state.

strategies: list[AcceptancePolicy][source]
class negmas.gb.ConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy, ABC

Offers 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 (see filter for 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:

    1. Should we continue trying other strategies

    2. Should we save this result.

strategies: list[OfferingPolicy][source]
class negmas.gb.ConcessionRecommender(*, negotiator: GBNegotiator | None = None)[source]

Bases: GBComponent

Decides the level of concession to use

class negmas.gb.EndImmediately(*, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Rejects immediately anything

class negmas.gb.EvaluationStrategy[source]

Bases: ABC

class negmas.gb.ExtendedResponseType(response: ResponseType, data: dict[str, Any] | None = None)[source]

Bases: object

A response with optional data fields.

This class allows acceptance policies to return additional data alongside the response decision, such as text explanations, reasoning, or metadata.

response[source]

The actual response type (ACCEPT_OFFER, REJECT_OFFER, etc.).

Type:

negmas.gb.common.ResponseType

data[source]

Optional dictionary of additional data. Can contain: - “text”: A text message explaining the response or providing context. - Any other key-value pairs for custom metadata.

Type:

dict[str, Any] | None

Example

>>> from negmas.gb.common import ResponseType, ExtendedResponseType
>>> extended = ExtendedResponseType(
...     response=ResponseType.REJECT_OFFER,
...     data={"text": "This price is too high", "counter_suggestion": 5},
... )
>>> extended.response
<ResponseType.REJECT_OFFER: 1>
>>> extended.data["text"]
'This price is too high'

See also

data: dict[str, Any] | None[source]
response: ResponseType[source]
class negmas.gb.FastMiCRONegotiator(*args, accept_same: bool = True, **kwargs)[source]

Bases: MAPNegotiator

Rational 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 Agent that owns the negotiator.

class negmas.gb.FirstOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: OfferOrientedSelector

Selects the offer nearest the partner’s first offer

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

class negmas.gb.FirstOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: OfferOrientedNegotiator

A 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.gb.FrequencyLinearUFunModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: UFunModel

A PartnerUfunModel that uses a simple frequency-based model of the opponent offers assuming the ufun is LinearAdditiveUtilityFunction .

eval(offer: Outcome) Value[source]

Eval.

Parameters:

offer – Offer being considered.

Returns:

The result.

Return type:

Value

class negmas.gb.FrequencyUFunModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: UFunModel

A PartnerUfunModel that uses a simple frequency-based model of the opponent offers.

eval(offer: Outcome) Value[source]

Eval.

Parameters:

offer – Offer being considered.

Returns:

The result.

Return type:

Value

class negmas.gb.GACCombi(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.99, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

a: float[source]
b: float[source]
offering_policy: OfferingPolicy[source]
t: float[source]
class negmas.gb.GACCombiAvg(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiBestAvg(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiBestAvgDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiMax(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiMaxInWindow(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiMaxInWindowDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiProb(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.GACCombiProbDiscounted(offering_policy: OfferingPolicy, t: float = 0.98, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
class negmas.gb.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: GeniusAcceptancePolicy

AC_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

a: float[source]
b: float[source]
decay: float[source]
offering_policy: OfferingPolicy[source]
t: float[source]
class negmas.gb.GACCombiV3(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, t: float = 0.95, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

a: float[source]
b: float[source]
offering_policy: OfferingPolicy[source]
t: float[source]
class negmas.gb.GACCombiV4(offering_policy: OfferingPolicy, t: float = 0.98, w: float = 0.5, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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]
t: float[source]
w: float[source]
class negmas.gb.GACConst(c: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

c: float[source]
class negmas.gb.GACConstDiscounted(c: float = 0.9, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

c: float[source]
class negmas.gb.GACFalse(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_False acceptance strategy from Genius.

Never accepts any offer. Useful for debugging and testing.

Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_False

class negmas.gb.GACGap(c: float = 0.01, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

c: float[source]
class negmas.gb.GACNext(offering_policy: OfferingPolicy, a: float = 1.0, b: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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: bilateralexamples.boacomponents.AC_Next

a: float[source]
b: float[source]
offering_policy: OfferingPolicy[source]
class negmas.gb.GACPrevious(a: float = 1.0, b: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

a: float[source]
b: float[source]
class negmas.gb.GACTime(t: float = 0.99, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_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

t: float[source]
class negmas.gb.GACTrue(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusAcceptancePolicy

AC_True acceptance strategy from Genius.

Always accepts any offer. Useful for debugging and testing.

Transcompiled from: negotiator.boaframework.acceptanceconditions.other.AC_True

class negmas.gb.GAOEvaluationStrategy[source]

Bases: LocalEvaluationStrategy

GAOEvaluation strategy.

eval(negotiator_id: str, state: ThreadState, history: list[ThreadState], mechanism_state: MechanismState) tuple | None | Literal['continue'][source]

Eval.

Parameters:
  • negotiator_id – Negotiator id.

  • state – Current state.

  • history – History.

  • mechanism_state – Mechanism state.

Returns:

The result.

Return type:

GBResponse

class negmas.gb.GAgentXFrequencyModel(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: GeniusOpponentModel

AgentX 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

default_value: int[source]
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.

learning_rate: float[source]
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.gb.GBComponent(*, negotiator: GBNegotiator | None = None)[source]

Bases: Component

GBComponent implementation.

after_proposing(state: GBState, offer: Outcome | ExtendedOutcome | None, dest: str | None = None)[source]

Called after proposing

after_responding(state: GBState, offer: Outcome | None, response: ResponseType | ExtendedResponseType, source: str | None = None)[source]

Called before offering

before_proposing(state: GBState, dest: str | None = None)[source]

Called before proposing

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Called before offering

on_partner_ended(partner: str)[source]

Called when a partner ends the negotiation.

Note that the negotiator owning this component may never receive this offer. This is only receivd if the mechanism is sending notifications on every offer.

on_partner_joined(partner: str)[source]

Called when a partner joins the negotiation.

This is only receivd if the mechanism is sending notifications.

on_partner_left(partner: str)[source]

Called when a partner leaves the negotiation.

This is only receivd if the mechanism is sending notifications.

on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]

A callback called by the mechanism when a partner proposes something

Parameters:
  • stateMechanismState giving the state of the negotiation when the offer was porposed.

  • partner_id – The ID of the agent who proposed

  • offer – The proposal.

Remarks:
  • Will only be called if enable_callbacks is set for the mechanism

on_partner_refused_to_propose(state: GBState, partner_id: str) None[source]

A callback called by the mechanism when a partner refuses to propose

Parameters:
  • stateMechanismState giving the state of the negotiation when the partner refused to offer.

  • partner_id – The ID of the agent who refused to propose

Remarks:
  • Will only be called if enable_callbacks is set for the mechanism

on_partner_response(state: GBState, partner_id: str, outcome: Outcome | None, response: ResponseType) None[source]

A callback called by the mechanism when a partner responds to some offer

Parameters:
  • stateMechanismState giving the state of the negotiation when the partner responded.

  • partner_id – The ID of the agent who responded

  • outcome – The proposal being responded to.

  • response – The response

Remarks:
  • Will only be called if enable_callbacks is set for the mechanism

class negmas.gb.GBMechanism(*args, evaluator_type: type[~negmas.gb.evaluators.base.EvaluationStrategy] | None = None, evaluator_params: dict[str, ~typing.Any] | None = None, local_evaluator_type: type[~negmas.gb.evaluators.base.LocalEvaluationStrategy] | None = None, local_evaluator_params: dict[str, ~typing.Any] | None = None, constraint_type: type[~negmas.gb.constraints.base.OfferingConstraint] | None = None, constraint_params: dict[str, ~typing.Any] | None = None, local_constraint_type: type[~negmas.gb.constraints.base.LocalOfferingConstraint] | None = None, local_constraint_params: dict[str, ~typing.Any] | None = None, response_combiner: ~typing.Callable[[list[tuple | None | ~typing.Literal['continue']]], tuple | None | ~typing.Literal['continue']] = <function all_accept>, dynamic_entry=False, extra_callbacks=False, check_offers=False, enforce_issue_types=False, cast_offers=False, end_on_no_response=True, ignore_negotiator_exceptions=False, parallel: bool = True, sync_calls: bool = False, initial_state: ~negmas.gb.common.GBState | None = None, **kwargs)[source]

Bases: BaseGBMechanism

GB mechanism.

add(negotiator: GBNegotiator, *, preferences: Preferences | None = None, role: str | None = None, ufun: BaseUtilityFunction | None = None) bool | None[source]

Add.

Parameters:

negotiator – Negotiator.

Returns:

The result.

Return type:

bool | None

property extended_trace: list[tuple[int, str, tuple]][source]

Returns the negotiation history as a list of step/negotiator/offer tuples.

property full_trace: list[TraceElement][source]

Full trace.

Returns:

The result.

Return type:

list[TraceElement]

negotiator_full_trace(negotiator_id: str) list[tuple[float, float, int, tuple, str]][source]

Returns the (time/relative-time/step/outcome/response) given by a negotiator (in order)

negotiator_offers(negotiator_id: str) list[tuple][source]

Returns the offers given by a negotiator (in order)

property offers: list[tuple][source]

Returns the negotiation history as a list of offers.

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_max_welfare_distance: bool = True, show_max_relative_welfare_distance: bool = False, show_end_reason: 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 = 'step', colorizer: Colorizer | None = None, only2d: bool = False, fast=False, simple_offers_view=False, **kwargs)[source]

Plot.

Parameters:
  • plotting_negotiators – Plotting negotiators.

  • save_fig – Save fig.

  • path – Path.

  • fig_name – Fig name.

  • ignore_none_offers – Ignore none offers.

  • with_lines – With lines.

  • show_agreement – Show agreement.

  • show_pareto_distance – Show pareto distance.

  • show_nash_distance – Show nash distance.

  • show_kalai_distance – Show kalai distance.

  • show_max_welfare_distance – Show max welfare distance.

  • show_max_relative_welfare_distance – Show max relative welfare distance.

  • show_end_reason – Show end reason.

  • show_annotations – Show annotations.

  • show_reserved – Show reserved.

  • show_total_time – Show total time.

  • show_relative_time – Show relative time.

  • show_n_steps – Show n steps.

  • colors – Colors.

  • markers – Markers.

  • colormap – Colormap.

  • ylimits – Ylimits.

  • common_legend – Common legend.

  • xdim – Xdim.

  • colorizer – Colorizer.

  • only2d – Only2d.

  • fast – Fast.

  • simple_offers_view – Simple offers view.

  • **kwargs – Additional keyword arguments.

set_sync_call(v: bool)[source]

Set sync call.

Parameters:

v

property trace: list[tuple[str, tuple]][source]

Returns the negotiation history as a list of negotiator/offer tuples.

class negmas.gb.GBNMI(id: str, n_outcomes: int | float, outcome_space: OutcomeSpace, time_limit: float, pend: float, pend_per_second: float, step_time_limit: float, negotiator_time_limit: float, n_steps: int | None, dynamic_entry: bool, max_n_negotiators: int | None, _mechanism: Mechanism, annotation: dict[str, Any]=<class 'dict'>)[source]

Bases: NegotiatorMechanismInterface

GBNMI implementation.

annotation[source]

An arbitrary annotation as a dict[str, Any] that is always available for all negotiators

dynamic_entry[source]

Whether it is allowed for negotiators to enter/leave the negotiation after it starts

id[source]

Mechanism session ID. That is unique for all mechanisms

max_n_negotiators[source]

Maximum allowed number of negotiators in the session. None indicates no limit

n_outcomes[source]

Number of outcomes which may be float('inf') indicating infinity

n_steps[source]

The allowed number of steps for this negotiation. None indicates infinity

negotiator_time_limit[source]

The time limit in seconds to wait for negotiator responses of this negotiation session. None indicates infinity

outcome_space[source]

Negotiation agenda as as an OutcomeSpace object. The most common type is CartesianOutcomeSpace which represents the cartesian product of a list of issues

pend[source]

The probability that the negotiation times out at every step. Must be less than one. If <= 0, it is ignored

pend_per_second[source]

The probability that the negotiation times out every second. Must be less than one. If <= 0, it is ignored

step_time_limit[source]

The time limit in seconds for each step of ;this negotiation session. None indicates infinity

time_limit[source]

The time limit in seconds for this negotiation session. None indicates infinity

class negmas.gb.GBNegotiator(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, **kwargs)[source]

Bases: Negotiator[GBNMI, GBState], Generic[TNMI, TState]

Base class for all GB negotiators.

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 Agent that owns the negotiator.

Remarks:
  • The only method that must be implemented by any GBNegotiator is propose.

  • The default respond method, accepts offers with a utility value no less than whatever propose returns with the same mechanism state.

on_partner_ended(partner: str)[source]

Called when a partner ends the negotiation.

Note that the negotiator owning this component may never receive this offer. This is only received if the mechanism is sending notifications on every offer.

on_partner_proposal(state: GBState, partner_id: str, offer: tuple) None[source]

A callback called by the mechanism when a partner proposes something

Parameters:
  • stateGBState giving the state of the negotiation when the offer was porposed.

  • partner_id – The ID of the agent who proposed

  • offer – The proposal.

Remarks:
  • Will only be called if enable_callbacks is set for the mechanism

on_partner_response(state: GBState, partner_id: str, outcome: tuple, response: ResponseType) None[source]

A callback called by the mechanism when a partner responds to some offer

Parameters:
  • stateGBState giving the state of the negotiation when the partner responded.

  • partner_id – The ID of the agent who responded

  • outcome – The proposal being responded to.

  • response – The response

Remarks:
  • Will only be called if enable_callbacks is set for the mechanism

abstractmethod propose(state: GBState, dest: str | None = None) tuple | ExtendedOutcome | None[source]

Propose an offer or None to refuse.

Parameters:

stateGBState giving current state of the negotiation.

Returns:

The outcome being proposed or None to refuse to propose

Remarks:
  • This function guarantees that no agents can propose something with a utility value

propose_(state: SAOState, dest: str | None = None) Outcome | ExtendedOutcome | None[source]

Propose .

Parameters:
  • state – Current state.

  • dest – Dest.

Returns:

The result.

Return type:

Outcome | ExtendedOutcome | None

abstractmethod respond(state: GBState, 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 GBState giving current state of the negotiation.

Returns:

The response to the offer

Return type:

ResponseType | ExtendedResponseType

Remarks:
  • The default implementation never ends the negotiation

  • The default implementation asks the negotiator to propose`() and accepts the `offer if its utility was at least as good as the offer that it would have proposed (and above the reserved value).

  • Current offer is accessible through state.threads[source].current_offer as long as source != None otherwise it is None

respond_(state: SAOState, source: str | None = None) ResponseType | ExtendedResponseType[source]

Respond .

Parameters:
  • state – Current state.

  • source – Source identifier.

Returns:

The result.

Return type:

ResponseType | ExtendedResponseType

class negmas.gb.GBState(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 = '')[source]

Bases: MechanismState

GBState implementation.

property base_state: MechanismState[source]

Base state.

Returns:

The result.

Return type:

MechanismState

last_thread: str[source]
classmethod thread_history(history: list[GBState], source: str) list[ThreadState][source]

Thread history.

Parameters:
  • history – History.

  • source – Source identifier.

Returns:

The result.

Return type:

list[ThreadState]

threads: dict[str, ThreadState][source]
class negmas.gb.GBayesianModel(n_hypotheses: int = 10, rationality: float = 5.0, 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: GeniusOpponentModel

Bayesian 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.

n_hypotheses: int[source]
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.

rationality: float[source]
class negmas.gb.GBoulwareOffering(e: float = 0.2, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Boulware 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

e: float[source]
k: float[source]
on_preferences_changed(changes: list[PreferencesChange]) None[source]

Initialize the delegate time-dependent offering strategy.

class negmas.gb.GChoosingAllBids(all_outcomes: list[Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

ChoosingAllBids 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.gb.GConcederOffering(e: float = 2.0, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Conceder 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

e: float[source]
k: float[source]
on_preferences_changed(changes: list[PreferencesChange]) None[source]

Initialize the delegate time-dependent offering strategy.

class negmas.gb.GDefaultModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Default 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 constant utility (0.5) for any outcome.

Parameters:

offer – The outcome to evaluate.

Returns:

Always returns 0.5.

eval_normalized(offer: Outcome | None, above_reserve: bool = True, expected_limits: bool = True) Value[source]

Return constant 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.gb.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: GeniusOpponentModel

Hard-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)

  1. 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: bilateralexamples.boacomponents.HardHeadedFrequencyModel

default_value: int[source]
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).

learning_coef: float[source]
learning_value_addition: int[source]
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.gb.GHardlinerOffering(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Hardliner 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.gb.GLinearOffering(k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Linear 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

k: float[source]
on_preferences_changed(changes: list[PreferencesChange]) None[source]

Initialize the delegate time-dependent offering strategy.

class negmas.gb.GNashFrequencyModel(default_value: int = 1, issue_weights: dict[int, float] = NOTHING, value_counts: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Nash 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

default_value: int[source]
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.gb.GOppositeModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Opposite 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.gb.GRandomOffering(*, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Random 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.gb.GScalableBayesianModel(learning_rate: float = 0.1, issue_weights: dict[int, float] = NOTHING, value_utils: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Scalable 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

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.

learning_rate: float[source]
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.gb.GSmithFrequencyModel(default_value: int = 1, value_counts: dict[int, dict] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Smith 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

default_value: int[source]
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.gb.GTimeDependentOffering(e: float = 0.2, k: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOfferingPolicy

Time-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: bilateralexamples.boacomponents.TimeDependent_Offering

e: float[source]
k: float[source]
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.gb.GUniformModel(outcome_utils: dict[tuple, float] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: GeniusOpponentModel

Uniform 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.gb.GeniusAcceptancePolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Base class for Genius acceptance policies.

class negmas.gb.GeniusOfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Base class for Genius offering policies.

class negmas.gb.GeniusOpponentModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: VolatileUFunMixin, GBComponent, BaseUtilityFunction

Base 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.gb.HybridNegotiator(*args, alpha: float = 1.0, beta: float = 0.0, **kwargs)[source]

Bases: MAPNegotiator

Rational 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 Agent that owns the negotiator.

class negmas.gb.HybridOfferingPolicy(initial_utility: float = nan, concession_ratio: float = nan, final_utility: float = nan, empathy_score: float = nan, frac_time_based: dict[int, tuple[float, ...]] = NOTHING, above_only: bool = False, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

HybridOffering policy implementation.

above_only: bool[source]
behaviour_based(t: float) float[source]

Target utility calculation of Behavior-Based strategy.

Parameters:

t – Negotiation time.

Returns:

Target utility.

concession_ratio: float[source]
empathy_score: float[source]
final_utility: float[source]
frac_time_based: dict[int, tuple[float, ...]][source]
initial_utility: float[source]
on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]

On partner proposal.

Parameters:
  • state – Current state.

  • partner_id – Partner id.

  • offer – Offer being considered.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

time_based(t: float) float[source]

Target utility calculation of Time-Based strategy.

Parameters:

t – Negotiation time.

Returns:

Target utility.

class negmas.gb.KindConcessionRecommender(kindness: float = 0.0, punish: float = True, initial_concession: float = 0.0, must_concede: bool = True, inverter: UtilityInverter | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcessionRecommender

A 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 True the agent is guaranteed to concede in the first step

  • inverter – Used only if must_concede is True to determine the lowest level of concession possible

initial_concession: float[source]
inverter: UtilityInverter | None[source]
kindness: float[source]
must_concede: bool[source]
punish: float[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.gb.LastOfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: OfferOrientedSelector

Selects the offer nearest the partner’s last offer

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

class negmas.gb.LastOfferOrientedTBNegotiator(*args, distance_fun: ~typing.Callable[[tuple, tuple, ~negmas.outcomes.protocols.OutcomeSpace | None], float] = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: FirstOfferOrientedTBNegotiator

A 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.gb.LimitedOutcomesAcceptancePolicy(prob: dict[Outcome, float] | float | None, p_ending: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Accepts from a list of predefined outcomes

Remarks:
  • if prob is a number, it is taken as the probability of aceptance for any outcome.

  • if prob is None, the probability of acceptance of any outcome will be set to the relative time

classmethod from_outcome_list(outcomes: list[Outcome], prob: list[float] | float = 1.0, p_ending: float = 0.0)[source]

From outcome list.

Parameters:
  • outcomes – Outcomes.

  • prob – Prob.

  • p_ending – P ending.

p_ending: float[source]
prob: dict[Outcome, float] | float | None[source]
class negmas.gb.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, GBNegotiator

A 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.gb.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, preferences=None, ufun=None, **kwargs)[source]

Bases: MAPNegotiator

A 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

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_outcomes is passed as None, it is considered the same as acceptable_outcomes

class negmas.gb.LimitedOutcomesOfferingPolicy(outcomes: list[Outcome] | None, prob: list[float] | None = None, p_ending: float = 0.0, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Offers from a given list of outcomes

outcomes: list[Outcome] | None[source]
p_ending: float[source]
prob: list[float] | None[source]
class negmas.gb.LinearTBNegotiator(*args, **kwargs)[source]

Bases: TimeBasedConcedingNegotiator

A Boulware time-based negotiator that conceeds linearly

class negmas.gb.LocalEvaluationStrategy[source]

Bases: EvaluationStrategy

LocalEvaluation strategy.

abstractmethod eval(negotiator_id: str, state: ThreadState, history: list[ThreadState], mechanism_state: MechanismState) tuple | None | Literal['continue'][source]

Eval.

Parameters:
  • negotiator_id – Negotiator id.

  • state – Current state.

  • history – History.

  • mechanism_state – Mechanism state.

Returns:

The result.

Return type:

GBResponse

class negmas.gb.LocalOfferingConstraint[source]

Bases: OfferingConstraint, ABC

eval_globally(source: str, state: GBState, history: list[GBState])[source]

Eval globally.

Parameters:
  • source – Source identifier.

  • state – Current state.

  • history – History.

class negmas.gb.MedianOfferSelector(*args, **kwargs)[source]

Bases: OfferSelector

MedianOfferSelector implementation.

class negmas.gb.MiCRONegotiator(*args, accept_same: bool = True, **kwargs)[source]

Bases: MAPNegotiator

Rational 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 Agent that owns the negotiator.

class negmas.gb.MiCROOfferingPolicy(next_indx: int = 0, sorter: PresortingInverseUtilityFunction | None = None, received: set[Outcome] = NOTHING, sent: set[Outcome] = NOTHING, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

MiCROOffering policy implementation.

best_offer_so_far() Outcome | ExtendedOutcome | None[source]

Best offer so far.

Returns:

The result.

Return type:

Outcome | None

ensure_sorter()[source]

Ensure sorter.

next_indx: int[source]
next_offer() Outcome | ExtendedOutcome | None[source]

Next offer.

Returns:

The result.

Return type:

Outcome | None

on_partner_proposal(state: GBState, partner_id: str, offer: Outcome) None[source]

On partner proposal.

Parameters:
  • state – Current state.

  • partner_id – Partner id.

  • offer – Offer being considered.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

ready_to_concede() bool[source]

Ready to concede.

Returns:

The result.

Return type:

bool

sample_sent() Outcome | ExtendedOutcome | None[source]

Sample sent.

Returns:

The result.

Return type:

Outcome | None

sorter: PresortingInverseUtilityFunction | None[source]
negmas.gb.Model[source]

alias of GBComponent

class negmas.gb.MultiplicativeFirstFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.MultiplicativeLastOfferFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.MultiplicativeParetoFollowingTBNegotiator(*args, dist_power: float = 2, issue_weights: list[float] | None = None, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]

Bases: TimeBasedNegotiator

A 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.gb.MultiplicativePartnerOffersOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]

Bases: PartnerOffersOrientedSelector

Orients 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

calculate_scores(outcomes: Sequence[Outcome], pivots: list[Outcome], state: GBState) Sequence[tuple[float, Outcome]][source]

Calculate scores.

Parameters:
  • outcomes – Outcomes.

  • pivots – Pivots.

  • state – Current state.

Returns:

The result.

Return type:

Sequence[tuple[float, Outcome]]

class negmas.gb.MyBestConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: UtilBasedConcensusOfferingPolicy

Offers my best outcome from the list of stratgies (different strategy every time).

decide_util(utils: list[Distribution | float]) int[source]

Decide util.

Parameters:

utils – Utils.

Returns:

The result.

Return type:

int

class negmas.gb.MyWorstConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: UtilBasedConcensusOfferingPolicy

Offers my worst outcome from the list of stratgies (different strategy every time) based on outcome utilities

decide_util(utils: list[Distribution | float]) int[source]

Decide util.

Parameters:

utils – Utils.

Returns:

The result.

Return type:

int

class negmas.gb.NaiveTitForTatNegotiator(*args, kindness=0.0, punish=False, initial_concession: float | Literal['min'] = 'min', rank_only: bool = False, stochastic: bool = False, **kwargs)[source]

Bases: MAPNegotiator

Implements a naive tit-for-tat strategy that does not depend on the availability of an opponent model.

Parameters:
  • name – Negotiator name

  • preferences – negotiator preferences

  • ufun – negotiator ufun (overrides preferences)

  • parent – A controller

  • kindness – How ‘kind’ is the agent. A value of zero is standard tit-for-tat. Positive values makes the negotiator concede faster and negative values slower.

  • stochastic – If True, the offers will be randomized above the level determined by the current concession which in turn reflects the opponent’s concession.

  • punish – If True the agent punish a partner who does not seem to conede by requiring higher utilities

  • initial_concession – How much should the agent concede in the beginning in terms of utility. Should be a number or the special string value ‘min’ for minimum concession

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.gb.NegotiatorAcceptancePolicy(acceptor: GBNegotiator, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Uses a negotiator as an offering strategy

acceptor: GBNegotiator[source]
class negmas.gb.NegotiatorMechanismInterface(id: str, n_outcomes: int | float, outcome_space: OutcomeSpace, time_limit: float, pend: float, pend_per_second: float, step_time_limit: float, negotiator_time_limit: float, n_steps: int | None, dynamic_entry: bool, max_n_negotiators: int | None, _mechanism: Mechanism, annotation: dict[str, Any]=<class 'dict'>)[source]

Bases: object

All information of a negotiation visible to negotiators.

property agent_ids: list[str][source]

Gets the IDs of all agents owning all negotiators

property agent_names: list[str][source]

Gets the names of all agents owning all negotiators

annotation: dict[str, Any][source]

An arbitrary annotation as a dict[str, Any] that is always available for all negotiators

asdict()[source]

Converts the object to a dict containing all fields

property atomic_steps: bool[source]

Atomic steps.

Returns:

The result.

Return type:

bool

property cartesian_outcome_space: CartesianOutcomeSpace[source]

Returns the outcome_space as a CartesianOutcomeSpace or raises a ValueError if that was not possible.

Remarks:

discrete_outcome_space(levels: int = 5, max_cardinality: int = 10000000000) DiscreteOutcomeSpace[source]

Returns a stable discrete version of the given outcome-space

discrete_outcomes(max_cardinality: int | float = inf) Iterable[tuple][source]

A discrete set of outcomes that spans the outcome space

Parameters:

max_cardinality – The maximum number of outcomes to return. If None, all outcomes will be returned for discrete outcome-spaces

Returns:

list of n or less outcomes

Return type:

list[Outcome]

dynamic_entry: bool[source]

Whether it is allowed for negotiators to enter/leave the negotiation after it starts

property estimated_n_steps: int[source]

Return an estimate of the number of steps for this negotiation.

property estimated_time_limit: float[source]

Return an estimate of the number of seconds for this negotiation.

genius_id(id: str | None) str | None[source]

Gets the Genius ID corresponding to the given negotiator if known otherwise its normal ID

property genius_negotiator_ids: list[str][source]

Gets the Java IDs of all negotiators (if the negotiator is not a GeniusNegotiator, its normal ID is returned)

property history: list[source]

History.

Returns:

The result.

Return type:

list

id: str[source]

Mechanism session ID. That is unique for all mechanisms

property issues: tuple[Issue, ...][source]

Issues.

Returns:

The result.

Return type:

tuple[Issue, …]

keys()[source]

Keys.

log_critical(nid: str, data: dict[str, Any]) None[source]

Logs at critical level

log_debug(nid: str, data: dict[str, Any]) None[source]

Logs at debug level

log_error(nid: str, data: dict[str, Any]) None[source]

Logs at error level

log_info(nid: str, data: dict[str, Any]) None[source]

Logs at info level

log_warning(nid: str, data: dict[str, Any]) None[source]

Logs at warning level

max_n_negotiators: int | None[source]

Maximum allowed number of negotiators in the session. None indicates no limit

property mechanism_id: str[source]

Gets the ID of the mechanism

property n_negotiators: int[source]

Syntactic sugar for state.n_negotiators

n_outcomes: int | float[source]

Number of outcomes which may be float('inf') indicating infinity

n_steps: int | None[source]

The allowed number of steps for this negotiation. None indicates infinity

property negotiator_ids: list[str][source]

Gets the IDs of all negotiators

negotiator_index(source: str) int[source]

Returns the negotiator index for the given negotiator. Raises an exception if not found

negotiator_time_limit: float[source]

The time limit in seconds to wait for negotiator responses of this negotiation session. None indicates infinity

outcome_space: OutcomeSpace[source]

Negotiation agenda as as an OutcomeSpace object. The most common type is CartesianOutcomeSpace which represents the cartesian product of a list of issues

property outcomes: Iterable[tuple] | None[source]

All outcomes for discrete outcome spaces or None for continuous outcome spaces. See discrete_outcomes

property params[source]

Returns the parameters used to initialize the mechanism.

property participants: list[NegotiatorInfo][source]

Participants.

Returns:

The result.

Return type:

list[NegotiatorInfo]

pend: float[source]

The probability that the negotiation times out at every step. Must be less than one. If <= 0, it is ignored

pend_per_second: float[source]

The probability that the negotiation times out every second. Must be less than one. If <= 0, it is ignored

random_outcome() tuple[source]

A single random outcome.

random_outcomes(n: int = 1) list[tuple][source]

A set of random outcomes from the outcome-space of this negotiation

Parameters:

n – number of outcomes requested

Returns:

list of n or less outcomes

Return type:

list[Outcome]

property requirements: dict[source]

The protocol requirements

Returns:

  • A dict of str/Any pairs giving the requirements

property state: MechanismState[source]

Access the current state of the mechanism.

Remarks:

  • Whenever a method receives a AgentMechanismInterface object, it can always access the current state of the protocol by accessing this property.

step_time_limit: float[source]

The time limit in seconds for each step of ;this negotiation session. None indicates infinity

time_limit: float[source]

The time limit in seconds for this negotiation session. None indicates infinity

values()[source]

Values.

class negmas.gb.NegotiatorOfferingPolicy(*, negotiator: GBNegotiator | None = None, proposer: GBNegotiator)[source]

Bases: OfferingPolicy

Uses a negotiator as an offering strategy

proposer: GBNegotiator[source]
class negmas.gb.NiceNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Offers 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 Agent that owns the negotiator.

class negmas.gb.NoneOfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Always offers None which means it never gets an agreement.

class negmas.gb.OfferBest(best: Outcome | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Offers Only the best outcome.

Remarks:
  • You can pass the best outcome if you know it as best otherwise it will find it.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

class negmas.gb.OfferOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, **kwargs)[source]

Bases: OfferSelector

Selects the nearest outcome to the pivot outcome which is updated before responding

class negmas.gb.OfferSelector(*args, **kwargs)[source]

Bases: OfferSelectorProtocol, GBComponent

Can select the best offer in some sense from a list of offers based on an inverter

class negmas.gb.OfferSelectorProtocol(*args, **kwargs)[source]

Bases: Protocol

Can select the best offer in some sense from a list of offers based on an inverter

class negmas.gb.OfferTop(fraction: float = 0.0, k: int = 1, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Offers outcomes that are in the given top fraction or top k. If neither is given it reverts to only offering the best outcome

Remarks:
  • The outcome-space is always discretized and the constraints fraction and k are applied to the discretized space

fraction: float[source]
k: int[source]
on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

class negmas.gb.OfferingConstraint[source]

Bases: ABC

class negmas.gb.OfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: GBComponent

Offering policy implementation.

propose(state: GBState, dest: str | None = None) Outcome | ExtendedOutcome | None[source]

Propose an offer or None to refuse.

Parameters:
  • stateGBState giving 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.gb.OutcomeSetOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]

Bases: OfferSelector

Selects 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]

Calculate scores.

Parameters:
  • outcomes – Outcomes.

  • pivots – Pivots.

  • state – Current state.

Returns:

The result.

Return type:

Sequence[tuple[float, Outcome]]

class negmas.gb.ParallelGBMechanism(*args, **kwargs)[source]

Bases: GBMechanism

ParallelGB mechanism.

class negmas.gb.PartnerOffersOrientedSelector(distance_fun: DistanceFun = <function generalized_minkowski_distance>, offer_filter: OfferFilterProtocol = <function NoFiltering>, **kwargs)[source]

Bases: OutcomeSetOrientedSelector

Orients offes toward the set of past opponent offers

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

negmas.gb.ProposalPolicy[source]

alias of OfferingPolicy

class negmas.gb.RandomAcceptancePolicy(p_acceptance: float = 0.15, p_rejection: float = 0.25, p_ending: float = 0.1, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

RandomAcceptance policy implementation.

p_acceptance: float[source]
p_ending: float[source]
p_rejection: float[source]
class negmas.gb.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: MAPNegotiator

RandomAlwaysAccepting negotiator.

class negmas.gb.RandomConcensusOfferingPolicy(strategies: list[OfferingPolicy], prob: list[float] | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcensusOfferingPolicy

Offers 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]

Decide.

Parameters:
  • indices – Indices.

  • responses – Responses.

Returns:

The result.

Return type:

Outcome | ExtendedOutcome | None

prob: list[float] | None[source]
class negmas.gb.RandomNegotiator(p_acceptance=0.15, p_rejection=0.75, p_ending=0.1, can_propose=True, **kwargs)[source]

Bases: MAPNegotiator

A 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.gb.RandomOfferSelector(*args, **kwargs)[source]

Bases: OfferSelector

RandomOfferSelector implementation.

class negmas.gb.RandomOfferingPolicy(*, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

Always offers None which means it never gets an agreement.

class negmas.gb.RejectAlways(*, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

Rejects everything

class negmas.gb.RepeatFinalOfferOnly(n: int = 9223372036854775807)[source]

Bases: LocalOfferingConstraint

RepeatFinalOfferOnly implementation.

n: int[source]
class negmas.gb.RepeatLastOfferOnly(n: int = 9223372036854775807)[source]

Bases: LocalOfferingConstraint

RepeatLastOfferOnly implementation.

eval(state: ThreadState, history: list[ThreadState]) bool[source]

Eval.

Parameters:
  • state – Current state.

  • history – History.

Returns:

The result.

Return type:

bool

n: int[source]
class negmas.gb.ResponseType(*values)[source]

Bases: IntEnum

Possible responses to offers during negotiation.

ACCEPT_OFFER = 0[source]
END_NEGOTIATION = 2[source]
NO_RESPONSE = 3[source]
REJECT_OFFER = 1[source]
WAIT = 4[source]
class negmas.gb.SerialGBMechanism(*args, **kwargs)[source]

Bases: GBMechanism

SerialGB mechanism.

class negmas.gb.SerialTAUMechanism(*args, cardinality=9223372036854775807, min_unique=0, outcome_space: OutcomeSpace | None = None, issues: list[Issue] | None = None, outcomes: list[tuple] | int | None = None, **kwargs)[source]

Bases: SerialGBMechanism

Implements the TAU protocol using the SerialGBMechanism construct in NegMAS

negmas.gb.SimpleTitForTatNegotiator[source]

alias of NaiveTitForTatNegotiator

class negmas.gb.TAUEvaluationStrategy(n_outcomes: int = 9223372036854775807, cardinality: int = 9223372036854775807, accepted: dict[tuple | None, set[str]] = NOTHING, offered: dict[tuple | None, set[str]] = NOTHING, repeating: dict[str, bool] = NOTHING, last: dict[str, tuple | None] = NOTHING)[source]

Bases: EvaluationStrategy

Implements the Tentative-Accept Unique-Offers Generalized Bargaining Protocol.

cardinality: int[source]
n_outcomes: int[source]
class negmas.gb.TAUMechanism(*args, accept_in_any_thread: bool = True, parallel: bool = True, **kwargs)[source]

Bases: BaseGBMechanism

TAU mechanism.

class negmas.gb.TFTAcceptancePolicy(partner_ufun: UFunModel, recommender: ConcessionRecommender, *, negotiator: GBNegotiator | None = None)[source]

Bases: AcceptancePolicy

An acceptance strategy that concedes as much as the partner (or more)

partner_ufun: UFunModel[source]
recommender: ConcessionRecommender[source]
class negmas.gb.TFTOfferingPolicy(partner_ufun: UFunModel, recommender: ConcessionRecommender, stochastic: bool = False, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

An acceptance strategy that concedes as much as the partner (or more)

before_responding(state: GBState, offer: Outcome | None, source: str | None = None)[source]

Before responding.

Parameters:
  • state – Current state.

  • offer – Offer being considered.

  • source – Source identifier.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

partner_ufun: UFunModel[source]
recommender: ConcessionRecommender[source]
stochastic: bool[source]
class negmas.gb.ThreadState(new_offer: tuple | None = None, new_data: dict | None = None, new_responses: dict[str, ResponseType] = NOTHING, accepted_offers: list[tuple] = NOTHING)[source]

Bases: object

ThreadState implementation.

accepted_offers: list[tuple][source]
new_data: dict | None[source]
new_offer: tuple | None[source]
new_responses: dict[str, ResponseType][source]
class negmas.gb.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: TimeBasedNegotiator

Represents a time-based negotiation strategy that is independent of the offers received during the negotiation.

Parameters:
  • offering_curve (TimeCurve) – A TimeCurve that is to be used to sample outcomes when offering

  • accepting_curve (TimeCurve) – A TimeCurve that is to be used to decide utility range to accept

  • starting_utility (float) – The relative utility (range 1.0 to 0.0) at which to give the first offer. Only used if offering_curve was not given

class negmas.gb.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: UtilBasedNegotiator

Represents a time-based negotiation strategy that is independent of the offers received during the negotiation.

Parameters:
  • offering_curve (TimeCurve) – A TimeCurve that is to be used to sample outcomes when offering

  • accepting_curve (TimeCurve) – A TimeCurve that is to be used to decide utility range to accept

  • inverter (UtilityInverter) – A component used to keep track of the ufun inverse

  • offer_selector (OfferSelector) – The way to select an offer from the set of valid offers at every time-step

utility_range_to_accept(state) tuple[float, float][source]

Utility range to accept.

Parameters:

state – Current state.

Returns:

The result.

Return type:

tuple[float, float]

utility_range_to_propose(state) tuple[float, float][source]

Utility range to propose.

Parameters:

state – Current state.

Returns:

The result.

Return type:

tuple[float, float]

class negmas.gb.TimeBasedOfferingPolicy(curve: PolyAspiration = NOTHING, stochastic: bool = False, sorter: PresortingInverseUtilityFunction | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

TimeBasedOffering policy implementation.

curve: PolyAspiration[source]
on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

sorter: PresortingInverseUtilityFunction | None[source]
stochastic: bool[source]
class negmas.gb.TopFractionNegotiator(min_utility=0.95, top_fraction=0.05, best_first=True, can_propose=True, **kwargs)[source]

Bases: MAPNegotiator

Offers and accepts only one of the top outcomes for the negotiator.

Parameters:
  • name – Negotiator name

  • parent – Parent controller if any

  • can_propose – If False the negotiator will never propose but can only accept

  • preferences – 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_fraction and min_utility

  • owner – The Agent that owns the negotiator.

propose(state, dest: str | None = None)[source]

Propose.

Parameters:
  • state – Current state.

  • dest – Dest.

class negmas.gb.ToughNegotiator(can_propose=True, **kwargs)[source]

Bases: MAPNegotiator

Accepts and proposes only the top offer (i.e. the one with highest utility).

Parameters:
  • name – Negotiator name

  • parent – Parent controller if any

  • can_propose – If False the negotiator will never propose but can only accept

  • preferences – The preferences of the negotiator

  • ufun – The ufun of the negotiator (overrides preferences)

  • owner – The Agent that owns the negotiator.

Remarks:
  • If there are multiple outcome with the same maximum utility, only one of them will be used.

class negmas.gb.UFunModel(*, negotiator: GBNegotiator | None = None)[source]

Bases: GBComponent, BaseUtilityFunction

A SAOComponent that 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 to SAOComponent to update the model.

class negmas.gb.UnanimousConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcensusOfferingPolicy

Offers only if all offering strategies gave exactly the same outcome

decide(indices: list[int], responses: list[Outcome | ExtendedOutcome | None]) Outcome | ExtendedOutcome | None[source]

Decide.

Parameters:
  • indices – Indices.

  • responses – Responses.

Returns:

The result.

Return type:

Outcome | ExtendedOutcome | None

class negmas.gb.UniqueOffers[source]

Bases: LocalOfferingConstraint

UniqueOffers implementation.

class negmas.gb.UtilBasedConcensusOfferingPolicy(strategies: list[OfferingPolicy], *, negotiator: GBNegotiator | None = None)[source]

Bases: ConcensusOfferingPolicy, ABC

Offers 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]

Decide.

Parameters:
  • indices – Indices.

  • responses – Responses.

Returns:

The result.

Return type:

Outcome | ExtendedOutcome | None

abstractmethod decide_util(utils: list[Distribution | float]) int[source]

Returns the index to chose based on utils

class negmas.gb.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: GBNegotiator

A negotiator that bases its decisions on the utility value of outcomes only.

Parameters:
  • inverter (UtilityInverter) – A component used to keep track of the ufun inverse

  • stochastic (bool) – If False the worst outcome in the current utility range will be used

  • rank_only (bool) – If True then the ranks of outcomes not their actual utilities will be used for decision making

  • max_cardinality (int) – The number of outocmes at which we switch to use the slower SamplingInverseUtilityFunction instead of the PresortingInverseUtilityFunction . Will only be used if ufun_inverter is None

  • eps (float) – A tolearnace around the utility range used when sampling outocmes

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

propose(state, dest: str | None = None)[source]

Propose.

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:

ResponseType

abstractmethod utility_range_to_accept(state) tuple[float, float][source]

Utility range to accept.

Parameters:

state – Current state.

Returns:

The result.

Return type:

tuple[float, float]

abstractmethod utility_range_to_propose(state) tuple[float, float][source]

Utility range to propose.

Parameters:

state – Current state.

Returns:

The result.

Return type:

tuple[float, float]

class negmas.gb.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: GBComponent

Recommends a set of outcome appropriate for proposal

before_proposing(state: GBState, dest: str | None = None)[source]

Before proposing.

Parameters:
  • state – Current state.

  • dest – Dest.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

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 tolerance from 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]

Set negotiator.

Parameters:

negotiator – Negotiator.

property tolerance[source]

Tolerance.

property ufun_max[source]

Ufun max.

property ufun_min[source]

Ufun min.

class negmas.gb.UtilityInverter(*args, offer_selector: OfferSelectorProtocol | Literal['min'] | Literal['max'] | None = None, **kwargs)[source]

Bases: GBComponent

A component that can recommend an outcome based on utility

before_proposing(state: GBState, dest: str | None = None)[source]

Before proposing.

Parameters:
  • state – Current state.

  • dest – Dest.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

scale_utilities(urange)[source]

Scale utilities.

Parameters:

urange – Urange.

set_negotiator(negotiator: GBNegotiator) None[source]

Set negotiator.

Parameters:

negotiator – Negotiator.

property tolerance[source]

Tolerance.

property ufun_max[source]

Ufun max.

property ufun_min[source]

Ufun min.

class negmas.gb.WABNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Wasting 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 Agent that owns the negotiator.

class negmas.gb.WANNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Wasting 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 Agent that owns the negotiator.

class negmas.gb.WARNegotiator(*args, **kwargs)[source]

Bases: MAPNegotiator

Wasting 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 Agent that owns the negotiator.

class negmas.gb.WAROfferingPolicy(next_indx: int = 0, sorter: PresortingInverseUtilityFunction | None = None, *, negotiator: GBNegotiator | None = None)[source]

Bases: OfferingPolicy

WAROffering policy implementation.

next_indx: int[source]
on_negotiation_start(state) None[source]

On negotiation start.

Parameters:

state – Current state.

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

sorter: PresortingInverseUtilityFunction | None[source]
class negmas.gb.WorstOfferSelector(*args, **kwargs)[source]

Bases: OfferSelector

WorstOfferSelector implementation.

class negmas.gb.ZeroSumModel(above_reserve: bool = True, rank_only: bool = False, *, negotiator: GBNegotiator | None = None)[source]

Bases: StationaryMixin, UFunModel

Assumes 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))

above_reserve: bool[source]
eval(offer: Outcome) Value[source]

Eval.

Parameters:

offer – Offer being considered.

Returns:

The result.

Return type:

Value

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:

Value

on_preferences_changed(changes: list[PreferencesChange])[source]

On preferences changed.

Parameters:

changes – Changes.

rank_only: bool[source]
negmas.gb.all_accept(responses: list[tuple | None | Literal['continue']]) tuple | None | Literal['continue'][source]

All accept.

Parameters:

responses – Responses.

Returns:

The result.

Return type:

GBResponse

negmas.gb.all_negotiator_types() list[GBNegotiator][source]

Returns all the negotiator types defined in negmas.gb.negotiators

negmas.gb.any_accept(responses: list[tuple | None | Literal['continue']]) tuple | None | Literal['continue'][source]

Any accept.

Parameters:

responses – Responses.

Returns:

The result.

Return type:

GBResponse