예제 #1
0
def run(
    competition="std",
    reveal_names=True,
    n_steps=15,
    n_configs=1,
    max_n_worlds_per_config=None,
    n_runs_per_world=2,
):
    """
    **Not needed for submission.** You can use this function to test your agent.

    Args:
        competition: The competition type to run (possibilities are std,
                     collusion).
        n_steps:     The number of simulation steps.
        n_configs:   Number of different world configurations to try.
                     Different world configurations will correspond to
                     different number of factories, profiles
                     , production graphs etc
        n_runs_per_world: How many times will each world simulation be run.

    Returns:
        None

    Remarks:

        - This function will take several minutes to run.
        - To speed it up, use af smaller `n_step` value

    """
    # ComponentBasedAgent
    # competitors = [MyComponentsBasedAgent, DecentralizingAgent,MovingRangeAgent, ReactiveAgent, BuyCheapSellExpensiveAgent,DoNothingAgent,IndependentNegotiationsAgent,RandomAgent]

    competitors = [
        ASMASH,
        IndDecentralizingAgent,
        DecentralizingAgent,
        MovingRangeAgent,
    ]
    start = time.perf_counter()
    if competition == "std":
        results = anac2020_std(
            competitors=competitors,
            verbose=True,
            n_steps=n_steps,
            n_configs=n_configs,
            n_runs_per_world=n_runs_per_world,
        )
    elif competition == "collusion":
        results = anac2020_collusion(
            competitors=competitors,
            verbose=True,
            n_steps=n_steps,
            n_configs=n_configs,
            n_runs_per_world=n_runs_per_world,
        )
    else:
        raise ValueError(f"Unknown competition type {competition}")
    print(tabulate(results.total_scores, headers="keys", tablefmt="psql"))
    print(f"Finished in {humanize_time(time.perf_counter() - start)}")
예제 #2
0
def run_tournament(
    competition="std",
    reveal_names=True,
    n_steps=100,
    n_configs=1,
    max_n_worlds_per_config=None,
    n_runs_per_world=1,
):
    """
    **Not needed for submission.** You can use this function to test your agent.

    Args:
        competition: The competition type to run (possibilities are std,
                     collusion).
        n_steps:     The number of simulation steps.
        n_configs:   Number of different world configurations to try.
                     Different world configurations will correspond to
                     different number of factories, profiles
                     , production graphs etc
        n_runs_per_world: How many times will each world simulation be run.

    Returns:
        None

    Remarks:

        - This function will take several minutes to run.
        - To speed it up, use a smaller `n_step` value

    """

    start = time.perf_counter()
    if competition == "std":
        results = anac2020_std(
            competitors=competitors,
            verbose=True,
            n_steps=n_steps,
            n_configs=n_configs,
            n_runs_per_world=n_runs_per_world,
            n_processes=3,
        )
    elif competition == "collusion":
        results = anac2020_collusion(
            competitors=competitors,
            verbose=True,
            n_steps=n_steps,
            n_configs=n_configs,
            n_runs_per_world=n_runs_per_world,
            n_processes=3,
        )
    else:
        raise ValueError(f"Unknown competition type {competition}")
예제 #3
0
def test_collusion(n):
    competitors = [eval(f"MyAgent{_}") for _ in range(n)]
    results = anac2020_collusion(
        competitors=competitors,
        n_steps=10,
        n_configs=1,
        n_runs_per_world=1,
        log_folder=str(Path.home() / "negmas" / "logs" / "tests"),
    )
    df = (results.scores[["agent_type", "score"
                          ]].groupby(["agent_type"]).count().reset_index())
    assert len(results.total_scores) == n
    assert (len(df["score"].unique()) == 1
            ), f"Agents do not appear the same number of times:\n{df}"
def run(competition='std',
        reveal_names=True,
        n_steps=20,
        n_configs=2,
        max_n_worlds_per_config=None,
        n_runs_per_world=1):
    """
    **Not needed for submission.** You can use this function to test your agent.

    Args:
        competition: The competition type to run (possibilities are std, 
                     collusion).        
        n_steps:     The number of simulation steps.
        n_configs:   Number of different world configurations to try. 
                     Different world configurations will correspond to
                     different number of factories, profiles
                     , production graphs etc
        n_runs_per_world: How many times will each world simulation be run.

    Returns:
        None

    Remarks:

        - This function will take several minutes to run.
        - To speed it up, use a smaller `n_step` value        

    """
    competitors = [
        MyComponentsBasedAgent, DecentralizingAgent, BuyCheapSellExpensiveAgent
    ]
    start = time.perf_counter()
    if competition == 'std':
        results = anac2020_std(competitors=competitors,
                               verbose=True,
                               n_steps=n_steps,
                               n_configs=n_configs,
                               n_runs_per_world=n_runs_per_world)
    elif competition == 'collusion':
        results = anac2020_collusion(competitors=competitors,
                                     verbose=True,
                                     n_steps=n_steps,
                                     n_configs=n_configs,
                                     n_runs_per_world=n_runs_per_world)
    else:
        raise ValueError(f'Unknown competition type {competition}')
    print(tabulate(results.total_scores, headers='keys', tablefmt='psql'))
    print(f'Finished in {humanize_time(time.perf_counter() - start)}')