scml.std.agents.rand ==================== .. py:module:: scml.std.agents.rand Classes ------- .. autoapisummary:: scml.std.agents.rand.SyncRandomOneShotAgent scml.std.agents.rand.RandomStdAgent scml.std.agents.rand.SyncRandomStdAgent Module Contents --------------- .. py:class:: 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) Bases: :py:obj:`scml.oneshot.agent.OneShotSyncAgent` An agent that distributes its needs over its partners randomly. :param equal: If given, it tries to equally distribute its needs over as many of its suppliers/consumers as possible :param 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. :param overordering_min: Minimum fraction of needs to over-order. Used in the last negotiation step. :param overordering_exp: Controls how fast does the over-ordering quantity go from max to min. :param concession_exp: Controls how fast does the agent concedes on matching its needs exactly. :param 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). .. py:attribute:: equal_distribution :value: False .. py:attribute:: overordering_max :value: 0.2 .. py:attribute:: overordering_min :value: 0.0 .. py:attribute:: overordering_exp :value: 0.4 .. py:attribute:: mismatch_exp :value: 4.0 .. py:attribute:: mismatch_max :value: 0.3 .. py:method:: init() Called once after the AWI is set. Remarks: - Use this for any proactive initialization code. .. py:method:: distribute_needs(t: float) -> dict[str, int] Distributes my needs randomly over all my partners .. py:method:: first_proposals() 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. .. py:method:: counter_all(offers, states) Calculate a response to all offers from all negotiators (negotiator ID is the key). :param offers: Maps negotiator IDs to offers :param 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. .. py:method:: _allowed_mismatch(r: float) .. py:method:: _overordering_fraction(t: float) .. py:method:: _step_and_price(best_price=False) Returns current step and a random (or max) price .. py:class:: RandomStdAgent(owner=None, ufun=None, name=None, p_accept=PROB_ACCEPTANCE, p_end=PROB_END) Bases: :py:obj:`scml.std.agent.StdAgent` A naive random agent .. py:method:: propose(negotiator_id: str, state: negmas.sao.SAOState) -> negmas.Outcome | None Proposes an offer to one of the partners. :param negotiator_id: ID of the negotiator (and partner) :param state: Mechanism state including current step :returns: an outcome to offer. .. py:method:: respond(negotiator_id, state, source=None) Responds to an offer from one of the partners. :param negotiator_id: ID of the negotiator (and partner) :param 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 .. py:class:: 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) Bases: :py:obj:`scml.std.agent.StdSyncAgent` An agent that distributes its needs over its partners randomly. .. py:attribute:: ptoday :value: 0.85 .. py:attribute:: today_exp :value: 2.0 .. py:attribute:: future_exp :value: 4.0 .. py:attribute:: fmin :value: 0.25 .. py:attribute:: today_productivity :value: 0.3 .. py:attribute:: future_productivity :value: 0.3 .. py:attribute:: near :value: False .. py:attribute:: far :value: False .. py:attribute:: future_concentration :value: 0.75 .. py:attribute:: today_concentration :value: 0.25 .. py:method:: first_proposals() 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. .. py:method:: counter_all(offers, states) Calculate a response to all offers from all negotiators (negotiator ID is the key). :param offers: Maps negotiator IDs to offers :param 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. .. py:method:: distribute_todays_needs(partners=None) -> dict[str, int] Distributes my needs randomly over all my partners .. py:method:: estimate_future_needs() Estimates how much I need to buy and sell for each future step .. py:method:: distribute_future_offers(partners: list[str]) -> dict[str, negmas.Outcome | None] Distribute future offers over the given partners .. py:method:: is_supplier(negotiator_id) .. py:method:: is_consumer(negotiator_id) .. py:method:: best_price(partner_id) Best price for a negotiation today .. py:method:: good_price(partner_id, today: bool) A good price to use .. py:method:: buy_price(t: float, mn: float, mx: float, today: bool) -> float Return a good price to buy at .. py:method:: sell_price(t: float, mn: float, mx: float, today: bool) -> float Return a good price to sell at .. py:method:: good2buy(p: float, t: float, mn, mx, today: bool) Is p a good price to buy at? .. py:method:: good2sell(p: float, t: float, mn, mx, today: bool) Is p a good price to sell at?