inc

DuneConverter

class sme::simulate::DuneConverter

Public Functions

explicit DuneConverter(const model::Model &model, const std::map<std::string, double, std::less<>> &substitutions = {}, bool forExternalUse = false, const QString &outputIniFile = {}, int doublePrecision = 18)
QString getIniFile(std::size_t compartmentIndex = 0) const
const std::vector<QString> &getIniFiles() const
bool hasIndependentCompartments() const
const mesh::Mesh *getMesh() const
const std::vector<std::vector<std::vector<double>>> &getConcentrations() const
double getXOrigin() const
double getYOrigin() const
double getPixelWidth() const
int getImageWidth() const

Pde

class sme::simulate::Pde

Public Functions

explicit Pde(const model::Model *doc_ptr, const std::vector<std::string> &speciesIDs, const std::vector<std::string> &reactionIDs, const std::vector<std::string> &relabelledSpeciesIDs = {}, const PdeScaleFactors &pdeScaleFactors = {}, const std::vector<std::string> &extraVariables = {}, const std::vector<std::string> &relabelledExtraVariables = {}, const std::map<std::string, double, std::less<>> &substitutions = {})
const std::vector<std::string> &getRHS() const
const std::vector<std::vector<std::string>> &getJacobian() const

Simulation

class sme::simulate::Simulation

Public Functions

explicit Simulation(model::Model &model)
~Simulation()
std::size_t doTimesteps(double time, std::size_t nSteps = 1, double timeout_ms = -1.0)
std::size_t doMultipleTimesteps(const std::vector<std::pair<std::size_t, double>> &timesteps, double timeout_ms = -1.0, const std::function<bool()> &stopRunningCallback = {})
const std::string &errorMessage() const
const QImage &errorImage() const
const std::vector<std::string> &getCompartmentIds() const
const std::vector<std::string> &getSpeciesIds(std::size_t compartmentIndex) const
const std::vector<QRgb> &getSpeciesColors(std::size_t compartmentIndex) const
const std::vector<double> &getTimePoints() const
const AvgMinMax &getAvgMinMax(std::size_t timeIndex, std::size_t compartmentIndex, std::size_t speciesIndex) const
std::vector<double> getConc(std::size_t timeIndex, std::size_t compartmentIndex, std::size_t speciesIndex) const
std::vector<double> getConcArray(std::size_t timeIndex, std::size_t compartmentIndex, std::size_t speciesIndex) const
void applyConcsToModel(model::Model &m, std::size_t timeIndex) const
std::vector<double> getDcdt(std::size_t compartmentIndex, std::size_t speciesIndex) const
std::vector<double> getDcdtArray(std::size_t compartmentIndex, std::size_t speciesIndex) const
double getLowerOrderConc(std::size_t compartmentIndex, std::size_t speciesIndex, std::size_t pixelIndex) const
QImage getConcImage(std::size_t timeIndex, const std::vector<std::vector<std::size_t>> &speciesToDraw = {}, bool normaliseOverAllTimepoints = false, bool normaliseOverAllSpecies = false) const
const std::vector<std::string> &getPyNames(std::size_t compartmentIndex) const
std::vector<std::vector<double>> getPyConcs(std::size_t timeIndex, std::size_t compartmentIndex) const
std::vector<std::vector<double>> getPyDcdts(std::size_t compartmentIndex) const
std::size_t getNCompletedTimesteps() const
const SimulationData &getSimulationData() const
bool getIsRunning() const
bool getIsStopping() const
void requestStop()

SimulationData

class sme::simulate::SimulationData

Public Functions

void clear()
std::size_t size() const
void reserve(std::size_t n)
void pop_back()
template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

std::vector<double> timePoints
std::vector<std::vector<std::vector<double>>> concentration
std::vector<std::vector<std::vector<AvgMinMax>>> avgMinMax
std::vector<std::vector<std::vector<double>>> concentrationMax
std::vector<std::size_t> concPadding
std::string xmlModel
struct sme::simulate::AvgMinMax

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

double avg = 0
double min = std::numeric_limits<double>::max()
double max = 0

SimulationOptions

struct sme::simulate::Options

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

DuneOptions dune
PixelOptions pixel
enum class sme::simulate::SimulatorType

Values:

enumerator DUNE
enumerator Pixel
struct sme::simulate::PixelOptions

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

PixelIntegratorType integrator = {PixelIntegratorType::RK212}
PixelIntegratorError maxErr
double maxTimestep = {std::numeric_limits<double>::max()}
bool enableMultiThreading = {false}
std::size_t maxThreads = {0}
bool doCSE = {true}
unsigned optLevel = {3}
struct sme::simulate::PixelIntegratorError

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

double abs = {std::numeric_limits<double>::max()}
double rel = {0.005}
enum class sme::simulate::PixelIntegratorType

