DiscreteCartesianOutcomeSpace
- class negmas.outcomes.DiscreteCartesianOutcomeSpace(issues, name=None)[source]
Bases:
negmas.outcomes.protocols.DiscreteOutcomeSpace
,negmas.outcomes.protocols.IndependentDiscreteIssuesOS
,negmas.outcomes.outcome_space.CartesianOutcomeSpace
A discrete outcome-space that is generated by the cartesian product of a tuple of
Issue
s (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[, ...])Returns the cardinality if discretized the given way.
Cheks that the given issue is in the tuple of issues constituting the outcome space (i.e.
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
Enumerates the outcome space returning all its outcomes (or up to max_cardinality for infinite ones)
enumerate_or_sample
([levels, max_cardinality])Enumerates all outcomes if possible (i.e.
from_dict
(d)from_genius
(file_name, **kwargs)Imports a utility function from a GENIUS XML file.
from_outcomes
(outcomes[, numeric_as_ranges, ...])- rtype
DiscreteCartesianOutcomeSpace
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 all issues are discrete
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)Checks if the given outcome is valid for that outcome space
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, ...])Samples up to n_outcomes with or without replacement.
to_dict
()to_discrete
(*args, **kwargs)Discretizes the outcome space by sampling
Logging Levels
values for each continuous issue.to_genius
(file_name, **kwargs)Exports a utility function to a GENIUS XML file.
to_largest_discrete
(levels[, max_cardinality])- rtype
DiscreteOutcomeSpace
to_single_issue
([numeric, stringify])Creates a new outcome space that is a single-issue version of this one
Exports a utility function to a well formatted string
Attributes Documentation
Methods Documentation
- are_types_ok(outcome)
Checks if the type of each value in the outcome is correct for the given issue
- Return type
- cardinality_if_discretized(levels, max_cardinality=inf)[source]
Returns the cardinality if discretized the given way.
- Return type
- contains_issue(x)
Cheks that the given issue is in the tuple of issues constituting the outcome space (i.e. it is one of its dimensions)
- Return type
- ensure_correct_types(outcome)
Returns an outcome that is guaratneed to have correct types or raises an exception
- Return type
- enumerate()[source]
Enumerates the outcome space returning all its outcomes (or up to max_cardinality for infinite ones)
- enumerate_or_sample(levels=inf, max_cardinality=inf)
Enumerates all outcomes if possible (i.e. discrete space) or returns
max_cardinality
different outcomes otherwise- Return type
Iterable[Outcome]
- classmethod from_dict(d)
- classmethod from_genius(file_name, **kwargs)
Imports a utility function from a GENIUS XML file.
- static from_outcomes(outcomes, numeric_as_ranges=False, issue_names=None, name=None)
- Return type
- classmethod from_xml_str(xml_str, safe_parsing=True, name=None)
Imports a utility function from a GENIUS XML string.
- Parameters
xml_str (str) – The string containing GENIUS style XML utility function definition
- Return type
- Returns
A utility function object (depending on the input file)
- limit_cardinality(max_cardinality=inf, levels=inf)[source]
Limits the cardinality of the outcome space to the given maximum (or the number of levels for each issue to
Logging Levels
)- Parameters
- Return type
- sample(n_outcomes, with_replacement=False, fail_if_not_enough=True)
Samples up to n_outcomes with or without replacement.
This methor provides a base implementation that is not memory efficient. It will simply create a list of all outcomes using
enumerate()
and then samples from it. Specific outcome space types should override this method to improve its efficiency if possible.
- to_dict()
- to_discrete(*args, **kwargs)
Discretizes the outcome space by sampling
Logging Levels
values for each continuous issue.The result of the discretization is stable in the sense that repeated calls will return the same output.
- Return type
- to_genius(file_name, **kwargs)
Exports a utility function to a GENIUS XML file.
- Remarks:
See
to_xml_str
for all the parameters
- to_largest_discrete(levels, max_cardinality=inf, **kwargs)
- Return type
- to_single_issue(numeric=False, stringify=True)[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
ContiguousIssue
otherwise it will be aCategoricalIssue
stringify – If given, the output issue will have string values. Checked only if
Numeric and Mathematical Modules
isFalse
- Remarks:
maps the agenda and ufuns to work correctly together
Only works if the outcome space is finite
- Return type