Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xavier Garrido
CAMEL
Commits
217869ae
Commit
217869ae
authored
Apr 01, 2016
by
Plaszczynski Stephane
Browse files
better seed generation
parent
1b7ffecc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
src/camel/MCMC/exec/mainMCMC.cc
src/camel/MCMC/exec/mainMCMC.cc
+13
-11
No files found.
src/camel/MCMC/exec/mainMCMC.cc
View file @
217869ae
...
...
@@ -26,8 +26,9 @@
#include <fstream>
#include <vector>
#include <ctime>
#include <stdint.h>
//#include <ctime>
#include <sys/time.h>
#include <cstdlib>
using
namespace
std
;
...
...
@@ -74,21 +75,23 @@ int main(int argc, char *argv[])
//--------defining seeds-----------------------------------------------
unsigned
int
seed
(
0
);
if
(
parser
.
params
.
param_present
(
"seed"
)){
seed
=
parser
.
params
.
find
<
int
>
(
"seed"
,
1234
);
seed
=
parser
.
params
.
find
<
int
>
(
"seed"
,
0
);
}
else
{
//pick automatiocally
time_t
result
=
time
(
NULL
);
seed
=
static_cast
<
uint32_t
>
(
result
);
else
{
//pick automatiocally: microseconds from current time
timeval
CurrentTime
;
gettimeofday
(
&
CurrentTime
,
NULL
);
seed
=
static_cast
<
unsigned
int
>
(
CurrentTime
.
tv_usec
);
}
cout
<<
"seed for proposal="
<<
seed
<<
endl
;
unsigned
int
seedU
(
0
);
//need anothe
rone for the algorithm itsel
//need another
one for the algorithm itsel
if
(
parser
.
params
.
param_present
(
"seedU"
)){
seedU
=
parser
.
params
.
find
<
int
>
(
"seedU"
,
1234
);
seedU
=
parser
.
params
.
find
<
int
>
(
"seedU"
,
0
);
}
else
{
//automatically
seedU
=
seed
%
1024
;
else
{
//throw a random number to avoid correlations
std
::
srand
(
seed
);
seedU
=
static_cast
<
unsigned
int
>
(
std
::
rand
()
%
32768
);
}
cout
<<
"seed for algorithm="
<<
seedU
<<
endl
;
...
...
@@ -175,7 +178,6 @@ int main(int argc, char *argv[])
cout
<<
"cov domove= "
<<
move
->
Get_cov_matrix
()
<<
endl
;
if
(
use_ext_cov
==
true
){
move
->
Set_cov_matrix
(
proposal
->
Get_cov_matrix
());}
HepVector
start
(
dim
);
sleep
(
1
);
move
->
init_generator
(
time
(
NULL
));
move
->
Set_scale
(
scale
);
cout
<<
"start="
<<
start
<<
endl
;
...
...
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