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
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
re6stnet
Commits
2776b12a
Commit
2776b12a
authored
Jul 11, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
You can now simulate the failure of a given percentage of the nodes
parent
3445fe8e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
simulation/graph.cpp
simulation/graph.cpp
+12
-1
simulation/main.cpp
simulation/main.cpp
+11
-10
No files found.
simulation/graph.cpp
View file @
2776b12a
...
...
@@ -50,5 +50,16 @@ void Graph::GetDistancesFrom(int node, int* distance)
// kill the last proportion*size machines of the graph
void
Graph
::
KillMachines
(
float
proportion
)
{
// TODO
size
=
proportion
*
size
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
auto
it
=
adjacency
[
i
].
begin
();
while
(
it
!=
adjacency
[
i
].
end
())
{
if
(
*
it
>=
size
)
it
=
adjacency
[
i
].
erase
(
it
);
else
it
++
;
}
}
}
simulation/main.cpp
View file @
2776b12a
...
...
@@ -6,14 +6,14 @@
const
char
*
outName
=
"out.csv"
;
Results
Simulate
(
mt19937
rng
,
int
n
,
int
k
,
int
maxPeer
,
int
maxDistanceFrom
,
int
runs
)
Results
Simulate
(
mt19937
rng
,
int
n
,
int
k
,
int
maxPeer
,
int
maxDistanceFrom
,
float
alivePercent
,
int
runs
)
{
Results
results
(
maxPeer
,
20
);
for
(
int
r
=
0
;
r
<
runs
;
r
++
)
{
Graph
graph
(
n
,
k
,
maxPeer
,
rng
);
graph
.
KillMachines
(
alivePercent
);
results
.
UpdateArity
(
graph
);
// Compute the shortest path
...
...
@@ -34,20 +34,21 @@ int main(int argc, char** argv)
mt19937
rng
(
time
(
NULL
));
fstream
output
(
outName
,
fstream
::
out
);
output
<<
"n,k,maxPeer,avgDistance,disconnected,maxDistance,maxArityDistrib"
<<
endl
;
output
<<
"n,k,maxPeer,avgDistance,disconnected,
disconnectionProba,
maxDistance,maxArityDistrib"
<<
endl
;
vector
<
future
<
string
>>
outputStrings
;
for
(
int
n
=
200
;
n
<=
20000
;
n
*=
2
)
for
(
int
k
=
5
;
k
<=
50
;
k
+=
5
)
for
(
int
n
=
200
;
n
<=
200
;
n
*=
2
)
for
(
int
k
=
10
;
k
<=
10
;
k
+=
5
)
for
(
float
a
=
0.05
;
a
<
1
;
a
+=
0.05
)
{
outputStrings
.
push_back
(
async
(
launch
::
async
,
[
rng
,
n
,
k
]()
outputStrings
.
push_back
(
async
(
launch
::
async
,
[
rng
,
n
,
k
,
a
]()
{
Results
results
=
Simulate
(
rng
,
n
,
k
,
3
*
k
,
10000
,
5
0
);
Results
results
=
Simulate
(
rng
,
n
,
k
,
3
*
k
,
10000
,
a
,
10
0
);
ostringstream
out
;
out
<<
n
<<
","
<<
k
<<
","
<<
3
*
k
<<
","
<<
results
.
avgDistance
<<
","
<<
results
.
disconnected
<<
","
<<
results
.
maxDistance
<<
","
<<
results
.
arityDistrib
[
3
*
k
];
<<
results
.
disconnected
<<
","
<<
results
.
disconnectionProba
<<
","
<<
results
.
maxDistanceReached
<<
","
<<
results
.
arityDistrib
[
3
*
k
];
return
out
.
str
();
}));
...
...
@@ -59,7 +60,7 @@ int main(int argc, char** argv)
for
(
int
i
=
0
;
i
<
nTask
;
i
++
)
{
output
<<
outputStrings
[
i
].
get
()
<<
endl
;
cout
<<
"
\r
"
<<
i
<<
"/"
<<
nTask
;
cout
<<
"
\r
"
<<
i
+
1
<<
"/"
<<
nTask
;
cout
.
flush
();
}
...
...
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