Values:

enumerator RK101
enumerator RK212
enumerator RK323
enumerator RK435
struct sme::simulate::DuneOptions

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

DuneDiscretizationType discretization = {DuneDiscretizationType::FEM1}
std::string integrator = {"alexander_2"}
double dt = {1e-1}
double minDt = {1e-10}
double maxDt = {1e4}
double increase = {1.5}
double decrease = {0.5}
bool writeVTKfiles = {false}
double newtonRelErr = {1e-8}
double newtonAbsErr = {1e-12}
enum class sme::simulate::DuneDiscretizationType

Values:

enumerator FEM1

Optimization

class sme::simulate::Optimization

Optimize model parameters.

Optimizes the supplied model parameters to minimize the supplied cost functions.

Public Functions

explicit Optimization(sme::model::Model &model)

Constructs an Optimization object from the supplied model.

Parameters

model[in] the model to optimize

std::size_t evolve(std::size_t n = 1)

Do n iterations of parameter optimization.

bool applyParametersToModel(sme::model::Model *model) const

Apply the current best parameter values to the supplied model.

const std::vector<std::vector<double>> &getParams() const

The best set of parameters from each iteration.

std::vector<QString> getParamNames() const

The names of the parameters being optimized.

const std::vector<double> &getFitness() const

The best fitness from each iteration.

bool setBestResults(double fitness, std::vector<std::vector<double>> &&results)

Try to set a new set of best results for each target.

The best results are only updated if fitness is lower than the current bestResultsFitness

QImage getTargetImage(std::size_t index) const

Get an image of the a target.

std::optional<QImage> getUpdatedBestResultImage(std::size_t index)

Get an image of the current best result for a target.

std::size_t getIterations() const

The number of completed evolve iterations.

bool getIsRunning() const

True if the optimization is currently running.

bool getIsStopping() const

True if requestStop() has been called.

void requestStop()

Stop the evolution as soon as possible.

const std::string &getErrorMessage() const

Returns a message if an error occurred - empty if no errors occurred.

OptimizationOptions

struct sme::simulate::OptimizeOptions

Optimization options.

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

OptAlgorithm optAlgorithm

The algorithm to use.

std::vector<OptParam> optParams

The parameters to optimize.

std::vector<OptCost> optCosts

The costs to minimize.

struct sme::simulate::OptParam

Defines a parameter to be used in optimization.

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

OptParamType optParamType

The type of parameter.

std::string name

The name of this OptParam as displayed to the user.

std::string id

The id of the parameter in the model.

std::string parentId

The id of the parent of the parameter in the model (optional)

double lowerBound

The lower bound on the allowed values of the parameter.

double upperBound

The upper bound on the allowed values of the parameter.

enum class sme::simulate::OptParamType

Types of model parameters that can be used in optimization.

Values:

enumerator ModelParameter
enumerator ReactionParameter
struct sme::simulate::OptCost

Defines a cost function to be minimized.

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

OptCostType optCostType

The type of cost function.

OptCostDiffType optCostDiffType

The type of difference (e.g. absolute, relative) used in the cost function.

std::string name

The name of this OptCost as displayed to the user.

std::string id

The id of the species in the model.

double simulationTime = {1.0}

The simulation time at which the cost function should be calculated.

double weight = {1.0}

The scale factor to multiply the cost by.

This assigns a relative weight to this cost when the optimization involves the sum of multiple cost functions.

std::size_t compartmentIndex

The index of the compartment containing the species.

std::size_t speciesIndex

The index of the species.

std::vector<double> targetValues

The target values to compare with the species concentration or dcdt.

Should contain a value for each pixel in the image, including those outside of the compartment the species is located in. If empty, the target values are assumed to be zero everywhere.

double epsilon = {1e-15}

A small number to avoid dividing by zero in relative differences.

A small value to be added to the denominator of relative differences to avoid numerical issues caused by dividing by zero.

enum class sme::simulate::OptCostType

Types of costs that can be used in optimization.

Values:

enumerator Concentration
enumerator ConcentrationDcdt
enum class sme::simulate::OptCostDiffType

Types of differences that can be used in costs.

Values:

enumerator Absolute
enumerator Relative
struct sme::simulate::OptAlgorithm

Optimization algorithm options.

Public Functions

template<class Archive>
inline void serialize(Archive &ar, std::uint32_t const version)

Public Members

OptAlgorithmType optAlgorithmType = {OptAlgorithmType::PSO}

The algorithm to use.

std::size_t islands = {1}

The number of islands.

std::size_t population = {2}

The population size in each island.

enum class sme::simulate::OptAlgorithmType

Types of algorithms that can be used in optimization.

Values:

enumerator PSO
enumerator GPSO
enumerator DE
enumerator iDE
enumerator jDE
enumerator pDE
enumerator ABC
enumerator gaco