Ejemplo n.º 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)}")
Ejemplo n.º 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}")
Ejemplo n.º 3
0
def test_std(n):
    competitors = [eval(f"MyAgent{_}") for _ in range(n)]
    results = anac2020_std(
        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}"
Ejemplo n.º 4
0
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)}')
Ejemplo n.º 5
0
import numpy as np

# to run collusion tournament from scml.scml2020.utils import anac2020_collusion

agent_types = [
    DecentralizingAgent,
    BuyCheapSellExpensiveAgent,
    IndDecentralizingAgent,
    MovingRangeAgent,
]
tournament_types = agent_types + [RandomAgent]

results = anac2020_std(
    competitors=tournament_types,
    n_configs=12,  # number of different configurations to generate
    n_runs_per_world=
    1,  # number of times to repeat every simulation (with agent assignment)
    n_steps=10,  # number of days (simulation steps) per simulation
    print_exceptions=True,
)
# the winner
print(results.winners)

# num of simulations
len(results.scores.run_id.unique())

print(results.score_stats)
print(results.total_scores)

# activity levels per simulation
plt.errorbar(
    range(len(results.agg_stats)),