Scenario
- class negmas.inout.Scenario(outcome_space: ~negmas.outcomes.outcome_space.CartesianOutcomeSpace, ufuns: tuple[~negmas.preferences.crisp_ufun.UtilityFunction, ...], mechanism_type: type[~negmas.mechanisms.Mechanism] | None = <class 'negmas.sao.mechanism.SAOMechanism'>, mechanism_params: dict = NOTHING, info: dict[str, ~typing.Any] = NOTHING)[source]
Bases:
objectA class representing a negotiation domain
Attributes Summary
Methods Summary
calc_extra_stats([max_cardinality])Calculates and returns several stats corresponding to the domain
discretize([levels])Discretize all issues
dumpas(folder[, type, compact, ...])Dumps the scenario in the given file format.
from_genius_files(domain, ufuns[, info, ...])from_genius_folder(path[, ignore_discount, ...])from_geniusweb_files(domain, ufuns[, info, ...])from_geniusweb_folder(path[, ...])from_yaml_files(domain, ufuns[, info, ...])from_yaml_folder(path[, ignore_discount, ...])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
load_info(folder)load_info_file(file)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)Removes discounting from all ufuns
Removes reserved values from all ufuns replaacing it with
rscale_max([to])Normalizes a utility function to the given range
scale_min([to])Normalizes a utility function to the given range
serialize([python_class_identifier])Converts the current scenario into a serializable dict.
to_genius_files(domain_path, ufun_paths)Save domain and ufun files to the
pathas XML.to_genius_folder(path)Save domain and ufun files to the
pathas XML.to_json(folder)Saves the scenario as json :param folder: The destination path
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 :param folder: The destination path
Attributes Documentation
- issue_names
- issues
- n_issues
- n_negotiators
- outcome_space: CartesianOutcomeSpace
- ufuns: tuple[UtilityFunction, ...]
Methods Documentation
- calc_extra_stats(max_cardinality: int = 10000000000) dict[str, Any][source]
Calculates and returns several stats corresponding to the domain
- Parameters:
max_cardinality (int) – The maximum number of outcomes considered when calculating the stats.
- Returns:
A dictionary with the compiled stats
- calc_stats() ScenarioStats[source]
- dumpas(folder: Path | str, type='yml', compact: bool = False, python_class_identifier='__python_class__') None[source]
Dumps the scenario in the given file format.
- static from_genius_files(domain: PathLike, ufuns: Iterable[PathLike], info: PathLike | None = None, ignore_discount=False, ignore_reserved=False, safe_parsing=True) Scenario | None[source]
- static from_genius_folder(path: PathLike | str, ignore_discount=False, ignore_reserved=False, safe_parsing=True) Scenario | None[source]
- static from_geniusweb_files(domain: PathLike, ufuns: Iterable[PathLike], info: PathLike | None = None, ignore_discount=False, ignore_reserved=False, use_reserved_outcome=False, safe_parsing=True) Scenario | None[source]
- static from_geniusweb_folder(path: PathLike | str, ignore_discount=False, ignore_reserved=False, use_reserved_outcome=False, safe_parsing=True) Scenario | None[source]
- classmethod from_yaml_files(domain: PathLike, ufuns: Iterable[PathLike], info: PathLike | None = None, ignore_discount=False, ignore_reserved=False, safe_parsing=True, python_class_identifier='type') Scenario | None[source]
- classmethod from_yaml_folder(path: PathLike | str, ignore_discount=False, ignore_reserved=False, safe_parsing=True) Scenario | None[source]
- is_normalized(to: tuple[float | None, float | None] = (None, 1.0), positive: bool = True, eps: float = 1e-06) bool[source]
Checks that all ufuns are normalized in the given range
- classmethod load(folder: Path | str, safe_parsing=False) Scenario | None[source]
Loads the scenario from a folder with supported formats: XML, YML
- make_session(negotiators: Callable[[], Negotiator] | type[Negotiator] | list[Negotiator] | tuple[Negotiator, ...] | None = None, n_steps: int | float | None = None, time_limit: float | None = None, roles: list[str] | None = None, raise_on_failure_to_enter: bool = True, share_ufuns: bool = False, share_reserved_values: bool = False, **kwargs)[source]
Generates a ready to run mechanism session for this domain.
- normalize(to: tuple[float, float] = (0.0, 1.0)) Scenario[source]
Normalizes a utility function to the given range
- Parameters:
rng – range to normalize to. Default is [0, 1]
- remove_reserved_values(r: float = -inf)[source]
Removes reserved values from all ufuns replaacing it with
r
- scale_max(to: float = 1.0) Scenario[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
- scale_min(to: float = 1.0) Scenario[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
- serialize(python_class_identifier='__python_class__') dict[str, Any][source]
Converts the current scenario into a serializable dict.
- Remarks:
- Rturns a dictionary with the following keys:
domain: The agenda/outcome-space
ufuns: A list of utility functions
- to_genius_files(domain_path: Path, ufun_paths: list[Path])[source]
Save domain and ufun files to the
pathas XML.
- to_json(folder: Path | str) None[source]
Saves the scenario as json :param folder: The destination path
- to_numeric() Scenario[source]
Forces all issues in the domain to become numeric
- Remarks:
maps the agenda and ufuns to work correctly together
- to_single_issue(numeric=False, stringify=True, randomize=False) Scenario[source]
Forces the domain to have a single issue with all possible outcomes
- Parameters:
numeric – If given, the output issue will be a
ContiguousIssueotherwise it will be aDiscreteCategoricalIssuestringify – If given, the output issue will have string values. Checked only if
Numeric and Mathematical ModulesisFalserandomize – Randomize outcome order when creating the single issue
- Remarks:
maps the agenda and ufuns to work correctly together
Only works if the outcome space is finite