Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
re6stnet
Commits
eb453702
Commit
eb453702
authored
Jul 30, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Todo update
parent
82df1543
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
15 deletions
+100
-15
TODO
TODO
+3
-0
simulation/realistic_dataset/graph.cpp
simulation/realistic_dataset/graph.cpp
+77
-1
simulation/realistic_dataset/main.cpp
simulation/realistic_dataset/main.cpp
+16
-14
simulation/realistic_dataset/main.h
simulation/realistic_dataset/main.h
+4
-0
No files found.
TODO
View file @
eb453702
...
...
@@ -6,5 +6,8 @@ To be done :
Write docstrings for all class/methods/functions
We should replace dead connection much more often than we refresh tunnels otherwise, it brings instability
If we do this, we must protect some tunnels
To be discussed:
Project name ? Resinet/resnet/rsnet
simulation/realistic_dataset/graph.cpp
View file @
eb453702
...
...
@@ -11,6 +11,20 @@ Graph::Graph(int size, int k, int maxPeers, mt19937& generator, const Latency&
SaturateNode
(
i
);
}
Graph
::
Graph
(
const
Graph
&
g
)
:
generator
(
g
.
generator
),
size
(
g
.
size
),
k
(
g
.
k
),
maxPeers
(
g
.
maxPeers
),
latency
(
latency
),
distrib
(
g
.
distrib
)
{
adjacency
=
new
unordered_set
<
int
>
[
size
];
generated
=
new
unordered_set
<
int
>
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
adjacency
[
i
]
=
unordered_set
<
int
>
(
g
.
adjacency
[
i
]);
generated
[
i
]
=
unordered_set
<
int
>
(
g
.
generated
[
i
]);
}
}
void
Graph
::
SaturateNode
(
int
node
)
{
while
(
generated
[
node
].
size
()
<
k
&&
AddEdge
(
node
))
{
}
...
...
@@ -86,11 +100,12 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
}
// get the BC
// The error is here
while
(
!
order
.
empty
())
{
int
node
=
order
.
top
();
order
.
pop
();
if
(
distances
[
node
]
!=
-
1
)
if
(
distances
[
node
]
!=
-
1
&&
node
!=
from
)
nRoutes
[
prevs
[
node
]]
+=
nRoutes
[
node
];
}
}
...
...
@@ -138,21 +153,82 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
//cout << "["; cout.flush();
routesResult
r
=
results
[
i
];
if
(
r
.
toDelete
>=
0
)
RemoveEdge
(
i
,
r
.
toDelete
);
//cout << "#"; cout.flush();
SaturateNode
(
i
);
//cout << "]"; cout.flush();
avgDistance
+=
r
.
avgDistance
*
(
size
-
r
.
unreachable
);
avgDistanceWeight
+=
size
-
r
.
unreachable
;
unreachable
+=
r
.
unreachable
;
arityDistrib
[
adjacency
[
i
].
size
()]
++
;
}
avgDistance
/=
avgDistanceWeight
;
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
arityDistrib
[
i
]
/=
size
;
}
int
Graph
::
CountUnreachableFrom
(
int
node
)
{
bool
accessibility
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
accessibility
[
i
]
=
false
;
accessibility
[
node
]
=
true
;
int
unreachable
=
size
;
queue
<
int
>
toVisit
;
toVisit
.
push
(
node
);
while
(
!
toVisit
.
empty
())
{
int
n
=
toVisit
.
front
();
for
(
int
i
:
adjacency
[
n
])
{
if
(
!
accessibility
[
i
])
{
toVisit
.
push
(
i
);
accessibility
[
i
]
=
true
;
}
}
unreachable
--
;
toVisit
.
pop
();
}
return
unreachable
;
}
double
Graph
::
GetUnAvalaibility
()
{
double
moy
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
moy
+=
CountUnreachableFrom
(
i
);
return
moy
/
(
size
*
size
);
}
void
Graph
::
KillMachines
(
float
proportion
)
{
size
=
proportion
*
size
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
vector
<
int
>
toBeRemoved
;
for
(
int
j
:
adjacency
[
i
])
if
(
j
>=
size
)
toBeRemoved
.
push_back
(
j
);
for
(
int
j
:
toBeRemoved
)
{
generated
[
i
].
erase
(
j
);
adjacency
[
i
].
erase
(
j
);
}
}
}
\ No newline at end of file
simulation/realistic_dataset/main.cpp
View file @
eb453702
...
...
@@ -5,28 +5,30 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
{
FILE
*
output
=
fopen
(
outName
,
"wt"
);
int
fno
=
fileno
(
output
);
fprintf
(
output
,
"round,a
vgdistance,unreachable,arity 0..30
\n
"
);
fprintf
(
output
,
"round,a
live,unreachable
\n
"
);
mt19937
rng
(
seed
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
cout
<<
"
\r
"
<<
0
<<
"/"
<<
20
00
;
cout
<<
"
\r
"
<<
0
<<
"/"
<<
3
00
;
cout
.
flush
();
for
(
int
i
=
0
;
i
<
20
00
;
i
++
)
for
(
int
i
=
0
;
i
<
3
00
;
i
++
)
{
double
avgDistance
,
unreachable
;
double
arityDistrib
[
maxPeer
+
1
];
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
);
fprintf
(
output
,
"%d,%f,%f"
,
i
,
avgDistance
,
unreachable
);
for
(
int
j
=
0
;
j
<=
maxPeer
;
j
++
)
fprintf
(
output
,
",%f"
,
arityDistrib
[
j
]);
fprintf
(
output
,
"
\n
"
);
for
(
float
a
=
0.05
;
a
<
1
;
a
+=
0.05
)
{
Graph
copy
(
graph
);
copy
.
KillMachines
(
a
);
fprintf
(
output
,
"%d,%f,%f
\n
"
,
i
,
a
,
copy
.
GetUnAvalaibility
());
fflush
(
output
);
fsync
(
fno
);
}
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
2000
;
double
avgDistance
,
unreachable
;
double
arityDistrib
[
31
];
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
);
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
300
;
cout
.
flush
();
}
...
...
@@ -39,7 +41,7 @@ int main(int argc, char** argv)
mt19937
rng
(
time
(
NULL
));
//Latency latency("latency/pw-1715/pw-1715-latencies", 1715);
//latency.Rewrite(20);
Latency
latency
(
"latency/pw-1715/rewrite"
,
155
6
);
Latency
latency
(
"latency/pw-1715/rewrite"
,
155
5
);
vector
<
future
<
void
>>
threads
;
...
...
simulation/realistic_dataset/main.h
View file @
eb453702
...
...
@@ -27,14 +27,18 @@ class Graph
{
public:
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
);
Graph
(
const
Graph
&
g
);
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
};
void
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
);
double
GetUnAvalaibility
();
void
KillMachines
(
float
proportion
);
private:
void
SaturateNode
(
int
node
);
bool
AddEdge
(
int
from
);
void
RemoveEdge
(
int
from
,
int
to
);
void
GetRoutesFrom
(
int
from
,
int
*
nRoutes
,
int
*
prevs
,
int
*
distances
);
int
CountUnreachableFrom
(
int
node
);
mt19937
&
generator
;
uniform_int_distribution
<
int
>
distrib
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment