• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atlanticwave-sdx / pce / 3696789509

pending completion
3696789509

Pull #81

github

GitHub
<a href="https://github.com/atlanticwave-sdx/pce/commit/<a class=hub.com/atlanticwave-sdx/pce/commit/<a class="double-link" href="https://git"><a class=hub.com/atlanticwave-sdx/pce/commit/<a class="double-link" href="https://git"><a class=hub.com/atlanticwave-sdx/pce/commit/<a class="double-link" href="https://git"><a class=hub.com/atlanticwave-sdx/pce/commit/<a class="double-link" href="https://git"><a class=hub.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd">ff0d02016">&lt;a href=&quot;https://github.com/atlanticwave-sdx/pce/commit/</a><a class="double-link" href="https://github.com/atlanticwave-sdx/pce/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/atlanticwave-sdx/pce/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/atlanticwave-sdx/pce/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/atlanticwave-sdx/pce/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/atlanticwave-sdx/pce/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd">ff0d02016</a><a href="https://github.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd">&quot;&gt;&amp;lt;a href=&amp;quot;https://github.com/atlanticwave-sdx/pce/commit/&lt;/a&gt;&lt;a class=&quot;double-link&quot; href=&quot;https://github.com/atlanticwave-sdx/pce/commit/&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://git&quot;&gt;&amp;lt;a class=&lt;/a&gt;hub.com/atlanticwave-sdx/pce/commit/&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://git&quot;&gt;&amp;lt;a class=&lt;/a&gt;hub.com/atlanticwave-sdx/pce/commit/&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://git&quot;&gt;&amp;lt;a class=&lt;/a&gt;hub.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd&quot;&gt;ff0d02016&lt;/a&gt;&lt;a href=&quot;https://github.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd&quot;&gt;&amp;lt;a href=&amp;quot;https://github.com/atlanticwave-sdx/pce/commit/ff0d020164dd0bf2808d409fdfccaf947aaeeadd&amp;quot;&amp;gt;&amp;amp;quot;&amp;amp;gt;&amp;amp;amp;lt;a href=&amp;amp;amp;quot;https://github.com/atlanti... (continued)
Pull Request #81: Update coveralls.io configuration

845 of 1796 relevant lines covered (47.05%)

1.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.42
/src/Utility/randomConnectionGenerator.py
1
import json
3✔
2

3
import numpy as np
3✔
4

5

6
class RandomConnectionGenerator:
3✔
7
    def __init__(self, N):
3✔
8
        """
9
        init
10
        @param N number of nodes of the topology
11
        """
12
        self.num_nodes = N
3✔
13

14
    # Output: list of tuples of request
15
    def randomConnectionGenerator(self, querynum, l_bw, u_bw, l_lat, u_lat, seed=2022):
3✔
16
        """
17
        Create a random TM
18
        @param querynum number of connections
19
        @return a list of connections, each of which is a list [src, des, bw, lat]
20
        """
21
        np.random.seed(seed)
3✔
22
        connection = []
3✔
23
        bw = self.lognormal((l_bw + u_bw) / 2.0, 1, querynum)
3✔
24
        if querynum <= self.num_nodes:
3✔
25
            for i in range(querynum):
3✔
26
                query = []
3✔
27
                query.append(np.random.randint(1, (self.num_nodes + 1) / 2.0))
3✔
28
                query.append(
3✔
29
                    np.random.randint((self.num_nodes + 1) / 2.0, self.num_nodes)
30
                )
31
                # query.append(np.random.randint(l_bw, u_bw))
32
                query.append(bw[i])
3✔
33
                query.append(np.random.randint(l_lat, u_lat))
3✔
34
                connection.append(tuple(query))
3✔
35
        else:
36
            for i in range(querynum):
×
37
                query = []
×
38
                src = np.random.randint(0, self.num_nodes)
×
39
                query.append(src)
×
40
                dest = np.random.randint(0, self.num_nodes)
×
41
                while dest == src:
×
42
                    dest = np.random.randint(0, self.num_nodes)
×
43
                query.append(dest)
×
44
                # query.append(np.random.randint(l_bw, u_bw))
45
                query.append(bw[i])
×
46
                query.append(np.random.randint(l_lat, u_lat))
×
47
                connection.append(tuple(query))
×
48

49
        with open("connection.json", "w") as json_file:
3✔
50
            data = connection
3✔
51
            json.dump(data, json_file, indent=4)
3✔
52

53
        return connection
3✔
54

55
    def lognormal(self, mu, sigma, size):
3✔
56
        normal_std = 0.5
3✔
57
        # normal_std = np.sqrt(np.log(1 + (sigma/mu)**2))
58
        normal_mean = np.log(mu) - normal_std**2 / 2
3✔
59
        return np.random.lognormal(normal_mean, normal_std, size)
3✔
60

61
    def random(self, min, mx, size):
3✔
62
        return np.random.randint(min, max, 1000)
×
63

64
    def linearGrouping(self, tm, k):
3✔
65
        if len(tm) > 20:
×
66
            tm.sort(key=lambda x: x[2])
×
67

68
        group_list = [tm[x : x + k] for x in range(0, len(tm), k)]
×
69

70
        # with open('splittedconnection.json', 'w') as json_file:
71
        #    data = splitted_list
72
        #    json.dump(data, json_file, indent=4)
73

74
        print(group_list)
×
75

76
        return group_list
×
77

78
    def geometricGrouping(self, tm, k):
3✔
79
        pass
×
80

81
    def altGeometricGrouping(self, tm, k):
3✔
82
        pass
×
83

84

85
# tm = RandomConnectionGenerator(20)
86
# connection = tm.randomConnectionGenerator(3, 100, 1000, 1000, 1500, 2022)
87
# split_connection = tm.connectionSplitter(5)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc