Scenario

class negmas.inout.Scenario(outcome_space, ufuns, mechanism_type=<class 'negmas.sao.mechanism.SAOMechanism'>, mechanism_params=NOTHING)[source]

Bases: object

A class representing a negotiation domain

Attributes Summary

issue_names

issues

mechanism_params

mechanism_type

n_issues

n_negotiators

outcome_space

ufuns

Methods Summary

calc_extra_stats([max_cardinality])

Calculates and returns several stats corresponding to the domain

calc_stats()

rtype:

ScenarioStats

discretize([levels])

Discretize all issues

dumpas(folder[, type, compact])

Dumps the scenario in the given file format.

from_genius_files(domain, ufuns[, ...])

rtype:

Scenario | None

from_genius_folder(path[, ignore_discount, ...])

rtype:

Scenario | None

from_geniusweb_files(domain, ufuns[, ...])

rtype:

Scenario | None

from_geniusweb_folder(path[, ...])

rtype:

Scenario | None

from_yaml_files(domain, ufuns[, ...])

rtype:

Scenario | None

from_yaml_folder(path[, ignore_discount, ...])

rtype:

Scenario | None

is_loadable(path)

is_normalized([to, positive, eps])

Checks that all ufuns are normalized in the given range

load(folder[, safe_parsing])

Loads the scenario from a folder with supported formats: XML, YML

make_session([negotiators, n_steps, ...])

Generates a ready to run mechanism session for this domain.

normalize([to])

Normalizes a utility function to the given range

plot(**kwargs)

remove_discounting()

Removes discounting from all ufuns

remove_reserved_values([r])

Removes reserved values from all ufuns replaacing it with r

scale_max([to])

Normalizes a utility function to the given range

scale_min([to])

Normalizes a utility function to the given range

serialize()

Converts the current scenario into a serializable dict.

to_genius_files(domain_path, ufun_paths)

Save domain and ufun files to the path as XML.

to_genius_folder(path)

Save domain and ufun files to the path as XML.

to_json(folder)

Saves the scenario as json :type folder: Path | str :param folder: The destination path

to_numeric()

Forces all issues in the domain to become numeric

to_single_issue([numeric, stringify, randomize])

Forces the domain to have a single issue with all possible outcomes

to_yaml(folder)

Saves the scenario as yaml :type folder: Path | str :param folder: The destination path

Attributes Documentation

issue_names
issues
mechanism_params: dict
mechanism_type: type[Mechanism] | None
n_issues
n_negotiators
outcome_space: CartesianOutcomeSpace
ufuns: tuple[UtilityFunction, ...]

Methods Documentation

calc_extra_stats(max_cardinality=10000000000)[source]

Calculates and returns several stats corresponding to the domain

Parameters:

max_cardinality (int) – The maximum number of outcomes considered when calculating the stats.

Return type:

dict[str, Any]

Returns:

A dictionary with the compiled stats

calc_stats()[source]
Return type:

ScenarioStats

discretize(levels=10)[source]

Discretize all issues

dumpas(folder, type='yml', compact=False)[source]

Dumps the scenario in the given file format.

Return type:

None

static from_genius_files(domain, ufuns, ignore_discount=False, ignore_reserved=False, safe_parsing=True)[source]
Return type:

Scenario | None

static from_genius_folder(path, ignore_discount=False, ignore_reserved=False, safe_parsing=True)[source]
Return type:

Scenario | None

static from_geniusweb_files(domain, ufuns, ignore_discount=False, ignore_reserved=False, use_reserved_outcome=False, safe_parsing=True)[source]
Return type:

Scenario | None

static from_geniusweb_folder(path, ignore_discount=False, ignore_reserved=False, use_reserved_outcome=False, safe_parsing=True)[source]
Return type:

Scenario | None

classmethod from_yaml_files(domain, ufuns, ignore_discount=False, ignore_reserved=False, safe_parsing=True)[source]
Return type:

Scenario | None

classmethod from_yaml_folder(path, ignore_discount=False, ignore_reserved=False, safe_parsing=True)[source]
Return type:

Scenario | None

classmethod is_loadable(path)[source]
is_normalized(to=(None, 1.0), positive=True, eps=1e-06)[source]

Checks that all ufuns are normalized in the given range

Return type:

bool

classmethod load(folder, safe_parsing=False)[source]

Loads the scenario from a folder with supported formats: XML, YML

Return type:

Scenario | None

make_session(negotiators=None, n_steps=None, time_limit=None, roles=None, raise_on_failure_to_enter=True, **kwargs)[source]

Generates a ready to run mechanism session for this domain.

normalize(to=(0.0, 1.0))[source]

Normalizes a utility function to the given range

Parameters:

rng – range to normalize to. Default is [0, 1]

Return type:

Scenario

plot(**kwargs)[source]
remove_discounting()[source]

Removes discounting from all ufuns

remove_reserved_values(r=-inf)[source]

Removes reserved values from all ufuns replaacing it with r

scale_max(to=1.0)[source]

Normalizes a utility function to the given range

Parameters:
  • ufun – The utility function to normalize

  • outcomes – A collection of outcomes to normalize for

  • rng – range to normalize to. Default is [0, 1]

  • levels – Number of levels to use for discretizing continuous issues (if any)

  • max_cardinality – Maximum allowed number of outcomes resulting after all discretization is done

Return type:

Scenario

scale_min(to=1.0)[source]

Normalizes a utility function to the given range

Parameters:
  • ufun – The utility function to normalize

  • outcomes – A collection of outcomes to normalize for

  • rng – range to normalize to. Default is [0, 1]

  • levels – Number of levels to use for discretizing continuous issues (if any)

  • max_cardinality – Maximum allowed number of outcomes resulting after all discretization is done

Return type:

Scenario

serialize()[source]

Converts the current scenario into a serializable dict.

Return type:

dict[str, Any]

Remarks:
Rturns a dictionary with the following keys:
  • domain: The agenda/outcome-space

  • ufuns: A list of utility functions

to_genius_files(domain_path, ufun_paths)[source]

Save domain and ufun files to the path as XML.

to_genius_folder(path)[source]

Save domain and ufun files to the path as XML.

to_json(folder)[source]

Saves the scenario as json :type folder: Path | str :param folder: The destination path

Return type:

None

to_numeric()[source]

Forces all issues in the domain to become numeric

Return type:

Scenario

Remarks:
  • maps the agenda and ufuns to work correctly together

to_single_issue(numeric=False, stringify=True, randomize=False)[source]

Forces the domain to have a single issue with all possible outcomes

Parameters:
  • numeric – If given, the output issue will be a ContiguousIssue otherwise it will be a DiscreteCategoricalIssue

  • stringify – If given, the output issue will have string values. Checked only if Numeric and Mathematical Modules is False

  • randomize – Randomize outcome order when creating the single issue

Return type:

Scenario

Remarks:
  • maps the agenda and ufuns to work correctly together

  • Only works if the outcome space is finite

to_yaml(folder)[source]

Saves the scenario as yaml :type folder: Path | str :param folder: The destination path

Return type:

None