Algorithmique Numérique Distribuée Public GIT Repository
1 #!/usr/bin/python
3 import sys, random
5 if len(sys.argv) != 4:
6         print("Usage: python generate.py nb_nodes nb_bits end_date > deployment_file.xml")
7         sys.exit(1)
9 nb_nodes = int(sys.argv[1])
10 nb_bits = int(sys.argv[2])
11 end_date = int(sys.argv[3])
13 max_id = 2 ** nb_bits - 1
14 all_ids = [42]
16 sys.stdout.write("<?xml version='1.0'?>\n"
17 "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n"
18 "<platform version=\"3\">\n"
19 "  <process host=\"c-0.me\" function=\"node\">\n"
20 "    <argument value=\"42\"/>\n"
21 "    <argument value=\"10000\"/>\n"
22 "  </process>\n")
24 for i in range(1, nb_nodes):
26         ok = False
27         while not ok:
28                 my_id = random.randint(0, max_id)
29                 ok = not my_id in all_ids
31         known_id = all_ids[random.randint(0, len(all_ids) - 1)]
32         start_date = i * 10
33         line = "  <process host=\"c-%d.me\" function=\"node\"><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /></process>\n" % (i, my_id, known_id, start_date, end_date)
34         sys.stdout.write(line)
35         all_ids.append(my_id)
37 sys.stdout.write("</platform>")