scml.oneshot.rl.helpers ======================= .. py:module:: scml.oneshot.rl.helpers .. autoapi-nested-parse:: Helpers for the observation and action managers. Functions --------- .. autoapisummary:: scml.oneshot.rl.helpers.recover_offers scml.oneshot.rl.helpers.read_offers scml.oneshot.rl.helpers.encode_offers_with_time scml.oneshot.rl.helpers.encode_offers_no_time scml.oneshot.rl.helpers.decode_offers_no_time scml.oneshot.rl.helpers.normalize_offers_no_time scml.oneshot.rl.helpers.unnormalize_offers scml.oneshot.rl.helpers.clip_normal scml.oneshot.rl.helpers.clip scml.oneshot.rl.helpers.discretize_and_clip scml.oneshot.rl.helpers.normalize_and_clip Module Contents --------------- .. py:function:: recover_offers(encoded: numpy.ndarray, awi: scml.oneshot.common.OneShotState | scml.oneshot.awi.OneShotAWI, n_suppliers: int, n_consumers: int, max_group_size: int, continuous: bool, n_prices: int) -> dict[str, negmas.outcomes.Outcome | None] .. py:function:: read_offers(state: scml.oneshot.awi.OneShotAWI | scml.oneshot.common.OneShotState, n_suppliers: int, n_consumers: int, max_group_size: int, continuous: bool) -> list[tuple[int, int]] | list[tuple[float, float]] .. py:function:: encode_offers_with_time(offers: Mapping[str, negmas.outcomes.Outcome | None], partner_groups: list[list[str]], min_price: int, max_price: int) -> list[tuple[int, int, int]] Encodes offers from the given partner groups into `n_partners` tuples of quantity, unit-price values. :param offers: All received offers. Keys are sources. Sources not in the `partner_groups` will be ignored :param partner_groups: A list of lists of partner IDs each defining a group to be considered together :param min_price: Minimum allowed price :param max_price: Maximum allowed price :returns: A list of quantity, unit-price tuples of length `len(partner_groups)`. .. py:function:: encode_offers_no_time(offers: Mapping[str, negmas.outcomes.Outcome | None], partner_groups: list[list[str]], min_price: int, max_price: int) -> list[tuple[int, int]] Encodes offers from the given partner groups into `n_partners` tuples of quantity, unit-price values. :param offers: All received offers. Keys are sources. Sources not in the `partner_groups` will be ignored :param partner_groups: A list of lists of partner IDs each defining a group to be considered together :param min_price: Minimum allowed price :param max_price: Maximum allowed price :returns: A list of quantity, unit-price tuples of length `len(partner_groups)`. .. py:function:: decode_offers_no_time(encoded: numpy.ndarray | list[tuple[int, int]] | list[tuple[float, float]], n_suppliers: int, n_consumers: int, suppliers: list[list[str]], consumers: list[list[str]], step: int, continuous: bool, min_buy_price: int, min_sell_price: int, max_buy_price: int = -1, max_sell_price: int = -1, max_buy_quantity: int = -1, max_sell_quantity: int = -1, n_prices: int | None = None) -> dict[str, negmas.outcomes.Outcome | None] Inverts `encode_offers_no_time` Remarks: - max_* are only needed if continuous is True .. py:function:: normalize_offers_no_time(offers: list[tuple[int, int]], min_price: int, max_price: int, min_quantity: int, max_quantity: int, subtract_min_price: int = False) -> list[tuple[float, float]] Normalize the offers to values between 0 and 1 for both quantity and unit price .. py:function:: unnormalize_offers(offers: list[tuple[float, float]], min_price: int, max_price: int, min_quantity: int, max_quantity: int, add_min_price: bool = False) -> list[tuple[int, int]] Reverses `normalize_offers` converting quantities and prices in the range 0,1 to integers .. py:function:: clip_normal(x: float, mu: float, sigma: float, n_sigmas: float | int = 3, eps: float = 1e-06) -> float Normalizes x between 0 and 1 given that it is sampled from a normal (mu, sigma). This is actually a very stupid way to do it. .. py:function:: clip(x: T, mn: T = 0, mx: T = 1) -> T .. py:function:: discretize_and_clip(x: float, n_bins: int) -> int .. py:function:: normalize_and_clip(x: int, mn: T, mx: T, eps=1e-06) -> float