tournament
- negmas.tournaments.tournament(competitors: list[str | Agent] | tuple[str | Agent, ...] | Sequence[str | Agent], config_generator: ConfigGenerator, config_assigner: ConfigAssigner, world_generator: WorldGenerator, score_calculator: Callable[[list[World], dict[str, Any], bool], WorldRunResults], competitor_params: Sequence[dict[str, Any]] | None = None, n_competitors_per_world: int | None = None, round_robin: bool = False, stage_winners_fraction: float = 0.0, agent_names_reveal_type=False, n_agents_per_competitor=1, n_configs: int = 10, max_worlds_per_config: int = 100, n_runs_per_world: int = 5, max_n_configs: int | None = None, n_runs_per_config: int | None = None, tournament_path: str | Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[WorldRunResults | None, int, int], None] | None = None, world_progress_callback: Callable[[World | None], None] | None = None, non_competitors: tuple[str | Any] | None = None, non_competitor_params: tuple[dict[str, Any]] | None = None, dynamic_non_competitors: tuple[str | Any] | None = None, dynamic_non_competitor_params: tuple[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only: bool = False, compact: bool = False, print_exceptions: bool = True, metric='median', save_video_fraction: float = 0.0, forced_logs_fraction: float = 0.0, video_params=None, video_saver=None, max_attempts: int = 9223372036854775807, extra_scores_to_use: str | None = None, **kwargs) TournamentResults | Path[source]
Runs a tournament
- Parameters:
name – Tournament name
config_generator – Used to generate unique configs that will be used to evaluate competitors
config_assigner – Used to generate assignments of competitors to the configs created by the
config_generatorworld_generator – A functions to generate worlds for the tournament that follows the assignments made by the
config_assignerscore_calculator – A function for calculating the score of all agents in a world After it finishes running. The second parameter is a dict describing any scoring context that may have been added by the world config generator or assigneer. The third parameter is a boolean specifying whether this is a dry_run. For dry runs, scores are not expected but names and types should exist in the returned
WorldRunResults.competitors – A list of class names for the competitors
competitor_params – A list of competitor parameters (used to initialize the competitors).
n_competitors_per_world –
The number of competitors allowed in every world. It must be >= 1 and <= len(competitors) or None.
If None or len(competitors), then all competitors will exist in every world.
If 1, then each world will have one competitor
round_robin – Only effective if 1 < n_competitors_per_world < len(competitors). if True, all combinations will be tried otherwise n_competitors_per_world must divide len(competitors) and every competitor appears only in one set.
stage_winners_fraction – in [0, 1). Fraction of agents to to go to the next stage at every stage. If zero, and round_robin, it becomes a single stage competition.
agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).
n_configs – The number of different world configs (up to competitor assignment) to be generated.
max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).
n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.
n_agents_per_competitor – The number of agents of each competing type to be instantiated in the world.
max_n_configs – [Depricated] The number of configs to use (it is replaced by separately setting
n_configandmax_worlds_per_config)n_runs_per_config – [Depricated] The number of runs (simulation) for every config. It is replaced by
n_runs_per_worldtotal_timeout – Total timeout for the complete process
tournament_path – Path at which to store all results. A new folder with the name of the tournament will be created at this path. A scores.csv file will keep the scores and logs folder will keep detailed logs
parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed! For parallel, you can add the fraction of CPUs to use after a colon (e.g. parallel:0.5 to use half of the CPU in the machine). By defaults parallel uses all CPUs in the machine
scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed
scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed
world_progress_callback – A function to be called after every step of every world run (only allowed for serial and parallel evaluation and should be used with cautious).
tournament_progress_callback – A function to be called with
WorldRunResultsafter each world finished processingnon_competitors – A list of agent types that will not be competing but will still exist in the world.
non_competitor_params – paramters of non competitor agents
dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created
dynamic_non_competitor_params – paramters of dynamic non competitor agents
exclude_competitors_from_reassignment – If true, competitors are excluded from the dyanamic non-competitors
verbose – Verbosity
configs_only – If true, a config file for each
compact – If true, compact logs will be created and effort will be made to reduce the memory footprint
print_exceptions – If true, print all exceptions to screen
metric – The metric to use for evaluation
save_video_fraction – The fraction of simulations for which to save videos
forced_logs_fraction – The fraction of simulations for which to always save logs. Notice that this has no effect except if no logs were to be saved otherwise (i.e.
no_logsis passed as True)video_params – The parameters to pass to the video saving function
video_saver – The parameters to pass to the video saving function after the world
max_attempts – The maximum number of times to retry running simulations
extra_scores_to_use – The type of extra-scores to use. If None normal scores will be used. Only effective if scores is None.
kwargs – Arguments to pass to the
config_generatorfunction
- Returns:
TournamentResultsThe results of the tournament or aPathgiving the location where configs were saved