scml.std.agents
Submodules
Attributes
Classes
Uses a time-based strategy to accept a single agreement from the set |
|
A greedy agent based on StdAgent |
|
A greedy agent based on OneShotSyncAgent |
|
A greedy agent based on OneShotAgent |
|
An agent that always raises an exception if called to negotiate. It is useful as a placeholder (for example for RL and MARL exposition) |
|
An agent that distributes its needs over its partners randomly. |
|
An agent that distributes its needs over its partners randomly. |
|
A naive random agent |
Package Contents
- class scml.std.agents.SingleAgreementAspirationAgent(*args, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotSyncAgent
Uses a time-based strategy to accept a single agreement from the set it is considering.
- before_step()[source]
Called at the beginning of every step.
- Remarks:
Use this for any proactive code that needs to be done every simulation step.
- 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.std.agents.GreedyStdAgent(*args, concession_exponent=None, acc_price_slack=float('inf'), step_price_slack=None, opp_price_slack=None, opp_acc_price_slack=None, range_slack=None, future_threshold=0.9, production_target=0.75, **kwargs)[source]
Bases:
scml.std.agent.StdAgent
A greedy agent based on StdAgent
- Parameters:
concession_exponent – A real number controlling how fast does the agent concede on price.
acc_price_slack – The allowed slack in price limits compared with best prices I got so far
step_price_slack – The allowed slack in price limits compared with best prices I got this step
opp_price_slack – The allowed slack in price limits compared with best prices I got so far from a given opponent in this step
opp_acc_price_slack – The allowed slack in price limits compared with best prices I got so far from a given opponent so far
range_slack – Always consider prices above (1-
range_slack
) of the best possible prices good enough.production_target – Fraction of production capacity to be secured in advance
- Remarks:
A
concession_exponent
greater than one makes the agent concede super linearly and vice versa
- _e = None
- _acc_price_slack
- _step_price_slack = None
- _opp_price_slack = None
- _opp_acc_price_slack = None
- _range_slack = None
- _production_target = 0.75
- _future_threshold = 0.9
- propose(negotiator_id: str, state, source=None) negmas.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.std.agents.GreedySyncAgent(*args, threshold=None, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotSyncAgent
,GreedyOneShotAgent
A greedy agent based on OneShotSyncAgent
- _threshold = None
- ufun: scml.oneshot.ufun.OneShotUFun
Returns the preferences if it is a
BaseUtilityFunction
else None
- before_step()[source]
Called at the beginning of every step.
- Remarks:
Use this for any proactive code that needs to be done every simulation step.
- first_proposals()[source]
Decide a first proposal on every negotiation. Returning None for a negotiation means ending it.
- counter_all(offers, states) dict [source]
Respond to a set of offers given the negotiation state of each.
- propose(negotiator_id, state)[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='')[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.std.agents.GreedyOneShotAgent(*args, concession_exponent=None, acc_price_slack=float('inf'), step_price_slack=None, opp_price_slack=None, opp_acc_price_slack=None, range_slack=None, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotAgent
A greedy agent based on OneShotAgent
- Parameters:
concession_exponent – A real number controlling how fast does the agent concede on price.
acc_price_slack – The allowed slack in price limits compared with best prices I got so far
step_price_slack – The allowed slack in price limits compared with best prices I got this step
opp_price_slack – The allowed slack in price limits compared with best prices I got so far from a given opponent in this step
opp_acc_price_slack – The allowed slack in price limits compared with best prices I got so far from a given opponent so far
range_slack – Always consider prices above (1-
range_slack
) of the best possible prices good enough.
- Remarks:
A
concession_exponent
greater than one makes the agent concede super linearly and vice versa
- _e = None
- _acc_price_slack
- _step_price_slack = None
- _opp_price_slack = None
- _opp_acc_price_slack = None
- _range_slack = None
- propose(negotiator_id: str, state, source=None) negmas.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.std.agents.StdPlaceholder(*args, **kwargs)[source]
Bases:
scml.std.policy.StdPolicy
An agent that always raises an exception if called to negotiate. It is useful as a placeholder (for example for RL and MARL exposition)
- class scml.std.agents.SyncRandomStdAgent(*args, today_target_productivity=0.3, future_target_productivity=0.3, today_concentration=0.25, future_concentration=0.75, today_concession_exp=2.0, future_concession_exp=4.0, future_min_price=0.25, prioritize_near_future: bool = False, prioritize_far_future: bool = False, pfuture=0.15, **kwargs)[source]
Bases:
scml.std.agent.StdSyncAgent
An agent that distributes its needs over its partners randomly.
- ptoday = 0.85
- today_exp = 2.0
- future_exp = 4.0
- fmin = 0.25
- today_productivity = 0.3
- future_productivity = 0.3
- near = False
- far = False
- future_concentration = 0.75
- today_concentration = 0.25
- 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.
- distribute_todays_needs(partners=None) dict[str, int] [source]
Distributes my needs randomly over all my partners
- distribute_future_offers(partners: list[str]) dict[str, negmas.Outcome | None] [source]
Distribute future offers over the given partners
- buy_price(t: float, mn: float, mx: float, today: bool) float [source]
Return a good price to buy at
- class scml.std.agents.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).
- equal_distribution = False
- overordering_max = 0.2
- overordering_min = 0.0
- overordering_exp = 0.4
- mismatch_exp = 4.0
- mismatch_max = 0.3
- 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.std.agents.RandomStdAgent(owner=None, ufun=None, name=None, p_accept=PROB_ACCEPTANCE, p_end=PROB_END)[source]
Bases:
scml.std.agent.StdAgent
A naive random agent
- propose(negotiator_id: str, state: negmas.sao.SAOState) negmas.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)[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