Commit 0e51d948 authored by Vincent Noël's avatar Vincent Noël
Browse files

Change timestep noise in PhysiBoSS to now follow a log normal distribution

parent 7f66df26
#ifndef _MaBoSS_Net_h_
#define _MaBoSS_Net_h_
#include "StochasticSimulationEngine.h"
#include "BooleanNetwork.h"
#include "RunConfig.h"
#include "utils.h"
#include "../../../core/PhysiCell_utilities.h"
/**
* \class MaBoSSNetwork
* \brief Interface with MaBoSS software
*
* \details The MaBOSS network class contains network configs to handel the initialization and run the simulations given an input.
*
* \date 06/08/2020
* \author Gaelle Letort, Institut Curie
* \author Gerard Pradas, BSC-CNS
*/
class MaBoSSNetwork
{
private:
/** \brief MaBoSS instances: network */
Network* network;
/** \brief MaBoSS instances: configurations */
RunConfig* config;
StochasticSimulationEngine* engine;
//NetworkState state; <--- Gaurav Saxena is making this public again so that we cast test code
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
double update_time_step = 12.0;
/** \brief Real time to update, after applying noise */
double time_to_update;
double time_stochasticity = 0;
double scaling = 1.0;
/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;
/** \brief Mutations to apply to the network */
std::map< std::string, double > mutations;
std::map< std::string, Node*> nodesByName;
std::map< std::string, const Symbol*> parametersByName;
inline void set_time_to_update(){this->time_to_update = ( 1 + (PhysiCell::UniformRandom()*2-1)*time_stochasticity ) * this->get_update_time_step();}
public:
NetworkState state;
/** Constructor */
MaBoSSNetwork() {
network = NULL;
config = NULL;
engine = NULL;
this->nodesByName.clear();
}
/** Desctructor */
~MaBoSSNetwork() {
delete this->engine;
this->engine = NULL;
delete this->network;
this->network = NULL;
delete this->config;
this->config = NULL;
}
/**
* \brief Class initializer
* \param networkFile,configFile MaBoSS configutation files
*/
void init_maboss( std::string networkFile, std::string configFile);
bool has_init() const { return network != NULL && config != NULL; }
void mutate(std::map<std::string, double> mutations);
void set_initial_values(std::map<std::string, double> initial_values)
{ this->initial_values = initial_values; }
void set_parameters(std::map<std::string, double> parameters);
double get_parameter_value(std::string name);
void set_parameter_value(std::string name, double value);
//The next 2 functions possibly aid in packing/unpacking
Network* getNetwork() { return network; }
NetworkState getState() { return state; }
/**
* \brief Restart a vector of bools, to the init values of the network
* \param node_values Vector of bools to write an initial state of the network
*/
void restart_node_values();
/**
* \brief Run the current network
* \param node_values Vector mapping a boolean network to run a simulation
*/
void run_simulation();
/** \brief Return node of given name current value
*
* Return -1 if node doesn't exit \n
* Return 0 if node is 0 \n
* Return 1 if node is 1 */
// int get_maboss_node_index( std::string name );
bool has_node( std::string name );
void set_node_value(std::string name, bool value);
bool get_node_value(std::string name);
std::string get_state();
/** \brief Return update time value */
inline double get_update_time_step(){ return this->update_time_step; }
/**
* \brief Set update time step
* \param time_step Time step between each MaBoSS simulation
*/
inline void set_update_time_step(double time_step) { this->update_time_step = time_step;}
/** \brief Get time to update*/
inline double get_time_to_update() {return this->time_to_update;}
inline void set_time_to_update(double time) { this->time_to_update = ( 1 + (PhysiCell::UniformRandom()*2-1)*time_stochasticity ) * time; }
/** \brief Change simulation mode */
inline void set_discrete_time(bool discrete_time, double time_tick) {
this->engine->setDiscreteTime(discrete_time); this->engine->setTimeTick(time_tick);
}
inline void set_scaling(double scaling) { this->scaling = scaling; }
inline void set_time_stochasticity(double t_stochasticity) { this->time_stochasticity = t_stochasticity; }
/**
* \brief Print current state of all the nodes of the network
* \param node_values Boolean vector mapping a boolean network
*/
void print_nodes();
void set_state(NetworkState _state) { state = NetworkState(_state.getState()); }
NetworkState get_maboss_state() { return state;}
};
#endif
<<<<<<< HEAD
#ifndef _MaBoSS_Net_h_
#define _MaBoSS_Net_h_
#include "StochasticSimulationEngine.h"
#include "BooleanNetwork.h"
#include "RunConfig.h"
#include "utils.h"
#include "../../../core/PhysiCell_utilities.h"
/**
* \class MaBoSSNetwork
* \brief Interface with MaBoSS software
*
* \details The MaBOSS network class contains network configs to handel the initialization and run the simulations given an input.
*
* \date 06/08/2020
* \author Gaelle Letort, Institut Curie
* \author Gerard Pradas, BSC-CNS
*/
class MaBoSSNetwork
{
private:
/** \brief MaBoSS instances: network */
Network* network;
/** \brief MaBoSS instances: configurations */
RunConfig* config;
StochasticSimulationEngine* engine;
//NetworkState state; <--- Gaurav Saxena is making this public again so that we cast test code
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
double update_time_step = 12.0;
/** \brief Real time to update, after applying noise */
double time_to_update;
double time_stochasticity = 0;
double scaling = 1.0;
/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;
/** \brief Mutations to apply to the network */
std::map< std::string, double > mutations;
std::map< std::string, Node*> nodesByName;
std::map< std::string, const Symbol*> parametersByName;
inline void set_time_to_update(){this->time_to_update = PhysiCell::LogNormalRandom( this->get_update_time_step() , time_stochasticity );}
public:
NetworkState state;
/** Constructor */
MaBoSSNetwork() {
network = NULL;
config = NULL;
engine = NULL;
this->nodesByName.clear();
}
/** Desctructor */
~MaBoSSNetwork() {
delete this->engine;
this->engine = NULL;
delete this->network;
this->network = NULL;
delete this->config;
this->config = NULL;
}
/**
* \brief Class initializer
* \param networkFile,configFile MaBoSS configutation files
*/
void init_maboss( std::string networkFile, std::string configFile);
bool has_init() const { return network != NULL && config != NULL; }
void mutate(std::map<std::string, double> mutations);
void set_initial_values(std::map<std::string, double> initial_values)
{ this->initial_values = initial_values; }
void set_parameters(std::map<std::string, double> parameters);
double get_parameter_value(std::string name);
void set_parameter_value(std::string name, double value);
//The next 2 functions possibly aid in packing/unpacking
Network* getNetwork() { return network; }
NetworkState getState() { return state; }
/**
* \brief Restart a vector of bools, to the init values of the network
* \param node_values Vector of bools to write an initial state of the network
*/
void restart_node_values();
/**
* \brief Run the current network
* \param node_values Vector mapping a boolean network to run a simulation
*/
void run_simulation();
/** \brief Return node of given name current value
*
* Return -1 if node doesn't exit \n
* Return 0 if node is 0 \n
* Return 1 if node is 1 */
// int get_maboss_node_index( std::string name );
bool has_node( std::string name );
void set_node_value(std::string name, bool value);
bool get_node_value(std::string name);
std::string get_state();
/** \brief Return update time value */
inline double get_update_time_step(){ return this->update_time_step; }
/**
* \brief Set update time step
* \param time_step Time step between each MaBoSS simulation
*/
inline void set_update_time_step(double time_step) { this->update_time_step = time_step;}
/** \brief Get time to update*/
inline double get_time_to_update() {return this->time_to_update;}
inline void set_time_to_update(double time) { this->time_to_update = ( 1 + (PhysiCell::UniformRandom()*2-1)*time_stochasticity ) * time; }
/** \brief Change simulation mode */
inline void set_discrete_time(bool discrete_time, double time_tick) {
this->engine->setDiscreteTime(discrete_time); this->engine->setTimeTick(time_tick);
}
inline void set_scaling(double scaling) { this->scaling = scaling; }
inline void set_time_stochasticity(double t_stochasticity) { this->time_stochasticity = t_stochasticity; }
/**
* \brief Print current state of all the nodes of the network
* \param node_values Boolean vector mapping a boolean network
*/
void print_nodes();
void set_state(NetworkState _state) { state = NetworkState(_state.getState()); }
NetworkState get_maboss_state() { return state;}
};
#endif
=======
#ifndef _MaBoSS_Net_h_
#define _MaBoSS_Net_h_
#include "StochasticSimulationEngine.h"
#include "BooleanNetwork.h"
#include "RunConfig.h"
#include "utils.h"
#include "../../../core/PhysiCell_utilities.h"
/**
* \class MaBoSSNetwork
* \brief Interface with MaBoSS software
*
* \details The MaBOSS network class contains network configs to handel the initialization and run the simulations given an input.
*
* \date 06/08/2020
* \author Gaelle Letort, Institut Curie
* \author Gerard Pradas, BSC-CNS
*/
class MaBoSSNetwork
{
private:
/** \brief MaBoSS instances: network */
Network* network;
/** \brief MaBoSS instances: configurations */
RunConfig* config;
StochasticSimulationEngine* engine;
NetworkState state;
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
double update_time_step = 12.0;
/** \brief Real time to update, after applying noise */
double time_to_update;
/** \brief Scaling coefficient for time */
double scaling = 1.0;
/** \brief Noise coefficient for time to update */
double time_stochasticity = 0;
/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;
/** \brief Mutations to apply to the network */
std::map< std::string, double > mutations;
std::map< std::string, Node*> nodesByName;
std::map< std::string, const Symbol*> parametersByName;
inline void set_time_to_update(){this->time_to_update = PhysiCell::LogNormalRandom( this->get_update_time_step() , time_stochasticity );}
public:
/** Constructor */
MaBoSSNetwork() {
network = NULL;
config = NULL;
engine = NULL;
this->nodesByName.clear();
}
/** Desctructor */
~MaBoSSNetwork() {
delete this->engine;
this->engine = NULL;
delete this->network;
this->network = NULL;
delete this->config;
this->config = NULL;
}
/**
* \brief Class initializer
* \param networkFile,configFile MaBoSS configutation files
*/
void init_maboss( std::string networkFile, std::string configFile);
bool has_init() const { return network != NULL && config != NULL; }
void mutate(std::map<std::string, double> mutations);
void set_initial_values(std::map<std::string, double> initial_values)
{ this->initial_values = initial_values; }
void set_parameters(std::map<std::string, double> parameters);
double get_parameter_value(std::string name);
void set_parameter_value(std::string name, double value);
/**
* \brief Restart a vector of bools, to the init values of the network
* \param node_values Vector of bools to write an initial state of the network
*/
void restart_node_values();
/**
* \brief Run the current network
* \param node_values Vector mapping a boolean network to run a simulation
*/
void run_simulation();
/** \brief Return node of given name current value
*
* Return -1 if node doesn't exit \n
* Return 0 if node is 0 \n
* Return 1 if node is 1 */
// int get_maboss_node_index( std::string name );
bool has_node( std::string name );
void set_node_value(std::string name, bool value);
bool get_node_value(std::string name);
std::string get_state();
/** \brief Return update time value */
inline double get_update_time_step(){ return this->update_time_step; }
/**
* \brief Set update time step
* \param time_step Time step between each MaBoSS simulation
*/
inline void set_update_time_step(double time_step) { this->update_time_step = time_step;}
/** \brief Get time to update*/
inline double get_time_to_update() {return this->time_to_update;}
/** \brief Change simulation mode */
inline void set_discrete_time(bool discrete_time, double time_tick) {
this->engine->setDiscreteTime(discrete_time); this->engine->setTimeTick(time_tick);
}
inline void set_scaling(double scaling) { this->scaling = scaling; }
inline void set_time_stochasticity(double t_stochasticity) { this->time_stochasticity = t_stochasticity; }
/**
* \brief Print current state of all the nodes of the network
* \param node_values Boolean vector mapping a boolean network
*/
void print_nodes();
void set_state(NetworkState _state) { state = NetworkState(_state.getState()); }
NetworkState get_maboss_state() { return state;}
};
#endif
>>>>>>> fc999954 (Change timestep noise in PhysiBoSS to now follow a log normal distribution)
This diff is collapsed.
/*
###############################################################################
# If you use PhysiCell in your project, please cite PhysiCell and the version #
# number, such as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# See VERSION.txt or call get_PhysiCell_version() to get the current version #
# x.y.z. Call display_citations() to get detailed information on all cite-#
# able software used in your PhysiCell application. #
# #
# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM #
# as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1], #
# with BioFVM [2] to solve the transport equations. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- #
# llelized diffusive transport solver for 3-D biological simulations, #
# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 #
# #
###############################################################################
# #
# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) #
# #
# Copyright (c) 2015-2018, Paul Macklin and the PhysiCell Project #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
# 1. Redistributions of source code must retain the above copyright notice, #
# this list of conditions and the following disclaimer. #
# #
# 2. Redistributions in binary form must reproduce the above copyright #
# notice, this list of conditions and the following disclaimer in the #
# documentation and/or other materials provided with the distribution. #
# #
# 3. Neither the name of the copyright holder nor the names of its #
# contributors may be used to endorse or promote products derived from this #
# software without specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE #
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR #
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS #
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN #
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) #
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
# POSSIBILITY OF SUCH DAMAGE. #
# #
###############################################################################
*/
#ifndef __PhysiCell_utilities_h__
#define __PhysiCell_utilities_h__
#include <iostream>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <random>
#include <chrono>
namespace PhysiCell{
long SeedRandom( long input );
long SeedRandom( void );
double UniformRandom( void );
int UniformInt( void );
double NormalRandom( double mean, double standard_deviation );
std::vector<double> UniformOnUnitSphere( void );
std::vector<double> UniformOnUnitCircle( void );
std::vector<double> LegacyRandomOnUnitSphere( void );
double dist_squared(std::vector<double> p1, std::vector<double> p2);
double dist(std::vector<double> p1, std::vector<double> p2);
std::string get_PhysiCell_version( void );
void get_PhysiCell_version( std::string& pString );
void display_citations( std::ostream& os );
void display_citations( void );
void add_software_citation( std::string name , std::string version, std::string DOI, std::string URL );
int choose_event( std::vector<double>& probabilities );
};
#endif
/*
###############################################################################
# If you use PhysiCell in your project, please cite PhysiCell and the version #
# number, such as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# See VERSION.txt or call get_PhysiCell_version() to get the current version #
# x.y.z. Call display_citations() to get detailed information on all cite-#
# able software used in your PhysiCell application. #
# #
# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM #
# as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1], #
# with BioFVM [2] to solve the transport equations. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- #
# llelized diffusive transport solver for 3-D biological simulations, #
# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 #
# #
###############################################################################
# #
# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) #
# #
# Copyright (c) 2015-2018, Paul Macklin and the PhysiCell Project #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
# 1. Redistributions of source code must retain the above copyright notice, #
# this list of conditions and the following disclaimer. #
# #
# 2. Redistributions in binary form must reproduce the above copyright #
# notice, this list of conditions and the following disclaimer in the #
# documentation and/or other materials provided with the distribution. #
# #
# 3. Neither the name of the copyright holder nor the names of its #
# contributors may be used to endorse or promote products derived from this #
# software without specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #