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.

check_one_at_most(outcome_space, issues, ...)

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

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, **kwargs)

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_xml_str(xml_str[, safe_parsing, ...])

Exports a list/dict of issues from a GENIUS XML 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()

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 may not have differences between values defined and may not have a natural ordering.

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.

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.

Class Inheritance Diagram

digraph inheritance60bd24e8d4 { bgcolor=transparent; fontsize=11; randkir=TB; rankdir=LR; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "CallableIssue" [URL="../../api/negmas.outcomes.CallableIssue.html#negmas.outcomes.CallableIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An `Issue` with a callable for generating values. This is a very limited issue type and most operations are not supported on it."]; "Issue" -> "CallableIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CardinalIssue" [URL="../../api/negmas.outcomes.CardinalIssue.html#negmas.outcomes.CardinalIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An `Issue` for which differences between values are meaningful."]; "OrdinalIssue" -> "CardinalIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CartesianOutcomeSpace" [URL="../../api/negmas.outcomes.CartesianOutcomeSpace.html#negmas.outcomes.CartesianOutcomeSpace",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An outcome-space that is generated by the cartesian product of a tuple of `Issue` s."]; "OutcomeSpace" -> "CartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "IndependentIssuesOS" -> "CartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "XmlSerializable" -> "CartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CategoricalIssue" [URL="../../api/negmas.outcomes.CategoricalIssue.html#negmas.outcomes.CategoricalIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An `Issue` type representing discrete values that may not have differences between values defined and may not have a natural ordering."]; "DiscreteIssue" -> "CategoricalIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Collection" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Sized" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Iterable" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Container" -> "Collection" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Container" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "ContiguousIssue" [URL="../../api/negmas.outcomes.ContiguousIssue.html#negmas.outcomes.ContiguousIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A `RangeIssue` (also a `DiscreteIssue`) representing a contiguous range of integers."]; "RangeIssue" -> "ContiguousIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteIssue" -> "ContiguousIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousInfiniteIssue" [URL="../../api/negmas.outcomes.ContinuousInfiniteIssue.html#negmas.outcomes.ContinuousInfiniteIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An issue that can represent all real numbers"]; "ContinuousIssue" -> "ContinuousInfiniteIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "InfiniteIssue" -> "ContinuousInfiniteIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousIssue" [URL="../../api/negmas.outcomes.ContinuousIssue.html#negmas.outcomes.ContinuousIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A `RangeIssue` representing a continous range of real numbers with finite limits."]; "RangeIssue" -> "ContinuousIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CountableInfiniteIssue" [URL="../../api/negmas.outcomes.CountableInfiniteIssue.html#negmas.outcomes.CountableInfiniteIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An issue that can have all integer values."]; "ContiguousIssue" -> "CountableInfiniteIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "InfiniteIssue" -> "CountableInfiniteIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteCartesianOutcomeSpace" [URL="../../api/negmas.outcomes.DiscreteCartesianOutcomeSpace.html#negmas.outcomes.DiscreteCartesianOutcomeSpace",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A discrete outcome-space that is generated by the cartesian product of a tuple of `Issue` s (i.e. with finite number of outcomes)."]; "DiscreteOutcomeSpace" -> "DiscreteCartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "IndependentDiscreteIssuesOS" -> "DiscreteCartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CartesianOutcomeSpace" -> "DiscreteCartesianOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteIssue" [URL="../../api/negmas.outcomes.DiscreteIssue.html#negmas.outcomes.DiscreteIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An `Issue` with a discrete set of values."]; "Issue" -> "DiscreteIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteOrdinalIssue" [URL="../../api/negmas.outcomes.DiscreteOrdinalIssue.html#negmas.outcomes.DiscreteOrdinalIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A `DiscreteIssue` that have some defined ordering of outcomes but not necessarily a meaningful difference function between its values."]; "DiscreteIssue" -> "DiscreteOrdinalIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "OrdinalIssue" -> "DiscreteOrdinalIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteOutcomeSpace" [URL="../../api/negmas.outcomes.DiscreteOutcomeSpace.html#negmas.outcomes.DiscreteOutcomeSpace",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The base protocol for all outcome spaces with a finite number of items."]; "OutcomeSpace" -> "DiscreteOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Collection" -> "DiscreteOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Protocol" -> "DiscreteOutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Generic" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Abstract base class for generic types."]; "HasMinMax" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Protocol" -> "HasMinMax" [arrowsize=0.5,style="setlinewidth(0.5)"]; "IndependentDiscreteIssuesOS" [URL="../../api/negmas.outcomes.IndependentDiscreteIssuesOS.html#negmas.outcomes.IndependentDiscreteIssuesOS",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An Outcome-Space that is constructed from a tuple of `DiscreteIssue` objects."]; "Protocol" -> "IndependentDiscreteIssuesOS" [arrowsize=0.5,style="setlinewidth(0.5)"]; "IndependentIssuesOS" [URL="../../api/negmas.outcomes.IndependentIssuesOS.html#negmas.outcomes.IndependentIssuesOS",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An Outcome-Space that is constructed from a tuple of `Issue` objects."]; "Protocol" -> "IndependentIssuesOS" [arrowsize=0.5,style="setlinewidth(0.5)"]; "InfiniteIssue" [URL="../../api/negmas.outcomes.InfiniteIssue.html#negmas.outcomes.InfiniteIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates that the issue is infinite (i.e. one or more of its limits is infinity)"]; "Issue" [URL="../../api/negmas.outcomes.Issue.html#negmas.outcomes.Issue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class of all issues in NegMAS"]; "HasMinMax" -> "Issue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Iterable" -> "Issue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Generic" -> "Issue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "Issue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Iterable" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "OrdinalIssue" [URL="../../api/negmas.outcomes.OrdinalIssue.html#negmas.outcomes.OrdinalIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An `Issue` that have some defined ordering of outcomes but not necessarily a meaningful difference function between its values."]; "Issue" -> "OrdinalIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "OutcomeSpace" [URL="../../api/negmas.outcomes.OutcomeSpace.html#negmas.outcomes.OutcomeSpace",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The base protocol for all outcome spaces."]; "Container" -> "OutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Protocol" -> "OutcomeSpace" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Protocol" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for protocol classes."]; "Generic" -> "Protocol" [arrowsize=0.5,style="setlinewidth(0.5)"]; "RangeIssue" [URL="../../api/negmas.outcomes.RangeIssue.html#negmas.outcomes.RangeIssue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An issue representing a range of values (can be continuous or discrete)"]; "CardinalIssue" -> "RangeIssue" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Sized" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "XmlSerializable" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="setlinewidth(0.5),filled"]; "Protocol" -> "XmlSerializable" [arrowsize=0.5,style="setlinewidth(0.5)"]; }