CartesianOutcomeSpace

class negmas.outcomes.CartesianOutcomeSpace(issues, name=None)[source]

Bases: XmlSerializable

An outcome-space that is generated by the cartesian product of a tuple of Issue s.

Attributes Summary

cardinality

The space cardinality = the number of outcomes

issue_names

Returns an ordered list of issue names

issues

name

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[, ...])

rtype:

int

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).

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_cardinality different outcomes otherwise.

enumerate_or_sample_rational(preferences[, ...])

Enumerates all outcomes if possible (i.e. discrete space) or returns max_cardinality different outcomes otherwise.

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.

is_all_continuous()

Checks whether all issues are discrete

is_compact()

Checks whether all issues are complete ranges

is_discrete()

Checks whether all issues are discrete

is_finite()

Checks whether the space is finite

is_float()

Checks whether all issues are real

is_integer()

Checks whether all issues are integer

is_not_discrete()

Checks whether all issues are discrete

is_numeric()

Checks whether all issues are numeric

is_valid(outcome)

rtype:

bool

random_outcome()

sample(n_outcomes[, with_replacement, ...])

rtype:

Iterable[tuple]

to_dict()

to_discrete([levels, max_cardinality])

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:

DiscreteCartesianOutcomeSpace

to_single_issue([numeric, stringify, ...])

Creates a new outcome space that is a single-issue version of this one discretizing it as needed

to_xml_str()

Exports a utility function to a well formatted string

Attributes Documentation

cardinality

The space cardinality = the number of outcomes

issue_names

Returns an ordered list of issue names

issues: tuple[Issue, ...]
name: str | None

Methods Documentation

are_types_ok(outcome)[source]

Checks if the type of each value in the outcome is correct for the given issue

Return type:

bool

cardinality_if_discretized(levels, max_cardinality=inf)[source]
Return type:

int

contains_issue(x)[source]

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:

bool

contains_os(x)[source]

Checks whether an outcome-space is contained in this outcome-space

Return type:

bool

ensure_correct_types(outcome)[source]

Returns an outcome that is guaratneed to have correct types or raises an exception

Return type:

tuple

enumerate_or_sample(levels=inf, max_cardinality=inf)[source]

Enumerates all outcomes if possible (i.e. discrete space) or returns max_cardinality different outcomes otherwise

Return type:

Iterable[tuple]

enumerate_or_sample_rational(preferences, levels=inf, max_cardinality=inf, aggregator=<built-in function any>)[source]

Enumerates all outcomes if possible (i.e. discrete space) or returns max_cardinality different outcomes otherwise.

Parameters:
  • preferences (Iterable[HasReservedValue | HasReservedOutcome]) – A list of Preferences that is used to judge outcomes

  • levels (int | float) – The number of levels to use for discretization if needed

  • max_cardinality (int | float) – The maximum cardinality allowed in case of discretization

  • aggregator (Callable[[Iterable[bool]], bool]) – A predicate that takes an Iterable of booleans representing whether or not an outcome is rational for a given Preferences (i.e. better than reservation) and returns a single boolean representing the result for all preferences. Default is any but can be all.

Return type:

Iterable[Outcome]

classmethod from_dict(d)[source]
classmethod from_genius(file_name, **kwargs)

Imports a utility function from a GENIUS XML file.

Parameters:

file_name (str) – File name to import from

Return type:

TypeVar(X, bound= XmlSerializable)

Returns:

A utility function object (depending on the input file)

static from_outcomes(outcomes, numeric_as_ranges=False, issue_names=None, name=None)[source]
Return type:

DiscreteCartesianOutcomeSpace

classmethod from_xml_str(xml_str, safe_parsing=True, name=None)[source]

Imports a utility function from a GENIUS XML string.

Parameters:

xml_str (str) – The string containing GENIUS style XML utility function definition

Return type:

CartesianOutcomeSpace

Returns:

A utility function object (depending on the input file)

is_all_continuous()[source]

Checks whether all issues are discrete

Return type:

bool

is_compact()[source]

Checks whether all issues are complete ranges

Return type:

bool

is_discrete()[source]

Checks whether all issues are discrete

Return type:

bool

is_finite()[source]

Checks whether the space is finite

Return type:

bool

is_float()[source]

Checks whether all issues are real

Return type:

bool

is_integer()[source]

Checks whether all issues are integer

Return type:

bool

is_not_discrete()[source]

Checks whether all issues are discrete

Return type:

bool

is_numeric()[source]

Checks whether all issues are numeric

Return type:

bool

is_valid(outcome)[source]
Return type:

bool

random_outcome()[source]
sample(n_outcomes, with_replacement=True, fail_if_not_enough=True)[source]
Return type:

Iterable[tuple]

to_dict()[source]
to_discrete(levels=10, max_cardinality=inf)[source]

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:

DiscreteCartesianOutcomeSpace

to_genius(file_name, **kwargs)

Exports a utility function to a GENIUS XML file.

Parameters:

file_name (str) – File name to export to

Return type:

None

Returns:

None

Remarks:

See to_xml_str for all the parameters

to_largest_discrete(levels, max_cardinality=inf, **kwargs)[source]
Return type:

DiscreteCartesianOutcomeSpace

to_single_issue(numeric=False, stringify=True, levels=5, max_cardinality=inf)[source]

Creates a new outcome space that is a single-issue version of this one discretizing it as needed

Parameters:
Return type:

DiscreteCartesianOutcomeSpace

Remarks:
  • Will discretize inifinte outcome spaces

to_xml_str()[source]

Exports a utility function to a well formatted string

Return type:

str