create_tournament

negmas.tournaments.create_tournament(competitors, config_generator, config_assigner, world_generator, score_calculator, competitor_params=None, n_competitors_per_world=None, round_robin=True, agent_names_reveal_type=False, n_agents_per_competitor=1, n_configs=10, max_worlds_per_config=100, n_runs_per_world=5, max_n_configs=None, n_runs_per_config=None, base_tournament_path=None, total_timeout=None, parallelism='parallel', scheduler_ip=None, scheduler_port=None, non_competitors=None, non_competitor_params=None, dynamic_non_competitors=None, dynamic_non_competitor_params=None, exclude_competitors_from_reassignment=True, name=None, verbose=False, compact=False, save_video_fraction=0.0, forced_logs_fraction=0.0, video_params=None, video_saver=None, **kwargs)[source]

Creates a tournament

Parameters:
  • name (str | None) – Tournament name

  • config_generator (ConfigGenerator) – Used to generate unique configs that will be used to evaluate competitors

  • config_assigner (ConfigAssigner) – Used to generate assignments of competitors to the configs created by the config_generator

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

  • score_calculator (Callable[[list[World], dict[str, Any], bool], WorldRunResults]) – 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 (Sequence[str | type[Agent]]) – A list of class names for the competitors

  • competitor_params (Optional[Sequence[dict[str, Any]]]) – A list of competitor parameters (used to initialize the competitors).

  • n_competitors_per_world (int | None) –

    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 (bool) – 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.

  • 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 (int) – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config (int | None) – 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 (int) – 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 (int | None) – [Depricated] The number of configs to use (it is replaced by separately setting n_config and max_worlds_per_config )

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

  • total_timeout (int | None) – Total timeout for the complete process

  • base_tournament_path (Path | str | None) – 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 (str | None) – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip (str | None) – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • non_competitors (tuple[str | Any, ...] | None) – A list of agent types that will not be competing but will still exist in the world.

  • non_competitor_params (tuple[dict[str, Any], ...] | None) – paramters of non competitor agents

  • dynamic_non_competitors (tuple[str | Any, ...] | None) – 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 (tuple[dict[str, Any], ...] | None) – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment (bool) – If true, copmetitors are not included in the reassignment even if they exist in dynamic_non_competitors

  • verbose (bool) – Verbosity

  • compact (bool) – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • save_video_fraction (float) – The fraction of simulations for which to save videos

  • forced_logs_fraction (float) – 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

  • kwargs – Arguments to pass to the config_generator function

Return type:

Path

Returns:

The path at which tournament configs are stored