scml.oneshot.agents.rand
Module Contents
Classes
An agent that randomly leaves the negotiation, accepts or counters with random outcomes |
|
An agent that distributes its needs over its partners randomly. |
|
An agent that distributes its needs over its partners randomly. |
|
Same as RandDistOneShotAgent but defaulting to equal distribution of needs |
|
A controller that agrees randomly to one offer |
- class scml.oneshot.agents.rand.RandomOneShotAgent(*args, p_accept=PROB_ACCEPTANCE, p_end=PROB_END, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotAgent
An agent that randomly leaves the negotiation, accepts or counters with random outcomes
- propose(negotiator_id, state) negmas.outcomes.Outcome | None [source]
Proposes an offer to one of the partners.
- Parameters:
negotiator_id – ID of the negotiator (and partner)
state – Mechanism state including current step
- Returns:
an outcome to offer.
- respond(negotiator_id, state, source=None) negmas.ResponseType [source]
Responds to an offer from one of the partners.
- Parameters:
negotiator_id – ID of the negotiator (and partner)
state – Mechanism state including current step
- Returns:
A response type which can either be reject, accept, or end negotiation.
- Remarks:
default behavior is to accept only if the current offer is the same or has a higher utility compared with what the agent would have proposed in the given state and reject otherwise
- class scml.oneshot.agents.rand.SyncRandomOneShotAgent(*args, equal: bool = False, overordering_max: float = 0.2, overordering_min: float = 0.0, overordering_exp: float = 0.4, mismatch_exp: float = 4.0, mismatch_max: float = 0.3, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotSyncAgent
An agent that distributes its needs over its partners randomly.
- Parameters:
equal – If given, it tries to equally distribute its needs over as many of its suppliers/consumers as possible
overordering_max – Maximum fraction of needs to over-order. For example, it the agent needs 5 items and this is 0.2, it will order 6 in the first negotiation step.
overordering_min – Minimum fraction of needs to over-order. Used in the last negotiation step.
overordering_exp – Controls how fast does the over-ordering quantity go from max to min.
concession_exp – Controls how fast does the agent concedes on matching its needs exactly.
mismatch_max – Maximum mismtach in quantity allowed between needs and accepted offers. If a fraction, it is will be this fraction of the production capacity (n_lines).
- init()[source]
Called once after the AWI is set.
- Remarks:
Use this for any proactive initialization code.
- distribute_needs(t: float) dict[str, int] [source]
Distributes my needs randomly over all my partners
- first_proposals()[source]
Gets a set of proposals to use for initializing the negotiation.
- Returns:
A dictionary mapping each negotiator (in self.negotiators dict) to an outcome to be used as the first proposal if the agent is to start a negotiation.
- counter_all(offers, states)[source]
Calculate a response to all offers from all negotiators (negotiator ID is the key).
- Parameters:
offers – Maps negotiator IDs to offers
states – Maps negotiator IDs to offers AT the time the offers were made.
- Returns:
A dictionary mapping negotiator ID to an
SAOResponse
. The response per agent consist of a tuple. In case of acceptance or ending the negotiation the second item of the tuple should be None. In case of rejection, the second item should be the counter offer.
- Remarks:
The response type CANNOT be WAIT.
If the system determines that a loop is formed, the agent may
receive this call for a subset of negotiations not all of them.
- class scml.oneshot.agents.rand.RandDistOneShotAgent(*args, **kwargs)[source]
Bases:
SyncRandomOneShotAgent
An agent that distributes its needs over its partners randomly.
- Parameters:
equal – If given, it tries to equally distribute its needs over as many of its suppliers/consumers as possible
overordering_max – Maximum fraction of needs to over-order. For example, it the agent needs 5 items and this is 0.2, it will order 6 in the first negotiation step.
overordering_min – Minimum fraction of needs to over-order. Used in the last negotiation step.
overordering_exp – Controls how fast does the over-ordering quantity go from max to min.
concession_exp – Controls how fast does the agent concedes on matching its needs exactly.
mismatch_max – Maximum mismtach in quantity allowed between needs and accepted offers. If a fraction, it is will be this fraction of the production capacity (n_lines).
- class scml.oneshot.agents.rand.EqualDistOneShotAgent(*args, **kwargs)[source]
Bases:
SyncRandomOneShotAgent
Same as RandDistOneShotAgent but defaulting to equal distribution of needs
- Parameters:
equal – If given, it tries to equally distribute its needs over as many of its suppliers/consumers as possible
overordering_max – Maximum fraction of needs to over-order. For example, it the agent needs 5 items and this is 0.2, it will order 6 in the first negotiation step.
overordering_min – Minimum fraction of needs to over-order. Used in the last negotiation step.
overordering_exp – Controls how fast does the over-ordering quantity go from max to min.
concession_exp – Controls how fast does the agent concedes on matching its needs exactly.
mismatch_max – Maximum mismtach in quantity allowed between needs and accepted offers. If a fraction, it is will be this fraction of the production capacity (n_lines).
- class scml.oneshot.agents.rand.SingleAgreementRandomAgent(*args, p_accept: float = PROB_ACCEPTANCE, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotSingleAgreementAgent
A controller that agrees randomly to one offer
- is_acceptable(offer: negmas.outcomes.Outcome, source: str, state: negmas.sao.SAOState) bool [source]
Should decide if the given offer is acceptable
- Parameters:
offer – The offer being tested
source – The ID of the negotiator that received this offer
state – The state of the negotiation handled by that negotiator
- Remarks:
If True is returned, this offer will be accepted and all other negotiations will be ended.
- best_offer(offers: dict[str, negmas.outcomes.Outcome]) str | None [source]
Return the ID of the negotiator with the best offer
- Parameters:
offers – A mapping from negotiator ID to the offer it received
- Returns:
The ID of the negotiator with best offer. Ties should be broken. Return None only if there is no way to calculate the best offer.
- is_better(a: negmas.outcomes.Outcome | None, b: negmas.outcomes.Outcome | None, negotiator: str, state: negmas.sao.SAOState) bool [source]
Compares two outcomes of the same negotiation
- Parameters:
a – “Outcome”
b – “Outcome”
negotiator – The negotiator for which the comparison is to be made
state – Current state of the negotiation
- Returns:
True if utility(a) > utility(b)