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 :
...
@@ -6,5 +6,8 @@ To be done :
Write docstrings for all class/methods/functions
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:
To be discussed:
Project name ? Resinet/resnet/rsnet
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&
...
@@ -11,6 +11,20 @@ Graph::Graph(int size, int k, int maxPeers, mt19937& generator, const Latency&
SaturateNode
(
i
);
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
)
void
Graph
::
SaturateNode
(
int
node
)
{
{
while
(
generated
[
node
].
size
()
<
k
&&
AddEdge
(
node
))
{
}
while
(
generated
[
node
].
size
()
<
k
&&
AddEdge
(
node
))
{
}
...
@@ -86,11 +100,12 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
...
@@ -86,11 +100,12 @@ void Graph::GetRoutesFrom(int from, int* nRoutes, int* prevs, int* distances)
}
}
// get the BC
// get the BC
// The error is here
while
(
!
order
.
empty
())
while
(
!
order
.
empty
())
{
{
int
node
=
order
.
top
();
int
node
=
order
.
top
();
order
.
pop
();
order
.
pop
();
if
(
distances
[
node
]
!=
-
1
)
if
(
distances
[
node
]
!=
-
1
&&
node
!=
from
)
nRoutes
[
prevs
[
node
]]
+=
nRoutes
[
node
];
nRoutes
[
prevs
[
node
]]
+=
nRoutes
[
node
];
}
}
}
}
...
@@ -138,21 +153,82 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
...
@@ -138,21 +153,82 @@ void Graph::UpdateLowRoutes(double& avgDistance, double unreachable, double* ari
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
{
//cout << "["; cout.flush();
routesResult
r
=
results
[
i
];
routesResult
r
=
results
[
i
];
if
(
r
.
toDelete
>=
0
)
if
(
r
.
toDelete
>=
0
)
RemoveEdge
(
i
,
r
.
toDelete
);
RemoveEdge
(
i
,
r
.
toDelete
);
//cout << "#"; cout.flush();
SaturateNode
(
i
);
SaturateNode
(
i
);
//cout << "]"; cout.flush();
avgDistance
+=
r
.
avgDistance
*
(
size
-
r
.
unreachable
);
avgDistance
+=
r
.
avgDistance
*
(
size
-
r
.
unreachable
);
avgDistanceWeight
+=
size
-
r
.
unreachable
;
avgDistanceWeight
+=
size
-
r
.
unreachable
;
unreachable
+=
r
.
unreachable
;
unreachable
+=
r
.
unreachable
;
arityDistrib
[
adjacency
[
i
].
size
()]
++
;
arityDistrib
[
adjacency
[
i
].
size
()]
++
;
}
}
avgDistance
/=
avgDistanceWeight
;
avgDistance
/=
avgDistanceWeight
;
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
for
(
int
i
=
0
;
i
<=
maxPeers
;
i
++
)
arityDistrib
[
i
]
/=
size
;
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
...
@@ -5,28 +5,30 @@ void simulate(int size, int k, int maxPeer, int seed, const Latency& latency, co
{
{
FILE
*
output
=
fopen
(
outName
,
"wt"
);
FILE
*
output
=
fopen
(
outName
,
"wt"
);
int
fno
=
fileno
(
output
);
int
fno
=
fileno
(
output
);
fprintf
(
output
,
"round,a
vgdistance,unreachable,arity 0..30
\n
"
);
fprintf
(
output
,
"round,a
live,unreachable
\n
"
);
mt19937
rng
(
seed
);
mt19937
rng
(
seed
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
Graph
graph
(
size
,
k
,
maxPeer
,
rng
,
latency
);
cout
<<
"
\r
"
<<
0
<<
"/"
<<
20
00
;
cout
<<
"
\r
"
<<
0
<<
"/"
<<
3
00
;
cout
.
flush
();
cout
.
flush
();
for
(
int
i
=
0
;
i
<
20
00
;
i
++
)
for
(
int
i
=
0
;
i
<
3
00
;
i
++
)
{
{
double
avgDistance
,
unreachable
;
for
(
float
a
=
0.05
;
a
<
1
;
a
+=
0.05
)
double
arityDistrib
[
maxPeer
+
1
];
{
graph
.
UpdateLowRoutes
(
avgDistance
,
unreachable
,
arityDistrib
);
Graph
copy
(
graph
);
copy
.
KillMachines
(
a
);
fprintf
(
output
,
"%d,%f,%f"
,
i
,
avgDistance
,
unreachable
);
fprintf
(
output
,
"%d,%f,%f
\n
"
,
i
,
a
,
copy
.
GetUnAvalaibility
());
for
(
int
j
=
0
;
j
<=
maxPeer
;
j
++
)
fprintf
(
output
,
",%f"
,
arityDistrib
[
j
]);
fprintf
(
output
,
"
\n
"
);
fflush
(
output
);
fflush
(
output
);
fsync
(
fno
);
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
();
cout
.
flush
();
}
}
...
@@ -39,7 +41,7 @@ int main(int argc, char** argv)
...
@@ -39,7 +41,7 @@ int main(int argc, char** argv)
mt19937
rng
(
time
(
NULL
));
mt19937
rng
(
time
(
NULL
));
//Latency latency("latency/pw-1715/pw-1715-latencies", 1715);
//Latency latency("latency/pw-1715/pw-1715-latencies", 1715);
//latency.Rewrite(20);
//latency.Rewrite(20);
Latency
latency
(
"latency/pw-1715/rewrite"
,
155
6
);
Latency
latency
(
"latency/pw-1715/rewrite"
,
155
5
);
vector
<
future
<
void
>>
threads
;
vector
<
future
<
void
>>
threads
;
...
...
simulation/realistic_dataset/main.h
View file @
eb453702
...
@@ -27,14 +27,18 @@ class Graph
...
@@ -27,14 +27,18 @@ class Graph
{
{
public:
public:
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
);
Graph
(
int
size
,
int
k
,
int
maxPeers
,
mt19937
&
generator
,
const
Latency
&
latency
);
Graph
(
const
Graph
&
g
);
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
};
~
Graph
()
{
delete
[]
adjacency
;
delete
[]
generated
;
};
void
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
);
void
UpdateLowRoutes
(
double
&
avgDistance
,
double
unreachable
,
double
*
arityDistrib
);
double
GetUnAvalaibility
();
void
KillMachines
(
float
proportion
);
private:
private:
void
SaturateNode
(
int
node
);
void
SaturateNode
(
int
node
);
bool
AddEdge
(
int
from
);
bool
AddEdge
(
int
from
);
void
RemoveEdge
(
int
from
,
int
to
);
void
RemoveEdge
(
int
from
,
int
to
);
void
GetRoutesFrom
(
int
from
,
int
*
nRoutes
,
int
*
prevs
,
int
*
distances
);
void
GetRoutesFrom
(
int
from
,
int
*
nRoutes
,
int
*
prevs
,
int
*
distances
);
int
CountUnreachableFrom
(
int
node
);
mt19937
&
generator
;
mt19937
&
generator
;
uniform_int_distribution
<
int
>
distrib
;
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