Mentions légales du service

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rouzaudc/aevol
  • aevol/aevol
  • tgrohens/aevol
  • mfoley/aevol
  • jluisell/aevol
  • jluisell/aevol-eukaryotes
  • rouzaudc/aevol-asyncgarbage
  • elie.dumont/aevol
8 results
Show changes
Commits on Source (51)
Showing
with 7023 additions and 252 deletions
......@@ -30,6 +30,11 @@ src/post_treatments/aevol_misc_template
src/post_treatments/aevol_misc_view_generation
*.o
# ignore build dir
build/**
# ignore .idea dir (clion config)
.idea/**
# ignore the files that are generated from the user guide source
doc/user_guide/user_manual.aux
......@@ -41,11 +46,12 @@ doc/user_guide/user_manual.toc
# ignore performance records
perf.data*
# ignore example generated files
# i.e. ignore everything under examples directory
examples/*/**
# but consider param.in files
!examples/**/param.in
!examples/**/README
#ignore the tmp dir
tmp/**
cmake_minimum_required(VERSION 3.2)
project(aevol_regul)
# ============================================================================
# Require minimal version of cmake
# ============================================================================
cmake_minimum_required(VERSION 3.0.2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(aevol_regul ${SOURCE_FILES} src/libaevol/HabitatFactory.cpp src/libaevol/HabitatFactory.h)
# ============================================================================
# Set project name and languages
# ============================================================================
project(aevol VERSION 5.0 LANGUAGES C CXX)
add_definitions(-DVERSION="${PROJECT_VERSION}")
# Temporary stuff to be fully integrated into CMake
add_definitions(-DSFMT_MEXP=607)
add_definitions(-D__X11)
add_definitions(-DDEBUG)
FIND_PACKAGE ( X11 REQUIRED )
IF ( X11_FOUND )
INCLUDE_DIRECTORIES ( ${X11_INCLUDE_DIR} )
LINK_LIBRARIES ( ${X11_LIBRARIES} )
ENDIF ( X11_FOUND )
# ============================================================================
# Get GNU standard installation directories (GNUInstallDirs module)
# ============================================================================
include(GNUInstallDirs)
# ============================================================================
# Tell CMake where to look for custom modules
# ============================================================================
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# ============================================================================
# Tell cmake where to put binary files.
# By GNU standards "executable programs that users can run" should go in
# bindir a.k.a ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
# and "executable programs to be run by other programs rather than by users"
# in libexecdir a.k.a ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}
# ============================================================================
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
# ============================================================================
# Set build type specific compilation flags
# ============================================================================
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
# ============================================================================
# Tell cmake about subdirectories to look into
# ============================================================================
add_subdirectory(src)
# ============================================================================
# Adds the 'dist' target (that will use CPack)
# ============================================================================
#add_custom_target(dist COMMAND ${CMAKE_BUILD_TOOL} package_source)
# ============================================================================
# Add the 'uninstall' target (uses a custom script)
# ============================================================================
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
......@@ -5,10 +5,14 @@ RELEASE HowTo
-> in all the manpages (update date too)
-> in the user guide (if needed)
2) Write an entry in the NEWS file
2) Write an entry in the NEWS file for users
and in ChangeLog for developers.
3) [TEMPORAIRE tant que les tests sont quasi inexistants]
-> Virer les tests
3) [TEMPRORARY as long as tests are scarce]
-> Remove tests directories
-> Remove references to tests in configure.ac, src/Makefile.am
3') Clean up examples: remove all computed data files
4) Run the following commands (from aevol root dir)
-> autoreconf
......@@ -17,7 +21,6 @@ RELEASE HowTo
This will generate a file called aevol-X.Y.tar.gz in aevol root dir
5) Add a version in the "files" section of the forge
-> In the "files" section click on the link to "create a new version"
-> Fill in the form with
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
doc/dev/include/link.png

189 B

/* General CSS */
body {
background-color: #fff;
color: #333;
font-family: sans-serif;
font-size: 10pt;
margin-right: 100px;
margin-left: 100px;
}
h1 {
text-align: center;
font-size: 18pt;
}
h1, h2, h3, h4, h5, h6 {
color: #06c;
margin-top: 2em;
margin-bottom: 1em;
padding: 25px;
font-weight:bold;
}
h2,
h3,
h4,
h5,
h6 {
margin-top:1.5em;
margin-bottom:.75em;
}
h1 {font-size:200%;}
h2 {font-size:167%;}
h3 {font-size:133%;}
h4 {font-size:120%;}
h5 {font-size:110%;}
table {
border: 1px solid #bbb;
border-spacing: 0;
border-collapse: collapse;
margin: 0 0 1.5em;
vertical-align: middle;
width: 100%
}
td, th {
border: 1px solid #ccc;
padding: 2px 12px;
font-size: 10pt;
}
code, samp, var {
background-color:#FAFAFA;
white-space: nowrap
}
pre {
padding:6px 10px;
background-color:#FAFAFA;
border:1px solid #bbb;
overflow:auto;
}
pre.prettyprint {
padding:6px 10px !important;
border:1px solid #bbb !important;
}
code.bad, code.badcode {
color: magenta;
}
pre.bad, pre.badcode {
background-color:#ffe6d8;
border-top:1px inset #a03;
border-left:1px inset #a03;
}
hr {
margin-top: 3.5em;
border-width: 1px;
color: #fff;
}
/* TOC CSS */
table.columns {
border: none;
}
td.two_columns {
-webkit-column-count: 2;
column-count: 2;
}
.toc_category {
font-size: 10pt;
padding-top: 1em;
padding-bottom: 1em;
border-left-width: 2px;
border-right-width: 2px;
border-color: grey;
}
.toc_stylepoint {
font-size: 10pt;
padding-top: 1em;
padding-bottom: 1em;
}
li.toc_entry {
padding-right: 1em;
display: inline;
list-style-type: none;
}
/*
* This space is required to trigger the linewrap on the links
* at href boundaries
*/
li.toc_entry::after {
content: " ";
}
li.toc_entry a {
white-space: nowrap;
}
/* Horizontal TOC */
.toc td, .toc th {
border-width: 1px 5px;
overflow: hidden;
}
/* Vertical TOC */
.toc td.two_columns {
border-width: 0px;
}
/* Special Sections */
address {
text-align: right;
}
.revision {
text-align: right;
}
.headerbox {
margin-left: 50%;
font-size: 75%;
}
.legend {
padding-top: 1em;
margin-left: 50%;
font-size: 10pt;
}
.link_button {
float: left;
display: none;
background-color: #f8f8ff;
border-color: #f0f0ff;
border-style: solid;
border-width: 1px;
font-size: 75%;
margin-top: 0;
margin-left: -50px;
padding: 24px;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
.ignoreLink {
padding: 0px;
}
.divider{
width:5px;
height:auto;
display:inline-block;
}
/* Style Guide semantic CSS */
.summary {
margin-top: 1em;
margin-bottom: 1em;
}
.stylebody {
margin-top: 1em;
margin-bottom: 1em;
}
.stylepoint_section {
display: block;
margin-bottom: 1em;
font-family: sans-serif;
font-weight: bold;
}
.stylepoint_subsection {
display: block;
margin-bottom: 1em;
}
.stylepoint_subsubsection {
display: block;
margin-bottom: 1em;
}
.definition:before {
content: "Definition: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
.pros:before {
content: "Pros: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
.cons:before {
content: "Cons: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
.decision:before {
content: "Decision: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
.exception:before {
content: "Exception: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
.note:before {
content: "Note: ";
font-weight: bold;
display: block;
margin-bottom: 1em;
}
TocTypeEnum = {
VERTICAL: 1,
HORIZONTAL: 2
};
function CreateTOC(tocElement) {
// Find the toc element DIV. We'll place our TOC there.
var toc = document.getElementById(tocElement);
var tocTypeClass = toc.className;
var tocType;
switch (tocTypeClass) {
case 'horizontal_toc':
tocType = TocTypeEnum.HORIZONTAL;
break;
case 'vertical_toc':
tocType = TocTypeEnum.VERTICAL;
break;
default:
tocType = TocTypeEnum.VERTICAL;
break;
}
// If toc_levels is defined, set headingLevels to it.
// Otherwise, use default value of "h2,h3"
var headingLevels;
if (typeof toc_levels === 'undefined') {
headingLevels = 'h2,h3';
} else {
}
// Collect all section heading elements in an array
var headings = document.querySelectorAll(headingLevels);
// Add TOC title elements
var tocHeadingDiv = document.createElement('div');
toc.appendChild(tocHeadingDiv);
tocHeadingDiv.className = 'toc_title';
var tocHeading = document.createElement('h3');
toc.appendChild(tocHeading);
tocHeading.className = 'ignoreLink';
tocHeading.id = 'toc';
var tocText = document.createTextNode('Table of Contents');
tocHeading.appendChild(tocText);
// Add table and tbody
var tocTable = document.createElement('table');
if (tocType == TocTypeEnum.VERTICAL) {
tocTable.className = 'columns';
}
toc.appendChild(tocTable);
var tbody_element = document.createElement('tbody');
tbody_element.setAttribute('valign', 'top');
tbody_element.className = 'toc';
tocTable.appendChild(tbody_element);
// Get the highest level heading
var firstHeading = headings[0];
var masterLevel = parseInt(headingLevels.charAt(1));
// Get the lowest heading level
var lowestLevel = parseInt(headingLevels.charAt(headingLevels - 1));
switch (tocType) {
case TocTypeEnum.HORIZONTAL:
CreateHorizontalTOC(headings, masterLevel, lowestLevel, tbody_element);
break;
case TocTypeEnum.VERTICAL:
CreateVerticalTOC(headings, masterLevel, lowestLevel, tbody_element);
break;
default:
}
}
function CreateHorizontalTOC(
headings, masterLevel, lowestLevel, tbody_element) {
// Initialize the header counter
var h = 0;
var ignoreChildren = false;
while (h < headings.length) {
// Get current heading
var heading = headings[h];
// Get the current heading level
var level = parseInt(heading.tagName.charAt(1));
if (isNaN(level) || level < 1 || level > lowestLevel) continue;
// If level is a masterLevel, make it a TOC parent category
if ((level == masterLevel) && (!hasClass(heading, 'ignoreLink'))) {
toc_current_row = AddTOCMaster(tbody_element, heading);
ignoreChildren = false;
}
if ((level == masterLevel) && (hasClass(heading, 'ignoreLink'))) {
ignoreChildren = true;
}
if ((level != masterLevel) && (!ignoreChildren)) {
AddTOCElements(toc_current_row, heading);
}
// Advance the header counter
h++;
}
}
// Adds a master Table of Content heading
function AddTOCMaster(tocTable, heading) {
// Add the table row scaffolding
var toc_tr = document.createElement('tr');
tocTable.appendChild(toc_tr);
toc_tr.setAttribute('valign', 'top');
var toc_tr_td = document.createElement('td');
toc_tr.appendChild(toc_tr_td);
var toc_category = document.createElement('div');
toc_tr_td.appendChild(toc_category);
toc_category.className = 'toc_category';
// Create the link to this header
var link = document.createElement('a');
link.href = '#' + heading.id; // Create the anchor link
link.textContent = heading.textContent; // Link text is same as heading
toc_category.appendChild(link);
// Add the container table cell for its children
var toc_td = document.createElement('td');
toc_tr.appendChild(toc_td);
var toc_td_div = document.createElement('div');
toc_td_div.className = 'toc_stylepoint';
toc_td.appendChild(toc_td_div);
return (toc_td_div);
}
// Adds Table of Contents element to a master heading as children
function AddTOCElements(toc_div, heading) {
if (heading.offsetParent === null) {
// The element is currently hidden, so don't create a TOC entry
} else {
// Create the list item element
var toc_list_element = document.createElement('li');
toc_list_element.className = 'toc_entry';
toc_div.appendChild(toc_list_element);
// Create the link to this header
var link = document.createElement('a');
link.href = '#' + heading.id; // Create the anchor link
link.textContent = heading.textContent; // Link text is same as heading
toc_list_element.appendChild(link);
}
}
function CreateVerticalTOC(headings, masterLevel, lowestLevel, tbody_element) {
// Create the Column scaffolding
var toc_tr = document.createElement('tr');
tbody_element.appendChild(toc_tr);
var toc_tr_td = document.createElement('td');
toc_tr_td.className = 'two_columns';
toc_tr.appendChild(toc_tr_td);
// Initialize the header counter and the current row
var h = 0;
var toc_current_col = null;
var ignoreChildren = false;
while (h < headings.length) {
// Get current heading
var heading = headings[h];
// Get the current heading level
var level = parseInt(heading.tagName.charAt(1));
if (isNaN(level) || level < 1 || level > lowestLevel) continue;
// If level is a masterLevel, make it a TOC parent category
if ((level == masterLevel) && (!hasClass(heading, 'ignoreLink'))) {
if (heading.offsetParent === null) {
// The element is currently hidden, so don't create a TOC entry
} else {
var td_dl = document.createElement('dl');
toc_tr_td.appendChild(td_dl);
var td_dt = document.createElement('dt');
td_dl.appendChild(td_dt);
toc_current_col = td_dl;
// Create the link to this header
var link = document.createElement('a');
link.href = '#' + heading.id; // Create the anchor link
link.textContent = heading.textContent; // Link text is same as heading
td_dt.appendChild(link);
ignoreChildren = false;
}
}
// If level is a masterLevel but it's specified to ignore links, skip it
// and its children.
if ((level == masterLevel) && (hasClass(heading, 'ignoreLink'))) {
ignoreChildren = true;
}
if ((level != masterLevel) && (!ignoreChildren)) {
if (heading.offsetParent === null) {
// The element is currently hidden, so don't create a TOC entry
} else {
var td_dd = document.createElement('dd');
toc_current_col.appendChild(td_dd);
// Create the link to this header
var link = document.createElement('a');
link.href = '#' + heading.id; // Create the anchor link
link.textContent = heading.textContent; // Link text is same as heading
td_dd.appendChild(link);
}
}
// Advance the header counter
h++;
}
}
/*
* Utility function for finding elements with a given
* class.
*/
function hasClass(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
/*
* Linkify all h2 through h4 headers, except for those marked
* "ignoreLink"
*/
// Add the link image to the element.
function LinkifyHeader(header, fileName, sizePixels) {
var link = document.createElement('a');
link.href = '#' + header.id;
link.alt = 'link to ' + header.id;
link.innerHTML =
'<img src="include/' + fileName + '"' +
' width=' + sizePixels +
' height=' + sizePixels +
' style="float:left;position:relative;bottom:5px;">';
header.appendChild(link);
}
// Find all elements of the given tag and linkify if
// they don't have 'ignoreLink' in their class.
function LinkifyHeadersForTag(tagName) {
var headers = document.getElementsByTagName(tagName);
var header;
for (var j = 0; j != headers.length; j++) {
header = headers[j];
if (!hasClass(header, 'ignoreLink') && ('id' in header)) {
if (header.id != '') {
LinkifyHeader(header, 'link.png', 21);
header.style.left = '-46px';
header.style.position = 'relative';
}
}
}
}
// Linkify all h2, h3, and h4s. h1s are titles.
function LinkifyHeaders() {
LinkifyHeadersForTag('h2');
LinkifyHeadersForTag('h3');
LinkifyHeadersForTag('h4');
}
/*
* Initialize the style guide by showing all internal
* elements and then linkifying the headers.
*/
function initStyleGuide() {
LinkifyHeaders();
CreateTOC('tocDiv');
}
###################################
# AEVOL PARAMATERS #
# AEVOL PARAMETERS #
###################################
##### 1. Initial setup ############
......@@ -9,7 +9,7 @@ INIT_POP_SIZE 1024
WORLD_SIZE 32 32
INIT_METHOD ONE_GOOD_GENE CLONE
CHROMOSOME_INITIAL_LENGTH 5000
FUZZY_FLAVOR 0
FUZZY_FLAVOR 0
##### 2. Selection ################
SELECTION_SCHEME fitness_proportionate 1000
......
......@@ -70,7 +70,7 @@ class raevol_matrix(Engine):
job_is_dead = False
# While there are combinations to treat
while len(self.sweeper.get_remaining()) > 0:
while len(self.sweeper.get_remaining()) > 0 or len(self.sweeper.get_inprogress()) > 0:
# If no job, we make a reservation and prepare the hosts for the experiments
if self.oar_job_id is None:
self.submit_all_available_best_effort(self.list_of_clusters, self.options.walltime)
......@@ -131,6 +131,9 @@ class raevol_matrix(Engine):
if not t.is_alive():
del threads[t]
logger.info('Waiting for threads to complete')
if not self.is_job_alive():
job_is_dead = True
break
sleep(20)
break
......@@ -269,6 +272,13 @@ class raevol_matrix(Engine):
bucketname = self.working_dir+'/raevol_5_mut_lat/'+slugify(comb)+'/'
logger.info(thread_name + "Killing other RAevol")
killa = Remote("killall -9 aevol_run",[host])
for killp in killa.processes:
killp.ignore_error = True
killa.run()
if os.path.isdir(bucketname) and os.path.exists(bucketname+'/last_gener.txt'):
logger.info(thread_name + "Resuming AEVOL from NFS backup")
......@@ -537,7 +547,7 @@ class raevol_matrix(Engine):
def is_job_alive(self):
rez=get_oar_job_info(self.oar_job_id)
while 'start_date' not in rez and 'Error' not in rez:
while 'start_date' not in rez and 'state' not in rez:
rez=get_oar_job_info(self.oar_job_id)
if rez['state'] == 'Error':
return False
......
......@@ -61,7 +61,7 @@ class raevol_matrix(Engine):
else:
self.oar_job_id = None
self.list_of_clusters = ['hercule','orion','taurus']
self.list_of_clusters = ['taurus','hercule','orion']
try:
# Creation of the main iterator which is used for the first control loop.
......@@ -70,7 +70,7 @@ class raevol_matrix(Engine):
job_is_dead = False
# While there are combinations to treat
while len(self.sweeper.get_remaining()) > 0:
while len(self.sweeper.get_remaining()) > 0 or len(self.sweeper.get_inprogress()) > 0:
# If no job, we make a reservation and prepare the hosts for the experiments
if self.oar_job_id is None:
self.submit_all_available_best_effort(self.list_of_clusters, self.options.walltime)
......@@ -121,26 +121,30 @@ class raevol_matrix(Engine):
if job_is_dead:
break
# Getting the next combination
comb = self.sweeper.get_next()
if not comb:
while len(threads.keys()) > 0:
tmp_threads = dict(threads)
for t in tmp_threads:
if not t.is_alive():
del threads[t]
logger.info('Waiting for threads to complete')
sleep(20)
break
host = available_hosts[0]
available_hosts = available_hosts[1:]
logger.info("Launching thread "+str(self.is_job_alive())+" "+str(len(threads.keys())))
t = Thread(target=self.workflow,
args=(comb, host, comb_dir))
threads[t] = {'host': host}
t.daemon = True
t.start()
if True: #len(threads.keys()) < 83:
# Getting the next combination
comb = self.sweeper.get_next()
if not comb:
while len(threads.keys()) > 0:
tmp_threads = dict(threads)
for t in tmp_threads:
if not t.is_alive():
del threads[t]
logger.info('Waiting for threads to complete')
if not self.is_job_alive():
job_is_dead = True
break
sleep(20)
break
host = available_hosts[0]
available_hosts = available_hosts[1:]
logger.info("Launching thread "+str(self.is_job_alive())+" "+str(len(threads.keys())))
t = Thread(target=self.workflow,
args=(comb, host, comb_dir))
threads[t] = {'host': host}
t.daemon = True
t.start()
sleep(3)
if not self.is_job_alive():
......@@ -162,8 +166,8 @@ class raevol_matrix(Engine):
def define_parameters(self):
""" """
parameters = {
'seed' : [51456165, 33263658, 7158785, 456847894, 1223144, 878944, 121145, 3587842],
'mutation' : ['5e-4','1e-4','5e-5','5e-6'],
'seed' : [51456165, 33263658, 7158785, 456847894, 1223144, 878944, 121145, 3587842, 9875026, 76469871],
'mutation' : ['5e-7','1e-7'],
'env' : ['const','lat_3','lat_all'],
'selection' : [750,2000,4000]
}
......@@ -268,6 +272,13 @@ class raevol_matrix(Engine):
bucketname = self.working_dir+'/raevol_5_mut_lat/'+slugify(comb)+'/'
logger.info(thread_name + "Killing other RAevol")
killa = Remote("killall -9 aevol_run",[host])
for killp in killa.processes:
killp.ignore_error = True
killa.run()
if os.path.isdir(bucketname) and os.path.exists(bucketname+'/last_gener.txt'):
logger.info(thread_name + "Resuming AEVOL from NFS backup")
......@@ -536,7 +547,7 @@ class raevol_matrix(Engine):
def is_job_alive(self):
rez=get_oar_job_info(self.oar_job_id)
while 'start_date' not in rez and 'Error' not in rez:
while 'start_date' not in rez and 'state' not in rez:
rez=get_oar_job_info(self.oar_job_id)
if rez['state'] == 'Error':
return False
......@@ -551,9 +562,19 @@ class raevol_matrix(Engine):
slots = compute_slots(planning, walltime)
wanted = { cluster: 0 for cluster in list_of_clusters }
start_date, end_date, resources = find_first_slot(slots, wanted)
actual_resources = { resource: n_nodes
for resource, n_nodes in resources.iteritems()
if resource in list_of_clusters and n_nodes > 0 }
g_nodes = 0
actual_resources = {}
for resource, n_nodes in resources.iteritems():
if resource in list_of_clusters and n_nodes > 0:
if g_nodes >= 83:
break
elif g_nodes + n_nodes >= 83:
l_nodes = 83 - g_nodes
actual_resources = { resource : l_nodes }
break
else:
actual_resources = { resource : n_nodes }
g_nodes += n_nodes
return start_date, end_date, actual_resources
def submit_all_available_best_effort(self,list_of_clusters, walltime):
......
......@@ -84,7 +84,7 @@ int main(int argc, char* argv[])
// 1) Initialize command-line option variables with default values
// 2) Define allowed options
// 3) Get actual values of the command-line options
// 4) Check the consistancy of the command-line options
// 4) Check the consistency of the command-line options
// 5) Set file names according to options
// =========================================================================
......@@ -92,7 +92,7 @@ int main(int argc, char* argv[])
// 1) Initialize command-line option variables with default values
// -------------------------------------------------------------------------
// bool pause_on_startup = false;
bool verbose = false;
bool verbose = false;
int64_t t0 = -1;
int64_t t_end = -1;
......
......@@ -195,28 +195,30 @@ char* Dna::subsequence(int32_t from, int32_t to, Strand strand) const {
// =================================================================
// Public Methods
// =================================================================
void Dna::perform_mutations(int32_t parent_id) {
if (indiv_->with_HT()) {
do_transfer(parent_id);
}
/// Perform mutations and record how many of them occurred
int32_t Dna::perform_mutations(int32_t parent_id) {
int32_t nb_events = 0;
if (indiv_->with_alignments()) {
do_rearrangements_with_align();
}
else {
do_rearrangements();
}
if (indiv_->with_HT())
nb_events += do_transfer(parent_id);
do_small_mutations();
if (indiv_->with_alignments())
nb_events += do_rearrangements_with_align();
else
nb_events += do_rearrangements();
nb_events += do_small_mutations();
return nb_events;
}
void Dna::do_small_mutations() {
int32_t Dna::do_small_mutations() {
// ==============================================================
// 1. Compute how many rearrangements this genome will undertake
// ==============================================================
//
// Given the rate p (by nucl.) of insertion - for instance -, the number of
// insertions we perform on the genome follows a binomial law B(n, p), with
// insertions we perform on the genome follows a binomial law B(n,p), with
// n = genome length.
int32_t nb_swi = indiv_->mut_prng_->
......@@ -227,8 +229,6 @@ void Dna::do_small_mutations() {
binomial_random(length_, indiv_->small_deletion_rate());
int32_t nb_mut = nb_swi + nb_ins + nb_del;
// ====================================================
// 2. Perform those small mutations in a random order
// ====================================================
......@@ -258,17 +258,14 @@ void Dna::do_small_mutations() {
if (random_value < nb_swi) {
mut = do_switch();
nb_swi--; // updating the urn (no replacement!)...
}
else if (random_value < nb_swi + nb_ins) {
mut = do_small_insertion();
nb_ins--;
}
else { // (random_value >= nb_swi + nb_ins) => del
mut = do_small_deletion();
nb_del--;
}
......@@ -278,9 +275,11 @@ void Dna::do_small_mutations() {
delete mut;
}
}
return nb_mut;
}
void Dna::do_rearrangements() {
int32_t Dna::do_rearrangements() {
// ==============================================================
// 1. Compute how many rearrangements this genome will undertake
// ==============================================================
......@@ -347,9 +346,10 @@ void Dna::do_rearrangements() {
delete mut;
}
}
return nb_rear;
}
void Dna::do_rearrangements_with_align() {
int32_t Dna::do_rearrangements_with_align() {
// Whether we look for a direct or indirect alignment
bool direct_sense;
// Determines the type of rearrangement that will be done if an alignment
......@@ -366,6 +366,7 @@ void Dna::do_rearrangements_with_align() {
int32_t nb_pairs;
// Keep trace of the original length of the genome
int32_t genome_size = length_;
int32_t nb_rearr = 0;
Mutation* mut = nullptr;
VisAVis* alignment = NULL;
......@@ -491,7 +492,7 @@ void Dna::do_rearrangements_with_align() {
alignment->i_2(),
alignment->i_2(),
segment_length, needed_score);
nb_rearr++;
// Write a line in rearrangement logfile
if (exp_m_->output_m()->is_logged(LOG_REAR)) {
fprintf(exp_m_->output_m()->log(LOG_REAR),
......@@ -533,6 +534,7 @@ void Dna::do_rearrangements_with_align() {
mut = new Deletion(alignment->i_1(),
alignment->i_2(),
segment_length, needed_score);
nb_rearr++;
// Write a line in rearrangement logfile
if (exp_m_->output_m()->is_logged(LOG_REAR)) {
......@@ -631,6 +633,7 @@ void Dna::do_rearrangements_with_align() {
segment_length,
(alignment_2->sense() == INDIRECT),
needed_score, needed_score_2);
nb_rearr++;
// Write a line in rearrangement logfile
if (exp_m_->output_m()->is_logged(LOG_REAR)) {
......@@ -693,7 +696,7 @@ void Dna::do_rearrangements_with_align() {
mut = new Inversion(alignment->i_1(),
alignment->i_2(),
segment_length, needed_score);
nb_rearr++;
// Write a line in rearrangement logfile
if (exp_m_->output_m()->is_logged(LOG_REAR)) {
fprintf(exp_m_->output_m()->log(LOG_REAR),
......@@ -729,15 +732,18 @@ void Dna::do_rearrangements_with_align() {
delete mut;
}
}
return nb_rearr;
}
void Dna::do_transfer(int32_t parent_id) {
int32_t Dna::do_transfer(int32_t parent_id) {
Mutation* mut = nullptr;
int32_t nb_transfer = 0;
if (indiv_->mut_prng()->random() < indiv_->HT_ins_rate()) {
mut = do_ins_HT(parent_id);
if (mut != nullptr) {
indiv_->notifyObservers(MUTATION, mut);
nb_transfer++;
delete mut;
}
}
......@@ -746,9 +752,11 @@ void Dna::do_transfer(int32_t parent_id) {
mut = do_repl_HT(parent_id);
if (mut != nullptr) {
indiv_->notifyObservers(MUTATION, mut);
nb_transfer++;
delete mut;
}
}
return nb_transfer;
}
PointMutation* Dna::do_switch() {
......
......@@ -97,18 +97,18 @@ class Dna : public ae_string {
// Public Methods
// =================================================================
// Perform all the mutations (local mutations, rearrangements and transfer)
void perform_mutations(int32_t parent_id);
int32_t perform_mutations(int32_t parent_id);
// Perform all the local mutations (point mutations and indels)
void do_small_mutations();
int32_t do_small_mutations();
// Perform all the chromosomal rearrangements (duplications, deletions,
// translocations and inversions)
void do_rearrangements();
void do_rearrangements_with_align();
int32_t do_rearrangements();
int32_t do_rearrangements_with_align();
// Perform all transfer (with insertion and with replacement)
void do_transfer(int32_t parent_id);
int32_t do_transfer(int32_t parent_id);
// Perform a single local mutation at a random position
PointMutation* do_switch();
......
......@@ -64,7 +64,7 @@ using std::endl;
namespace aevol {
//##############################################################################
// #
// Class ExpManager #
// Class ExpManager #
// #
//##############################################################################
......@@ -75,8 +75,7 @@ namespace aevol {
// ===========================================================================
// Constructors
// ===========================================================================
ExpManager::ExpManager()
{
ExpManager::ExpManager() {
// ------------------------------------------------------ Experimental setup
exp_s_ = new ExpSetup(this);
......@@ -324,11 +323,8 @@ void ExpManager::load(gzFile& exp_s_file,
// -------------------------------------------- Link world and output profile
if (record_tree()) {
// TODO(dpa) Document this !!!
sel()->addObserver(tree(), NEW_INDIV);
for (auto indiv : world_->indivs())
indiv->addObserver(
tree()->report_by_index(AeTime::time(), indiv->id()),
END_REPLICATION);
sel()->addObserver(tree(), END_GENERATION);
}
......@@ -444,81 +440,67 @@ void ExpManager::run_evolution()
// We are running a simulation.
// Save the setup files to keep track of the setup history
WriteSetupFiles();
#ifdef __TRACING__
ae_logger::init("logger_csv.log");
printf("Launching TRACING...\n");
#ifdef __TRACING__
ae_logger::init("logger_csv.log");
printf("Launching TRACING...\n");
#else
printf("Launching NOT TRACING...\n");
#endif
#ifdef __TRACING__
high_resolution_clock::time_point t_t1 = high_resolution_clock::now();
high_resolution_clock::time_point t_t2,t1,t2;
#endif
#ifdef __TRACING__
high_resolution_clock::time_point t_t1 = high_resolution_clock::now();
high_resolution_clock::time_point t_t2,t1,t2;
#endif
// For each generation
if (exp_s_->first_regul())
if (AeTime::time() < 10000 || AeTime::time() > 20000)
regul_or_not_ = true;
else
regul_or_not_ = false;
else
if (AeTime::time() < 10000 || AeTime::time() > 20000)
regul_or_not_ = false;
else
regul_or_not_ = true;
// For each generation
while (true) { // termination condition is into the loop
printf("============================== %" PRId64 " ==============================\n",
AeTime::time());
printf(" Best individual's distance to target (metabolic) : %f\n",
best_indiv()->dist_to_target_by_feature(METABOLISM));
int16_t nb_activators = 0;
int16_t nb_operators = 0;
Individual_R* test = dynamic_cast<Individual_R*>(best_indiv());
//test->init_indiv(dynamic_cast<const Habitat_R&>(test->habitat()));
int nb_protein = 0;
for (const auto& rnax: test->_rna_list_coding) {
Rna_R* rna = (Rna_R*) rnax;
for (unsigned int i = 0; i < rna->nb_influences(); i++) {
nb_protein++;
if (rna->_enhancing_coef_list[i] > 0) {
nb_activators++;
}
if (rna->_operating_coef_list[i] > 0) {
nb_operators++;
}
}
}
printf(" Proteins %ld (%d) - RNA %ld - Link A %d - I %d\n",test->protein_list().size(),nb_protein,
test->_rna_list_coding.size(),
nb_activators,nb_operators);
if (AeTime::time() >= t_end_ or quit_signal_received())
if (AeTime::time() >= t_end_ or quit_signal_received())
break;
#ifdef __X11
display();
#endif
#ifdef __TRACING__
t1 = high_resolution_clock::now();
t1 = high_resolution_clock::now();
#endif
// Take one step in the evolutionary loop
if (AeTime::time() == 10000 || AeTime::time() == 20000)
regul_or_not_ = !regul_or_not_;
step_to_next_generation();
#ifdef __TRACING__
t2 = high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
ae_logger::addLog(SELECTION,duration);
ae_logger::flush(AeTime::get_time());
t2 = high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
ae_logger::addLog(SELECTION,duration);
ae_logger::flush(AeTime::get_time());
#endif
}
#ifdef __TRACING__
t_t2 = high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t_t2 - t_t1 ).count();
ae_logger::addLog(TOTAL,duration);
ae_logger::flush(AeTime::get_time());
t_t2 = high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t_t2 - t_t1 ).count();
ae_logger::addLog(TOTAL,duration);
ae_logger::flush(AeTime::get_time());
#endif
output_m_->flush();
printf("================================================================\n");
printf(" The run is finished. \n");
......@@ -674,4 +656,18 @@ Individual* ExpManager::indiv_by_id(int32_t id) const {
return world_->indiv_by_id(id);
}
/**
* Returns a list of all the individuals with their replication report
*/
std::list<std::pair<Individual*, ReplicationReport*>>
ExpManager::indivs_annotated() const {
std::list<std::pair<Individual*, ReplicationReport*>> annotated_list;
for (const auto& indiv : indivs()) {
annotated_list.emplace_back(indiv, tree() ?
tree()->report_by_index(AeTime::time(), indiv->id()) : nullptr);
}
return annotated_list;
}
} // namespace aevol
......@@ -107,6 +107,8 @@ class ExpManager : public Observer {
// Accessors to population stuff
std::list<Individual*> indivs() const { return world()->indivs(); }
std::list<std::pair<Individual*, ReplicationReport*>> indivs_annotated()
const;
int32_t nb_indivs() const { return world()->nb_indivs(); }
Individual* best_indiv() const { return world()->best_indiv(); }
Individual* indiv_by_id(int32_t id) const;
......@@ -117,6 +119,8 @@ class ExpManager : public Observer {
int32_t tree_step() const { return static_cast<int32_t>(output_m()->tree_step()); }
Tree* tree() const { return output_m()->tree(); }
bool regul_or_not() const { return regul_or_not_; }
// =======================================================================
// Accessors: setters
// =======================================================================
......@@ -191,7 +195,7 @@ class ExpManager : public Observer {
World* world_;
/// Output manager
OutputManager*output_m_;
OutputManager* output_m_;
/// Time step up to which we want to simulate
int64_t t_end_;
......@@ -199,6 +203,8 @@ class ExpManager : public Observer {
/// Should the simulation be stopped? Set to true when ctrl-Q is received.
/// Will cause the simulation to be ended after the current time step is completed.
bool quit_signal_received_;
bool regul_or_not_;
};
// ===========================================================================
......
......@@ -172,7 +172,8 @@ void ExpSetup::write_setup_file(gzFile exp_setup_file) const {
gzwrite(exp_setup_file, eval_step);
}
#endif
gzwrite(exp_setup_file,
first_regul_);
}
void ExpSetup::load(gzFile setup_file, gzFile backup_file, bool verbose) {
......@@ -255,6 +256,8 @@ void ExpSetup::load(gzFile setup_file, gzFile backup_file, bool verbose) {
}
#endif
gzread(setup_file,
first_regul_);
}
#ifdef __REGUL
......
......@@ -104,6 +104,8 @@ class ExpSetup {
}
#endif
bool first_regul() const { return first_regul_; }
// =======================================================================
// Accessors: setters
// =======================================================================
......@@ -143,6 +145,7 @@ class ExpSetup {
inline void set_list_eval_step(std::set<int> list_eval_step);
#endif
void set_first_regul(bool first_regul) { first_regul_ = first_regul; }
// =======================================================================
// Public Methods
......@@ -227,7 +230,7 @@ double _binding_matrix[MAX_QUADON][MAX_CODON];
std::set<int>* _list_eval_step;
#endif
bool first_regul_;
};
......
......@@ -50,7 +50,7 @@ void gz(GzAction action, gzFile file) {
/// Warning: as it is currently written, this template overrides any
/// call to gzwrite, which causes writing the length of the field to the file.
template<typename Field, typename... Args>
void gz(GzAction action, gzFile file, Field& field, Args... fields_list) {
void gz(GzAction action, gzFile file, Field& field, Args&&... fields_list) {
// This switch is unfortunate especially since the alternatives are pretty much the same.
// But there is a subtle difference that prevented me from a trivial factorization:
// gzwrite takes a _const_ void pointer as second argument.
......
......@@ -1659,123 +1659,6 @@ int32_t Individual::nb_terminators() {
}
/*!
\brief Compute reproduction statistics and statistics about the offsprings of the current individual
* Make nb_children replications of the current individual.
* For each replication, determine if the offsprings is neutral, beneficial or deleterious by comparison of fitness with the current individual (the parent)
* If statistics about offsprings are required (offsprings_statistics != NULL), fitness mean, fitness variance, size mean, size variance, functional gene number mean, functional gene number variance fo the nb_children offsprings are computed
* If information about each children are required (replication_file != NULL), fitness, genome_size, nb of functional genes, number of coding bases, number of transcribed but not translated bases, number of non transcribed bases of each offsprings are written in replication_file
\param nb_children number of replications made to have the statistics
\param reproduction_statistics statistics about the replications (proportion of neutral offsprings, proportion of beneficial offsprings, proportion of deleterious offsprings)
\param offsprings_statistics statistics about the nb_children offsprings (fitness mean, fitness variance, size mean, size variance, functional gene number mean,
functional gene number variance) compute if not null
\param replication_file file with information about each children of the current individual (fitness, genome_size, nb of functional genes, number of coding bases,
number of transcribed but not translated bases, number of non transcribed bases) if not null
*/
void Individual::compute_experimental_f_nu(int32_t nb_children,
double* reproduction_statistics,
double* offsprings_statistics,
FILE* replication_file) {
double initial_fitness = fitness();
if (reproduction_statistics != NULL) {
reproduction_statistics[0] = 0; // proportion of neutral offsprings
reproduction_statistics[1] = 0; // proportion of beneficial offsprings
reproduction_statistics[2] = 0; // proportion of deleterious offsprings
}
else {
printf("%s:%d: error: reproduction_statistics was not initialized\n",
__FILE__, __LINE__);
exit(EXIT_FAILURE);
}
if (offsprings_statistics != NULL) {
offsprings_statistics[0] = 0; // offspring fitness mean
offsprings_statistics[1] = 0; // offspring fitness variance
offsprings_statistics[2] = 0; // offspring size mean
offsprings_statistics[3] = 0; // offspring size variance
offsprings_statistics[4] = 0; // offspring functional gene number mean
offsprings_statistics[5] = 0; // offspring functional gene number variance
}
// ------------------------------------------
// Simulate fitness degradation
// ------------------------------------------
double fitness_child = 0.0;
double metabolic_error_child = 0.0;
// replicate this individual to create 'nb_children' children
Individual* child = NULL;
int32_t genome_size = 0;
int32_t nb_functional_genes = 0;
int32_t nb_bases_in_0_functional_CDS = 0;
int32_t nb_bases_in_0_coding_RNA = 0;
for (int i = 0; i < nb_children; i++) {
child = exp_m_->exp_s()->sel()->do_replication(this, id_);
fitness_child = child->fitness();
metabolic_error_child = child->dist_to_target_by_feature(METABOLISM);
if (fabs(initial_fitness - fitness_child) <
1e-10 * std::max(initial_fitness, fitness_child)) {
reproduction_statistics[0] += 1;
}
else if (fitness_child > initial_fitness) {
reproduction_statistics[1] += 1;
}
else {
reproduction_statistics[2] += 1;
}
genome_size = child->total_genome_size();
nb_functional_genes = child->nb_functional_genes();
nb_bases_in_0_functional_CDS = child->nb_bases_in_0_functional_CDS();
nb_bases_in_0_coding_RNA = child->nb_bases_in_0_coding_RNA();
if (offsprings_statistics != NULL) {
offsprings_statistics[0] += fitness_child;
offsprings_statistics[1] += pow(fitness_child, 2);
offsprings_statistics[2] += (double) genome_size;
offsprings_statistics[3] += pow((double) genome_size, 2);
offsprings_statistics[4] += (double) nb_functional_genes;
offsprings_statistics[5] += pow((double) nb_functional_genes, 2);
}
if (replication_file != NULL) {
fprintf(replication_file,
"%le %le %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "\n",
fitness_child, metabolic_error_child, genome_size,
nb_functional_genes, genome_size - nb_bases_in_0_functional_CDS,
nb_bases_in_0_functional_CDS - nb_bases_in_0_coding_RNA,
nb_bases_in_0_coding_RNA);
}
delete child;
}
//compute Fv
reproduction_statistics[0] /= (double) nb_children;
reproduction_statistics[1] /= (double) nb_children;
reproduction_statistics[2] /= (double) nb_children;
if (offsprings_statistics != NULL) {
offsprings_statistics[0] /= (double) nb_children;
offsprings_statistics[1] /= (double) nb_children;
offsprings_statistics[2] /= (double) nb_children;
offsprings_statistics[3] /= (double) nb_children;
offsprings_statistics[4] /= (double) nb_children;
offsprings_statistics[5] /= (double) nb_children;
offsprings_statistics[1] -= pow(offsprings_statistics[0], 2);
offsprings_statistics[3] -= pow(offsprings_statistics[2], 2);
offsprings_statistics[5] -= pow(offsprings_statistics[4], 2);
}
}
/// Compute reproduction theoretical proportion of neutral offsprings.
///
/// Compute the theoretical proportion of neutral offsprings given the
......
......@@ -77,8 +77,7 @@ Individual* IndividualFactory::create_random_individual(
int32_t plasmid_initial_length,
char* strain_name,
std::shared_ptr<JumpingMT> local_prng,
bool better_than_flat)
{
bool better_than_flat) {
// Create a genome-less individual with the provided parameters
#ifndef __REGUL
......