negmas.tournaments.tournament(competitors: Sequence[Union[str, Type[negmas.situated.Agent]]], config_generator: negmas.tournaments.tournaments.ConfigGenerator, config_assigner: negmas.tournaments.tournaments.ConfigAssigner, world_generator: negmas.tournaments.WorldGenerator, score_calculator: Callable[[List[negmas.situated.World], Dict[str, Any], bool], negmas.tournaments.WorldRunResults], competitor_params: Optional[Sequence[Dict[str, Any]]] = None, n_competitors_per_world: Optional[int] = 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: Optional[int] = None, n_runs_per_config: Optional[int] = None, tournament_path: Optional[str] = None, total_timeout: Optional[int] = None, parallelism='parallel', scheduler_ip: Optional[str] = None, scheduler_port: Optional[str] = None, tournament_progress_callback: Optional[Callable[[Optional[negmas.tournaments.WorldRunResults], int, int], None]] = None, world_progress_callback: Optional[Callable[[Optional[negmas.situated.World]], None]] = None, non_competitors: Optional[Tuple[Union[str, Any]]] = None, non_competitor_params: Optional[Tuple[Dict[str, Any]]] = None, dynamic_non_competitors: Optional[Tuple[Union[str, Any]]] = None, dynamic_non_competitor_params: Optional[Tuple[Dict[str, Any]]] = None, exclude_competitors_from_reassignment: bool = True, name: Optional[str] = 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 = inf, extra_scores_to_use: Optional[str] = None, **kwargs)Union[negmas.tournaments.TournamentResults, os.PathLike][source]

Runs a tournament

  • 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_generator

  • world_generator – A functions to generate worlds for the tournament that follows the assignments made by the config_assigner

  • score_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_config and max_worlds_per_config )

  • n_runs_per_config – [Depricated] The number of runs (simulation) for every config. It is replaced by n_runs_per_world

  • total_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 WorldRunResults after each world finished processing

  • non_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_logs is 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_generator function


TournamentResults The results of the tournament or a PathLike giving the location where configs were saved