sample_outcomes

negmas.outcomes.sample_outcomes(issues: Iterable[negmas.outcomes.Issue], n_outcomes: Optional[int] = None, keep_issue_names=None, astype=<class 'dict'>, min_per_dim=5, expansion_policy=None)Optional[List[Optional[Union[negmas.outcomes.OutcomeType, Tuple[Union[int, float, str, list]], Dict[Union[int, str], Union[int, float, str, list]]]]]][source]

Discretizes the issue space and returns either a predefined number of outcomes or uniform samples

Parameters
  • issues – The issues describing the issue space to be discretized

  • n_outcomes – If None then exactly min_per_dim bins will be used for every continuous dimension and all outcomes

  • be returned (will) –

  • keep_issue_names – DEPRICATED. Use astype instead

  • min_per_dim – Max levels of discretization per dimension

  • expansion_policy – None or ‘repeat’ or ‘null’ or ‘no’. If repeat, then some of the outcomes will be repeated

  • None or 'no' then no expansion will happen if the total number of outcomes is less than (if) –

  • n_outcomes – If ‘null’ then expansion will be with None values

  • astype – The type used for returning outcomes. Can be tuple, dict or any OutcomeType

Returns

List of outcomes

Examples

enumberate the whole space

>>> issues = [Issue(values=(0.0, 1.0), name='Price'), Issue(values=['a', 'b'], name='Name')]
>>> sample_outcomes(issues=issues)
[{'Price': 0.0, 'Name': 'a'}, {'Price': 0.0, 'Name': 'b'}, {'Price': 0.25, 'Name': 'a'}, {'Price': 0.25, 'Name': 'b'}, {'Price': 0.5, 'Name': 'a'}, {'Price': 0.5, 'Name': 'b'}, {'Price': 0.75, 'Name': 'a'}, {'Price': 0.75, 'Name': 'b'}, {'Price': 1.0, 'Name': 'a'}, {'Price': 1.0, 'Name': 'b'}]

enumerate with sampling for very large space (we have 10 outcomes in the discretized space)

>>> issues = [Issue(values=(0, 1), name='Price', value_type=float), Issue(values=['a', 'b'], name='Name')]
>>> issues[0].is_continuous()
True
>>> sampled=sample_outcomes(issues=issues, n_outcomes=5)
>>> len(sampled)
5
>>> len(set(tuple(_.values()) for _ in sampled))
5
>>> issues = [Issue(values=(0, 1), name='Price'), Issue(values=['a', 'b'], name='Name')]
>>> issues[0].is_continuous()
False
>>> sampled=sample_outcomes(issues=issues, n_outcomes=5)
>>> len(sampled)
4
>>> len(set(tuple(_.values()) for _ in sampled))
4