Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SSWM_prototype
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aevol
SSWM_prototype
Commits
d1a04d4c
Commit
d1a04d4c
authored
3 years ago
by
SINDT--BARET Yanis
Browse files
Options
Downloads
Patches
Plain Diff
[Update] Rename + patch
parent
db8c4273
No related branches found
No related tags found
1 merge request
!3
[New] Add new module to AEVOL : SSWM
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/CMakeLists.txt
src/MutationFactorySswm.cpp
+14
-19
14 additions, 19 deletions
src/MutationFactorySswm.cpp
src/MutationFactorySswm.h
+3
-4
3 additions, 4 deletions
src/MutationFactorySswm.h
src/sswm.cpp
+28
-11
28 additions, 11 deletions
src/sswm.cpp
with
46 additions
and
35 deletions
src/CMakeLists.txt
+
1
−
1
View file @
d1a04d4c
...
...
@@ -19,5 +19,5 @@ target_link_libraries(module_lineage PUBLIC aevol)
add_executable
(
module_anc_stat module_anc_stat.cpp
)
target_link_libraries
(
module_anc_stat PUBLIC aevol
)
add_executable
(
sswm sswm.cpp MutationSswm.cpp
)
add_executable
(
sswm sswm.cpp Mutation
Factory
Sswm.cpp
)
target_link_libraries
(
sswm PUBLIC aevol
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/MutationSswm.cpp
→
src/Mutation
Factory
Sswm.cpp
+
14
−
19
View file @
d1a04d4c
#include
"MutationSswm.h"
#include
"Mutation
Factory
Sswm.h"
#include
"AbstractFuzzy_7.h"
#include
"AeTime.h"
#include
"DnaMutator.h"
#include
"Individual_7.h"
#include
"JumpingMT.h"
#include
"Metadata.h"
#include
"MutationDataAdapter.h"
#include
"Promoter.h"
#include
"Protein_7.h"
#include
"Rna_7.h"
#include
"MutationDataAdapter.h"
#include
"Individual_7.h"
#include
"JumpingMT.h"
#include
"DnaMutator.h"
#include
<algorithm>
#include
<chrono>
#include
<err.h>
#include
<fstream>
#include
<utility>
#include
<sys/stat.h>
#include
<utility>
MutationFactorySswm
::
MutationFactorySswm
(
std
::
shared_ptr
<
aevol
::
JumpingMT
>
prng
,
MutationParametersSswm
mut_parameters
)
{
prng_nb
=
prng
;
// permet d'eviter d'incrimenter 2 fois
mp_sswm
=
mut_parameters
;
}
MutationFactorySswm
::
MutationFactorySswm
(
int
seed
,
MutationParametersSswm
mut_parameters
)
:
mp_sswm
(
mut_parameters
),
prng_nb
(
seed
)
{}
bool
MutationFactorySswm
::
is_inversion
()
{
auto
*
probs
=
new
double
[
2
];
//
probs
[
0
]
=
mp_sswm
.
inversion_rate_
;
// par défaut [0] = prob de inversion
probs
[
1
]
=
1
-
probs
[
0
];
int
nb
=
prng_nb
->
roulette_random
(
probs
,
2
);
int
nb
=
prng_nb
.
roulette_random
(
probs
,
2
);
return
nb
==
0
;
// par defition on 0 = inversion
}
...
...
@@ -41,12 +36,12 @@ aevol::MutationEvent MutationFactorySswm::do_mutation(int dna_lenght) {
// _____ If inversion
if
(
is_inversion_bool
)
{
int32_t
pos_1
,
pos_2
;
pos_1
=
prng_nb
->
random
(
dna_lenght
);
pos_2
=
prng_nb
->
random
(
dna_lenght
);
pos_1
=
prng_nb
.
random
(
dna_lenght
);
pos_2
=
prng_nb
.
random
(
dna_lenght
);
while
(
pos_2
==
pos_1
)
{
pos_2
=
prng_nb
->
random
(
dna_lenght
);
pos_2
=
prng_nb
.
random
(
dna_lenght
);
}
// if (pos_1 == pos_2) return nullptr; // Invert everything <=> Invert nothing!
...
...
@@ -62,7 +57,7 @@ aevol::MutationEvent MutationFactorySswm::do_mutation(int dna_lenght) {
}
// _____If not inversion
else
{
int32_t
pos
=
prng_nb
->
random
(
dna_lenght
);
int32_t
pos
=
prng_nb
.
random
(
dna_lenght
);
auto
mevent
=
aevol
::
MutationEvent
();
mevent
.
switch_pos
(
pos
);
// printf("Its a ponctual mutation\n");
...
...
This diff is collapsed.
Click to expand it.
src/MutationSswm.h
→
src/Mutation
Factory
Sswm.h
+
3
−
4
View file @
d1a04d4c
...
...
@@ -20,11 +20,10 @@ struct MutationParametersSswm {
class
MutationFactorySswm
{
bool
is_inversion
();
MutationParametersSswm
mp_sswm
{}
;
std
::
shared_ptr
<
aevol
::
JumpingMT
>
prng_nb
;
const
MutationParametersSswm
mp_sswm
;
aevol
::
JumpingMT
prng_nb
;
public:
MutationFactorySswm
(
std
::
shared_ptr
<
aevol
::
JumpingMT
>
prng
,
MutationParametersSswm
mut_parameters
);
MutationFactorySswm
(
int
seed
,
MutationParametersSswm
mut_parameters
);
aevol
::
MutationEvent
do_mutation
(
int
dna_lenght
);
...
...
This diff is collapsed.
Click to expand it.
src/sswm.cpp
+
28
−
11
View file @
d1a04d4c
...
...
@@ -4,12 +4,12 @@
#include
"Individual_7.h"
#include
"json.hpp"
#include
"JumpingMT.h"
#include
"MutationSswm.h"
#include
"Mutation
Factory
Sswm.h"
#include
<iomanip>
#include
<iostream>
#include
<string>
#include
<vector>
#include
<iostream>
using
namespace
aevol
;
using
json
=
nlohmann
::
json
;
...
...
@@ -75,7 +75,7 @@ void from_json(const json& j, Parameters& p) {
}
int
main
(
int
argc
,
char
*
argv
[])
{
// USAGE: program GENE_JSON_FILE MUTATION_RATE NB_GENERATION NEUTRAL_MUTATION_BOOL
if
(
argc
!=
5
)
{
if
(
argc
!=
6
and
argc
!=
5
)
{
printf
(
"!!!
\n
Please don't forget to write the json file then the"
" inversion rate, the number of generation"
" and to chose if neutral mutation are selected
\n
!!!
\n
"
);
...
...
@@ -92,6 +92,10 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
const
float
inversion_rate
=
std
::
stof
(
argv
[
2
]);
const
long
nb_gen
=
std
::
stol
(
argv
[
3
]);
const
std
::
string
if_eq
=
argv
[
4
];
std
::
string
hikes
;
if
(
argc
==
6
)
{
hikes
=
argv
[
5
];
}
json
inputs
;
input_file
>>
inputs
;
...
...
@@ -120,9 +124,6 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
}
FuzzyFactory_7
fuzzyFactory
(
VECTOR
,
p
.
sampling
);
auto
*
target
=
define_target
(
gaussians
,
p
.
sampling
,
fuzzyFactory
);
JumpingMT
prng
(
p
.
seed
);
// générateur de nombre aléatoire à partir d'une seed.
const
auto
&
seq
=
inputs
.
at
(
"individual"
).
get
<
std
::
string
>
();
int
src_seq_length
=
seq
.
length
();
...
...
@@ -137,7 +138,6 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
Individual_7
*
new_indiv
=
nullptr
;
auto
*
fuzzyFac
=
&
fuzzyFactory
;
auto
prng_shared_ptr
=
std
::
make_shared
<
aevol
::
JumpingMT
>
(
prng
);
// ici on crééer un shared pointeur (le truc a droite permet de faire un shared pointeur)
const
int
dna_length
=
individual
->
dna_
->
length
();
long
good_mut
=
0
;
long
neutral_mut
=
0
;
...
...
@@ -156,19 +156,23 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
underscore
+
if_eq
+
underscore
+
hikes
+
underscore
+
extension
;
std
::
ofstream
output_evol_file
(
result_evol_file
);
output_evol_file
<<
" nb_gen,non_mutant,mutant,mutation"
<<
std
::
endl
;
MutationFactorySswm
mutationFactorySswm
(
prng_shared_ptr
,
mp
);
// Création de la fabrique de mutation, la seed permet d'initialiser le
// générateur de nombre aléatoire interne
MutationFactorySswm
mutationFactorySswm
(
p
.
seed
,
mp
);
if
(
not
output_evol_file
.
is_open
())
{
fprintf
(
stderr
,
"Error, cannot open file %s
\n
"
,
result_evol_file
.
c_str
());
// utilisation de `fprintf` parmet d'écrire spécifiquement dans le stderr. C'est explicitement une erreur
exit
(
EXIT_FAILURE
);
}
for
(
int
i
=
0
;
i
<
=
nb_gen
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nb_gen
;
i
++
)
{
auto
mutationEvent
=
mutationFactorySswm
.
do_mutation
(
dna_length
);
new_indiv
=
new
aevol
::
Individual_7
(
individual
);
new_indiv
->
dna_
->
apply_mutation
(
mutationEvent
);
...
...
@@ -187,9 +191,15 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
else
if
(
individual
->
fitness
==
new_indiv
->
fitness
and
if_eq
==
"y"
)
{
delete
individual
;
individual
=
new_indiv
;
output_evol_file
<<
i
<<
","
<<
individual
->
fitness
<<
","
<<
new_indiv
->
fitness
<<
","
<<
mutationEvent
.
type
()
<<
std
::
endl
;
neutral_mut
++
;
}
else
{
output_evol_file
<<
i
<<
","
<<
individual
->
fitness
<<
","
<<
new_indiv
->
fitness
<<
","
<<
mutationEvent
.
type
()
<<
std
::
endl
;
delete
new_indiv
;
new_indiv
=
nullptr
;
}
...
...
@@ -206,8 +216,15 @@ int main(int argc, char* argv[]) { // USAGE: program GENE_JSON_FILE MUTATION_RAT
inputs
[
"individual"
]
=
result
;
std
::
string
base_result_file
=
"sswm_result_"
;
std
::
string
result_file
=
base_result_file
+
nbgen_result_file
+
underscore
+
prob_result_file
+
underscore
+
if_eq
+
underscore
+
std
::
string
result_file
=
base_result_file
+
nbgen_result_file
+
underscore
+
prob_result_file
+
underscore
+
if_eq
+
underscore
+
hikes
+
underscore
+
who_result_file
;
std
::
ofstream
output_file
(
result_file
);
output_file
<<
std
::
setw
(
2
)
<<
inputs
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment