inc
DuneConverter
-
class 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() const
-
const std::unordered_map<std::string, std::vector<double>> &getConcentrations() const
-
const std::unordered_map<std::string, std::vector<std::string>> &getSpeciesNames() const
-
const std::vector<std::string> &getCompartmentNames() const
-
explicit DuneConverter(const model::Model &model, const std::map<std::string, double, std::less<>> &substitutions = {}, bool forExternalUse = false, const QString &outputIniFile = {}, int doublePrecision = 18)
Pde
-
class 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
-
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 = {})
Simulation
-
class Simulation
Public Functions
-
~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>> ×teps, double timeout_ms = -1.0, const std::function<bool()> &stopRunningCallback = {})
-
const std::string &errorMessage() 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
-
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
-
common::ImageStack 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()
-
~Simulation()
SimulationData
-
class SimulationData
SimulationOptions
-
struct Options
Public Functions
-
struct PixelOptions
Public Functions
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}
-
PixelIntegratorType integrator = {PixelIntegratorType::RK212}
-
struct PixelIntegratorError
Public Functions
-
enum class sme::simulate::PixelIntegratorType
Values:
-
enumerator RK101
-
enumerator RK212
-
enumerator RK323
-
enumerator RK435
-
enumerator RK101
-
struct DuneOptions
Public Functions
Public Members
-
DuneDiscretizationType discretization = {DuneDiscretizationType::FEM1}
-
std::string integrator = {"Alexander2"}
-
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 = {0.0}
-
std::string linearSolver = {"RestartedGMRes"}
-
DuneDiscretizationType discretization = {DuneDiscretizationType::FEM1}
Optimization
-
class 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 currentbestResultsFitness
-
std::optional<common::ImageStack> 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.
-
explicit Optimization(sme::model::Model &model)
OptimizationOptions
-
struct OptimizeOptions
Optimization options.
Public Functions
-
struct OptParam
Defines a parameter to be used in optimization.
Public Functions
Public Members
-
OptParamType optParamType
The type of parameter.
-
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.
-
OptParamType optParamType
-
enum class sme::simulate::OptParamType
Types of model parameters that can be used in optimization.
Values:
-
enumerator ModelParameter
-
enumerator ReactionParameter
-
enumerator ModelParameter
-
struct OptCost
Defines a cost function to be minimized.
Public Functions
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 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.
-
OptCostType optCostType
-
enum class sme::simulate::OptCostType
Types of costs that can be used in optimization.
Values:
-
enumerator Concentration
-
enumerator ConcentrationDcdt
-
enumerator Concentration
-
enum class sme::simulate::OptCostDiffType
Types of differences that can be used in costs.
Values:
-
enumerator Absolute
-
enumerator Relative
-
enumerator Absolute
-
struct OptAlgorithm
Optimization algorithm options.
Public Functions
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.
-
OptAlgorithmType optAlgorithmType = {OptAlgorithmType::PSO}