negmas.outcomes Package

Defines basic concepts related to outcomes

Outcomes in this package are always assumed to be multi-issue outcomes where single-issue outcomes can be implemented as the special case with a single issue.

  • Both Continuous and discrete issues are supported. All issue will have names. If none is given, a random name will be used. It is HIGHLY recommended to always name your issues.

  • Outcomes are dictionaries with issue names as keys and issue values as values.

Examples

Different ways to create issues:

>>> issues = [make_issue((0.5, 2.0), 'price'), make_issue(['2018.10.'+ str(_) for _ in range(1, 4)], 'date')
...           , make_issue(20, 'count')]
>>> for _ in issues: print(_)
price: (0.5, 2.0)
date: ['2018.10.1', '2018.10.2', '2018.10.3']
count: (0, 19)

Outcome example compatible with the given set of issues:

>>> a = {'price': 1.2, 'date': '2018.10.04', 'count': 4}

Functions

check_one_and_only(outcome_space, issues, ...)

Ensures that one and only one of the three inputs is given (i.e. not None).

check_one_at_most(outcome_space, issues, ...)

Ensures that at most one of the three inputs is given (i.e. not None).

ensure_os(outcome_space, issues, outcomes)

Returns an outcome space from either an outcome-space, a list of issues, a list of outcomes, or the number of outcomes

os_or_none(outcome_space, issues, outcomes)

Returns an outcome space from either an outcome-space, a list of issues, a list of outcomes, or the number of outcomes

make_issue(values, *args[, optional])

A factory for creating issues based on values type as well as the base class of all issues

generate_issues(params[, counts, names])

Generates a set of issues with given parameters.

issues_from_genius(file_name[, ...])

Imports a the domain issues from a GENIUS XML file.

issues_from_geniusweb(file_name[, ...])

Imports a the domain issues from a GENIUS XML file.

issues_from_xml_str(xml_str[, safe_parsing, ...])

Exports a list/dict of issues from a GENIUS XML file.

issues_from_geniusweb_json_str(json_str[, ...])

Exports a list/dict of issues from a GeniusWeb json file.

issues_to_genius(issues, file_name)

Exports a the domain issues to a GENIUS XML file.

issues_to_xml_str(issues)

Converts the list of issues into a well-formed xml string.

issues_from_outcomes(outcomes[, ...])

Create a set of issues given some outcomes.

num_outcomes(issues)

Returns the total number of outcomes in a set of issues.

enumerate_issues(issues[, max_cardinality])

Enumerates the outcomes of a list of issues.

enumerate_discrete_issues(issues)

Enumerates all outcomes of this set of discrete issues if possible.

discretize_and_enumerate_issues(issues[, ...])

Enumerates the outcomes of a list of issues.

sample_issues(issues, n_outcomes[, ...])

Samples some outcomes from the outcome space defined by the list of issues.

sample_outcomes(issues[, n_outcomes, ...])

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

combine_issues(issues[, name, ...])

Combines multiple issues into a single issue.

dict2outcome(d, issues)

Converts the outcome to a tuple no matter what was its type

outcome2dict(outcome, issues)

Converts the outcome to a dict no matter what was its type.

outcome_in_range(outcome, outcome_range, *)

Tests that the outcome is contained within the given range of outcomes.

outcome_is_complete(outcome, issues)

Tests that the outcome is valid and complete.

outcome_types_are_ok(outcome, issues)

Checks that the types of all issue values in the outcome are correct

outcome_is_valid(outcome, issues)

Test validity of an outcome given a set of issues.

generalized_minkowski_distance(a, b, ...[, ...])

Calculates the difference between two outcomes given an outcome-space (optionally with issue weights).

min_dist(test_outcome, outcomes, outcome_space)

Minimum distance between an outcome and a set of outcomes in an outcome-spaceself.

make_os([issues, outcomes, name])

A factory to create outcome-spaces from lists of Issue s or Outcome s.

Classes

Outcome

alias of tuple

PartialOutcomeTuple

alias of tuple

OutcomeSpace(*args, **kwargs)

The base protocol for all outcome spaces.

DiscreteOutcomeSpace(*args, **kwargs)

The base protocol for all outcome spaces with a finite number of items.

IndependentIssuesOS(*args, **kwargs)

An Outcome-Space that is constructed from a tuple of Issue objects.

IndependentDiscreteIssuesOS(*args, **kwargs)

An Outcome-Space that is constructed from a tuple of DiscreteIssue objects.

Issue(values[, name])

Base class of all issues in NegMAS

DiscreteIssue(values[, name])

An Issue with a discrete set of values.

CallableIssue(values[, name])

An Issue with a callable for generating values.

CategoricalIssue(values[, name])

An Issue type representing discrete values that have no ordering or difference defined.

OrdinalIssue(values[, name])

An Issue that have some defined ordering of outcomes but not necessarily a meaningful difference function between its values.

DiscreteOrdinalIssue(values[, name])

A DiscreteIssue that have some defined ordering of outcomes but not necessarily a meaningful difference function between its values.

RangeIssue(values[, name])

An issue representing a range of values (can be continuous or discrete)

CardinalIssue(values[, name])

An Issue for which differences between values are meaningful.

ContiguousIssue(values[, name])

A RangeIssue (also a DiscreteIssue) representing a contiguous range of integers.

ContinuousIssue(values[, name, n_levels])

A RangeIssue representing a continous range of real numbers with finite limits.

CountableInfiniteIssue(values, *args, **kwargs)

An issue that can have all integer values.

ContinuousInfiniteIssue(values[, name, n_levels])

An issue that can represent all real numbers

InfiniteIssue()

Indicates that the issue is infinite (i.e. one or more of its limits is infinity).

CartesianOutcomeSpace(issues[, name])

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

DiscreteCartesianOutcomeSpace(issues[, name])

A discrete outcome-space that is generated by the cartesian product of a tuple of Issue s (i.e. with finite number of outcomes).

Class Inheritance Diagram

Inheritance diagram of negmas.outcomes.protocols.OutcomeSpace, negmas.outcomes.protocols.DiscreteOutcomeSpace, negmas.outcomes.protocols.IndependentIssuesOS, negmas.outcomes.protocols.IndependentDiscreteIssuesOS, negmas.outcomes.base_issue.Issue, negmas.outcomes.base_issue.DiscreteIssue, negmas.outcomes.callable_issue.CallableIssue, negmas.outcomes.categorical_issue.CategoricalIssue, negmas.outcomes.ordinal_issue.OrdinalIssue, negmas.outcomes.ordinal_issue.DiscreteOrdinalIssue, negmas.outcomes.range_issue.RangeIssue, negmas.outcomes.cardinal_issue.CardinalIssue, negmas.outcomes.contiguous_issue.ContiguousIssue, negmas.outcomes.continuous_issue.ContinuousIssue, negmas.outcomes.infinite.CountableInfiniteIssue, negmas.outcomes.infinite.ContinuousInfiniteIssue, negmas.outcomes.infinite.InfiniteIssue, negmas.outcomes.outcome_space.CartesianOutcomeSpace, negmas.outcomes.outcome_space.DiscreteCartesianOutcomeSpace