scml.std.agents.greedy ====================== .. py:module:: scml.std.agents.greedy Classes ------- .. autoapisummary:: scml.std.agents.greedy.GreedyOneShotAgent scml.std.agents.greedy.GreedySyncAgent scml.std.agents.greedy.GreedyStdAgent Module Contents --------------- .. py:class:: 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) Bases: :py:obj:`scml.oneshot.agent.OneShotAgent` A greedy agent based on OneShotAgent :param concession_exponent: A real number controlling how fast does the agent concede on price. :param acc_price_slack: The allowed slack in price limits compared with best prices I got so far :param step_price_slack: The allowed slack in price limits compared with best prices I got this step :param opp_price_slack: The allowed slack in price limits compared with best prices I got so far from a given opponent in this step :param opp_acc_price_slack: The allowed slack in price limits compared with best prices I got so far from a given opponent so far :param 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 .. py:attribute:: _e :value: None .. py:attribute:: _acc_price_slack .. py:attribute:: _step_price_slack :value: None .. py:attribute:: _opp_price_slack :value: None .. py:attribute:: _opp_acc_price_slack :value: None .. py:attribute:: _range_slack :value: None .. py:method:: init() Initialize the quantities and best prices received so far .. py:method:: before_step() Initialize the quantities and best prices received for next step .. py:method:: on_negotiation_success(contract, mechanism) Record sales/supplies secured .. py:method:: propose(negotiator_id: str, state, source=None) -> 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) -> negmas.ResponseType 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:method:: best_offer(negotiator_id) .. py:method:: _needed(negotiator_id) .. py:method:: _is_selling(nmi) .. py:method:: _is_good_price(nmi, state, price) Checks if a given price is good enough at this stage .. py:method:: _find_good_price(nmi, state) Finds a good-enough price conceding linearly over time .. py:method:: _price_range(nmi) Limits the price by the best price received .. py:method:: _th(step, n_steps) calculates a descending threshold (0 <= th <= 1) .. py:class:: GreedySyncAgent(*args, threshold=None, **kwargs) Bases: :py:obj:`scml.oneshot.agent.OneShotSyncAgent`, :py:obj:`GreedyOneShotAgent` A greedy agent based on OneShotSyncAgent .. py:attribute:: _threshold :value: None .. py:attribute:: ufun :type: scml.oneshot.ufun.OneShotUFun Returns the preferences if it is a `BaseUtilityFunction` else None .. py:method:: before_step() Called at the beginning of every step. Remarks: - Use this for any proactive code that needs to be done every simulation step. .. py:method:: first_proposals() Decide a first proposal on every negotiation. Returning None for a negotiation means ending it. .. py:method:: counter_all(offers, states) -> dict Respond to a set of offers given the negotiation state of each. .. py:method:: _needs() Returns both input and output needs .. py:method:: propose(negotiator_id, state) 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='') 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:: 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) Bases: :py:obj:`scml.std.agent.StdAgent` A greedy agent based on StdAgent :param concession_exponent: A real number controlling how fast does the agent concede on price. :param acc_price_slack: The allowed slack in price limits compared with best prices I got so far :param step_price_slack: The allowed slack in price limits compared with best prices I got this step :param opp_price_slack: The allowed slack in price limits compared with best prices I got so far from a given opponent in this step :param opp_acc_price_slack: The allowed slack in price limits compared with best prices I got so far from a given opponent so far :param range_slack: Always consider prices above (1-`range_slack`) of the best possible prices *good enough*. :param 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 .. py:attribute:: _e :value: None .. py:attribute:: _acc_price_slack .. py:attribute:: _step_price_slack :value: None .. py:attribute:: _opp_price_slack :value: None .. py:attribute:: _opp_acc_price_slack :value: None .. py:attribute:: _range_slack :value: None .. py:attribute:: _production_target :value: 0.75 .. py:attribute:: _future_threshold :value: 0.9 .. py:method:: init() Initialize the quantities and best prices received so far .. py:method:: before_step() Initialize the quantities and best prices received for next step .. py:method:: on_negotiation_success(contract, mechanism) Record sales/supplies secured .. py:method:: propose(negotiator_id: str, state, source=None) -> 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) -> negmas.ResponseType 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:method:: best_offer(negotiator_id) .. py:method:: _future_needs(negotiator_id, t) .. py:method:: _needed(negotiator_id) .. py:method:: _is_selling(nmi) .. py:method:: _is_good_price(nmi, state, offer) Checks if a given price is good enough at this stage .. py:method:: _find_good_price(nmi, state, offer) Finds a good-enough price conceding linearly over time .. py:method:: _price_range(nmi, offer) Limits the price by the best price received .. py:method:: _th(step, n_steps) calculates a descending threshold (0 <= th <= 1)