DiscreteCartesianOutcomeSpace
- class negmas.outcomes.DiscreteCartesianOutcomeSpace(issues, name: str | None = None)[source]
Bases:
CartesianOutcomeSpaceA discrete outcome-space that is generated by the cartesian product of a tuple of
Issues (i.e. with finite number of outcomes).Attributes Summary
The space cardinality = the number of outcomes
Returns an ordered list of issue names
Methods Summary
are_types_ok(outcome)Checks if the type of each value in the outcome is correct for the given issue
cardinality_if_discretized(levels[, ...])Cheks that the given issue is in the tuple of issues constituting the outcome space (i.e. it is one of its dimensions).
contains_os(x)Checks whether an outcome-space is contained in this outcome-space
ensure_correct_types(outcome)Returns an outcome that is guaratneed to have correct types or raises an exception
enumerate_or_sample([levels, max_cardinality])Enumerates all outcomes if possible (i.e. discrete space) or returns
max_cardinalitydifferent outcomes otherwise.enumerate_or_sample_rational(preferences[, ...])Enumerates all outcomes if possible (i.e. discrete space) or returns
max_cardinalitydifferent outcomes otherwise.from_dict(d[, python_class_identifier])from_genius(file_name, **kwargs)Imports a utility function from a GENIUS XML file.
from_outcomes(outcomes[, numeric_as_ranges, ...])from_xml_str(xml_str[, safe_parsing, name])Imports a utility function from a GENIUS XML string.
Checks whether all issues are discrete
Checks whether all issues are complete ranges
Checks whether there are no continua components of the space
Checks whether the space is finite
is_float()Checks whether all issues are real
Checks whether all issues are integer
Checks whether all issues are discrete
Checks whether all issues are numeric
is_valid(outcome)limit_cardinality([max_cardinality, levels])Limits the cardinality of the outcome space to the given maximum (or the number of levels for each issue to
Logging Levels)sample(n_outcomes[, with_replacement, ...])to_dict([python_class_identifier])to_discrete([levels, max_cardinality])Discretizes the outcome space by sampling
Logging Levelsvalues for each continuous issue.to_genius(file_name, **kwargs)Exports a utility function to a GENIUS XML file.
to_largest_discrete(levels[, max_cardinality])to_single_issue([numeric, stringify, ...])Creates a new outcome space that is a single-issue version of this one
to_xml_str(**kwargs)Exports a utility function to a well formatted string
Attributes Documentation
- cardinality
- issue_names
Returns an ordered list of issue names
Methods Documentation
- are_types_ok(outcome: tuple) bool
Checks if the type of each value in the outcome is correct for the given issue
- contains_issue(x: Issue) bool
Cheks that the given issue is in the tuple of issues constituting the outcome space (i.e. it is one of its dimensions)
- contains_os(x: OutcomeSpace) bool
Checks whether an outcome-space is contained in this outcome-space
- ensure_correct_types(outcome: tuple) tuple
Returns an outcome that is guaratneed to have correct types or raises an exception
- enumerate_or_sample(levels: int | float = inf, max_cardinality: int | float = inf) Iterable[tuple]
Enumerates all outcomes if possible (i.e. discrete space) or returns
max_cardinalitydifferent outcomes otherwise
- enumerate_or_sample_rational(preferences: Iterable[HasReservedValue | HasReservedOutcome], levels: int | float = inf, max_cardinality: int | float = inf, aggregator: Callable[[Iterable[bool]], bool] = <built-in function any>) Iterable[Outcome]
Enumerates all outcomes if possible (i.e. discrete space) or returns
max_cardinalitydifferent outcomes otherwise.- Parameters:
preferences – A list of
Preferencesthat is used to judge outcomeslevels – The number of levels to use for discretization if needed
max_cardinality – The maximum cardinality allowed in case of discretization
aggregator – A predicate that takes an
Iterableof booleans representing whether or not an outcome is rational for a givenPreferences(i.e. better than reservation) and returns a single boolean representing the result for all preferences. Default is any but can be all.
- classmethod from_dict(d, python_class_identifier='__python_class__')
- classmethod from_genius(file_name: PathLike, **kwargs) X
Imports a utility function from a GENIUS XML file.
- Parameters:
file_name (str) – File name to import from
- Returns:
A utility function object (depending on the input file)
- static from_outcomes(outcomes: list[tuple], numeric_as_ranges: bool = False, issue_names: list[str] | None = None, name: str | None = None) DiscreteCartesianOutcomeSpace
- classmethod from_xml_str(xml_str: str, safe_parsing=True, name=None, **kwargs) CartesianOutcomeSpace
Imports a utility function from a GENIUS XML string.
- Parameters:
xml_str (str) – The string containing GENIUS style XML utility function definition
- Returns:
A utility function object (depending on the input file)
- limit_cardinality(max_cardinality: int | float = inf, levels: int | float = inf) DiscreteCartesianOutcomeSpace[source]
Limits the cardinality of the outcome space to the given maximum (or the number of levels for each issue to
Logging Levels)- Parameters:
max_cardinality – The maximum number of outcomes in the resulting space
levels – The maximum number of levels for each issue/subissue
- random_outcome()
- to_dict(python_class_identifier='__python_class__')
- to_discrete(levels: int | float = 10, max_cardinality: int | float = inf) DiscreteCartesianOutcomeSpace[source]
Discretizes the outcome space by sampling
Logging Levelsvalues for each continuous issue.The result of the discretization is stable in the sense that repeated calls will return the same output.
- to_genius(file_name: PathLike, **kwargs) None
Exports a utility function to a GENIUS XML file.
- Parameters:
file_name (str) – File name to export to
- Returns:
None
- Remarks:
See
to_xml_strfor all the parameters
- to_largest_discrete(levels: int, max_cardinality: int | float = inf, **kwargs) DiscreteCartesianOutcomeSpace[source]
- to_single_issue(numeric=False, stringify=True, levels: int = 5, max_cardinality: int | float = inf) DiscreteCartesianOutcomeSpace[source]
Creates a new outcome space that is a single-issue version of this one
- Parameters:
numeric – If given, the output issue will be a
ContiguousIssueotherwise it will be aCategoricalIssuestringify – If given, the output issue will have string values. Checked only if
Numeric and Mathematical ModulesisFalse
- Remarks:
maps the agenda and ufuns to work correctly together
Only works if the outcome space is finite