File size: 1,511 Bytes
7180a66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import random
import srsly
from tqdm import tqdm


def load_task_init_mas(n: int, k: int):
    N, K = n, k
    l = random.sample(range(N * K * 10), N * K)
    ans = sorted(l)
    random.shuffle(l)
    agent_input = [l[i * K : i * K + K] for i in range(N)]
    expected_agent_ans = [ans[i * K : i * K + K] for i in range(N)]
    dataset = []
    for i in tqdm(range(n)):
        prompt = f"""
You are Agent-{i} in a multi agent system.
Your task is to output `ys[{i}]` given `xs[{i}]` that passes the following `check_results` by cooperating with other agents.
You can use the given tools to use the BBS for communication. When you have the final answer, submit it using the given `submit` tool.

```
def check_results(n: int, k: int, xs: list[list[int]], ys: list[list[int]]):
    xl = []
    for x in xs:
        xl += x
    xl.sort()
    yl = []
    if len(ys) != n:
        return False
    for y in ys:
        if len(y) != k:
            return False
        yl += y
    return xl == yl
```
n = {N}
k = {K}
xs[{i}] = {agent_input[i]}
"""
        agent = {
            "agent_id": i,
            "prompt": prompt,
            "input_data": agent_input[i],
            "expected_output": expected_agent_ans[i],
        }
        dataset.append(agent)
    return {"n": n, "k": k, "agents": dataset}


if __name__ == "__main__":
    k = 10
    for ne in range(1, 7):
        n = 10**ne
        dataset = load_task_init_mas(n, k)
        srsly.write_json(f"masc/task_n{n}_k{k}.json", dataset)
        print(ne)