Code Documentation

class korali::neuralNetwork::layer::Activation : public korali::neuralNetwork::Layer
#include <activation.hpp>

Class declaration for module: Activation.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void createForwardPipeline() override

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

Public Members

std::string _function

Indicates the activation function for the weighted inputs to the current layer.

float _alpha

First (alpha) argument to the activation function, as detailed in https://oneapi-src.github.io/oneDNN/dev_guide_eltwise.html.

float _beta

Second (beta) argument to the activation function, as detailed in https://oneapi-src.github.io/oneDNN/dev_guide_eltwise.html.

class korali::solver::optimizer::AdaBelief : public korali::solver::Optimizer
#include <AdaBelief.hpp>

Class declaration for module: AdaBelief.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void processResult(double evaluation, std::vector<double> &gradient)

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

double _beta1

Smoothing factor for momentum update.

double _beta2

Smoothing for gradient update.

double _eta

Learning Rate (Step Size)

double _epsilon

Term to facilitate numerical stability.

std::vector<double> _currentVariable

[Internal Use] Current value of parameters.

std::vector<double> _gradient

[Internal Use] Gradient of Function with respect to Parameters.

std::vector<double> _bestEverGradient

[Internal Use] Gradient of function with respect to Best Ever Variables.

double _gradientNorm

[Internal Use] Norm of gradient of function with respect to Parameters.

std::vector<double> _firstMoment

[Internal Use] Estimate of first moment of Gradient.

std::vector<double> _biasCorrectedFirstMoment

[Internal Use] Bias corrected estimate of first moment of Gradient.

std::vector<double> _secondCentralMoment

[Internal Use] Previous estimate of second moment of Gradient.

std::vector<double> _biasCorrectedSecondCentralMoment

[Internal Use] Bias corrected estimate of second moment of Gradient.

double _minGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

double _maxGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

class korali::solver::optimizer::Adam : public korali::solver::Optimizer
#include <Adam.hpp>

Class declaration for module: Adam.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void processResult(double evaluation, std::vector<double> &gradient)

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

double _beta1

Smoothing factor for momentum update.

double _beta2

Smoothing factor for gradient update.

double _eta

Learning Rate (Step Size)

double _epsilon

Term to facilitate numerical stability.

std::vector<double> _currentVariable

[Internal Use] Current value of parameters.

std::vector<double> _gradient

[Internal Use] Gradient of Function with respect to Parameters.

std::vector<double> _bestEverGradient

[Internal Use] Gradient of function with respect to Best Ever Variables.

std::vector<double> _squaredGradient

[Internal Use] Square of gradient of function with respect to Parameters.

double _gradientNorm

[Internal Use] Norm of gradient of function with respect to Parameters.

std::vector<double> _firstMoment

[Internal Use] Estimate of first moment of Gradient.

std::vector<double> _biasCorrectedFirstMoment

[Internal Use] Bias corrected estimate of first moment of Gradient.

std::vector<double> _secondMoment

[Internal Use] Old estimate of second moment of Gradient.

std::vector<double> _biasCorrectedSecondMoment

[Internal Use] Bias corrected estimate of second moment of Gradient.

double _minGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

double _maxGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

class korali::solver::Agent : public korali::Solver
#include <agent.hpp>

Class declaration for module: Agent.

Subclassed by korali::solver::agent::Continuous, korali::solver::agent::Discrete

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void normalizeStateActionNeuralNetwork(NeuralNetwork *neuralNetwork, size_t miniBatchSize, size_t normalizationSteps)

Mini-batch based normalization routine for Neural Networks with state and action inputs (typically critics)

Parameters
  • neuralNetwork – Neural Network to normalize

  • miniBatchSize – Number of entries in the normalization minibatch

  • normalizationSteps – How many normalization steps to perform (and grab the average)

void normalizeStateNeuralNetwork(NeuralNetwork *neuralNetwork, size_t miniBatchSize, size_t normalizationSteps)

Mini-batch based normalization routine for Neural Networks with state inputs only (typically policy)

Parameters
  • neuralNetwork – Neural Network to normalize

  • miniBatchSize – Number of entries in the normalization minibatch

  • normalizationSteps – How many normalization steps to perform (and grab the average)

void processEpisode(size_t episodeId, knlohmann::json &episode)

Additional post-processing of episode after episode terminated.

Parameters
  • episodeId – The unique identifier of the provided episode

  • episode – A vector of experiences pertaining to the episode.

std::vector<size_t> generateMiniBatch(size_t miniBatchSize)

Generates an experience mini batch from the replay memory.

Parameters

miniBatchSize – Size of the mini batch to create

Returns

A vector with the indexes to the experiences in the mini batch

void updateExperienceMetadata(const std::vector<size_t> &miniBatch, const std::vector<policy_t> &policyData)

Updates the state value, retrace, importance weight and other metadata for a given minibatch of experiences.

Parameters
  • miniBatch – The mini batch of experience ids to update

  • policyData – The policy to use to evaluate the experiences

void resetTimeSequence()

Resets time sequence within the agent, to forget past actions from other episodes.

virtual std::vector<policy_t> runPolicy(const std::vector<std::vector<std::vector<float>>> &stateBatch) = 0

Function to pass a state time series through the NN and calculates the action probabilities, along with any additional information.

Parameters

stateBatch – The batch of state time series (Format: BxTxS, B is batch size, T is the time series lenght, and S is the state size)

Returns

A JSON object containing the information produced by the policies given the current state series

size_t getTimeSequenceStartExpId(size_t expId)

Calculates the starting experience index of the time sequence for the selected experience.

Parameters

expId – The index of the latest experience in the sequence

Returns

The starting time sequence index

std::vector<std::vector<std::vector<float>>> getMiniBatchStateSequence(const std::vector<size_t> &miniBatch, const bool includeAction = false)

Gets a vector of states corresponding of time sequence corresponding to the provided last experience index.

Parameters
  • miniBatch – Indexes to the latest experiences in a batch of sequences

  • includeAction – Specifies whether to include the experience’s action in the sequence

Returns

The time step vector of states

std::vector<std::vector<float>> getTruncatedStateSequence(size_t expId)

Gets a vector of states corresponding of time sequence corresponding to the provided second-to-last experience index for which a truncated state exists.

Parameters

expId – The index of the second-to-latest experience in the sequence

Returns

The time step vector of states, including the truncated state

virtual float calculateImportanceWeight(const std::vector<float> &action, const policy_t &curPolicy, const policy_t &oldPolicy) = 0

Calculates importance weight of current action from old and new policies.

Parameters
  • action – The action taken

  • curPolicy – The current policy

  • oldPolicy – The old policy, the one used for take the action in the first place

Returns

The importance weight

void attendAgent(const size_t agentId)

Listens to incoming experience from the given agent, sends back policy or terminates the episode depending on what’s needed.

Parameters

agentId – The Agent’s ID

void serializeExperienceReplay()

Serializes the experience replay into a JSON compatible format.

void deserializeExperienceReplay()

Deserializes a JSON object into the experience replay.

void trainingGeneration()

Runs a generation when running in training mode.

void testingGeneration()

Runs a generation when running in testing mode.

void rescaleStates()

Rescales states to have a zero mean and unit variance.

inline float getScaledReward(const size_t environmentId, const float reward)

Rescales a given reward by the square root of the sum of squarred rewards.

Parameters
  • environmentId – The id of the environment to which this reward belongs

  • reward – the input reward to rescale

Returns

The normalized reward

virtual void trainPolicy() = 0

Trains the Agent’s policy, based on the new experiences.

virtual knlohmann::json getAgentPolicy() = 0

Obtains the policy hyperaparamters from the learner for the agent to generate new actions.

Returns

The current policy hyperparameters

virtual void setAgentPolicy(const knlohmann::json &hyperparameters) = 0

Updates the agent’s hyperparameters.

Parameters

hyperparameters – The hyperparameters to update the agent.

virtual void initializeAgent() = 0

Initializes the internal state of the policy.

virtual void printAgentInformation() = 0

Prints information about the training policy.

virtual void getAction(korali::Sample &sample) = 0

Gathers the next action either from the policy or randomly.

Parameters

sampleSample on which the action and metadata will be stored

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

Public Members

std::string _mode

Specifies the operation mode for the agent.

std::vector<size_t> _testingSampleIds

A vector with the identifiers for the samples to test the hyperparameters with.

knlohmann::json _testingCurrentPolicy

The current hyperparameters of the policy to test.

size_t _trainingAverageDepth

Specifies the depth of the running training average to report.

size_t _concurrentEnvironments

Indicates the number of concurrent environments to use to collect experiences.

size_t _episodesPerGeneration

Indicates how many episodes to complete in a generation (checkpoints are generated between generations).

size_t _miniBatchSize

The number of experiences to randomly select to train the neural network(s) with.

std::string _miniBatchStrategy

Determines how to select experiences from the replay memory for mini batch creation.

size_t _timeSequenceLength

Indicates the number of contiguous experiences to pass to the NN for learning. This is only useful when using recurrent NNs.

float _learningRate

The initial learning rate to use for the NN hyperparameter optimization.

int _l2RegularizationEnabled

Boolean to determine if l2 regularization will be applied to the neural networks.

float _l2RegularizationImportance

Coefficient for l2 regularization.

knlohmann::json _neuralNetworkHiddenLayers

Indicates the configuration of the hidden neural network layers.

std::string _neuralNetworkOptimizer

Indicates the optimizer algorithm to update the NN hyperparameters.

std::string _neuralNetworkEngine

Specifies which Neural Network backend to use.

float _discountFactor

Represents the discount factor to weight future experiences.

int _experienceReplaySerialize

Indicates whether to serialize and store the experience replay after each generation. Disabling will reduce I/O overheads but will disable the checkpoint/resume function.

size_t _experienceReplayStartSize

The minimum number of experiences before learning starts.

size_t _experienceReplayMaximumSize

The size of the replay memory. If this number is exceeded, experiences are deleted.

float _experienceReplayOffPolicyCutoffScale

Initial Cut-Off to classify experiences as on- or off-policy. (c_max in https://arxiv.org/abs/1807.05827)

float _experienceReplayOffPolicyTarget

Target fraction of off-policy experiences in the replay memory. (D in https://arxiv.org/abs/1807.05827)

float _experienceReplayOffPolicyAnnealingRate

Annealing rate for Off Policy Cutoff Scale and Learning Rate. (A in https://arxiv.org/abs/1807.05827)

float _experienceReplayOffPolicyREFERBeta

Initial value for the penalisation coefficient for off-policiness. (beta in https://arxiv.org/abs/1807.05827)

float _experiencesBetweenPolicyUpdates

The number of experiences to receive before training/updating (real number, may be less than < 1.0, for more than one update per experience).

int _stateRescalingEnabled

Determines whether to normalize the states, such that they have mean 0 and standard deviation 1 (done only once after the initial exploration phase).

int _rewardRescalingEnabled

Determines whether to normalize the rewards, such that they have mean 0 and standard deviation 1.

int _rewardOutboundPenalizationEnabled

If enabled, it penalizes the rewards for experiences with out of bound actions. This is useful for problems with truncated actions (e.g., openAI gym Mujoco) where out of bounds actions are clipped in the environment. This prevents policy means to extend too much outside the bounds.

float _rewardOutboundPenalizationFactor

The factor (f) by which te reward is scaled down. R = f * R.

std::vector<float> _actionLowerBounds

[Internal Use] Lower bounds for actions.

std::vector<float> _actionUpperBounds

[Internal Use] Upper bounds for actions.

size_t _currentEpisode

[Internal Use] Indicates the current episode being processed.

std::vector<float> _trainingRewardHistory

[Internal Use] Keeps a history of all training episode rewards.

std::vector<size_t> _trainingEnvironmentIdHistory

[Internal Use] Keeps a history of all training environment ids.

std::vector<size_t> _trainingExperienceHistory

[Internal Use] Keeps a history of all training episode experience counts.

float _trainingAverageReward

[Internal Use] Contains a running average of the training episode rewards.

float _trainingLastReward

[Internal Use] Remembers the cumulative sum of rewards for the last training episode.

float _trainingBestReward

[Internal Use] Remembers the best cumulative sum of rewards found so far in any episodes.

size_t _trainingBestEpisodeId

[Internal Use] Remembers the episode that obtained the maximum cumulative sum of rewards found so far.

knlohmann::json _trainingCurrentPolicy

[Internal Use] Stores the current training policy configuration.

knlohmann::json _trainingBestPolicy

[Internal Use] Stores the best training policy configuration found so far.

std::vector<float> _testingReward

[Internal Use] The cumulative sum of rewards obtained when evaluating the testing samples.

size_t _experienceReplayOffPolicyCount

[Internal Use] Number of off-policy experiences in the experience replay.

float _experienceReplayOffPolicyRatio

[Internal Use] Current off policy ratio in the experience replay.

float _experienceReplayOffPolicyCurrentCutoff

[Internal Use] Indicates the current cutoff to classify experiences as on- or off-policy

float _currentLearningRate

[Internal Use] The current learning rate to use for the NN hyperparameter optimization.

size_t _policyUpdateCount

[Internal Use] Keeps track of the number of policy updates that have been performed.

size_t _currentSampleID

[Internal Use] Keeps track of the current Sample ID, and makes sure no two equal sample IDs are produced such that this value can be used as random seed.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

size_t _experienceCount

[Internal Use] Count of the number of experiences produced so far.

std::vector<size_t> _experienceCountPerEnvironment

[Internal Use] Count of the number of experiences in the replay memory per environment.

std::vector<float> _rewardRescalingSigma

[Internal Use] Contains the standard deviation of the rewards. They will be scaled by this value in order to normalize the reward distribution in the RM.

std::vector<float> _rewardRescalingSumSquaredRewards

[Internal Use] Sum of squared rewards in experience replay.

size_t _rewardOutboundPenalizationCount

[Internal Use] Keeps track of the number of out of bound actions taken.

std::vector<float> _stateRescalingMeans

[Internal Use] Contains the mean of the states. They will be shifted by this value in order to normalize the state distribution in the RM.

std::vector<float> _stateRescalingSigmas

[Internal Use] Contains the standard deviations of the states. They will be scaled by this value in order to normalize the state distribution in the RM.

size_t _maxEpisodes

[Termination Criteria] The solver will stop when the given number of episodes have been run.

size_t _maxExperiences

[Termination Criteria] The solver will stop when the given number of experiences have been gathered.

size_t _maxPolicyUpdates

[Termination Criteria] The solver will stop when the given number of optimization steps have been performed.

std::vector<Sample> _agents

Array of agents collecting new experiences.

std::vector<bool> _isAgentRunning

Keeps track of the age.

size_t _sessionExperienceCount

Session-specific experience count. This is useful in case of restart: counters from the old session won’t count.

size_t _sessionEpisodeCount

Session-specific episode count. This is useful in case of restart: counters from the old session won’t count.

size_t _sessionGeneration

Session-specific generation count. This is useful in case of restart: counters from the old session won’t count.

size_t _sessionPolicyUpdateCount

Session-specific policy update count. This is useful in case of restart: counters from the old session won’t count.

size_t _sessionExperiencesUntilStartSize

Session-specific counter that keeps track of how many experiences need to be obtained this session to reach the start training threshold.

cBuffer<std::vector<float>> _stateVector

Stores the state of the experience.

cBuffer<std::vector<float>> _actionVector

Stores the action taken by the agent at the given state.

cBuffer<std::vector<float>> _stateTimeSequence

Stores the current sequence of states observed by the agent (limited to time sequence length defined by the user)

cBuffer<size_t> _episodeIdVector

Episode that experience belongs to.

cBuffer<size_t> _episodePosVector

Position within the episode of this experience.

cBuffer<float> _importanceWeightVector

Contains the latest calculation of the experience’s importance weight.

cBuffer<float> _truncatedImportanceWeightVector

Contains the latest calculation of the experience’s truncated importance weight.

cBuffer<float> _priorityVector

For prioritized experience replay, this stores the experience’s priority.

cBuffer<float> _probabilityVector

For prioritized experience replay, this stores the experience’s probability.

cBuffer<policy_t> _curPolicyVector

Contains the most current policy information given the experience state.

cBuffer<policy_t> _expPolicyVector

Contains the policy information produced at the moment of the action was taken.

cBuffer<bool> _isOnPolicyVector

Indicates whether the experience is on policy, given the specified off-policiness criteria.

cBuffer<termination_t> _terminationVector

Specifies whether the experience is terminal (truncated or normal) or not.

cBuffer<float> _retraceValueVector

Contains the result of the retrace (Vtbc) function for the currrent experience.

cBuffer<float> _truncatedStateValueVector

If this is a truncated terminal experience, this contains the state value for that state.

cBuffer<std::vector<float>> _truncatedStateVector

If this is a truncated terminal experience, the truncated state is also saved here.

cBuffer<size_t> _environmentIdVector

Contains the environment id of every experience.

cBuffer<float> _rewardVector

Contains the rewards of every experience.

cBuffer<float> _stateValueVector

Contains the state value evaluation for every experience.

float _priorityAnnealingRate

Stores the priority annealing rate.

float _importanceWeightAnnealingRate

Stores the importance weight annealing factor.

problem::ReinforcementLearning *_problem

Storage for the pointer to the learning problem.

std::random_device rd

Random device for the generation of shuffling numbers.

std::mt19937 *mt

Mersenne twister for the generation of shuffling numbers.

double _sessionRunningTime

[Profiling] Measures the amount of time taken by the generation

double _sessionSerializationTime

[Profiling] Measures the amount of time taken by ER serialization

double _sessionAgentComputationTime

[Profiling] Stores the computation time per episode taken by Agents

double _sessionAgentCommunicationTime

[Profiling] Measures the average communication time per episode taken by Agents

double _sessionAgentPolicyEvaluationTime

[Profiling] Measures the average policy evaluation time per episode taken by Agents

double _sessionPolicyUpdateTime

[Profiling] Measures the time taken to update the policy in the current generation

double _sessionAgentAttendingTime

[Profiling] Measures the time taken to update the attend the agent’s state

double _generationRunningTime

[Profiling] Measures the amount of time taken by the generation

double _generationSerializationTime

[Profiling] Measures the amount of time taken by ER serialization

double _generationAgentComputationTime

[Profiling] Stores the computation time per episode taken by Agents

double _generationAgentCommunicationTime

[Profiling] Measures the average communication time per episode taken by Agents

double _generationAgentPolicyEvaluationTime

[Profiling] Measures the average policy evaluation time per episode taken by Agents

double _generationPolicyUpdateTime

[Profiling] Measures the time taken to update the policy in the current generation

double _generationAgentAttendingTime

[Profiling] Measures the time taken to update the attend the agent’s state

class korali::problem::Bayesian : public korali::Problem
#include <bayesian.hpp>

Class declaration for module: Bayesian.

Subclassed by korali::problem::bayesian::Custom, korali::problem::bayesian::Reference

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void evaluate(korali::Sample &sample)

Produces a generic evaluation from the Posterior distribution of the sample, for optimization with CMAES, DEA, storing it in and stores it in sample[“F(x)”].

Parameters

sample – A Korali Sample

void evaluateLogPrior(korali::Sample &sample)

Evaluates the log prior of the given sample, and stores it in sample[“Log Prior”].

Parameters

sample – A Korali Sample

virtual void evaluateLoglikelihood(korali::Sample &sample) = 0

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

void evaluateLogPosterior(korali::Sample &sample)

Evaluates the log posterior of the given sample, and stores it in sample[“Log Posterior”].

Parameters

sample – A Korali Sample

virtual void evaluateGradient(korali::Sample &sample)

Evaluates the gradient of the objective w.r.t. to the variables, and stores it in sample[“Gradient”].

Parameters

sample – A Korali Sample

void evaluateLogPriorGradient(korali::Sample &sample)

Evaluates the gradient of the logPrior w.r.t. to the variables, and stores it in sample[“logPrior Gradient”].

Parameters

sample – A Korali Sample

inline virtual void evaluateLoglikelihoodGradient(korali::Sample &sample)

Evaluates the gradient of the logLikelikood w.r.t. to the variables, and stores it in sample[“logLikelihood Gradient”].

Parameters

sample – A Korali Sample

virtual void evaluateHessian(korali::Sample &sample)

Evaluates the hessian of the objective w.r.t. to the variables, and stores it in sample[“Hessian”].

Parameters

sample – A Korali Sample

void evaluateLogPriorHessian(korali::Sample &sample)

Evaluates the gradient of the logPrior w.r.t. to the variables, and stores it in sample[“logPrior Hessian”].

Parameters

sample – A Korali Sample

inline virtual void evaluateLogLikelihoodHessian(korali::Sample &sample)

Evaluates the gradient of the logLikelikood w.r.t. to the variables, and stores it in sample[“logLikelihood Hessian”].

Parameters

sample – A Korali Sample

inline virtual void evaluateFisherInformation(korali::Sample &sample)

Evaluates the empirical Fisher information.

Parameters

sample – A Korali Sample

class korali::distribution::univariate::Beta : public korali::distribution::Univariate
#include <beta.hpp>

Class declaration for module: Beta.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _alpha

[Conditional Variable Value]

std::string _alphaConditional

[Conditional Variable Reference]

double _beta

[Conditional Variable Value]

std::string _betaConditional

[Conditional Variable Reference]

template<typename valType, typename timerType>
struct korali::cacheElement_t
#include <kcache.hpp>

Struct that defines an element present in Korali’s cache structure.

Public Members

valType value

Value of the element.

timerType time

Time when the element was last updated.

class korali::distribution::univariate::Cauchy : public korali::distribution::Univariate
#include <cauchy.hpp>

Class declaration for module: Cauchy.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _location

[Conditional Variable Value] Specifies the location of the peak of the distribution.

std::string _locationConditional

[Conditional Variable Reference] Specifies the location of the peak of the distribution.

double _scale

[Conditional Variable Value] Specifies the half-width at half-maximum (HWHM)

std::string _scaleConditional

[Conditional Variable Reference] Specifies the half-width at half-maximum (HWHM)

template<typename T>
class korali::cBuffer
#include <cbuffer.hpp>

This class defines a circular buffer with overwrite policy on add.

Public Functions

inline cBuffer()

Default constructor.

inline cBuffer(size_t size)

Constructor with a specific size.

Parameters

size – The buffer size

inline size_t size()

Returns the current number of elements in the buffer.

Returns

The number of elements

inline void resize(size_t maxSize)

Returns the current number of elements in the buffer.

Parameters

maxSize – The buffer size

inline void add(const T &v)

Adds an element to the buffer.

Parameters

v – The element to add

inline std::vector<T> getVector()

Returns the elements of the buffer in a vector format.

Returns

The vector with the circular buffer elements

inline void clear()

Eliminates all contents of the buffer.

inline T &operator[](size_t pos)

Accesses an element at the required position.

Parameters

pos – The access position

Returns

The element corresponding to the position

Private Members

size_t _maxSize

Size of buffer container.

size_t _size

Number of elements already added.

std::unique_ptr<T[]> _data

Container for data.

size_t _start

Position of the start of the buffer.

size_t _end

Position of the end of the buffer.

class korali::solver::optimizer::CMAES : public korali::solver::Optimizer
#include <CMAES.hpp>

Class declaration for module: CMAES.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void prepareGeneration()

Prepares generation for the next set of evaluations.

void sampleSingle(size_t sampleIdx, const std::vector<double> &randomNumbers)

Evaluates a single sample.

Parameters
  • sampleIdx – Index of the sample to evaluate

  • randomNumbers – Random numbers to generate sample

void adaptC(int hsig)

Adapts the covariance matrix.

Parameters

hsig – Sign

void updateSigma()

Updates scaling factor of covariance matrix.

void updateDistribution()

Updates mean and covariance of Gaussian proposal distribution.

void updateEigensystem(const std::vector<double> &M)

Updates the system of eigenvalues and eigenvectors.

Parameters

M – Input matrix

void numericalErrorTreatment()

Method that checks potential numerical issues and does correction. Not yet implemented.

void eigen(size_t N, const std::vector<double> &C, std::vector<double> &diag, std::vector<double> &Q) const

Function for eigenvalue decomposition.

Parameters
  • N – Matrix size

  • C – Input matrix

  • diag – Sorted eigenvalues

  • Q – eingenvectors of C

void sort_index(const std::vector<double> &vec, std::vector<size_t> &_sortingIndex, size_t N) const

Descending sort of vector elements, stores ordering in _sortingIndex.

Parameters
  • _sortingIndex – Ordering of elements in vector

  • vec – Vector to sort

  • N – Number of current samples.

void initMuWeights(size_t numsamples)

Initializes the weights of the mu vector.

Parameters

numsamples – Length of mu vector

void initCovariance()

Initialize Covariance Matrix and Cholesky Decomposition.

void checkMeanAndSetRegime()

Check if mean of proposal distribution is inside of valid domain (does not violate constraints), if yes, re-initialize internal vars. Method for CCMA-ES.

void updateConstraints()

Update constraint evaluationsa. Method for CCMA-ES.

void updateViabilityBoundaries()

Update viability boundaries. Method for CCMA-ES.

void handleConstraints()

Process samples that violate constraints. Method for CCMA-ES.

void reEvaluateConstraints()

Reevaluate constraint evaluations. Called in handleConstraints. Method for CCMA-ES.

void updateDiscreteMutationMatrix()

Update mutation matrix for discrete variables. Method for discrete/integer optimization.

void discretize(std::vector<double> &sample)

Discretize variables to given granularity using arithmetic rounding.

Parameters

sampleSample to discretize

virtual void setInitialConfiguration() override

Configures CMA-ES.

virtual void runGeneration() override

Executes sampling & evaluation generation.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

virtual void finalize() override

Final console output at termination.

Public Members

size_t _populationSize

Specifies the number of samples to evaluate per generation (preferably $4+3*log(N)$, where $N$ is the number of variables).

size_t _muValue

Number of best samples (offspring samples) used to update the covariance matrix and the mean (by default it is half the Sample Count).

std::string _muType

Weights given to the Mu best values to update the covariance matrix and the mean.

double _initialSigmaCumulationFactor

Controls the learning rate of the conjugate evolution path (by default this variable is internally calibrated).

double _initialDampFactor

Controls the updates of the covariance matrix scaling factor (by default this variable is internally calibrated).

int _useGradientInformation

Include gradient information for proposal distribution update.

float _gradientStepSize

Scaling factor for gradient step, only relevant if gradient information used.

int _isSigmaBounded

Sets an upper bound for the covariance matrix scaling factor. The upper bound is given by the average of the initial standard deviation of the variables.

double _initialCumulativeCovariance

Controls the learning rate of the evolution path for the covariance update (must be in (0,1], by default this variable is internally calibrated).

int _diagonalCovariance

Covariance matrix updates will be optimized for diagonal matrices.

int _mirroredSampling

Generate the negative counterpart of each random number during sampling.

size_t _viabilityPopulationSize

Specifies the number of samples per generation during the viability regime, i.e. during the search for a parameter vector not violating the constraints.

size_t _viabilityMuValue

Number of best samples used to update the covariance matrix and the mean during the viability regime (by default this variable is half the Viability Sample Count).

size_t _maxCovarianceMatrixCorrections

Max number of covairance matrix adaptions per generation during the constraint handling loop.

double _targetSuccessRate

Controls the updates of the covariance matrix scaling factor during the viability regime.

double _covarianceMatrixAdaptionStrength

Controls the covariane matrix adaption strength if samples violate constraints.

double _normalVectorLearningRate

Learning rate of constraint normal vectors (must be in (0, 1], by default this variable is internally calibrated).

double _globalSuccessLearningRate

Learning rate of success probability of objective function improvements.

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Normal random number generator.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

int _isViabilityRegime

[Internal Use] True if mean is outside feasible domain. During viability regime CMA-ES is working with relaxed constraint boundaries that contract towards the true constraint boundaries.

std::vector<double> _valueVector

[Internal Use] Objective function values.

std::vector<std::vector<double>> _gradients

[Internal Use] Gradients of objective function evaluations.

size_t _currentPopulationSize

[Internal Use] Actual number of samples used per generation (Population Size or Viability Population Size).

size_t _currentMuValue

[Internal Use] Actual value of mu (Mu Value or Viability Mu Value).

std::vector<double> _muWeights

[Internal Use] Calibrated Weights for each of the Mu offspring samples.

double _effectiveMu

[Internal Use] Variance effective selection mass.

double _sigmaCumulationFactor

[Internal Use] Increment for sigma, calculated from muEffective and dimension.

double _dampFactor

[Internal Use] Dampening parameter controls step size adaption.

double _cumulativeCovariance

[Internal Use] Controls the step size adaption.

double _chiSquareNumber

[Internal Use] Expectation of $||N(0,I)||^2$.

size_t _covarianceEigenvalueEvaluationFrequency

[Internal Use] Establishes how frequently the eigenvalues are updated.

double _sigma

[Internal Use] Determines the step size.

double _trace

[Internal Use] The trace of the initial covariance matrix.

std::vector<std::vector<double>> _samplePopulation

[Internal Use] Sample coordinate information.

size_t _finishedSampleCount

[Internal Use] Counter of evaluated samples to terminate evaluation.

std::vector<double> _currentBestVariables

[Internal Use] Best variables of current generation.

double _previousBestValue

[Internal Use] Best model evaluation from previous generation.

size_t _bestSampleIndex

[Internal Use] Index of the best sample in current generation.

double _previousBestEverValue

[Internal Use] Best ever model evaluation as of previous generation.

std::vector<size_t> _sortingIndex

[Internal Use] Sorted indeces of samples according to their model evaluation.

std::vector<double> _covarianceMatrix

[Internal Use] (Unscaled) covariance Matrix of proposal distribution.

std::vector<double> _auxiliarCovarianceMatrix

[Internal Use] Temporary Storage for Covariance Matrix.

std::vector<double> _covarianceEigenvectorMatrix

[Internal Use] Matrix with eigenvectors in columns.

std::vector<double> _auxiliarCovarianceEigenvectorMatrix

[Internal Use] Temporary Storage for Matrix with eigenvectors in columns.

std::vector<double> _axisLengths

[Internal Use] Axis lengths (sqrt(Evals))

std::vector<double> _auxiliarAxisLengths

[Internal Use] Temporary storage for Axis lengths.

std::vector<double> _bDZMatrix

[Internal Use] Temporary storage.

std::vector<double> _auxiliarBDZMatrix

[Internal Use] Temporary storage.

std::vector<double> _currentMean

[Internal Use] Current mean of proposal distribution.

std::vector<double> _previousMean

[Internal Use] Previous mean of proposal distribution.

std::vector<double> _meanUpdate

[Internal Use] Update differential from previous to current mean.

std::vector<double> _evolutionPath

[Internal Use] Evolution path for Covariance Matrix update.

std::vector<double> _conjugateEvolutionPath

[Internal Use] Conjugate evolution path for sigma update.

double _conjugateEvolutionPathL2Norm

[Internal Use] L2 Norm of the conjugate evolution path.

size_t _infeasibleSampleCount

[Internal Use] Keeps count of the number of infeasible samples.

double _maximumDiagonalCovarianceMatrixElement

[Internal Use] Maximum diagonal element of the Covariance Matrix.

double _minimumDiagonalCovarianceMatrixElement

[Internal Use] Minimum diagonal element of the Covariance Matrix.

double _maximumCovarianceEigenvalue

[Internal Use] Maximum Covariance Matrix Eigenvalue.

double _minimumCovarianceEigenvalue

[Internal Use] Minimum Covariance Matrix Eigenvalue.

int _isEigensystemUpdated

[Internal Use] Flag determining if the covariance eigensystem is up to date.

std::vector<std::vector<int>> _viabilityIndicator

[Internal Use] Evaluation of each constraint for each sample.

int _hasConstraints

[Internal Use] True if the number of constraints is higher than zero.

double _covarianceMatrixAdaptionFactor

[Internal Use] This is the beta factor that indicates how fast the covariance matrix is adapted.

int _bestValidSample

[Internal Use] Index of best sample without constraint violations (otherwise -1).

double _globalSuccessRate

[Internal Use] Estimated Global Success Rate, required for calibration of covariance matrix scaling factor updates.

double _viabilityFunctionValue

[Internal Use] Viability Function Value.

size_t _resampledParameterCount

[Internal Use] Number of resampled parameters due constraint violation.

size_t _covarianceMatrixAdaptationCount

[Internal Use] Number of Covariance Matrix Adaptations.

std::vector<double> _viabilityBoundaries

[Internal Use] Viability Boundaries.

std::vector<int> _viabilityImprovement

[Internal Use] Sample evaluations larger than fviability.

size_t _maxConstraintViolationCount

[Internal Use] Temporary counter of maximal amount of constraint violations attained by a sample (must be 0).

std::vector<size_t> _sampleConstraintViolationCounts

[Internal Use] Maximal amount of constraint violations.

std::vector<std::vector<double>> _constraintEvaluations

[Internal Use] Functions to be evaluated as constraint evaluations, if the return from any of them is > 0, then the constraint is met.

std::vector<std::vector<double>> _normalConstraintApproximation

[Internal Use] Normal approximation of constraints.

std::vector<double> _bestConstraintEvaluations

[Internal Use] Constraint evaluations for best ever.

int _hasDiscreteVariables

[Internal Use] Flag indicating if at least one of the variables is discrete.

std::vector<double> _discreteMutations

[Internal Use] Vector storing discrete mutations, required for covariance matrix update.

size_t _numberOfDiscreteMutations

[Internal Use] Number of discrete mutations in current generation.

size_t _numberMaskingMatrixEntries

[Internal Use] Number of nonzero entries on diagonal in Masking Matrix.

std::vector<double> _maskingMatrix

[Internal Use] Diagonal Matrix signifying where an integer mutation may be conducted.

std::vector<double> _maskingMatrixSigma

[Internal Use] Sigma of the Masking Matrix.

double _chiSquareNumberDiscreteMutations

[Internal Use] Expectation of $||N(0,I^S)||^2$ for discrete mutations.

double _currentMinStandardDeviation

[Internal Use] Current minimum standard deviation of any variable.

double _currentMaxStandardDeviation

[Internal Use] Current maximum standard deviation of any variable.

size_t _constraintEvaluationCount

[Internal Use] Number of Constraint Evaluations.

size_t _maxInfeasibleResamplings

[Termination Criteria] Maximum number of resamplings per candidate per generation if sample is outside of Lower and Upper Bound.

double _maxConditionCovarianceMatrix

[Termination Criteria] Specifies the maximum condition of the covariance matrix.

double _minStandardDeviation

[Termination Criteria] Specifies the minimal standard deviation for any variable in any proposed sample.

double _maxStandardDeviation

[Termination Criteria] Specifies the maximal standard deviation for any variable in any proposed sample.

class korali::conduit::Concurrent : public korali::Conduit
#include <concurrent.hpp>

Class declaration for module: Concurrent.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool isRoot() override

Determines whether the caller rank/thread/process is root.

Returns

True, if it is root; false, otherwise.

virtual void initServer() override

Initializes the worker/server bifurcation in the conduit.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void terminateServer() override

Finalizes the workers.

virtual void stackEngine(Engine *engine) override

Stacks a new Engine into the engine stack.

Parameters

engine – A Korali Engine

virtual void popEngine() override

Pops the current Engine from the engine stack.

virtual void listenWorkers() override

(Engine <- Worker) Receives all pending incoming messages and stores them into the corresponding sample’s message queue.

virtual void broadcastMessageToWorkers(knlohmann::json &message) override

(Engine -> Worker) Broadcasts a message to all workers

Parameters

message – JSON object with information to broadcast

virtual void sendMessageToEngine(knlohmann::json &message) override

(Sample -> Engine) Sends an update to the engine to provide partial information while the sample is still active

Parameters

message – Message to send to engine

virtual knlohmann::json recvMessageFromEngine() override

(Sample <- Engine) Blocking call that waits until any message incoming from the engine.

Returns

message from the engine.

virtual void sendMessageToSample(Sample &sample, knlohmann::json &message) override

(Engine -> Sample) Sends an update to a still active sample

Parameters
  • sample – The sample from which to receive an update

  • message – Message to send to the sample.

virtual size_t getProcessId() override

Returns the identifier corresponding to the executing process (to differentiate their random seeds)

Returns

The executing process id

Public Members

size_t _concurrentJobs

Specifies the number of worker processes (jobs) running concurrently.

std::vector<pid_t> _workerPids

PID of worker processes.

int _workerId

Worker Id for current workers - 0 for the master process.

std::vector<std::vector<int>> _resultContentPipe

OS Pipe to handle result contents communication coming from worker processes.

std::vector<std::vector<int>> _resultSizePipe

OS Pipe to handle result size communication coming from worker processes.

std::vector<std::vector<int>> _inputsPipe

OS Pipe to handle sample parameter communication to worker processes.

struct korali::problem::hierarchical::Psi::conditionalPriorInfo

Stores the pre-computed positions (pointers) of the conditional priors to evaluate for performance.

Public Members

std::vector<size_t> _samplePositions

Stores the position of the conditional prior.

std::vector<double*> _samplePointers

Stores the pointer of the conditional prior.

class korali::Conduit : public korali::Module
#include <conduit.hpp>

Class declaration for module: Conduit.

Subclassed by korali::conduit::Concurrent, korali::conduit::Distributed, korali::conduit::Sequential

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void worker()

Lifetime function for korali workers.

inline virtual bool isRoot()

Determines whether the caller rank/thread/process is root.

Returns

True, if it is root; false, otherwise.

inline virtual bool isWorkerLeadRank()

Determines whether the caller rank is the leader of its worker root.

Returns

True, if it is the worker leader rank; false, otherwise.

void workerProcessSample(const knlohmann::json &js)

(Worker Side) Starts the processing of a sample at the worker side

Parameters

js – Contains sample’s input data and metadata

void workerStackEngine(const knlohmann::json &js)

(Worker Side) Accepts and stacks an incoming Korali engine from the main process

Parameters

js – Contains Engine’s input data and metadata

void workerPopEngine()

(Worker Side) Pops the top of the engine stack

void start(Sample &sample)

Starts the execution of the sample.

Parameters

sample – A Korali sample

void wait(Sample &sample)

Waits for a given sample to finish. The experiment will not continue until the sample has been evaluated.

Parameters

sample – A Korali sample

void waitAll(std::vector<Sample> &samples)

Waits for a set of sample to finish. The experiment will not continue until all samples have been evaluated.

Parameters

samples – A list of Korali samples

size_t waitAny(std::vector<Sample> &samples)

Waits for a set of sample to finish. The experiment will not continue until at least one of the samples have been evaluated.

Parameters

samples – A list of Korali samples

Returns

Position in the vector of the sample that has finished.

virtual void stackEngine(Engine *engine) = 0

Stacks a new Engine into the engine stack.

Parameters

engine – A Korali Engine

virtual void popEngine() = 0

Pops the current Engine from the engine stack.

void runSample(Sample *sample, Engine *engine)

Starts the execution of a sample, given an Engine.

Parameters
  • sample – the sample to execute

  • engine – The Korali engine to use for its execution

virtual void initServer() = 0

Initializes the worker/server bifurcation in the conduit.

virtual void terminateServer() = 0

Finalizes the workers.

virtual void broadcastMessageToWorkers(knlohmann::json &message) = 0

(Engine -> Worker) Broadcasts a message to all workers

Parameters

message – JSON object with information to broadcast

virtual void listenWorkers() = 0

(Engine <- Worker) Receives all pending incoming messages and stores them into the corresponding sample’s message queue.

void listen(std::vector<Sample> &samples)

Start pending samples and retrieve any pending messages for them.

Parameters

samples – The set of samples

virtual void sendMessageToEngine(knlohmann::json &message) = 0

(Sample -> Engine) Sends an update to the engine to provide partial information while the sample is still active

Parameters

message – Message to send to engine

virtual knlohmann::json recvMessageFromEngine() = 0

(Sample <- Engine) Blocking call that waits until any message incoming from the engine.

Returns

message from the engine.

virtual void sendMessageToSample(Sample &sample, knlohmann::json &message) = 0

(Engine -> Sample) Sends an update to a still active sample

Parameters
  • sample – The sample from which to receive an update

  • message – Message to send to the sample.

virtual size_t getProcessId() = 0

Returns the identifier corresponding to the executing process (to differentiate their random seeds)

Returns

The executing process id

Public Members

std::queue<size_t> _workerQueue

Queue to store idle workers to assign samples to.

std::map<size_t, Sample*> _workerToSampleMap

Map that links workers to their currently-executing sample.

Public Static Functions

static void coroutineWrapper()

Wrapper function for the sample coroutine.

class korali::problem::reinforcementLearning::Continuous : public korali::problem::ReinforcementLearning
#include <continuous.hpp>

Class declaration for module: Continuous.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

class korali::solver::agent::Continuous : public korali::solver::Agent
#include <continuous.hpp>

Class declaration for module: Continuous.

Subclassed by korali::solver::agent::continuous::VRACER

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

std::vector<float> calculateImportanceWeightGradient(const std::vector<float> &action, const policy_t &curPolicy, const policy_t &oldPolicy)

Calculates the gradient of teh importance weight wrt to the parameter of the 2nd (current) distribution evaluated at old action.

Parameters
  • action – The action taken by the agent in the given experience

  • oldPolicy – The policy for the given state used at the time the action was performed

  • curPolicy – The current policy for the given state

Returns

gradient of policy wrt curParamsOne and curParamsTwo

std::vector<float> calculateKLDivergenceGradient(const policy_t &oldPolicy, const policy_t &curPolicy)

Calculates the gradient of KL(p_old, p_cur) wrt to the parameter of the 2nd (current) distribution.

Parameters
  • oldPolicy – The policy for the given state used at the time the action was performed

  • curPolicy – The current policy for the given state

Returns

std::vector<float> generateTrainingAction(policy_t &curPolicy)

Function to generate randomized actions from neural network output.

Parameters

curPolicy – The current policy for the given state

Returns

An action vector

std::vector<float> generateTestingAction(const policy_t &curPolicy)

Function to generate deterministic actions from neural network output required for policy evaluation, respectively testing.

Parameters

curPolicy – The current policy for the given state

Returns

An action vector

virtual float calculateImportanceWeight(const std::vector<float> &action, const policy_t &curPolicy, const policy_t &oldPolicy) override

Calculates importance weight of current action from old and new policies.

Parameters
  • action – The action taken

  • curPolicy – The current policy

  • oldPolicy – The old policy, the one used for take the action in the first place

Returns

The importance weight

virtual void getAction(korali::Sample &sample) override

Gathers the next action either from the policy or randomly.

Parameters

sampleSample on which the action and metadata will be stored

virtual void initializeAgent() override

Initializes the internal state of the policy.

Public Members

std::string _policyDistribution

Specifies which probability distribution to use for the policy.

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Gaussian random number generator to generate the agent’s action.

std::vector<float> _actionShifts

[Internal Use] Shifts required for bounded actions.

std::vector<float> _actionScales

[Internal Use] Scales required for bounded actions (half the action domain width).

size_t _policyParameterCount

[Internal Use] Stores the number of parameters that determine the probability distribution for the current state sequence.

std::vector<std::string> _policyParameterTransformationMasks

[Internal Use] Stores the transformations required for each parameter.

std::vector<float> _policyParameterScaling

[Internal Use] Stores the scaling required for the parameter after the transformation is applied.

std::vector<float> _policyParameterShifting

[Internal Use] Stores the shifting required for the parameter after the scaling is applied.

problem::reinforcementLearning::Continuous *_problem

Storage for the pointer to the (continuous) learning problem.

class korali::problem::bayesian::Custom : public korali::problem::Bayesian
#include <custom.hpp>

Class declaration for module: Custom.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void evaluateLoglikelihood(korali::Sample &sample) override

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

virtual void evaluateLoglikelihoodGradient(korali::Sample &sample) override

Evaluates the gradient of the logLikelikood w.r.t. to the variables, and stores it in sample[“logLikelihood Gradient”].

Parameters

sample – A Korali Sample

virtual void evaluateFisherInformation(korali::Sample &sample) override

Evaluates the empirical Fisher information.

Parameters

sample – A Korali Sample

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

std::uint64_t _likelihoodModel

Stores the user-defined likelihood model. It should return the value of the Log Likelihood of the given sample.

class korali::solver::optimizer::DEA : public korali::solver::Optimizer
#include <DEA.hpp>

Class declaration for module: DEA.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setInitialConfiguration() override

Configures Differential Evolution/.

virtual void runGeneration() override

Executes sampling & evaluation generation.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

virtual void finalize() override

Final console output at termination.

Public Members

size_t _populationSize

Specifies the number of samples to evaluate per generation (preferably 5-10x the number of variables).

double _crossoverRate

Controls the rate at which dimensions of the samples are mixed (must be in [0,1]).

double _mutationRate

Controls the scaling of the vector differentials (must be in [0,2], preferably < 1).

std::string _mutationRule

Controls the Mutation Rate.

std::string _parentSelectionRule

Defines the selection rule of the parent vector.

std::string _acceptRule

Sets the accept rule after sample mutation and evaluation.

int _fixInfeasible

If set true, Korali samples a random sample between Parent and the voiolated boundary. If set false, infeasible samples are mutated again until feasible.

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Normal random number generator.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

std::vector<double> _valueVector

[Internal Use] Objective Function Values.

std::vector<double> _previousValueVector

[Internal Use] Objective Function Values from previous evaluations.

std::vector<std::vector<double>> _samplePopulation

[Internal Use] Sample variable information.

std::vector<std::vector<double>> _candidatePopulation

[Internal Use] Sample candidates variable information.

size_t _bestSampleIndex

[Internal Use] Index of the best sample in current generation.

double _previousBestEverValue

[Internal Use] Best ever model evaluation as of previous generation.

std::vector<double> _currentMean

[Internal Use] Current mean of population.

std::vector<double> _previousMean

[Internal Use] Previous mean of population.

std::vector<double> _currentBestVariables

[Internal Use] Best variables of current generation.

std::vector<double> _maxDistances

[Internal Use] Max distance between samples per dimension.

size_t _infeasibleSampleCount

[Internal Use] Keeps count of infeasible samples so far.

double _currentMinimumStepSize

[Internal Use] Minimum step size of any variable in the current generation.

size_t _maxInfeasibleResamplings

[Termination Criteria] Max number of mutations per sample per generation if infeasible (only relevant if Fix Infeasible is set False).

double _minValue

[Termination Criteria] Specifies the target fitness to stop minimization.

double _minStepSize

[Termination Criteria] Specifies the minimal step size of the population mean from one gneration to another.

Private Functions

void mutateSingle(size_t sampleIdx)

Mutate a sample.

Parameters

sampleIdx – Index of sample to be mutated.

void fixInfeasible(size_t sampleIdx)

Fix sample params that are outside of domain.

Parameters

sampleIdx – Index of sample that is outside of domain.

void updateSolver(std::vector<Sample> &samples)

Update the state of Differential Evolution.

Parameters

samplesSample evaluations.

void initSamples()

Create new set of candidates.

void prepareGeneration()

Mutate samples and distribute them.

class korali::solver::learner::DeepSupervisor : public korali::solver::Learner
#include <deepSupervisor.hpp>

Class declaration for module: DeepSupervisor.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual std::vector<std::vector<float>> &getEvaluation(const std::vector<std::vector<std::vector<float>>> &input) override

For learner modules which have been trained, test returns an inferred output batch, from a batch of inputs to process.

Parameters

input – The inputs from which to infer outputs. Format: BxTxIC (B: Batch Size, T: Time steps, IC: Input channels)

Returns

The inferred batch outputs for the last given timestep. Format: BxOC (B: Batch Size, OC: Output channels)

virtual std::vector<float> getHyperparameters() override

Returns the hyperparameters required to continue training in the future.

Returns

The hyperparameters

virtual void setHyperparameters(const std::vector<float> &hyperparameters) override

Sets the hyperparameters required to continue training from a previous state.

Parameters

hyperparameters – The hyperparameters to use

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

knlohmann::json _neuralNetworkHiddenLayers

Sets the configuration of the hidden layers for the neural network.

knlohmann::json _neuralNetworkOutputActivation

Allows setting an aditional activation for the output layer.

knlohmann::json _neuralNetworkOutputLayer

Sets any additional configuration (e.g., masks) for the output NN layer.

std::string _neuralNetworkEngine

Specifies which Neural Network backend engine to use.

std::string _neuralNetworkOptimizer

Determines which optimizer algorithm to use to apply the gradients on the neural network’s hyperparameters.

std::vector<float> _hyperparameters

Stores the training neural network hyperparameters (weights and biases).

std::string _lossFunction

Function to calculate the difference (loss) between the NN inference and the exact solution and its gradients for optimization.

size_t _stepsPerGeneration

Represents the number of opitmization steps to run per each generation.

float _learningRate

Learning rate for the underlying ADAM optimizer.

int _l2RegularizationEnabled

Regulates if l2 regularization will be applied to the neural network.

int _l2RegularizationImportance

Importance weight of l2 regularization.

float _outputWeightsScaling

Specified by how much will the weights of the last linear transformation of the NN be scaled. A value of < 1.0 is useful for a more deterministic start.

float _currentLoss

[Internal Use] Current value of the loss function.

std::vector<float> _normalizationMeans

[Internal Use] Stores the current neural network normalization mean parameters.

std::vector<float> _normalizationVariances

[Internal Use] Stores the current neural network normalization variance parameters.

float _targetLoss

[Termination Criteria] Specifies the maximum number of suboptimal generations.

problem::SupervisedLearning *_problem

Korali Problem for optimizing NN weights and biases.

korali::Experiment _optExperiment

Korali Experiment for optimizing the NN’s weights and biases.

korali::fGradientBasedOptimizer *_optimizer

Gradient-based solver pointer to access directly (for performance)

NeuralNetwork *_neuralNetwork

A neural network to be trained based on inputs and solutions.

class korali::problem::reinforcementLearning::Discrete : public korali::problem::ReinforcementLearning
#include <discrete.hpp>

Class declaration for module: Discrete.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

std::vector<std::vector<float>> _possibleActions

The set of all possible actions.

class korali::solver::agent::Discrete : public korali::solver::Agent
#include <discrete.hpp>

Class declaration for module: Discrete.

Subclassed by korali::solver::agent::discrete::dVRACER

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual float calculateImportanceWeight(const std::vector<float> &action, const policy_t &curPolicy, const policy_t &oldPolicy) override

Calculates importance weight of current action from old and new policies.

Parameters
  • action – The action taken

  • curPolicy – The current policy

  • oldPolicy – The old policy, the one used for take the action in the first place

Returns

The importance weight

std::vector<float> calculateImportanceWeightGradient(const size_t actionIdx, const std::vector<float> &curPvalues, const std::vector<float> &oldPvalues)

Calculates the gradient of importance weight wrt to NN output.

Parameters
  • actionIdx – Action from memory

  • curPvalues – todo

  • oldPvalues – todo

Returns

gradient of importance weight wrt NN output

std::vector<float> calculateKLDivergenceGradient(const std::vector<float> &oldPvalues, const std::vector<float> &curPvalues)

Calculates the gradient of KL(p_old, p_cur) wrt to the parameter of the 2nd (current) distribution.

Parameters
  • oldPvalues – todo

  • curPvalues – todo

Returns

gradient of KL wrt curParamsOne and curParamsTwo

virtual void getAction(korali::Sample &sample) override

Gathers the next action either from the policy or randomly.

Parameters

sampleSample on which the action and metadata will be stored

virtual void initializeAgent() override

Initializes the internal state of the policy.

Public Members

float _randomActionProbability

Specifies the probability of taking a random action for the epsilon-greedy strategy.

problem::reinforcementLearning::Discrete *_problem

Storage for the pointer to the (discrete) learning problem.

class korali::conduit::Distributed : public korali::Conduit
#include <distributed.hpp>

Class declaration for module: Distributed.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void checkRankCount()

Checks whether the number of MPI workers satisfies the requirement.

virtual void initServer() override

Initializes the worker/server bifurcation in the conduit.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void terminateServer() override

Finalizes the workers.

virtual void stackEngine(Engine *engine) override

Stacks a new Engine into the engine stack.

Parameters

engine – A Korali Engine

virtual void popEngine() override

Pops the current Engine from the engine stack.

virtual void listenWorkers() override

(Engine <- Worker) Receives all pending incoming messages and stores them into the corresponding sample’s message queue.

virtual void broadcastMessageToWorkers(knlohmann::json &message) override

(Engine -> Worker) Broadcasts a message to all workers

Parameters

message – JSON object with information to broadcast

virtual void sendMessageToEngine(knlohmann::json &message) override

(Sample -> Engine) Sends an update to the engine to provide partial information while the sample is still active

Parameters

message – Message to send to engine

virtual knlohmann::json recvMessageFromEngine() override

(Sample <- Engine) Blocking call that waits until any message incoming from the engine.

Returns

message from the engine.

virtual void sendMessageToSample(Sample &sample, knlohmann::json &message) override

(Engine -> Sample) Sends an update to a still active sample

Parameters
  • sample – The sample from which to receive an update

  • message – Message to send to the sample.

virtual size_t getProcessId() override

Returns the identifier corresponding to the executing process (to differentiate their random seeds)

Returns

The executing process id

int getRootRank()

Determines which rank is the root.

Returns

The rank id of the root rank.

virtual bool isRoot() override

Determines whether the caller rank/thread/process is root.

Returns

True, if it is root; false, otherwise.

virtual bool isWorkerLeadRank() override

Determines whether the caller rank is the leader of its worker root.

Returns

True, if it is the worker leader rank; false, otherwise.

Public Members

int _ranksPerWorker

Specifies the number of MPI ranks per Korali worker (k).

int _rankId

ID of the current rank.

int _rankCount

Total number of ranks in execution.

int _workerCount

Number of Korali Teams in execution.

int _workerIdSet

Signals whether the worker has been assigned a team.

int _localRankId

Local ID the rank within its Korali Worker.

std::vector<std::vector<int>> _workerTeams

Storage that contains the rank teams for each worker.

std::vector<int> _rankToWorkerMap

Map that indicates to which worker does the current rank correspond to.

class korali::Distribution : public korali::Module
#include <distribution.hpp>

Class declaration for module: Distribution.

Subclassed by korali::distribution::Multivariate, korali::distribution::Specific, korali::distribution::Univariate

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

gsl_rng *setRange(const std::string rangeString)

Creates and sets the RNG range (state and seed) of the random distribution.

Parameters

rangeString – The range to load, in string of hexadecimal values form

Returns

Pointer to the new range.

std::string getRange(gsl_rng *range) const

Gets a hexadecimal string from a given range’s state and seed.

Parameters

range – Range to read from

Returns

Hexadecimal string produced.

inline virtual void updateDistribution()

Updates the parameters of the distribution based on conditional variables.

inline virtual double *getPropertyPointer(const std::string &property)

Gets the pointer to a distribution property.

Parameters

property – The name of the property to update

Returns

Pointer to the property

Public Members

std::string _name

Defines the name of the distribution.

size_t _randomSeed

Defines the random seed of the distribution.

gsl_rng *_range

Stores the current state of the distribution in hexadecimal notation.

std::map<std::string, double*> _conditionalsMap

Map to store the link between parameter names and their pointers.

double _aux

Auxiliar variable to hold pre-calculated data to avoid re-processing information.

bool _hasConditionalVariables

Indicates whether or not this distribution contains conditional variables.

class korali::solver::agent::discrete::dVRACER : public korali::solver::agent::Discrete
#include <dVRACER.hpp>

Class declaration for module: dVRACER.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void updateVtbc(size_t expId)

Update the V-target or current and previous experiences in the episode.

Parameters

expId – Current Experience Id

void calculatePolicyGradients(const std::vector<size_t> &miniBatch)

Calculates the gradients for the policy/critic neural network.

Parameters

miniBatch – The indexes of the experience mini batch

virtual std::vector<policy_t> runPolicy(const std::vector<std::vector<std::vector<float>>> &stateBatch) override

Function to pass a state time series through the NN and calculates the action probabilities, along with any additional information.

Parameters

stateBatch – The batch of state time series (Format: BxTxS, B is batch size, T is the time series lenght, and S is the state size)

Returns

A JSON object containing the information produced by the policies given the current state series

virtual knlohmann::json getAgentPolicy() override

Obtains the policy hyperaparamters from the learner for the agent to generate new actions.

Returns

The current policy hyperparameters

virtual void setAgentPolicy(const knlohmann::json &hyperparameters) override

Updates the agent’s hyperparameters.

Parameters

hyperparameters – The hyperparameters to update the agent.

virtual void trainPolicy() override

Trains the Agent’s policy, based on the new experiences.

virtual void printAgentInformation() override

Prints information about the training policy.

virtual void initializeAgent() override

Initializes the internal state of the policy.

Public Members

std::vector<float> _statisticsAverageActionSigmas

[Internal Use] Standard deviation of the actions in the minibatch.

learner::DeepSupervisor *_criticPolicyLearner

Pointer to training the actor network.

korali::Experiment _criticPolicyExperiment

Korali experiment for obtaining the agent’s action.

problem::SupervisedLearning *_criticPolicyProblem

Pointer to actor’s experiment problem.

struct korali::solver::sampler::ellipse_t
#include <Nested.hpp>

Ellipse object to generate bounds.

Public Functions

ellipse_t() = delete

Default c-tor (avoid empty initialization).

inline ellipse_t(size_t dim)

Init d-dimensional ellipse without covariance.

Parameters

dim – Dimension of ellipsoid.

void initSphere()

Init d-dimensional unit sphere.

void scaleVolume(double factor)

Scale volume.

Parameters

factor – Volume multiplicator.

Public Members

size_t dim

Dimension of ellipsoid.

size_t num

Number samples in ellipse.

double det

Determinant of covariance.

std::vector<size_t> sampleIdx

Indices of samples from live data set.

std::vector<double> mean

Mean vector of samples in ellipse.

std::vector<double> cov

Covariance Matrix of samples in ellipse.

std::vector<double> invCov

Inverse of Covariance Matrix.

std::vector<double> axes

Axes of the ellipse.

std::vector<double> evals

Eigenvalues of the ellipse.

std::vector<double> paxes

Principal axes of the ellipse.

double volume

Volume estimated from covariance.

double pointVolume

‘True’ volume from which the subset of samples were sampled from.

class korali::Engine
#include <engine.hpp>

A Korali Engine initializes the conduit and experiments, and guides their execution.

Public Functions

Engine()
void saveProfilingInfo(const bool forceSave = false)

Saves the profiling information to the specified path.

Parameters

forceSave – Saves even if the current generation does not divide _profilingFrequency. Reserved for last generation.

void initialize()

Initialization stage of the Korali Engine.

void run(std::vector<Experiment> &experiments)

Stores a set experiments into the experiment list and runs them to completion.

Parameters

experiments – Set of experiments.

void run(Experiment &experiment)

Stores a single experiment into the experiment list and runs it to completion.

Parameters

experiment – The experiment to run.

void start()

Runs the stored list of experiments.

knlohmann::json &operator[](const std::string &key)

C++ wrapper for the getItem operator.

Parameters

key – A C++ string acting as JSON key.

Returns

The referenced JSON object content.

knlohmann::json &operator[](const unsigned long int &key)

C++ wrapper for the getItem operator.

Parameters

key – A C++ integer acting as JSON key.

Returns

The referenced JSON object content.

pybind11::object getItem(const pybind11::object key)

Gets an item from the JSON object at the current pointer position.

Parameters

key – A pybind11 object acting as JSON key (number or string).

Returns

A pybind11 object

void setItem(const pybind11::object key, const pybind11::object val)

Sets an item on the JSON object at the current pointer position.

Parameters
  • key – A pybind11 object acting as JSON key (number or string).

  • val – The value of the item to set.

void serialize(knlohmann::json &js)

Serializes Engine’s data into a JSON object.

Parameters

js – Json object onto which to store the Engine data.

Public Members

Conduit *_conduit

A pointer to the execution conduit. Shared among all experiments in the engine.

std::string _verbosityLevel

Verbosity level of the Engine (‘Silent’, ‘Minimal’ (default), ‘Normal’ or ‘Detailed’).

std::vector<Experiment*> _experimentVector

Stores the list of experiments to run.

cothread_t _thread

Stores the main execution thread (coroutine).

std::string _profilingPath

Saves the output path for the profiling information file.

std::string _profilingDetail

Specifies how much detail will be saved in the profiling file (None, Full)

double _profilingFrequency

Specifies every how many generation will the profiling file be updated.

std::chrono::time_point<std::chrono::high_resolution_clock> _profilingLastSave

Stores the timepoint of the last time the profiling information was saved.

KoraliJson _js

Stores the JSON based configuration for the engine.

bool _isDryRun

Determines whether this is a dry run (no conduit initialization nor execution)

Experiment *_currentExperiment

(Worker) Stores a pointer to the current Experiment being processed

Public Static Functions

static Engine *deserialize(const knlohmann::json &js)

Deserializes JSON object and returns a Korali Engine.

Parameters

js – Json object onto which to store the Engine data.

Returns

The Korali Engine

class korali::solver::Executor : public korali::Solver
#include <executor.hpp>

Class declaration for module: Executor.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void runGeneration() override

Generate a sample and evaluate it.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

Public Members

size_t _executionsPerGeneration

Specifies the number of model executions per generation. By default this setting is 0, meaning that all executions will be performed in the first generation. For values greater 0, executions will be split into batches and split int generations for intermediate output.

size_t _sampleCount

[Internal Use] Number of samples to execute.

class korali::Experiment : public korali::Module
#include <experiment.hpp>

Class declaration for module: Experiment.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

Experiment()
virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

pybind11::object getItem(const pybind11::object key)

Gets an item from the JSON object at the current pointer position.

Parameters

key – A pybind11 object acting as JSON key (number or string).

Returns

A pybind11 object

void setItem(const pybind11::object key, const pybind11::object val)

Sets an item on the JSON object at the current pointer position.

Parameters
  • key – A pybind11 object acting as JSON key (number or string).

  • val – The value of the item to set.

bool loadState(const std::string &path)

Load the state of an experiment from a Korali result file.

Parameters

path – Path from which to load the experiment state.

Returns

true, if file was found; false, otherwise

void saveState()

Saves the state into the experiment’s result path.

void run()

Start the execution of the current experiment.

knlohmann::json &operator[](const std::string &key)

C++ wrapper for the getItem operator.

Parameters

key – A C++ string acting as JSON key.

Returns

The referenced JSON object content.

std::vector<std::vector<float>> getEvaluation(const std::vector<std::vector<std::vector<float>>> &inputBatch)

For learner modules which have been trained, test returns an inferred output batch, from a batch of inputs to process.

Parameters

inputBatch – The inputs from which to infer outputs. Format: TxBxIC (T: Time steps, B: Batch Size, IC: Input channels)

Returns

The inferred outputs. Format: BxOC (Time steps, B: Batch Size, OC: Output channels)

void setSeed(knlohmann::json &js)

Initializes seed to a random value based on current time if not set by the user (i.e. Random Seed is 0).

Parameters

js – Json object onto which to store the Experiment data.

Public Members

size_t _randomSeed

Specifies the initializing seed for the generation of random numbers. If 0 is specified, Korali will automatically derivate a new seed base on the current time.

int _preserveRandomNumberGeneratorStates

Indicates that the engine must preserve the state of their RNGs for reproducibility purposes.

std::vector<korali::distribution::Univariate*> _distributions

Represents the distributions to use during execution.

std::vector<korali::Variable*> _variables

Sample coordinate information.

korali::Problem *_problem

Represents the configuration of the problem to solve.

korali::Solver *_solver

Represents the state and configuration of the solver algorithm.

std::string _fileOutputPath

Specifies the path of the results directory.

int _fileOutputUseMultipleFiles

If true, Korali stores a different generation file per generation with incremental numbering. If disabled, Korali stores the latest generation files into a single file, overwriting previous results.

int _fileOutputEnabled

Specifies whether the partial results should be saved to the results directory.

size_t _fileOutputFrequency

Specifies how often (in generations) will partial result files be saved on the results directory. The default, 1, indicates that every generation’s results will be saved. 0 indicates that only the latest is saved.

int _storeSampleInformation

Specifies whether the sample information should be saved to samples.json in the results path.

std::string _consoleOutputVerbosity

Specifies how much information will be displayed on console when running Korali.

size_t _consoleOutputFrequency

Specifies how often (in generations) will partial results be printed on console. The default, 1, indicates that every generation’s results will be printed.

size_t _currentGeneration

[Internal Use] Indicates the current generation in execution.

int _isFinished

[Internal Use] Indicates whether execution has reached a termination criterion.

size_t _runID

[Internal Use] Specifies the Korali run’s unique identifier. Used to distinguish run results when two or more use the same output directory.

std::string _timestamp

[Internal Use] Indicates the current time when saving a result file.

KoraliJson _js

JSON object to store the experiment’s configuration.

Logger *_logger

A pointer to the Experiment’s logger object.

Engine *_engine

A pointer to the parent engine.

KoraliJson _sampleInfo

JSON object to details of all the samples that have been executed, if requested by the user.

size_t _experimentId

Experiment Identifier.

cothread_t _thread

Experiment’s coroutine (thread). It is swapped among other experiments, and sample threads.

bool _isInitialized

Flag to indicate that the experiment has been initialized to prevent it from re-initializing upon resuming.

double _resultSavingTime

[Profiling] Measures the amount of time taken by saving results

bool _overrideEngine = false

For testing purposes, this field establishes whether the engine is the one to run samples (default = false) or a custom function (true)

std::function<void(Sample&)> _overrideFunction

For testing purposes, this field establishes which custom function to use to override the engine on sample execution for testing.

class korali::distribution::univariate::Exponential : public korali::distribution::Univariate
#include <exponential.hpp>

Class declaration for module: Exponential.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _location

[Conditional Variable Value]

std::string _locationConditional

[Conditional Variable Reference]

double _mean

[Conditional Variable Value]

std::string _meanConditional

[Conditional Variable Reference]

class korali::fAdaBelief : public korali::fAdam
#include <fAdaBelief.hpp>

Class declaration for module: AdaBelief.

Public Functions

fAdaBelief(size_t nVars)

Default constructor for the optimizer.

Parameters

nVars – Variable-space dimensionality

virtual void processResult(float evaluation, std::vector<float> &gradient) override

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() override

Restores the optimizer to the initial state.

Public Members

std::vector<float> _secondCentralMoment

[Internal Use] Old estimate of second moment of Gradient.

class korali::fAdagrad : public korali::fAdam
#include <fAdagrad.hpp>

Class declaration for module: MADGRAD.

Public Functions

fAdagrad(size_t nVars)

Default constructor for the optimizer.

Parameters

nVars – Variable-space dimensionality

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void processResult(float evaluation, std::vector<float> &gradient) override

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() override

Restores the optimizer to the initial state.

virtual void printInfo() override

Prints progress information.

Public Members

std::vector<float> _s

Squared Gradient Component.

class korali::fAdam : public korali::fGradientBasedOptimizer
#include <fAdam.hpp>

Class declaration for module: Adam.

Subclassed by korali::fAdaBelief, korali::fAdagrad

Public Functions

fAdam(size_t nVars)

Default constructor for the optimizer.

Parameters

nVars – Variable-space dimensionality

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void processResult(float evaluation, std::vector<float> &gradient) override

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() override

Restores the optimizer to the initial state.

virtual void printInfo() override

Prints progress information.

Public Members

float _beta1

Beta for momentum update.

float _beta2

Beta for gradient update.

float _beta1Pow

Running powers of _beta2.

float _beta2Pow

Running powers of _beta2.

float _epsilon

Smoothing Term.

std::vector<float> _firstMoment

[Internal Use] Estimate of first moment of Gradient.

std::vector<float> _secondMoment

[Internal Use] Old estimate of second moment of Gradient.

float _minGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

float _maxGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

class korali::fCMAES
#include <fCMAES.hpp>

Class declaration for module: fCMAES.

Public Functions

fCMAES(size_t nVars, size_t populationSize = 0, size_t muSize = 0)

Default constructor for the optimizer.

Parameters
  • nVars – Variable-space dimensionality

  • populationSize – How many samples per generation to use

  • muSize – How many sample selections for covariance matrix adaptation

~fCMAES()

Default destructor for the optimizer.

void setSeed(size_t seed)

Defines the random number generator seed.

Parameters

seed – Random seed

bool checkTermination()

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

void prepareGeneration()

Prepares generation for the next set of evaluations.

void sampleSingle(size_t sampleIdx)

Evaluates a single sample.

Parameters

sampleIdx – Index of the sample to evaluate

void adaptC(int hsig)

Adapts the covariance matrix.

Parameters

hsig – Sign

void updateSigma()

Updates scaling factor of covariance matrix.

void updateDistribution(const std::vector<float> &evaluations)

Updates mean and covariance of Gaussian proposal distribution.

Parameters

evaluations – Model evaluations for all proposed samples

void updateEigensystem(std::vector<float> &M)

Updates the system of eigenvalues and eigenvectors.

Parameters

M – Input matrix

void eigen(size_t N, std::vector<float> &C, std::vector<float> &diag, std::vector<float> &Q) const

Function for eigenvalue decomposition.

Parameters
  • N – Matrix size

  • C – Input matrix

  • diag – Means

  • Q – Output Matrix

void sort_index(const std::vector<float> &vec, std::vector<size_t> &_sortingIndex, size_t N) const

Descending sort of vector elements, stores ordering in _sortingIndex.

Parameters
  • _sortingIndex – Ordering of elements in vector

  • vec – Vector to sort

  • N – Number of current samples.

void initMuWeights(size_t numsamples)

Initializes the weights of the mu vector.

Parameters

numsamples – Length of mu vector

void initCovariance()

Initialize Covariance Matrix and Cholesky Decomposition.

void printInfo()

Console output after generation.

void reset()

Restores the optimizer to the initial state.

bool isSampleFeasible(const std::vector<float> &sample)

Checks whether a proposed sample is feasible (all variables within acceptable range)

Parameters

sampleSample to check

Returns

Whether the sample is feasible

Public Members

size_t _nVars

Number of problem variables.

size_t _currentGeneration

Counter for the current generation.

std::vector<float> _initialMeans

Indicates the initial gaussian means for all variables.

std::vector<float> _initialStandardDeviations

Indicates the initial gaussian standard deviations for all variables.

std::vector<float> _lowerBounds

Indicates the lower bounds for all variables.

std::vector<float> _upperBounds

Indicates the upper bounds for all variables.

std::default_random_engine _randomGenerator

Random number generator.

std::normal_distribution<float> _normalGenerator

Gaussian number generator.

size_t _populationSize

Specifies the number of samples to evaluate per generation (default: $4+3*log(N)$, where $N$ is the number of variables).

size_t _muValue

Number of best samples used to update the covariance matrix and the mean (by default it is half the Sample Count).

std::string _muType

Weights given to the Mu best values to update the covariance matrix and the mean.

float _initialSigmaCumulationFactor

Controls the learning rate of the conjugate evolution path (by default this variable is internally calibrated).

float _initialDampFactor

Controls the updates of the covariance matrix scaling factor (by default this variable is internally calibrated).

int _isSigmaBounded

Sets an upper bound for the covariance matrix scaling factor. The upper bound is given by the average of the initial standard deviation of the variables.

float _initialCumulativeCovariance

Controls the learning rate of the evolution path for the covariance update (must be in (0,1], by default this variable is internally calibrated).

int _isDiagonal

Covariance matrix updates will be optimized for diagonal matrices.

std::vector<float> _valueVector

[Internal Use] Objective function values.

std::vector<float> _previousValueVector

[Internal Use] Objective function values from previous generation.

std::vector<float> _muWeights

[Internal Use] Weights for each of the Mu samples.

float _effectiveMu

[Internal Use] Variance effective selection mass.

float _sigmaCumulationFactor

[Internal Use] Increment for sigma, calculated from muEffective and dimension.

float _dampFactor

[Internal Use] Dampening parameter controls step size adaption.

float _cumulativeCovariance

[Internal Use] Controls the step size adaption.

float _chiSquareNumber

[Internal Use] Expectation of $||N(0,I)||^2$.

size_t _covarianceEigenvalueEvaluationFrequency

[Internal Use] Establishes how frequently the eigenvalues are updated.

float _sigma

[Internal Use] Determines the step size.

bool _noUpdatePossible

[Internal Use] This flag remembers if it was not possible to produce an update and terminates

float _trace

[Internal Use] The trace of the initial covariance matrix.

std::vector<std::vector<float>> _samplePopulation

[Internal Use] Sample coordinate information.

size_t _finishedSampleCount

[Internal Use] Counter of evaluated samples to terminate evaluation.

float _currentBestValue

[Internal Use] Best model evaluation from current generation.

std::vector<float> _currentBestVariables

[Internal Use] Best variables of current generation.

std::vector<float> _bestEverVariables

[Internal Use] Best ever found variables.

float _previousBestValue

[Internal Use] Best model evaluation from previous generation.

size_t _bestSampleIndex

[Internal Use] Index of the best sample in current generation.

float _bestEverValue

[Internal Use] Best ever model evaluation.

float _previousBestEverValue

[Internal Use] Best ever model evaluation as of previous generation.

std::vector<size_t> _sortingIndex

[Internal Use] Sorted indeces of samples according to their model evaluation.

std::vector<float> _covarianceMatrix

[Internal Use] (Unscaled) covariance Matrix of proposal distribution.

std::vector<float> _auxiliarCovarianceMatrix

[Internal Use] Temporary Storage for Covariance Matrix.

std::vector<float> _covarianceEigenvectorMatrix

[Internal Use] Matrix with eigenvectors in columns.

std::vector<float> _auxiliarCovarianceEigenvectorMatrix

[Internal Use] Temporary Storage for Matrix with eigenvectors in columns.

std::vector<float> _axisLengths

[Internal Use] Axis lengths (sqrt(Evals))

std::vector<float> _auxiliarAxisLengths

[Internal Use] Temporary storage for Axis lengths.

std::vector<float> _bDZMatrix

[Internal Use] Temporary storage.

std::vector<float> _auxiliarBDZMatrix

[Internal Use] Temporary storage.

std::vector<float> _currentMean

[Internal Use] Current mean of proposal distribution.

std::vector<float> _previousMean

[Internal Use] Previous mean of proposal distribution.

std::vector<float> _meanUpdate

[Internal Use] Update differential from previous to current mean.

std::vector<float> _evolutionPath

[Internal Use] Evolution path for Covariance Matrix update.

std::vector<float> _conjugateEvolutionPath

[Internal Use] Conjugate evolution path for sigma update.

float _conjugateEvolutionPathL2Norm

[Internal Use] L2 Norm of the conjugate evolution path.

size_t _infeasibleSampleCount

[Internal Use] Keeps count of the number of infeasible samples.

float _maximumDiagonalCovarianceMatrixElement

[Internal Use] Maximum diagonal element of the Covariance Matrix.

float _minimumDiagonalCovarianceMatrixElement

[Internal Use] Minimum diagonal element of the Covariance Matrix.

float _maximumCovarianceEigenvalue

[Internal Use] Maximum Covariance Matrix Eigenvalue.

float _minimumCovarianceEigenvalue

[Internal Use] Minimum Covariance Matrix Eigenvalue.

int _isEigensystemUpdated

[Internal Use] Flag determining if the covariance eigensystem is up to date.

float _covarianceMatrixAdaptionFactor

[Internal Use] This is the beta factor that indicates how fast the covariance matrix is adapted.

float _globalSuccessRate

[Internal Use] Estimated Global Success Rate, required for calibration of covariance matrix scaling factor updates.

size_t _covarianceMatrixAdaptationCount

[Internal Use] Number of Covariance Matrix Adaptations.

float _currentMinStandardDeviation

[Internal Use] Current minimum standard deviation of any variable.

float _currentMaxStandardDeviation

[Internal Use] Current maximum standard deviation of any variable.

size_t _maxInfeasibleResamplings

[Termination Criteria] Maximum number of resamplings per candidate per generation if sample is outside of Lower and Upper Bound.

float _maxConditionCovarianceMatrix

[Termination Criteria] Specifies the maximum condition of the covariance matrix.

float _minValue

[Termination Criteria] Specifies the minimum target fitness to stop minimization.

float _maxValue

[Termination Criteria] Specifies the maximum target fitness to stop maximization.

float _minValueDifferenceThreshold

[Termination Criteria] Specifies the minimum fitness differential between two consecutive generations before stopping execution.

float _targetMaxStandardDeviation

[Termination Criteria] Finishes execution when the maximum standard deviation falls below this threshold

std::vector<float> _minMeanUpdates

[Termination Criteria] Specifies the mininum update to the variable means before triggering termination.

size_t _maxGenerations

Stores how many generations to run for.

gsl_vector *_gsl_eval

Internal GSL storage.

gsl_matrix *_gsl_evec

Internal GSL storage.

gsl_eigen_symmv_workspace *_gsl_work

Internal GSL storage.

class korali::fGradientBasedOptimizer
#include <fGradientBasedOptimizer.hpp>

Class declaration for module: GRADIENT_BASED_OPTIMIZER.

Subclassed by korali::fAdam, korali::fMadGrad, korali::fRMSProp

Public Functions

virtual ~fGradientBasedOptimizer() = default

Default destructor to avoid warnings.

virtual bool checkTermination() = 0

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void processResult(float evaluation, std::vector<float> &gradient) = 0

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() = 0

Restores the optimizer to the initial state.

virtual void printInfo() = 0

Prints progress information.

Public Members

size_t _nVars

Number of problem variables.

float _eta

Learning Rate.

float _decay

Decay for gradient update.

size_t _currentGeneration

Counter for the current generation.

std::vector<float> _initialValues

Initial values for the variables.

size_t _maxGenerations

Indicates how many generations to run.

size_t _modelEvaluationCount

Keeps track of how many model evaluations performed.

std::vector<float> _currentValue

[Internal Use] Current value of parameters.

float _currentEvaluation

[Internal Use] Function evaluation for the current parameters.

float _bestEvaluation

[Internal Use] Smaller function evaluation

std::vector<float> _gradient

[Internal Use] Gradient of Function with respect to Parameters.

class korali::fMadGrad : public korali::fGradientBasedOptimizer
#include <fMadGrad.hpp>

Class declaration for module: MADGRAD.

Public Functions

fMadGrad(size_t nVars)

Default constructor for the optimizer.

Parameters

nVars – Variable-space dimensionality

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void processResult(float evaluation, std::vector<float> &gradient) override

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() override

Restores the optimizer to the initial state.

virtual void printInfo() override

Prints progress information.

Public Members

std::vector<float> _s

Gradient Component.

std::vector<float> _v

Squared Gradient Component.

std::vector<float> _z

Update rule.

float _epsilon

Safety addition on divide.

float _momentum

Update momentum.

struct korali::solver::sampler::fparam_s
#include <TMCMC.hpp>

Struct for TMCMC optimization operations.

Public Members

const double *loglike

Likelihood values in current generation.

size_t Ns

Population size of current generation.

double exponent

Annealing exponent of current generation.

double cov

Target coefficient of variation.

class korali::fRMSProp : public korali::fGradientBasedOptimizer
#include <fRMSProp.hpp>

Class declaration for module: MADGRAD.

Public Functions

fRMSProp(size_t nVars)

Default constructor for the optimizer.

Parameters

nVars – Variable-space dimensionality

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void processResult(float evaluation, std::vector<float> &gradient) override

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void reset() override

Restores the optimizer to the initial state.

virtual void printInfo() override

Prints progress information.

Public Members

std::vector<float> _r

Square gradient contribution.

std::vector<float> _v

Update rule.

float _epsilon

Safety addition on divide.

float _decay

Decay of gradient contribution over time.

class korali::distribution::univariate::Gamma : public korali::distribution::Univariate
#include <gamma.hpp>

Class declaration for module: Gamma.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _shape

[Conditional Variable Value]

std::string _shapeConditional

[Conditional Variable Reference]

double _scale

[Conditional Variable Value]

std::string _scaleConditional

[Conditional Variable Reference]

class korali::solver::learner::GaussianProcess : public korali::solver::Learner
#include <gaussianProcess.hpp>

Class declaration for module: GaussianProcess.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual std::vector<std::vector<float>> &getEvaluation(const std::vector<std::vector<std::vector<float>>> &input) override

For learner modules which have been trained, test returns an inferred output batch, from a batch of inputs to process.

Parameters

input – The inputs from which to infer outputs. Format: BxTxIC (B: Batch Size, T: Time steps, IC: Input channels)

Returns

The inferred batch outputs for the last given timestep. Format: BxOC (B: Batch Size, OC: Output channels)

virtual std::vector<float> getHyperparameters() override

Returns the hyperparameters required to continue training in the future.

Returns

The hyperparameters

virtual void setHyperparameters(const std::vector<float> &hyperparameters) override

Sets the hyperparameters required to continue training from a previous state.

Parameters

hyperparameters – The hyperparameters to use

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

std::string _covarianceFunction

Covariance function for the libgp library.

float _defaultHyperparameter

Default value of the hyperparameters, used to initialize the Gaussian Processes.

knlohmann::json _optimizer

Represents the state and configuration of the optimization algorithm.

size_t _gpInputDimension

[Internal Use] Dimension of the input space.

size_t _gpParameterDimension

[Internal Use] Number of the Gaussian Process’ parameters.

std::vector<float> _gpHyperparameters

[Internal Use] Gaussian Process’ hyperparameters.

int _terminateWithOptimizer

[Termination Criteria] Execution will end as soon as the internal optimizer reaches one of its termination criteria.

std::vector<std::vector<float>> _outputValues

Storage for the output values.

problem::SupervisedLearning *_problem

Korali engine for optimizing NN weights and biases.

std::unique_ptr<libgp::GaussianProcess> _gp

Pointer to the gaussian processes library.

Experiment _koraliExperiment

Korali experiment for optimizing the GP’s parameters.

class korali::distribution::univariate::Geometric : public korali::distribution::Univariate
#include <geometric.hpp>

Class declaration for module: Geometric.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _successProbability

[Conditional Variable Value]

std::string _successProbabilityConditional

[Conditional Variable Reference]

class korali::solver::optimizer::GridSearch : public korali::solver::Optimizer
#include <gridSearch.hpp>

Class declaration for module: GridSearch.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

size_t _numberOfValues

[Internal Use] Total number of parameter to evaluate (samples per generation).

std::vector<double> _objective

[Internal Use] Vector containing values of the objective function.

std::vector<size_t> _indexHelper

[Internal Use] Holds helper to calculate cartesian indices from linear index.

class korali::neuralNetwork::layer::recurrent::GRU : public korali::neuralNetwork::layer::Recurrent
#include <gru.hpp>

Class declaration for module: GRU.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void createForwardPipeline() override

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

class korali::solver::sampler::Hamiltonian
#include <hamiltonian_base.hpp>

Abstract base class for Hamiltonian objects.

Subclassed by korali::solver::sampler::HamiltonianEuclidean, korali::solver::sampler::HamiltonianRiemannian

Public Functions

Hamiltonian() = default

Default constructor.

inline Hamiltonian(const size_t stateSpaceDim, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • k – Pointer to Korali object.

virtual ~Hamiltonian() = default

Destructor of abstract base class.

virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely abstract total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverse of metric.

Returns

Total energy.

virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely virtual kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverse of metric.

Returns

Kinetic energy.

virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely virtual gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverse metric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual double U()

Potential Energy function.

Returns

Potential energy.

inline virtual std::vector<double> dU()

Gradient of Potential Energy function.

Returns

Gradient of Potential energy.

virtual double tau(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely virtual function tau(q, p) = 0.5 * momentum^T * inverseMetric(q) * momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

virtual std::vector<double> dtau_dq(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely virtual gradient of dtau_dq(q, p) wrt. position.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

virtual std::vector<double> dtau_dp(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) = 0

Purely virtual gradient of dtau_dp(q, p) wrt. momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

virtual double phi() = 0

Purely virtual gradient of kinetic energy.

Returns

Gradient of kinetic energy.

virtual std::vector<double> dphi_dq() = 0

Purely virtual gradient of kinetic energy.

Returns

Gradient of kinetic energy.

virtual double innerProduct(const std::vector<double> &leftMomentum, const std::vector<double> &rightMomentum, const std::vector<double> &inverseMetric) const = 0

Purely virtual, calculates inner product induces by inverse metric.

Parameters
  • leftMomentum – Left vector of inner product.

  • rightMomentum – Right vector of inner product.

  • inverseMetric – Inverse of current metric.

Returns

inner product

inline virtual void updateHamiltonian(const std::vector<double> &position, std::vector<double> &metric, std::vector<double> &inverseMetric)

Updates current position of hamiltonian.

Parameters
  • position – Current position.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const = 0

Purely virtual function to generates momentum vector.

Parameters

metric – Current metric.

Returns

Momentum sampled from normal distribution with metric as covariance matrix.

inline bool computeStandardCriterion(const std::vector<double> &positionLeft, const std::vector<double> &momentumLeft, const std::vector<double> &positionRight, const std::vector<double> &momentumRight) const

Computes NUTS criterion on euclidean domain.

Parameters
  • positionLeft – Leftmost position.

  • momentumLeft – Leftmost momentum.

  • positionRight – Rightmost position.

  • momentumRight – Rightmost momentum.

Returns

Returns criterion if tree should be further increased.

inline virtual int updateMetricMatricesEuclidean(const std::vector<std::vector<double>> &samples, std::vector<double> &metric, std::vector<double> &inverseMetric)

Updates Inverse Metric by approximating the covariance matrix with the Fisher information.

Parameters
  • samples – Vector of samples.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code of Cholesky decomposition.

inline virtual int updateMetricMatricesRiemannian(std::vector<double> &metric, std::vector<double> &inverseMetric)

Updates Metric and Inverse Metric by using hessian.

Parameters
  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code to indicate if update was successful.

Public Members

size_t _modelEvaluationCount

Number of model evaluations.

korali::Experiment *_k

Pointer to the korali experiment.

korali::problem::Sampling *samplingProblemPtr

Pointer to the sampling problem (might be NULL)

korali::problem::Bayesian *bayesianProblemPtr

Pointer to the Bayesian problem (might be NULL)

double _currentEvaluation

Current evaluation of objective (return value of sample evaluation).

std::vector<double> _currentGradient

Current gradient of objective (return value of sample evaluation).

size_t _stateSpaceDim

State Space Dimension needed for Leapfrog integrator.

class korali::solver::sampler::HamiltonianEuclidean : public korali::solver::sampler::Hamiltonian
#include <hamiltonian_euclidean_base.hpp>

Abstract base class for Euclidean Hamiltonian objects.

Subclassed by korali::solver::sampler::HamiltonianEuclideanDense, korali::solver::sampler::HamiltonianEuclideanDiag

Public Functions

HamiltonianEuclidean() = default

Default constructor.

inline HamiltonianEuclidean(const size_t stateSpaceDim, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • k – Pointer to Korali object.

virtual ~HamiltonianEuclidean() = default

Destructor of abstract base class.

inline virtual double tau(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates tau(q, p) = 0.5 * momentum^T * inverseMetric(q) * momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dq(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. position.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dp(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual double phi() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual std::vector<double> dphi_dq() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

class korali::solver::sampler::HamiltonianEuclideanDense : public korali::solver::sampler::HamiltonianEuclidean
#include <hamiltonian_euclidean_dense.hpp>

Used for calculating energies with euclidean metric.

Public Functions

inline HamiltonianEuclideanDense(const size_t stateSpaceDim, korali::distribution::multivariate::Normal *multivariateGenerator, const std::vector<double> &metric, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • metric – Metric of space.

  • multivariateGenerator – Generator needed for momentum sampling.

  • k – Pointer to Korali object.

~HamiltonianEuclideanDense() = default

Destructor of derived class.

inline virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Total energy.

inline virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Kinetic energy.

inline virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of kinetic energy wrt. current momentum.

inline virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const override

Generates sample of momentum.

Parameters

metric – Current metric.

Returns

Momentum sampled from normal distribution with metric as covariance matrix.

inline virtual double innerProduct(const std::vector<double> &leftMomentum, const std::vector<double> &rightMomentum, const std::vector<double> &inverseMetric) const override

Calculates inner product induced by inverse metric.

Parameters
  • leftMomentum – Left vector of inner product.

  • rightMomentum – Right vector of inner product.

  • inverseMetric – Inverse of current metric.

Returns

inner product

inline virtual int updateMetricMatricesEuclidean(const std::vector<std::vector<double>> &samples, std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates inverse Metric by approximating the covariance matrix with the Fisher information.

Parameters
  • samples – Vector of samples.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code of Cholesky decomposition.

Protected Functions

inline int invertMatrix(const std::vector<double> &matrix, std::vector<double> &inverseMat)

Inverts s.p.d. matrix via Cholesky decomposition.

Parameters
  • matrix – Input matrix interpreted as square symmetric matrix.

  • inverseMat – Result of inversion.

Returns

Error code of Cholesky decomposition used to invert matrix.

Private Members

korali::distribution::multivariate::Normal *_multivariateGenerator

Multivariate normal generator needed for sampling of momentum from dense metric.

class korali::solver::sampler::HamiltonianEuclideanDiag : public korali::solver::sampler::HamiltonianEuclidean
#include <hamiltonian_euclidean_diag.hpp>

Used for calculating energies with unit euclidean metric.

Public Functions

inline HamiltonianEuclideanDiag(const size_t stateSpaceDim, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • k – Pointer to Korali object.

inline HamiltonianEuclideanDiag(const size_t stateSpaceDim, korali::distribution::univariate::Normal *normalGenerator, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • normalGenerator – Generator needed for momentum sampling.

  • k – Pointer to Korali object.

~HamiltonianEuclideanDiag() = default

Destructor of derived class.

inline virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Total energy.

inline virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Kinetic energy.

inline virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of kinetic energy wrt. current momentum.

inline virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const override

Generates sample of momentum.

Parameters

metric – Current metric.

Returns

Momentum sampled from normal distribution with metric as covariance matrix.

inline virtual double innerProduct(const std::vector<double> &leftMomentum, const std::vector<double> &rightMomentum, const std::vector<double> &inverseMetric) const override

Calculates inner product induces by inverse metric.

Parameters
  • leftMomentum – Left vector of inner product.

  • rightMomentum – Right vector of inner product.

  • inverseMetric – Inverse of current metric.

Returns

inner product

inline virtual int updateMetricMatricesEuclidean(const std::vector<std::vector<double>> &samples, std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates inverse Metric by approximating the covariance matrix with the Fisher information.

Parameters
  • samples – Vector of samples.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code of Cholesky decomposition.

Private Members

korali::distribution::univariate::Normal *_normalGenerator

One dimensional normal generator needed for sampling of momentum from diagonal _metric.

class korali::solver::sampler::HamiltonianRiemannian : public korali::solver::sampler::Hamiltonian
#include <hamiltonian_riemannian_base.hpp>

Abstract base class for Hamiltonian objects.

Subclassed by korali::solver::sampler::HamiltonianRiemannianConstDense, korali::solver::sampler::HamiltonianRiemannianConstDiag, korali::solver::sampler::HamiltonianRiemannianDiag

Public Functions

inline HamiltonianRiemannian(const size_t stateSpaceDim, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • k – Pointer to Korali object.

virtual ~HamiltonianRiemannian() = default

Destructor of abstract base class.

inline std::vector<double> hessianU() const

Hessian of potential energy function used for Riemannian metric.

Returns

Hessian of potential energy.

inline double softAbsFunc(const double x, const double alpha) const

Helper function f(x) = x * coth(alpha * x) for SoftAbs metric.

Parameters
  • x – Point of evaluation.

  • alpha – Hardness parameter

Returns

function value at x.

Public Members

std::vector<double> _currentHessian

Current Hessian of objective (return value of sample evaluation).

double _logDetMetric

normalization constant for kinetic energy (isn’t constant compared to Euclidean Hamiltonian => have to include term in calculation)

class korali::solver::sampler::HamiltonianRiemannianConstDense : public korali::solver::sampler::HamiltonianRiemannian
#include <hamiltonian_riemannian_const_dense.hpp>

Used for dense Riemannian metric.

Public Functions

inline HamiltonianRiemannianConstDense(const size_t stateSpaceDim, korali::distribution::multivariate::Normal *multivariateGenerator, const std::vector<double> &metric, const double inverseRegularizationParam, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • multivariateGenerator – Generator needed for momentum sampling.

  • metric – Metric of space.

  • inverseRegularizationParam – Inverse regularization parameter of SoftAbs metric that controls hardness of approximation: For large values inverseMetric is closer to analytical formula (and therefore closer to degeneracy in certain cases).

  • k – Pointer to Korali object.

~HamiltonianRiemannianConstDense() = default

Destructor of derived class.

inline virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Total energy.

inline virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Kinetic energy.

inline virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of kinetic energy wrt. current momentum.

inline virtual double tau(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates tau(q, p) = 0.5 * momentum^T * inverseMetric(q) * momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dq(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. position.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dp(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual double phi() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual std::vector<double> dphi_dq() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual void updateHamiltonian(const std::vector<double> &position, std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates current position of hamiltonian.

Parameters
  • position – Current position.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

inline virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const override

Generates sample of momentum.

Parameters

metric – Current metric.

Returns

Momentum sampled from normal distribution with metric as covariance matrix.

inline virtual double innerProduct(const std::vector<double> &momentumLeft, const std::vector<double> &momentumRight, const std::vector<double> &inverseMetric) const override

Calculates inner product induces by inverse metric.

Parameters
  • momentumLeft – Left vector of inner product.

  • momentumRight – Right vector of inner product.

  • inverseMetric – Inverse of current metric.

Returns

inner product

inline virtual int updateMetricMatricesRiemannian(std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates Metric and Inverse Metric by using hessian.

Parameters
  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code to indicate if update was successful.

Public Members

double _inverseRegularizationParam

Inverse regularization parameter of SoftAbs metric that controls hardness of approximation.

Private Members

korali::distribution::multivariate::Normal *_multivariateGenerator

Multi dimensional normal generator needed for sampling of momentum from dense metric.

gsl_matrix *Q
gsl_vector *lambda
gsl_eigen_symmv_workspace *w
gsl_matrix *lambdaSoftAbs
gsl_matrix *inverseLambdaSoftAbs
gsl_matrix *tmpMatOne
gsl_matrix *tmpMatTwo
gsl_matrix *tmpMatThree
gsl_matrix *tmpMatFour
class korali::solver::sampler::HamiltonianRiemannianConstDiag : public korali::solver::sampler::HamiltonianRiemannian
#include <hamiltonian_riemannian_const_diag.hpp>

Used for diagonal Riemannian metric.

Public Functions

inline HamiltonianRiemannianConstDiag(const size_t stateSpaceDim, korali::distribution::univariate::Normal *normalGenerator, const double inverseRegularizationParam, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • normalGenerator – Generator needed for momentum sampling.

  • inverseRegularizationParam – Inverse regularization parameter of SoftAbs metric that controls hardness of approximation: For large values inverseMetric is closer to analytical formula (and therefore closer to degeneracy in certain cases).

  • k – Pointer to Korali object.

~HamiltonianRiemannianConstDiag() = default

Destructor of derived class.

inline virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Total energy.

inline virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Kinetic energy.

inline virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of kinetic energy wrt. current momentum.

inline virtual double tau(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates tau(q, p) = 0.5 * momentum^T * inverseMetric(q) * momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dq(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. position.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dp(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual double phi() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual std::vector<double> dphi_dq() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual void updateHamiltonian(const std::vector<double> &position, std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates current position of hamiltonian.

Parameters
  • position – Current position.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

inline virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const override

Generates sample of momentum.

Parameters

metric – Current metric.

Returns

Momentum sampled from normal distribution with metric as covariance matrix.

inline virtual double innerProduct(const std::vector<double> &momentumLeft, const std::vector<double> &momentumRight, const std::vector<double> &inverseMetric) const override

Calculates inner product induces by inverse metric.

Parameters
  • momentumLeft – Left vector of inner product.

  • momentumRight – Right vector of inner product.

  • inverseMetric – Inverse of curret metric.

Returns

inner product

inline virtual int updateMetricMatricesRiemannian(std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates Metric and Inverse Metric by using hessian.

Parameters
  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

Returns

Error code to indicate if update was successful.

Public Members

double _inverseRegularizationParam

Inverse regularization parameter of SoftAbs metric that controls hardness of approximation.

Private Members

korali::distribution::univariate::Normal *_normalGenerator

One dimensional normal generator needed for sampling of momentum from diagonal metric.

class korali::solver::sampler::HamiltonianRiemannianDiag : public korali::solver::sampler::HamiltonianRiemannian
#include <hamiltonian_riemannian_diag.hpp>

Used for diagonal Riemannian metric.

Public Functions

inline HamiltonianRiemannianDiag(const size_t stateSpaceDim, korali::distribution::univariate::Normal *normalGenerator, const double inverseRegularizationParam, korali::Experiment *k)

Constructor with State Space Dim.

Parameters
  • stateSpaceDim – Dimension of State Space.

  • normalGenerator – Generator needed for momentum sampling.

  • inverseRegularizationParam – Inverse regularization parameter of SoftAbs metric that controls hardness of approximation: For large values inverseMetric is closer to analytical formula (and therefore closer to degeneracy in certain cases).

  • k – Pointer to Korali object.

~HamiltonianRiemannianDiag() = default

Destructor of derived class.

inline virtual double H(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Total energy function used for Hamiltonian Dynamics.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Total energy.

inline virtual double K(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Kinetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Inverse of current metric.

Returns

Kinetic energy.

inline virtual std::vector<double> dK(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Gradient of kintetic energy function.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of kinetic energy wrt. current momentum.

inline virtual double tau(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates tau(q, p) = 0.5 * momentum^T * inverseMetric(q) * momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dq(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. position.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dtau_dp(const std::vector<double> &momentum, const std::vector<double> &inverseMetric) override

Calculates gradient of tau(q, p) wrt. momentum.

Parameters
  • momentum – Current momentum.

  • inverseMetric – Current inverseMetric.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual double phi() override

Purely virtual gradient of phi(q) = 0.5 * logDetMetric(q) + U(q) used for Hamiltonian Dynamics.

Returns

Gradient of Kinetic energy with current momentum.

inline virtual std::vector<double> dphi_dq() override

Calculates gradient of kinetic energy.

Returns

Gradient of kinetic energy.

inline virtual void updateHamiltonian(const std::vector<double> &position, std::vector<double> &metric, std::vector<double> &inverseMetric) override

Updates current position of hamiltonian.

Parameters
  • position – Current position.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

inline virtual std::vector<double> sampleMomentum(const std::vector<double> &metric) const override

Generates sample of momentum.

Parameters

metric – Current metric.

Returns

Sample of momentum from normal distribution with covariance matrix metric. Only variance taken into account with diagonal metric.

inline virtual double innerProduct(const std::vector<double> &momentumLeft, const std::vector<double> &momentumRight, const std::vector<double> &inverseMetric) const override

Calculates inner product induces by inverse metric.

Parameters
  • momentumLeft – Left vector of inner product.

  • momentumRight – Right vector of inner product.

  • inverseMetric – Inverse of current metric.

Returns

inner product

inline double taylorSeriesPhiFunc(const double x, const double alpha)

Helper function f(x) = 1/x - alpha * x / (sinh(alpha * x^2) * cosh(alpha * x^2)) for SoftAbs metric.

Parameters
  • x – Point of evaluation.

  • alpha – Hyperparameter.

Returns

function value at x.

inline double taylorSeriesTauFunc(const double x, const double alpha)

Helper function f(x) = 1/x * (alpha / cosh(alha * x^2)^2 - tanh(alpha * x^2) / x^2) for SoftAbs metric.

Parameters
  • x – Point of evaluation.

  • alpha – Hyperparameter.

Returns

function value at x.

Public Members

double _inverseRegularizationParam

Inverse regularization parameter of SoftAbs metric that controls hardness of approximation.

korali::distribution::univariate::Normal *_normalGenerator

One dimensional normal generator needed for sampling of momentum from diagonal metric.

class korali::problem::Hierarchical : public korali::Problem
#include <hierarchical.hpp>

Class declaration for module: Hierarchical.

Subclassed by korali::problem::hierarchical::Psi, korali::problem::hierarchical::Theta, korali::problem::hierarchical::ThetaNew

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

bool isSampleFeasible(korali::Sample &sample)

Checks whether the proposed sample fits within the range of the prior distribution.

Parameters

sample – A Korali Sample

Returns

True, if feasible; false, otherwise.

virtual void evaluate(korali::Sample &sample)

Produces a generic evaluation from the Posterior distribution of the sample, for optimization with CMAES, DEA, storing it in and stores it in sample[“F(x)”].

Parameters

sample – A Korali Sample

void evaluateLogPrior(korali::Sample &sample)

Evaluates the log prior of the given sample, and stores it in sample[“Log Prior”].

Parameters

sample – A Korali Sample

virtual void evaluateLogLikelihood(korali::Sample &sample) = 0

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

void evaluateLogPosterior(korali::Sample &sample)

Evaluates the log posterior of the given sample, and stores it in sample[“Log Posterior”].

Parameters

sample – A Korali Sample

class korali::solver::sampler::HMC : public korali::solver::Sampler
#include <HMC.hpp>

Class declaration for module: HMC.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setInitialConfiguration() override

Configures HMC.

virtual void finalize() override

Final console output at termination.

virtual void runGeneration() override

Generate a sample and evaluate it.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

Public Members

size_t _burnIn

Specifies the number of preliminary HMC steps before samples are being drawn. This may reduce effects from improper initialization.

int _useDiagonalMetric

Specifies if Metric is restricted to be diagonal.

size_t _numIntegrationSteps

Number of Integration steps used in Leapfrog scheme. Only relevant if Adaptive Step Size not used.

size_t _maxIntegrationSteps

Number of Integration steps used in Leapfrog scheme. Only relevant if Adaptive Step Size is used.

int _useNUTS

Specifies if No-U-Turn Sampler (NUTS) is used.

double _stepSize

Step size used in Leapfrog scheme.

int _useAdaptiveStepSize

Controls whether dual averaging technique for adaptive step size calibration is used.

double _targetAcceptanceRate

Desired Acceptance Rate for Adaptive Step Size calibration.

double _acceptanceRateLearningRate

Learning rate of running acceptance rate estimate.

double _targetIntegrationTime

Targeted Integration Time for Leapfrog scheme. Only relevant if Adaptive Step Size used.

double _adaptiveStepSizeSpeedConstant

Controls how fast the step size is adapted. Only relevant if Adaptive Step Size used.

double _adaptiveStepSizeStabilizationConstant

Controls stability of adaptive step size calibration during the inital iterations. Only relevant if Adaptive Step Size used.

double _adaptiveStepSizeScheduleConstant

Controls the weight of the previous step sizes. Only relevant if Adaptive Step Size used. The smaller the higher the weight.

size_t _maxDepth

Sets the maximum depth of NUTS binary tree.

std::string _version

Metric can be set to ‘Static’, ‘Euclidean’ or ‘Riemannian’.

double _inverseRegularizationParameter

Controls hardness of inverse metric approximation: For large values the Inverse Metric is closer the to Hessian (and therefore closer to degeneracy in certain cases).

size_t _maxFixedPointIterations

Max number of fixed point iterations during implicit leapfrog scheme.

double _stepSizeJitter

Step Size Jitter to vary trajectory length. Number must be in the interval [0.0. 1.0]. A uniform realization between [-(Step Size Jitter) * (Step Size), (Step Size Jitter) * (Step Size)) is sampled and added to the current Step Size.

size_t _initialFastAdaptionInterval

Initial warm-up interval during which step size is adaptively adjusted.

size_t _finalFastAdaptionInterval

Final warm-up interval during which step size is adaptively adjusted.

size_t _initialSlowAdaptionInterval

Lenght of first (out of 5) warm-up intervals during which euclidean metric is adapted. The length of each following slow adaption intervals is doubled.

Metric _metricType

[Internal Use] Metric Type can be set to ‘Static’, ‘Euclidean’ or ‘Riemannian’.

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Normal random number generator.

korali::distribution::multivariate::Normal *_multivariateGenerator

[Internal Use] Random number generator with a multivariate normal distribution.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

double _acceptanceRate

[Internal Use] Ratio proposed to accepted samples (including Burn In period).

double _runningAcceptanceRate

[Internal Use] Running estimate of current acceptance rate.

size_t _acceptanceCount

[Internal Use] Number of accepted samples (including Burn In period).

size_t _proposedSampleCount

[Internal Use] Number of proposed samples.

std::vector<std::vector<double>> _sampleDatabase

[Internal Use] Parameters generated by HMC and stored in the database.

std::vector<std::vector<double>> _euclideanWarmupSampleDatabase

[Internal Use] Parameters generated during warmup. Used for Euclidean Metric approximation.

std::vector<double> _sampleEvaluationDatabase

[Internal Use] Sample evaluations coresponding to the samples stored in Sample Databse.

size_t _chainLength

[Internal Use] Current Chain Length (including Burn In and Leaped Samples).

double _leaderEvaluation

[Internal Use] Evaluation of leader.

double _candidateEvaluation

[Internal Use] Evaluation of candidate.

std::vector<double> _positionLeader

[Internal Use] Variables of the newest position/sample in the Markov chain.

std::vector<double> _positionCandidate

[Internal Use] Candidate position to be accepted or rejected.

std::vector<double> _momentumLeader

[Internal Use] Latest momentum sample.

std::vector<double> _momentumCandidate

[Internal Use] Proposed momentum after propagating Chain Leader and Momentum Leader according to Hamiltonian dynamics.

double _logDualStepSize

[Internal Use] Logarithm of smoothed average step size. Step size that is used after burn in period. Only relevant if adaptive step size used.

double _mu

[Internal Use] Constant used for Adaptive Step Size option.

double _hBar

[Internal Use] Constant used for Adaptive Step Size option.

double _acceptanceCountNUTS

[Internal Use] TODO: is this the number of accepted proposals?

size_t _currentDepth

[Internal Use] Depth of NUTS binary tree in current generation.

double _acceptanceProbability

[Internal Use] Metropolis update acceptance probability - usually denoted with alpha - needed due to numerical error during integration.

double _acceptanceRateError

[Internal Use] Accumulated differences of Acceptance Probability and Target Acceptance Rate.

std::vector<double> _metric

[Internal Use] Metric for proposal distribution.

std::vector<double> _inverseMetric

[Internal Use] Inverse Metric for proposal distribution.

size_t _maxSamples

[Termination Criteria] Number of Samples to Generate.

Private Functions

void updateState()

Updates internal state such as mean, Metric and InverseMetric.

void finishSample(size_t sampleId)

Process sample after evaluation.

void runGenerationHMC(const double logUniSample)

Runs generation of HMC sampler.

Parameters

logUniSample – Log of uniform sample needed for Metropolis accepance / rejection step.

void runGenerationNUTS(const double logUniSample)

Runs NUTS algorithm with buildTree.

Parameters

logUniSample – Log of uniform sample needed for Metropolis accepance / rejection step.

void runGenerationNUTSRiemannian(const double logUniSample)

Runs NUTS algorithm with buildTree.

Parameters

logUniSample – Log of uniform sample needed for Metropolis accepance / rejection step.

void saveSample()

Saves sample.

void updateStepSize()

Updates Step Size for Adaptive Step Size.

void buildTree(std::shared_ptr<TreeHelperEuclidean> helper, const size_t depth)

Recursive binary tree building algorithm. Applied if configuration ‘Use NUTS’ is set to True.

Parameters
  • helper – Helper struct for large argument list.

  • depth – Current depth of binary tree.

void buildTreeIntegration(std::shared_ptr<TreeHelperRiemannian> helper, std::vector<double> &rho, const size_t depth)

Recursive binary tree building algorithm. Applied if configuration ‘Use NUTS’ is set to True.

Parameters
  • helper – Helper struct for large argument list.

  • rho – Sum of momenta encountered along path.

  • depth – Current depth of binary tree.

Private Members

std::shared_ptr<Hamiltonian> _hamiltonian
std::unique_ptr<Leapfrog> _integrator
class korali::distribution::univariate::Igamma : public korali::distribution::Univariate
#include <igamma.hpp>

Class declaration for module: Igamma.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _shape

[Conditional Variable Value]

std::string _shapeConditional

[Conditional Variable Reference]

double _scale

[Conditional Variable Value]

std::string _scaleConditional

[Conditional Variable Reference]

Private Members

double _auxLog
class korali::neuralNetwork::layer::Input : public korali::neuralNetwork::Layer
#include <input.hpp>

Class declaration for module: Input.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

class korali::problem::Integration : public korali::Problem
#include <integration.hpp>

Class declaration for module: Integration.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

void execute(korali::Sample &sample)

Produces an evaluation of the model, storing it in and stores it in sample[“Evaluation”].

Parameters

sample – A Korali Sample

Public Members

std::uint64_t _integrand

Stores the function to integrate.

std::string _integrationMethod

Indicates the name of the integration method to use.

class korali::solver::Integrator : public korali::Solver
#include <integrator.hpp>

Class declaration for module: Integrator.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

Public Members

size_t _executionsPerGeneration

Specifies the number of model executions per generation. By default this setting is 0, meaning that all executions will be performed in the first generation. For values greater 0, executions will be split into batches and split int generations for intermediate output.

size_t _sampleCount

[Internal Use] Number of samples to execute.

double _integral

[Internal Use] Current value of the integral.

std::vector<size_t> _indicesHelper

[Internal Use] Holds helper to calculate cartesian indices from linear index.

template<typename keyType, typename valType, typename timerType>
class korali::kCache
#include <kcache.hpp>

This class defines a circular buffer with overwrite policy on add.

Public Functions

inline kCache()

Lock for thread-safe operation.

Default constructor

inline void setMaxAge(const timerType &maxAge)

Re-sets the maximum age threshold.

Parameters

maxAge – the maximum age threshold

inline void setTimer(timerType *timer)

Sets the pointer to an external timer.

Parameters

timer – The external timer

inline void set(const keyType &key, const valType &val)

Updates the value of a data element in the cache.

Parameters
  • key – Key of the data element to update

  • val – Value of the data element to update

inline void set(const keyType &key, const valType &val, const timerType &time)

Updates the value of a data element in the cache, forcing a specific time for it.

Parameters
  • key – Key of the data element to update

  • val – Value of the data element to update

  • time – Time assigned to the data element

inline bool contains(const keyType &key)

Checks whether a given data element is present in cache.

Parameters

key – Key of the data element to check

Returns

Whether or not the data element is present

inline valType get(const keyType &key)

Reads the value of a data element from the cache. The data element should be present, or an error will occur.

Parameters

key – Key of the data element to access

Returns

The value of the element stored in cache

inline valType access(const keyType &key, std::function<valType(void)> func)

Reads the value of a data element from the cache. If the element is not present, it calls the provided function to generate it.

Parameters
  • key – Key of the data element to access

  • func – Function (lambda or regular) that, upon calling, will return the new value for the element.

Returns

The value of the element stored in cache or generated by the function

inline std::vector<keyType> getKeys()

Returns the stored entry keys as an ordered vector.

Returns

A vector containing all ordered keys

inline std::vector<valType> getValues()

Returns the stored entry values in the cache.

Returns

A vector containing all stored entry values, ordered by key

inline std::vector<timerType> getTimes()

Returns the stored entry times in the cache.

Returns

A vector containing all stored entry times, ordered by key

Private Members

std::map<keyType, cacheElement_t<valType, timerType>> _data

Container for cache elements.

timerType *_timer

Pointer to the external timer.

timerType _maxAge

Maximum age threshold of data before expiration.

class korali::KoraliJson
#include <koraliJson.hpp>

This class encapsulates a JSON object, making it compatible with Korali C++ objects and Pybind11.

Public Functions

KoraliJson()
knlohmann::json &getJson()

Function to obtain the JSON object.

Returns

A reference to the JSON object.

void getCopy(knlohmann::json &dst) const

Function to make a copy of the JSON object.

Parameters

dst – destination js

void setJson(knlohmann::json &js)

Function to set the JSON object.

Parameters

js – The input JSON object.

pybind11::object getItem(const pybind11::object key)

Gets an item from the JSON object at the current pointer position.

Parameters

key – A pybind11 object acting as JSON key (number or string).

Returns

A pybind11 object

void setItem(const pybind11::object key, const pybind11::object val)

Sets an item on the JSON object at the current pointer position.

Parameters
  • key – A pybind11 object acting as JSON key (number or string).

  • val – The value of the item to set.

knlohmann::json &operator[](const std::string &key)

C++ wrapper for the getItem operator.

Parameters

key – A C++ string acting as JSON key.

Returns

The referenced JSON object content.

knlohmann::json &operator[](const unsigned long int &key)

C++ wrapper for the getItem operator.

Parameters

key – A C++ integer acting as JSON key.

Returns

The referenced JSON object content.

bool contains(const std::string &key)

Indicates whether the JSON object contains the given path.

Parameters

key – key A C++ string acting as JSON key.

Returns

true, if path is found; false, otherwise.

void traverseKey(pybind11::object key)

Advances the JSON object pointer, given the key.

Parameters

key – A C++ string acting as JSON key.

Public Members

knlohmann::json _js

Container for the JSON object.

knlohmann::json *_opt

Pointer that stores the current access position of the JSON object. It advances with getItem, and resets upon setJson or finding a native data type (not a path).

class korali::distribution::univariate::Laplace : public korali::distribution::Univariate
#include <laplace.hpp>

Class declaration for module: Laplace.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _mean

[Conditional Variable Value]

std::string _meanConditional

[Conditional Variable Reference]

double _width

[Conditional Variable Value]

std::string _widthConditional

[Conditional Variable Reference]

class korali::neuralNetwork::Layer : public korali::Module
#include <layer.hpp>

Class declaration for module: Layer.

Subclassed by korali::neuralNetwork::layer::Activation, korali::neuralNetwork::layer::Input, korali::neuralNetwork::layer::Linear, korali::neuralNetwork::layer::Output, korali::neuralNetwork::layer::Recurrent

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

Layer() = default

Default constructor.

virtual ~Layer() = default

Default destructor.

std::vector<std::vector<float>> getOutput()

Returns the output values for the current layer.

Returns

The output values

virtual std::vector<float> generateInitialHyperparameters()

Generates the initial weight/bias hyperparameters for the layer.

Returns

The initial hyperparameters

virtual void createHyperparameterMemory()

Initializes the layer’s internal memory structures for hyperparameter storage.

inline virtual void copyHyperparameterPointers(Layer *dstLayer)

Replicates the pointers for the current layer onto a destination layer.

Parameters

dstLayer – The destination layer onto which to copy the pointers

virtual void createForwardPipeline()

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline()

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) = 0

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

inline virtual void setHyperparameters(float *hyperparameters)

Updates layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Input) Pointer to read the hyperparameters from.

inline virtual void getHyperparameters(float *hyperparameters)

Gets layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Output) Pointer to write the hyperparameters to.

inline virtual void getHyperparameterGradients(float *gradient)

Gets the gradients of the layer’s output wrt to is hyperparameters (e.g., weights and biases)

Parameters

gradient – (Output) Pointer to write the hyperparameter gradients to.

virtual void backwardData(const size_t t) = 0

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

virtual void backwardHyperparameters(const size_t t)

Calculates the gradients of layer hyperparameters.

Parameters

t – Indicates the current timestep

Public Members

size_t _outputChannels

Indicates the size of the output vector produced by the layer.

float _weightScaling

Factor that is mutliplied by the layers’ weights.

size_t _index

Index of the current layer within the NN.

NeuralNetwork *_nn

Pointer to the parent neural network.

layerPipeline_t *_pipeline

A pointer to the layer’s containing pipeline.

Layer *_prevLayer

Pointer to previous layer, NULL if this is the first layer.

Layer *_nextLayer

Pointer to next layer, NULL if this is the last layer.

size_t _hyperparameterCount

Number of layer hyperparameters.

size_t _hyperparameterIndex

Starting index of hyperparameters.

size_t _batchSize

Contains the batch size corresponding to the pipeline.

float *_outputValues

Contains the output values of the layer.

float *_outputGradient

Contains the gradients of the outputs of the layer.

struct korali::layerPipeline_t
#include <neuralNetwork.hpp>

Structure containing the information of a layer pipeline. There is one pipeline per threadCount x batchSize combination.

Public Members

std::vector<korali::neuralNetwork::Layer*> _layerVector

Internal container for the NN layer forward/backward pipelines.

std::vector<float> _rawInputValues

Raw data for the NN input values. Format: TxNxIC (T: Time steps, N: Mini-batch size, IC: Input channels).

std::vector<float> _rawInputGradients

Raw data for the NN input gradients. Format: TxNxIC (T: Time steps, N: Mini-batch size, IC: Input channels).

std::vector<std::vector<float>> _inputGradients

Formatted data for the NN input gradients. Format: NxIC (N: Mini-batch size, IC: Input channels).

std::vector<float> _rawOutputValues

Raw data for the NN output values. Format: NxOC (N: Mini-batch size, OC: Output channels).

std::vector<float> _rawOutputGradients

Raw data for the NN output gradients. Format: NxOC (N: Mini-batch size, OC: Output channels).

std::vector<std::vector<float>> _outputValues

Formatted data for the NN output values. Format: NxOC (N: Mini-batch size, OC: Output channels).

std::vector<float> _hyperparameterGradients

F data for the NN hyperparameter gradients. Format: H (H: Hyperparameter count).

std::vector<size_t> _inputBatchLastStep

Remembers the position of the last timestep provided as input.

class korali::solver::sampler::Leapfrog
#include <leapfrog_base.hpp>

Abstract base class used for time propagation according to hamiltonian dynamics via Leapfrog integration schemes.

Subclassed by korali::solver::sampler::LeapfrogExplicit, korali::solver::sampler::LeapfrogImplicit

Public Functions

inline Leapfrog(std::shared_ptr<Hamiltonian> hamiltonian)

Abstract base class constructor for explicit or implicit leapfrog stepper.

Parameters

hamiltonianHamiltonian of the system.

virtual ~Leapfrog() = default

Default destructor.

virtual void step(std::vector<double> &position, std::vector<double> &momentum, std::vector<double> &metric, std::vector<double> &inverseMetric, const double stepSize) = 0

Purely virtual stepping function of the integrator.

Parameters
  • position – Position which is evolved.

  • momentum – Momentum which is evolved.

  • metric – Current mentric.

  • inverseMetric – Inverse metric.

  • stepSize – Step Size used for Leap Frog Scheme.

Protected Attributes

std::shared_ptr<Hamiltonian> _hamiltonian

Pointer to hamiltonian object to calculate energies..

class korali::solver::sampler::LeapfrogExplicit : public korali::solver::sampler::Leapfrog
#include <leapfrog_explicit.hpp>

Used for time propagation according to hamiltonian dynamics via explicit Leapfrog integration.

Public Functions

inline LeapfrogExplicit(std::shared_ptr<Hamiltonian> hamiltonian)

Constructor for explicit leapfrog stepper.

Parameters

hamiltonianHamiltonian of the system.

virtual ~LeapfrogExplicit() = default

Default destructor.

inline virtual void step(std::vector<double> &position, std::vector<double> &momentum, std::vector<double> &metric, std::vector<double> &inverseMetric, const double stepSize) override

Explicit Leapfrog stepping scheme used for evolving Hamiltonian Dynamics.

Parameters
  • position – Position which is evolved.

  • momentum – Momentum which is evolved.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

  • stepSize – Step Size used for Leap Frog Scheme.

class korali::solver::sampler::LeapfrogImplicit : public korali::solver::sampler::Leapfrog
#include <leapfrog_implicit.hpp>

Used for time propagation according to hamiltonian dynamics via implicit Leapfrog integration.

Public Functions

inline LeapfrogImplicit(size_t maxNumFixedPointIter, std::shared_ptr<Hamiltonian> hamiltonian)

Constructor for implicit leapfrog stepper.

Parameters
  • maxNumFixedPointIter – Maximum fixed point iterations.

  • hamiltonianHamiltonian of the system.

inline virtual void step(std::vector<double> &position, std::vector<double> &momentum, std::vector<double> &metric, std::vector<double> &inverseMetric, const double stepSize) override

Implicit Leapfrog stepping scheme used for evolving Hamiltonian Dynamics.

Parameters
  • position – Position which is evolved.

  • momentum – Momentum which is evolved.

  • metric – Current metric.

  • inverseMetric – Inverse of current metric.

  • stepSize – Step Size used for Leap Frog Scheme.

Private Members

size_t _maxNumFixedPointIter

Maximum fixed point iterations during each step.

class korali::solver::Learner : public korali::Solver
#include <learner.hpp>

Class declaration for module: Learner.

Subclassed by korali::solver::learner::DeepSupervisor, korali::solver::learner::GaussianProcess

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual std::vector<std::vector<float>> &getEvaluation(const std::vector<std::vector<std::vector<float>>> &input)

For learner modules which have been trained, test returns an inferred output batch, from a batch of inputs to process.

Parameters

input – The inputs from which to infer outputs. Format: BxTxIC (B: Batch Size, T: Time steps, IC: Input channels)

Returns

The inferred batch outputs for the last given timestep. Format: BxOC (B: Batch Size, OC: Output channels)

virtual std::vector<float> getHyperparameters() = 0

Returns the hyperparameters required to continue training in the future.

Returns

The hyperparameters

virtual void setHyperparameters(const std::vector<float> &hyperparameters) = 0

Sets the hyperparameters required to continue training from a previous state.

Parameters

hyperparameters – The hyperparameters to use

class korali::neuralNetwork::layer::Linear : public korali::neuralNetwork::Layer
#include <linear.hpp>

Class declaration for module: Linear.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void copyHyperparameterPointers(Layer *dstLayer) override

Replicates the pointers for the current layer onto a destination layer.

Parameters

dstLayer – The destination layer onto which to copy the pointers

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual std::vector<float> generateInitialHyperparameters() override

Generates the initial weight/bias hyperparameters for the layer.

Returns

The initial hyperparameters

virtual void createHyperparameterMemory() override

Initializes the layer’s internal memory structures for hyperparameter storage.

virtual void createForwardPipeline() override

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void setHyperparameters(float *hyperparameters) override

Updates layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Input) Pointer to read the hyperparameters from.

virtual void getHyperparameters(float *hyperparameters) override

Gets layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Output) Pointer to write the hyperparameters to.

virtual void getHyperparameterGradients(float *gradient) override

Gets the gradients of the layer’s output wrt to is hyperparameters (e.g., weights and biases)

Parameters

gradient – (Output) Pointer to write the hyperparameter gradients to.

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

virtual void backwardHyperparameters(const size_t t) override

Calculates the gradients of layer hyperparameters.

Parameters

t – Indicates the current timestep

Public Members

float *_weightValues

Contains the values of the weights.

float *_weightGradient

Contains the gradients of the weights.

float *_biasValues

Contains the values of the bias.

float *_biasGradient

Contains the gradients of the bias.

class korali::Logger
#include <logger.hpp>

Logger object for Korali Modules.

Public Functions

Logger(const std::string verbosityLevel, FILE *file = stdout)

parametrized constructor for Korali Logger

Parameters
  • verbosityLevel – The verbosity level above which nothing is printed.

  • file – Output file (default: stdout)

size_t getVerbosityLevel(const std::string verbosityLevel)

Gets the numerical value of a verbosity level, given its string value.

Parameters

verbosityLevel – specifies the verbosity level.

Returns

Numerical value corresponding to verbosity level: { SILENT=0, MINIMAL=1, NORMAL=2, DETAILED=3 }

bool isEnoughVerbosity(const std::string verbosityLevel)

Checks whether the current verbosity level is enough to authorize the requested level. Serves to filter out non-important messages when low verbosity is chosen.

Parameters

verbosityLevel – the requested verbosity level

Returns

true, if it is enough; false, otherwise.

void logData(const std::string verbosityLevel, const char *format, ...)

Outputs raw data to the console file.

Parameters
  • verbosityLevel – the requested verbosity level.

  • format – Format string of the data (printf-style)

  • ... – List of arguments for the format string

void logInfo(const std::string verbosityLevel, const char *format, ...)

Outputs an information message to the console file.

Parameters
  • verbosityLevel – the requested verbosity level.

  • format – Format string of the data (printf-style)

  • ... – List of arguments for the format string

void logWarning(const std::string verbosityLevel, const char *format, ...)

Outputs a warning message to the console file.

Parameters
  • verbosityLevel – the requested verbosity level.

  • format – Format string of the data (printf-style)

  • ... – List of arguments for the format string

Public Members

size_t _verbosityLevel

Global variable that contains the verbosity level for the current Korali experiment.

FILE *_outputFile

Global variable that contains the output file for the current Korali experiment.

Public Static Functions

static void logError(const char *fileName, const int lineNumber, const char *format, ...)

Outputs an error message to the console file. Overrides any verbosity level, prints, and exits execution with error.

Parameters
  • fileName – where the error occurred, given by the FILE macro

  • lineNumber – number where the error occurred, given by the LINE macro

  • format – Format string of the data (printf-style)

  • ... – List of arguments for the format string

class korali::distribution::univariate::LogNormal : public korali::distribution::Univariate
#include <logNormal.hpp>

Class declaration for module: LogNormal.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _mu

[Conditional Variable Value] Check: https://en.wikipedia.org/wiki/Log-normal_distribution

std::string _muConditional

[Conditional Variable Reference] Check: https://en.wikipedia.org/wiki/Log-normal_distribution

double _sigma

[Conditional Variable Value] Check: https://en.wikipedia.org/wiki/Log-normal_distribution

std::string _sigmaConditional

[Conditional Variable Reference] Check: https://en.wikipedia.org/wiki/Log-normal_distribution

class korali::neuralNetwork::layer::recurrent::LSTM : public korali::neuralNetwork::layer::Recurrent
#include <lstm.hpp>

Class declaration for module: LSTM.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void createForwardPipeline() override

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

class korali::solver::optimizer::MADGRAD : public korali::solver::Optimizer
#include <MADGRAD.hpp>

Class declaration for module: MADGRAD.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void processResult(double evaluation, std::vector<double> &gradient)

Takes a sample evaluation and its gradient and calculates the next set of parameters.

Parameters
  • evaluation – The value of the objective function at the current set of parameters

  • gradient – The gradient of the objective function at the current set of parameters

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

double _eta

Learning Rate (Step Size)

double _weightDecay

Smoothing factor for variable update.

double _epsilon

Term to facilitate numerical stability.

std::vector<double> _currentVariable

[Internal Use] Current value of parameters.

double _scaledLearningRate

[Internal Use] The learning rate of the current generation.

std::vector<double> _initialParameter

[Internal Use] Initial value of parameters.

std::vector<double> _gradient

[Internal Use] Gradient of Function with respect to Parameters.

std::vector<double> _bestEverGradient

[Internal Use] Gradient of function with respect to Best Ever Variables.

double _gradientNorm

[Internal Use] Norm of gradient of function with respect to Parameters.

std::vector<double> _gradientSum

[Internal Use] The sum of scaled gradients.

std::vector<double> _squaredGradientSum

[Internal Use] The sum of the scaled squares of the gradient.

double _minGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

double _maxGradientNorm

[Termination Criteria] Specifies the minimal norm for the gradient of function with respect to Parameters.

class korali::solver::sampler::MCMC : public korali::solver::Sampler
#include <MCMC.hpp>

Class declaration for module: MCMC.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

double recursiveAlpha(double &denominator, const double leaderLoglikelihood, const double *loglikelihoods, size_t N) const

Calculates recursively acceptance probability. Recursion required for Delayed Rejection.

Parameters
  • denominator – denominator of quotient (acceptance probability)

  • leaderLoglikelihood – loglikelihood of current chain leader

  • loglikelihoods – loglikelihoods of samples obtained after delay

  • N – rescursion depth

Returns

The acceptance probability

void updateState()

Updates internal state such as mean and covariance of chain.

void generateCandidate(size_t sampleIdx)

Generate new sample.

Parameters

sampleIdx – Id of the sample to generate a candidate for

void choleskyDecomp(const std::vector<double> &inC, std::vector<double> &outL) const

Cholesky decomposition of chain covariance matrix.

Parameters
  • inC – Input matrix

  • outL – Output lower triangular decomposed matrix

void finishSample(size_t sampleId)

Process sample after evaluation.

Parameters

sampleId – Id of the sample to process

virtual void setInitialConfiguration() override

Configures MCMC.

virtual void finalize() override

Final console output at termination.

virtual void runGeneration() override

Generate a sample and evaluate it.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

Public Members

size_t _burnIn

Specifies the number of preliminary MCMC steps before samples are being drawn. This may reduce effects from improper initialization.

size_t _leap

Generates a Markov Chain containing samples from every ‘Leap’-th step. This will increase the overall Chain Length by a factor of ‘Leap’.

size_t _rejectionLevels

Controls the number of accept-reject stages per MCMC step (by default, this value is set 1, for values greater 1 the delajed rejection algorithm is active.

int _useAdaptiveSampling

Specifies if covariance matrix of the proposal distribution is calculated from the samples.

size_t _nonAdaptionPeriod

Number of steps (after Burn In steps) during which the initial covariance is used instead of the Chain Covariance. If 0 (default) is specified, this value is calibrated as $5%$ of the Max Chain Length (only relevant for Adaptive Sampling).

double _chainCovarianceScaling

Learning rate of the Chain Covariance (only relevant for Adaptive Sampling).

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Normal random number generator.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

std::vector<double> _choleskyDecompositionCovariance

[Internal Use] Cholesky Decomposition of Covariance for sampling (using a lower triangular matrix, with rest zeros).

std::vector<double> _choleskyDecompositionChainCovariance

[Internal Use] Chain Cholesky Decomposition of Covariance for sampling (using a lower triangular matrix, with rest zeros).

std::vector<double> _chainLeader

[Internal Use] Variables of the newest sample in the Markov chain.

double _chainLeaderEvaluation

[Internal Use] The logLikelihood of the newest sample in the Markov chain.

std::vector<std::vector<double>> _chainCandidate

[Internal Use] Candidate variables to be accepted or rejected after comparison with the Chain Leader.

std::vector<double> _chainCandidatesEvaluations

[Internal Use] The loglikelihoods of the Chain Candidate Parameters.

std::vector<double> _rejectionAlphas

[Internal Use] Placeholder for recursive calculation of delayed rejection schemes.

double _acceptanceRate

[Internal Use] Ratio proposed to accepted samples (including Burn In period).

size_t _acceptanceCount

[Internal Use] Number of accepted samples (including Burn In period).

size_t _proposedSampleCount

[Internal Use] Number of proposed samples.

std::vector<std::vector<double>> _sampleDatabase

[Internal Use] Parameters generated by MCMC and stored in the database.

std::vector<double> _sampleEvaluationDatabase

[Internal Use] Evaluation associated with the parameters stored in the database.

std::vector<double> _chainMean

[Internal Use] Mean of Markov Chain calculated from samples in Database.

std::vector<double> _chainCovariancePlaceholder

[Internal Use] Placeholder for chain covariance calculation.

std::vector<double> _chainCovariance

[Internal Use] Chain Covariance calculated from samples in Database.

size_t _chainLength

[Internal Use] Current Chain Length (including Burn In and Leaped Samples).

size_t _maxSamples

[Termination Criteria] Number of Samples to Generate.

class korali::solver::optimizer::MOCMAES : public korali::solver::Optimizer
#include <MOCMAES.hpp>

Class declaration for module: MOCMAES.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void prepareGeneration()

Prepares generation for the next set of evaluations.

void sampleSingle(size_t sampleIdx)

Evaluates a single sample.

Parameters

sampleIdx – Index of the sample to evaluate

std::vector<int> sortSampleIndices(const std::vector<std::vector<double>> &values) const

Sort sample indeces based on non-dominance (primary) and contribution and contributing hypervolume (secondary).

Parameters

values – Values to sort

Returns

sorted indices

void updateDistribution()

Updates mean and covariance of Gaussian proposal distribution.

void updateStatistics()

Update statistics mostly for analysis.

virtual void setInitialConfiguration() override

Configures CMA-ES.

virtual void runGeneration() override

Executes sampling & evaluation generation.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

virtual void finalize() override

Final console output at termination.

Public Members

size_t _populationSize

Specifies the number of samples to evaluate per generation (preferably $4+3*log(N)$, where $N$ is the number of variables).

size_t _muValue

Number of best samples (offspring) advancing to the next generation (by default it is half the Sample Count).

double _evolutionPathAdaptionStrength

Controls the learning rate of the conjugate evolution path (must be in (0,1], by default this variable is internally calibrated, variable Cc in reference).

double _covarianceLearningRate

Controls the learning rate of the covariance matrices (must be in (0,1], by default this variable is internally calibrated, variable Ccov in reference).

double _targetSuccessRate

Value that controls the updates of the covariance matrix and the evolution path (must be in (0,1], variable Psucc in reference).

double _thresholdProbability

Threshold that defines update scheme for the covariance matrix and the evolution path (must be in (0,1], variable Pthresh in reference).

double _successLearningRate

Learning Rate of success rates (must be in (0,1], by default this variable is internally calibrated, variable Cp in reference).

size_t _numObjectives

[Internal Use] The number of objective functions to optimize.

korali::distribution::multivariate::Normal *_multinormalGenerator

[Internal Use] Multinormal random number generator.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

size_t _currentNonDominatedSampleCount

[Internal Use] Number of non dominated samples of current generation.

std::vector<std::vector<double>> _currentValues

[Internal Use] Objective function values.

std::vector<std::vector<double>> _previousValues

[Internal Use] Objective function values from previous generation.

std::vector<size_t> _parentIndex

[Internal Use] Tracking index of parent samples.

std::vector<std::vector<double>> _parentSamplePopulation

[Internal Use] Sample coordinate information of parents.

std::vector<std::vector<double>> _currentSamplePopulation

[Internal Use] Sample coordinate information.

std::vector<std::vector<double>> _previousSamplePopulation

[Internal Use] Sample coordinate information of previous offsprint.

std::vector<double> _parentSigma

[Internal Use] Step size of parent.

std::vector<double> _currentSigma

[Internal Use] Determines the step size.

std::vector<double> _previousSigma

[Internal Use] Previous step size.

std::vector<std::vector<double>> _parentCovarianceMatrix

[Internal Use] (Unscaled) covariance matrices of parents.

std::vector<std::vector<double>> _currentCovarianceMatrix

[Internal Use] (Unscaled) covariance matrices of proposal distributions.

std::vector<std::vector<double>> _previousCovarianceMatrix

[Internal Use] (Unscaled) covariance matrices of proposal distributions from previous offspring.

std::vector<std::vector<double>> _parentEvolutionPaths

[Internal Use] Evolution path of parents.

std::vector<std::vector<double>> _currentEvolutionPaths

[Internal Use] Evolution path of samples.

std::vector<std::vector<double>> _previousEvolutionPaths

[Internal Use] Evolution path of samples of previous offspring.

std::vector<double> _parentSuccessProbabilities

[Internal Use] Smoothed success probabilities of parents.

std::vector<double> _currentSuccessProbabilities

[Internal Use] Smoothed success probabilities.

std::vector<double> _previousSuccessProbabilities

[Internal Use] Smoothed success probabilities of previous generation.

size_t _finishedSampleCount

[Internal Use] Counter of evaluated samples to terminate evaluation.

std::vector<double> _bestEverValues

[Internal Use] Best value of each objective.

std::vector<std::vector<double>> _bestEverVariablesVector

[Internal Use] Samples associated with best ever objective values.

std::vector<double> _previousBestValues

[Internal Use] Best objectives from previous generation.

std::vector<std::vector<double>> _previousBestVariablesVector

[Internal Use] Samples associated with previous best objective values.

std::vector<double> _currentBestValues

[Internal Use] Best objectives from current generation.

std::vector<std::vector<double>> _currentBestVariablesVector

[Internal Use] Samples associated with current best objective values.

std::vector<std::vector<double>> _sampleCollection

[Internal Use] Candidate pareto optimal samples. Samples will be finalized at termination.

std::vector<std::vector<double>> _sampleValueCollection

[Internal Use] Model evaluations of pareto candidates.

size_t _infeasibleSampleCount

[Internal Use] Keeps count of the number of infeasible samples.

std::vector<double> _currentBestValueDifferences

[Internal Use] Value differences of current and previous best values found.

std::vector<double> _currentBestVariableDifferences

[Internal Use] L2 norm of previous and current best variable for each objective.

std::vector<double> _currentMinStandardDeviations

[Internal Use] Current minimum of any standard devs of a sample.

std::vector<double> _currentMaxStandardDeviations

[Internal Use] Current maximum of any standard devs of a sample.

double _minMaxValueDifferenceThreshold

[Termination Criteria] Specifies the min max fitness differential between two consecutive generations before stopping execution.

double _minVariableDifferenceThreshold

[Termination Criteria] Specifies the min L2 norm of the best samples between two consecutive generations before stopping execution.

double _minStandardDeviation

[Termination Criteria] Specifies the minimal standard deviation.

double _maxStandardDeviation

[Termination Criteria] Specifies the maximal standard deviation.

class korali::Module
#include <module.hpp>

Represents the basic building block of all Korali modules.

Subclassed by korali::Conduit, korali::Distribution, korali::Experiment, korali::NeuralNetwork, korali::neuralNetwork::Layer, korali::Problem, korali::Solver

Public Functions

virtual ~Module() = default
virtual void initialize()

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void finalize()

Finalizes Module. Deallocates memory and produces outputs.

virtual std::string getType()

Returns the module type.

Returns

A string containing the exact type with which it was created.

virtual bool checkTermination()

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js)

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js)

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js)

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults()

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample)

Runs the operation specified in the operation field. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on

  • operation – An operation accepted by this module or its parents

Returns

True, if operation found and executed; false, otherwise.

Public Members

std::string _type

Stores the name of the module type selected. Determines which C++ class is constructed upon initialization.

korali::Experiment *_k

Stores a pointer to its containing experiment.

Public Static Functions

static Module *getModule(knlohmann::json &js, korali::Experiment *e)

Instantiates the requested module class given its type and returns its pointer.

Parameters
  • js – JSON file containing the module’s configuration and type.

  • eKorali Experiment to serve as parent to the module.

Returns

Pointer with the newly created module.

class korali::distribution::specific::Multinomial : public korali::distribution::Specific
#include <multinomial.hpp>

Class declaration for module: Multinomial.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void getSelections(std::vector<double> &p, std::vector<unsigned int> &n, int N)

This function computes a random sample from the multinomial distribution.

Parameters
  • p – Underlying probability distributions

  • n – Random sample to draw

  • N – Number of trials

class korali::distribution::Multivariate : public korali::Distribution
#include <multivariate.hpp>

Class declaration for module: Multivariate.

Subclassed by korali::distribution::multivariate::Normal

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setProperty(const std::string &propertyName, const std::vector<double> &values) = 0

Updates a specific property with a vector of values.

Parameters
  • propertyName – The name of the property to update

  • values – double Numerical values to assign.

virtual void getDensity(double *x, double *result, const size_t n) = 0

Gets the probability density of the distribution at points x.

Parameters
  • x – points to evaluate

  • result – P(x) at the given points

  • n – number of points

virtual void getLogDensity(double *x, double *result, const size_t n) = 0

Gets Log probability density of the distribution at points x.

Parameters
  • x – points to evaluate

  • result – log(P(x)) at the given points

  • n – number of points

virtual void getRandomVector(double *x, const size_t n) = 0

Draws and returns a random number vector from the distribution.

Parameters
  • x – Random real number vector.

  • n – Vector size

class korali::solver::sampler::Nested : public korali::solver::Sampler
#include <Nested.hpp>

Class declaration for module: Nested.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setInitialConfiguration() override

Configures Sampler.

virtual void runGeneration() override

Main solver loop.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

virtual void finalize() override

Final console output at termination.

Public Members

size_t _numberLivePoints

Number of live samples.

size_t _batchSize

Number of samples to discard and replace per generation, maximal number of parallel sample evaluation.

int _addLivePoints

Add live points to dead points.

std::string _resamplingMethod

Method to generate new candidates (can be set to either ‘Box’ or ‘Ellipse’, ‘Multi Ellipse’).

size_t _proposalUpdateFrequency

Frequency of resampling distribution update (e.g. ellipse rescaling for Ellipse).

double _ellipsoidalScaling

Scaling factor of ellipsoidal (only relevant for ‘Ellipse’ and ‘Multi Ellipse’ proposal).

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator.

korali::distribution::univariate::Normal *_normalGenerator

[Internal Use] Gaussian random number generator.

korali::distribution::multivariate::Normal *_multivariateGenerator

[Internal Use] Random number generator with a multivariate normal distribution.

size_t _acceptedSamples

[Internal Use] Number of accepted samples.

size_t _generatedSamples

[Internal Use] Number of generated samples (after initialization).

double _logEvidence

[Internal Use] Accumulated LogEvidence.

double _logEvidenceVar

[Internal Use] Estimated accumulated variance of log evidence.

double _logVolume

[Internal Use] Remaining Prior Mass.

double _boundLogVolume

[Internal Use] Volume within bounds.

size_t _lastAccepted

[Internal Use] Number of generations past since a sample has been accepted.

size_t _nextUpdate

[Internal Use] Next time when bounds are being updated.

double _information

[Internal Use] Accumulated information.

double _lStar

[Internal Use] Likelihood constraint for sample acceptance.

double _lStarOld

[Internal Use] Previous likelihood constraint.

double _logWeight

[Internal Use] Log increment of evidence.

double _expectedLogShrinkage

[Internal Use] Expected volume shrinkage per sample.

double _maxEvaluation

[Internal Use] Largest sum of loglikelihood and logprior in live sample set.

double _remainingLogEvidence

[Internal Use] Estimated remaining log evidence.

double _logEvidenceDifference

[Internal Use] Difference of current and remaining log evidence.

double _effectiveSampleSize

[Internal Use] Number of effective Samples estimate.

double _sumLogWeights

[Internal Use] Sum of log weights in sample database.

double _sumSquareLogWeights

[Internal Use] Sum of squared log weights in sample database.

std::vector<double> _priorLowerBound

[Internal Use] Lower bound of unfirom prior.

std::vector<double> _priorWidth

[Internal Use] Width of uniform prior.

std::vector<std::vector<double>> _candidates

[Internal Use] Sample candidates to be evaluated in current generation.

std::vector<double> _candidateLogLikelihoods

[Internal Use] Loglikelihood evaluations of candidates.

std::vector<double> _candidateLogPriors

[Internal Use] The logpriors of the candidates.

std::vector<double> _candidateLogPriorWeights

[Internal Use] The logprior weights of the candidates.

std::vector<std::vector<double>> _liveSamples

[Internal Use] Samples to be processed and replaced in ascending order.

std::vector<double> _liveLogLikelihoods

[Internal Use] Loglikelihood evaluations of live samples.

std::vector<double> _liveLogPriors

[Internal Use] Logprior evaluations of live samples.

std::vector<double> _liveLogPriorWeights

[Internal Use] Logprior weights of live samples.

std::vector<size_t> _liveSamplesRank

[Internal Use] Ascending ranking of live samples (sorted based on likelihood and logprior weight).

size_t _numberDeadSamples

[Internal Use] Number of dead samples, which have been removed from the live samples.

std::vector<std::vector<double>> _deadSamples

[Internal Use] Dead samples stored in database.

std::vector<double> _deadLogLikelihoods

[Internal Use] Loglikelihood evaluations of dead samples.

std::vector<double> _deadLogPriors

[Internal Use] Logprior evaluations associated with dead samples.

std::vector<double> _deadLogPriorWeights

[Internal Use] Logprior weights associated with dead samples.

std::vector<double> _deadLogWeights

[Internal Use] Log weight (Priormass x Likelihood) of dead samples.

std::vector<double> _covarianceMatrix

[Internal Use] Sample covariance of the live samples.

double _logDomainSize

[Internal Use] Log of domain volumne given by uniform prior distribution.

std::vector<double> _domainMean

[Internal Use] Mean of the domain occupied by live samples.

std::vector<double> _boxLowerBound

[Internal Use] Lower bound of box constraint (only relevant for ‘Box’ resampling method).

std::vector<double> _boxUpperBound

[Internal Use] Upper bound of box constraint (only relevant for ‘Box’ resampling method).

std::vector<std::vector<double>> _ellipseAxes

[Internal Use] Axes of bounding ellipse (only relevant for ‘Ellipse’ resampling method).

double _minLogEvidenceDelta

[Termination Criteria] Minimal difference between estimated remaining log evidence and current logevidence.

size_t _maxEffectiveSampleSize

[Termination Criteria] Estimated maximal evidence gain smaller than accumulated evidence by given factor.

size_t _maxLogLikelihood

[Termination Criteria] Terminates if loglikelihood of sample removed from live set exceeds given value.

Private Functions

void runFirstGeneration()
void updateBounds()
void priorTransform(std::vector<double> &sample) const
void generateCandidates()
void generateCandidatesFromBox()

Generate new samples uniformly in Box.

void generateSampleFromEllipse(const ellipse_t &ellipse, std::vector<double> &sample) const

Generates a sample uniformly in Ellipse.

Parameters
  • ellipse – Bounding ellipsoid from which to sample.

  • sample – Generated sample.

void generateCandidatesFromEllipse()

Generate new samples uniformly in Ellipse.

void generateCandidatesFromMultiEllipse()

Generate new samples uniformly from multiple Ellipses.

bool processGeneration()
double logPriorWeight(std::vector<double> &sample)
void setBoundsVolume()
void consumeLiveSamples()
void updateBox()
void sortLiveSamplesAscending()
void updateDeadSamples(size_t sampleIdx)
void generatePosterior()
double l2distance(const std::vector<double> &sampleOne, const std::vector<double> &sampleTwo) const
bool updateEllipse(ellipse_t &ellipse) const
void updateMultiEllipse()
void initEllipseVector()
bool kmeansClustering(const ellipse_t &parent, size_t maxIter, ellipse_t &childOne, ellipse_t &childTwo) const
void updateEllipseMean(ellipse_t &ellipse) const
bool updateEllipseCov(ellipse_t &ellipse) const
bool updateEllipseVolume(ellipse_t &ellipse) const
double mahalanobisDistance(const std::vector<double> &sample, const ellipse_t &ellipse) const
void updateEffectiveSamples()
bool insideUnitCube(const std::vector<double> &sample) const

Private Members

size_t _shuffleSeed
std::vector<ellipse_t> _ellipseVector
class korali::NeuralNetwork : public korali::Module
#include <neuralNetwork.hpp>

Class declaration for module: NeuralNetwork.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

std::vector<float> generateInitialHyperparameters()

Generates the initial values for the hyperparameters.

Returns

The initial hyperparameters

void setHyperparameters(const std::vector<float> &hyperparameters)

Updates the values of weights, biases configuration to the NN.

Parameters

hyperparameters – The input hyperparameters

std::vector<float> getHyperparameters()

Gets the values of weights and biases configuration to the NN.

Returns

The hyperparameters of the NN

void forward(const std::vector<std::vector<std::vector<float>>> &inputValues)

Forward-propagates the input values through the network.

Parameters

inputValues – The input values. Format: TxNxIC (T: Time steps, N: Mini-batch, IC: Input channels).

void backward(const std::vector<std::vector<float>> &outputGradients)

Backward-propagates the gradients through the network.

Parameters

outputGradients – Output gradients. Format: NxOC (N: Mini-batch size, OC: Output channels).

size_t getBatchSizeIdx(const size_t batchSize)

Returns the pipeline index corresponding to the batch size requested.

Parameters

batchSize – Size of the batch to request

Returns

Pipeline Id correspoding to the batch size

std::vector<std::vector<float>> &getOutputValues(const size_t batchSize)

Returns a reference to the output values corresponding to the batch size’s pipeline.

Parameters

batchSize – Size of the batch to request

Returns

Reference to the output values

std::vector<std::vector<float>> &getInputGradients(const size_t batchSize)

Returns a reference to the input gradients corresponding to the batch size’s pipeline.

Parameters

batchSize – Size of the batch to request

Returns

Reference to the input gradients

std::vector<float> &getHyperparameterGradients(const size_t batchSize)

Returns a reference to the hyperparameter gradients corresponding to the batch size’s pipeline.

Parameters

batchSize – Size of the batch to request

Returns

Reference hyperparameter gradients

NeuralNetwork()

Creator that sets initialized flag to false.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

std::string _engine

Specifies which Neural Network backend engine to use.

std::string _mode

Specifies the execution mode of the Neural Network.

knlohmann::json _layers

Complete description of the NN’s layers.

size_t _timestepCount

Provides the sequence length for the input/output data.

std::vector<size_t> _batchSizes

Specifies the batch sizes.

float _currentTrainingLoss

[Internal Use] Current value of the training loss.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Uniform random number generator for setting the initial value of the weights and biases.

std::vector<std::vector<layerPipeline_t>> _pipelines

Layer pipelines, one per threadCount * BatchSize combination. These are all replicas of the user-defined layers that share the same hyperparameter space.

bool _isInitialized

Flag to make sure the NN is initialized before creating.

size_t _hyperparameterCount

Number of NN hyperparameters (weights/bias)

class korali::distribution::multivariate::Normal : public korali::distribution::Multivariate
#include <normal.hpp>

Class declaration for module: Normal.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual void setProperty(const std::string &propertyName, const std::vector<double> &values) override

Updates a specific property with a vector of values.

Parameters
  • propertyName – The name of the property to update

  • values – double Numerical values to assign.

virtual void getDensity(double *x, double *result, const size_t n) override

Gets the probability density of the distribution at points x.

Parameters
  • x – points to evaluate

  • result – P(x) at the given points

  • n – number of points

virtual void getLogDensity(double *x, double *result, const size_t n) override

Gets Log probability density of the distribution at points x.

Parameters
  • x – points to evaluate

  • result – log(P(x)) at the given points

  • n – number of points

virtual void getRandomVector(double *x, const size_t n) override

Draws and returns a random number vector from the distribution.

Parameters
  • x – Random real number vector.

  • n – Vector size

Public Members

std::vector<double> _meanVector

Means of the variables.

std::vector<double> _sigma

Cholesky Decomposition of the covariance matrix.

std::vector<double> _workVector

[Internal Use] Auxiliary work vector.

Private Members

gsl_matrix_view _sigma_view

Temporal storage for covariance matrix.

gsl_vector_view _mean_view

Temporal storage for variable means.

gsl_vector_view _work_view

Temporal storage for work.

class korali::distribution::univariate::Normal : public korali::distribution::Univariate
#include <normal.hpp>

Class declaration for module: Normal.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _mean

[Conditional Variable Value]

std::string _meanConditional

[Conditional Variable Reference]

double _standardDeviation

[Conditional Variable Value]

std::string _standardDeviationConditional

[Conditional Variable Reference]

Private Members

double _normalization
double _logNormalization
class korali::problem::Optimization : public korali::Problem
#include <optimization.hpp>

Class declaration for module: Optimization.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

void evaluate(korali::Sample &sample)

Evaluates a single objective, given a set of parameters.

Parameters

sample – A sample to process

void evaluateMultiple(korali::Sample &sample)

Evaluates multiple objectives, given a set of parameters.

Parameters

sample – A sample to process

void evaluateConstraints(korali::Sample &sample)

Evaluates whether at least one of constraints have been met.

Parameters

sample – A Korali Sample

void evaluateWithGradients(korali::Sample &sample)

Evaluates the F(x) and Gradient(x) of a sample, given a set of parameters.

Parameters

sample – A sample to process

Public Members

size_t _numObjectives

Number of return values to expect from objective function.

std::uint64_t _objectiveFunction

Stores the function to evaluate.

std::vector<std::uint64_t> _constraints

Stores constraints to the objective function.

int _hasDiscreteVariables

[Internal Use] Flag indicating if at least one of the variables is discrete.

class korali::solver::Optimizer : public korali::Solver
#include <optimizer.hpp>

Class declaration for module: Optimizer.

Subclassed by korali::solver::optimizer::AdaBelief, korali::solver::optimizer::Adam, korali::solver::optimizer::CMAES, korali::solver::optimizer::DEA, korali::solver::optimizer::GridSearch, korali::solver::optimizer::MADGRAD, korali::solver::optimizer::MOCMAES, korali::solver::optimizer::Rprop

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

bool isSampleFeasible(const std::vector<double> &sample)

Checks whether the proposed sample can be optimized.

Parameters

sample – A Korali Sample

Returns

True, if feasible; false, otherwise.

Public Members

double _currentBestValue

[Internal Use] Best model evaluation from current generation.

double _previousBestValue

[Internal Use] Best model evaluation from previous generation.

double _bestEverValue

[Internal Use] Best ever model evaluation.

std::vector<double> _bestEverVariables

[Internal Use] Variables associated to best ever value found.

double _maxValue

[Termination Criteria] Specifies the maximum target fitness to stop maximization.

double _minValueDifferenceThreshold

[Termination Criteria] Specifies the minimum fitness differential between two consecutive generations before stopping execution.

class korali::neuralNetwork::layer::Output : public korali::neuralNetwork::Layer
#include <output.hpp>

Class declaration for module: Output.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void createForwardPipeline() override

Initializes the layer’s internal memory structures for the forward pipeline.

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void forwardData(const size_t t) override

Performs the forward propagation of the Wx+b operations.

Parameters

t – Indicates the current timestep

virtual void backwardData(const size_t t) override

Performs the backward propagation of the data.

Parameters

t – Indicates the current timestep

Public Members

std::vector<std::string> _transformationMask

Indicates a transformation to be performed to the output at the last layer of the neural network. [Order of application on forward propagation: 1/3].

std::vector<float> _scale

Gives a scaling factor for each of the output values of the NN. [Order of application on forward propagation 2/3].

std::vector<float> _shift

Shifts the output of the NN by the values given. [Order of application on forward propagation 3/3].

float *_srcOutputValues

Contains the original output, before preprocessing.

float *_dstOutputGradients

Contains the postprocessed gradients.

std::vector<transformation_t> _transformationVector

Contains the description of the transformation to apply to each output element.

struct korali::solver::policy_t
#include <agent.hpp>

Structure to store policy information.

Public Members

float stateValue

Contains state value (V) estimation for the given state / policy combination.

std::vector<float> distributionParameters

Contains the parameters that define the policy distribution used to produced the action. For continuous policies, it depends on the distribution selected. For discrete policies, it contains the categorical probability of every action.

size_t actionIndex

[Discrete] Stores the index of the selected experience

std::vector<float> unboundedAction

[Continuous] Stores the Unbounded Actions of the Squashed Normal Policy Distribution

class korali::Problem : public korali::Module
#include <problem.hpp>

Class declaration for module: Problem.

Subclassed by korali::problem::Bayesian, korali::problem::Hierarchical, korali::problem::Integration, korali::problem::Optimization, korali::problem::Propagation, korali::problem::ReinforcementLearning, korali::problem::Sampling, korali::problem::SupervisedLearning

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

class korali::problem::Propagation : public korali::Problem
#include <propagation.hpp>

Class declaration for module: Propagation.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

void execute(korali::Sample &sample)

Produces an evaluation of the model, storing it in a file.

Parameters

sample – A Korali Sample

Public Members

std::uint64_t _executionModel

Stores the function to evaluate.

size_t _numberOfSamples

Number of samples to draw from Prior distribution.

class korali::problem::hierarchical::Psi : public korali::problem::Hierarchical
#include <psi.hpp>

Class declaration for module: Psi.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void updateConditionalPriors(korali::Sample &sample)

Updates the distribution parameters for the conditional priors, given variable values in the sample.

Parameters

sample – A Korali Sample

virtual void evaluateLogLikelihood(korali::Sample &sample) override

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

std::vector<knlohmann::json> _subExperiments

Provides results from previous Bayesian Inference sampling experiments.

std::vector<std::string> _conditionalPriors

List of conditional priors to use in the hierarchical problem.

std::vector<size_t> _conditionalPriorIndexes

Stores the indexes of conditional priors to Experiment variables.

Private Members

size_t _subProblemsCount

Stores the number of subproblems.

size_t _subProblemsVariablesCount

Stores the number of variables in the subproblems (all must be the same)

std::vector<std::vector<std::vector<double>>> _subProblemsSampleCoordinates

Stores the sample coordinates of all the subproblems.

std::vector<std::vector<double>> _subProblemsSampleLogLikelihoods

Stores the sample logLikelihoods of all the subproblems.

std::vector<std::vector<double>> _subProblemsSampleLogPriors

Stores the sample logPriors of all the subproblems.

std::vector<conditionalPriorInfo> _conditionalPriorInfos

Stores the precomputed conditional prior information, for performance.

class korali::neuralNetwork::layer::Recurrent : public korali::neuralNetwork::Layer
#include <recurrent.hpp>

Class declaration for module: Recurrent.

Subclassed by korali::neuralNetwork::layer::recurrent::GRU, korali::neuralNetwork::layer::recurrent::LSTM

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void createHyperparameterMemory() override

Initializes the layer’s internal memory structures for hyperparameter storage.

virtual void backwardHyperparameters(const size_t t) override

Calculates the gradients of layer hyperparameters.

Parameters

t – Indicates the current timestep

virtual void createBackwardPipeline() override

Initializes the internal memory structures for the backward pipeline.

virtual void copyHyperparameterPointers(Layer *dstLayer) override

Replicates the pointers for the current layer onto a destination layer.

Parameters

dstLayer – The destination layer onto which to copy the pointers

virtual std::vector<float> generateInitialHyperparameters() override

Generates the initial weight/bias hyperparameters for the layer.

Returns

The initial hyperparameters

virtual void setHyperparameters(float *hyperparameters) override

Updates layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Input) Pointer to read the hyperparameters from.

virtual void getHyperparameters(float *hyperparameters) override

Gets layer’s hyperparameters (e.g., weights and biases)

Parameters

hyperparameters – (Output) Pointer to write the hyperparameters to.

virtual void getHyperparameterGradients(float *gradient) override

Gets the gradients of the layer’s output wrt to is hyperparameters (e.g., weights and biases)

Parameters

gradient – (Output) Pointer to write the hyperparameter gradients to.

Public Members

size_t _depth

The number of copies of this layer. This has a better performance than just defining many of these layers manually since it is optimized by the underlying engine.

size_t _gateCount

Indicates the number of recurrent gates (depends on the architecture)

class korali::problem::bayesian::Reference : public korali::problem::Bayesian
#include <reference.hpp>

Class declaration for module: Reference.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void evaluateLoglikelihood(korali::Sample &sample) override

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

virtual void evaluateLoglikelihoodGradient(korali::Sample &sample) override

Evaluates the gradient of the logLikelikood w.r.t. to the variables, and stores it in sample[“logLikelihood Gradient”].

Parameters

sample – A Korali Sample

virtual void evaluateLogLikelihoodHessian(korali::Sample &sample) override

Evaluates the gradient of the logLikelikood w.r.t. to the variables, and stores it in sample[“logLikelihood Hessian”].

Parameters

sample – A Korali Sample

virtual void evaluateFisherInformation(korali::Sample &sample) override

Evaluates the empirical Fisher information.

Parameters

sample – A Korali Sample

Public Members

std::uint64_t _computationalModel

Stores the computational model. It should the evaluation of the model at the given reference data points.

std::vector<double> _referenceData

Reference data required to calculate likelihood. Model evaluations are compared against these data.

std::string _likelihoodModel

Specifies the likelihood model to approximate the reference data to.

Private Functions

double compute_normalized_sse(std::vector<double> f, std::vector<double> g, std::vector<double> y)

Precomputes the square distance between two vectors (f and y) of the same size normalized by a third vector (g)

Parameters
  • f – Vector f

  • g – Vector g, the normalization vector

  • y – Vector y

Returns

Normalized square distance of the vectors

void loglikelihoodNormal(korali::Sample &sample)

An implementation of the normal likelihood y~N(f,g), where f ang g are provided by the user.

Parameters

sample – A Korali Sample

void loglikelihoodPositiveNormal(korali::Sample &sample)

An implementation of the normal likelihood y~N(f,g) truncated at zero, where f ang g are provided by the user.

Parameters

sample – A Korali Sample

void loglikelihoodStudentT(korali::Sample &sample)

An implementation of the student’s t loglikelihood y~T(v), where v>0 (degrees of freedom) is provided by the user.

Parameters

sample – A Korali Sample

void loglikelihoodPositiveStudentT(Sample &sample)

An implementation of the student’s t loglikelihood y~T(v) truncated at zero, where v>0 (degrees of freedom) is provided by the user.

Parameters

sample – A Korali Sample

void loglikelihoodPoisson(korali::Sample &sample)

Poisson likelihood parametrized by mean.

Parameters

sample – A Korali Sample

void loglikelihoodGeometric(korali::Sample &sample)

Geometric likelihood parametrized by mean. Parametrization of number of trials before success used.

Parameters

sample – A Korali Sample

void loglikelihoodNegativeBinomial(korali::Sample &sample)

Negative Binomial likelihood parametrized by mean and dispersion.

Parameters

sample – A Korali Sample

void gradientLoglikelihoodNormal(korali::Sample &sample)

Calculates the gradient of the Normal loglikelihood model.

Parameters

sample – A Korali Sample

void gradientLoglikelihoodPositiveNormal(korali::Sample &sample)

Calculates the gradient of the Positive Normal (truncated at 0) loglikelihood model.

Parameters

sample – A Korali Sample

void gradientLoglikelihoodNegativeBinomial(korali::Sample &sample)

Calculates the gradient of the Negative Binomial loglikelihood model.

Parameters

sample – A Korali Sample

void hessianLogLikelihoodNormal(korali::Sample &sample)

Calculates the Hessian of the Normal logLikelihood model.

Parameters

sample – A Korali Sample

void hessianLogLikelihoodPositiveNormal(korali::Sample &sample)

Calculates the Hessian of the Positive Normal logLikelihood model.

Parameters

sample – A Korali Sample

void hessianLogLikelihoodNegativeBinomial(korali::Sample &sample)

Calculates the Hessian of the Negative Binomial logLikelihood model.

Parameters

sample – A Korali Sample

void fisherInformationLoglikelihoodNormal(korali::Sample &sample)

Calculates the Fisher information matrix of the Normal likelihood model.

Parameters

sample – A Korali Sample

void fisherInformationLoglikelihoodPositiveNormal(korali::Sample &sample)

Calculates the Fisher information matrix of the Positive Normal (truncated at 0) likelihood model.

Parameters

sample – A Korali Sample

void fisherInformationLoglikelihoodNegativeBinomial(korali::Sample &sample)

Calculates the Fisher information matrix of the Negative Binomial likelihood model.

Parameters

sample – A Korali Sample

Private Members

const double _log2pi = 1.83787706640934533908193770912476
class korali::problem::ReinforcementLearning : public korali::Problem
#include <reinforcementLearning.hpp>

Class declaration for module: ReinforcementLearning.

Subclassed by korali::problem::reinforcementLearning::Continuous, korali::problem::reinforcementLearning::Discrete

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

void runTrainingEpisode(korali::Sample &agent)

Runs an episode of the agent within the environment with actions produced by the policy + exploratory noise. If the reward exceeds the threshold, it also runs testing episodes.

Parameters

agentSample containing current agent/state information.

void runTestingEpisode(korali::Sample &agent)

Runs an episode of the agent within the environment with actions produced by the policy only.

Parameters

agentSample containing current agent/state information.

void initializeEnvironment(korali::Sample &agent)

Initializes the environment and agent configuration.

Parameters

agentSample containing current agent/state information.

void finalizeEnvironment()

Finalizes the environemnt (frees resources)

void runEnvironment(Sample &agent)

Runs/resumes the execution of the environment.

Parameters

agentSample containing current agent/state information.

void requestNewPolicy(Sample &agent)

Communicates with the Engine to get the latest policy.

Parameters

agentSample containing current agent/state information.

void getAction(Sample &agent)

Runs the policy on the current state to get the action.

Parameters

agentSample containing current agent/state information.

Public Members

size_t _agentsPerEnvironment

Number of agents in a given environment. All agents share the same policy .

size_t _environmentCount

Number of concurrent environments to run.

std::uint64_t _environmentFunction

Function to initialize and run an episode in the environment.

size_t _actionsBetweenPolicyUpdates

Number of actions to take before requesting a new policy.

knlohmann::json _customSettings

Any used-defined settings required by the environment.

size_t _actionVectorSize

[Internal Use] Stores the dimension of the action space.

size_t _stateVectorSize

[Internal Use] Stores the dimension of the state space.

std::vector<size_t> _actionVectorIndexes

[Internal Use] Stores the indexes of the variables that constitute the action vector.

std::vector<size_t> _stateVectorIndexes

[Internal Use] Stores the indexes of the variables that constitute the action vector.

std::vector<float> _stateRescalingMeans

Contains the state rescaling means.

std::vector<float> _stateRescalingSdevs

Contains the state rescaling sigmas.

double _agentPolicyEvaluationTime

[Profiling] Stores policy evaluation time per episode

double _agentComputationTime

[Profiling] Stores environment evaluation time per episode

double _agentCommunicationTime

[Profiling] Stores communication time per episode

class korali::solver::optimizer::Rprop : public korali::solver::Optimizer
#include <Rprop.hpp>

Class declaration for module: Rprop.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void setInitialConfiguration() override

Initializes the solver with starting values for the first generation.

virtual void finalize() override

Finalizes Module. Deallocates memory and produces outputs.

virtual void runGeneration() override

Runs the current generation.

virtual void printGenerationBefore() override

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter() override

Prints solver information after the execution of the current generation.

Public Members

double _delta0

Initial Delta.

double _deltaMin

Minimum Delta, parameter for step size calibration.

double _deltaMax

Maximum Delta, parameter for step size calibration.

double _etaMinus

Parameter for step size calibration.

double _etaPlus

Parameter for step size calibration.

std::vector<double> _currentVariable

[Internal Use] Current value of parameters.

std::vector<double> _bestEverVariable

[Internal Use] Best value of parameters.

std::vector<double> _delta

[Internal Use] Gradient scaling factor

std::vector<double> _currentGradient

[Internal Use] Gradient of parameters.

std::vector<double> _previousGradient

[Internal Use] Old gradient of parameters.

std::vector<double> _bestEverGradient

[Internal Use] Gradient of function with respect to Best Ever Variables.

double _normPreviousGradient

[Internal Use] Norm of old gradient.

double _maxStallCounter

[Internal Use] Counts the number the algorithm has been stalled in function evaluation bigger than the best one.

double _xDiff

[Internal Use] Norm of variable update.

double _maxGradientNorm

[Termination Criteria] Maximum value of the norm of the gradient.

size_t _maxStallGenerations

[Termination Criteria] Maximum times stalled with function evaluation bigger than the best one.

double _parameterRelativeTolerance

[Termination Criteria] Relative tolerance in parameter difference between generations.

Private Functions

void evaluateFunctionAndGradient(Sample &sample)
void performUpdate(void)
class korali::Sample
#include <sample.hpp>

Contains input/output data to computational models.

Public Functions

Sample()

Constructs Sample. Stores its own pointer, sets ID to zero, state as uninitialized, and isAllocated to false.

~Sample()
void run(size_t functionPosition)

Runs a computational model by reinterpreting a numerical pointer to a function(sample) object to an actual function pointer and calls it.

Parameters

functionPosition – Number containing a pointer to a function.

void sampleLauncher()

Handles the execution thread of individual samples on the worker’s side.

void update()

Returns results to the worker without finishing the execution of the computational model.

knlohmann::json &globals()

Returns global parameters broadcasted by the problem.

Returns

The global parameters

bool contains(const std::string &key)

Checks whether the sample contains the given key.

Parameters

key – Key (String) to look for.

Returns

True, if it is contained; false, otherwise.

knlohmann::json &operator[](const std::string &key)

Accesses the value of a given key in the sample.

Parameters

key – Key (String) to look for.

Returns

JSON object for the given key.

knlohmann::json &operator[](const unsigned long int &key)

Accesses the value of a given key in the sample.

Parameters

key – Key (number) to look for.

Returns

JSON object for the given key.

pybind11::object getItem(const pybind11::object key)

Gets the value of a given key in the sample.

Parameters

key – Key (pybind11 object) to look for.

Returns

Pybind11 object for the given key.

void setItem(const pybind11::object key, const pybind11::object val)

Sets the value of a given key in the sample.

Parameters
  • val – Value to assign.

  • key – Key (pybind11 object) to look for.

bool retrievePendingMessage(knlohmann::json &message)

Gets and dequeues a pending message, if exists.

Parameters

message – The message (json object) to overwrite, if a message exists.

Returns

True, if message found; false, if no message was found.

template<class T, typename ...Key>
inline T get(const char fileName[], int lineNumber, const Key&... key)

Retrieves an element from the sample information.

Parameters
  • fileName – where the error occurred, given by the FILE macro

  • lineNumber – number where the error occurred, given by the LINE macro

  • key – a list of keys describing the full path to traverse

Returns

Requested value

Public Members

Sample *_self

Pointer to the C++ object containing the sample. Necessary for integration with Python, because Python only passes objects by reference, and we need to access the original pointer when working on the C++ side. Therefore, we need to store the pointer as a variable.

std::queue<knlohmann::json> _messageQueue

Queue of messages sent from the sample to the engine.

SampleState _state

Current state of the sample.

cothread_t _sampleThread

User-Level thread (coroutine) containing the CPU execution state of the current Sample.

cothread_t _workerThread

User-Level thread (coroutine) containing the CPU execution state of the calling worker.

size_t _workerId

Storage to keep the iD of the worker processing this sample.

KoraliJson _js

JSON object containing the sample’s configuration and input/output data.

class korali::solver::Sampler : public korali::Solver
#include <sampler.hpp>

Class declaration for module: Sampler.

Subclassed by korali::solver::sampler::HMC, korali::solver::sampler::MCMC, korali::solver::sampler::Nested, korali::solver::sampler::TMCMC

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

class korali::problem::Sampling : public korali::Problem
#include <sampling.hpp>

Class declaration for module: Sampling.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool runOperation(std::string operation, korali::Sample &sample) override

Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents.

Parameters
  • sampleSample to operate on. Should contain in the ‘Operation’ field an operation accepted by this module or its parents.

  • operation – Should specify an operation type accepted by this module or its parents.

Returns

True, if operation found and executed; false, otherwise.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void evaluate(korali::Sample &sample)

Evaluates a function at the given parameters.

Parameters

sampleSample to evaluate

virtual void evaluateGradient(korali::Sample &sample)

Evaluates the gradient of a function at the given parameters.

Parameters

sampleSample to evaluate

virtual void evaluateHessian(korali::Sample &sample)

Evaluates the Heassian of a function at the given parameters.

Parameters

sampleSample to evaluate

Public Members

std::uint64_t _probabilityFunction

Stores the probability distribution function to evaluate.

class korali::conduit::Sequential : public korali::Conduit
#include <sequential.hpp>

Class declaration for module: Sequential.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual bool isRoot() override

Determines whether the caller rank/thread/process is root.

Returns

True, if it is root; false, otherwise.

virtual void initServer() override

Initializes the worker/server bifurcation in the conduit.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

virtual void terminateServer() override

Finalizes the workers.

virtual void stackEngine(Engine *engine) override

Stacks a new Engine into the engine stack.

Parameters

engine – A Korali Engine

virtual void popEngine() override

Pops the current Engine from the engine stack.

virtual void listenWorkers() override

(Engine <- Worker) Receives all pending incoming messages and stores them into the corresponding sample’s message queue.

virtual void broadcastMessageToWorkers(knlohmann::json &message) override

(Engine -> Worker) Broadcasts a message to all workers

Parameters

message – JSON object with information to broadcast

virtual void sendMessageToEngine(knlohmann::json &message) override

(Sample -> Engine) Sends an update to the engine to provide partial information while the sample is still active

Parameters

message – Message to send to engine

virtual knlohmann::json recvMessageFromEngine() override

(Sample <- Engine) Blocking call that waits until any message incoming from the engine.

Returns

message from the engine.

virtual void sendMessageToSample(Sample &sample, knlohmann::json &message) override

(Engine -> Sample) Sends an update to a still active sample

Parameters
  • sample – The sample from which to receive an update

  • message – Message to send to the sample.

virtual size_t getProcessId() override

Returns the identifier corresponding to the executing process (to differentiate their random seeds)

Returns

The executing process id

Public Members

cothread_t _workerThread

User-Level thread (coroutine) containing the CPU execution state of the single worker.

std::queue<knlohmann::json> _workerMessageQueue

Queue of messages sent from the engine to the worker.

class korali::Solver : public korali::Module
#include <solver.hpp>

Class declaration for module: Solver.

Subclassed by korali::solver::Agent, korali::solver::Executor, korali::solver::Integrator, korali::solver::Learner, korali::solver::Optimizer, korali::solver::Sampler

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void printGenerationBefore()

Prints solver information before the execution of the current generation.

virtual void printGenerationAfter()

Prints solver information after the execution of the current generation.

virtual void runGeneration() = 0

Runs the current generation.

virtual void setInitialConfiguration()

Initializes the solver with starting values for the first generation.

Public Members

size_t _variableCount

[Internal Use] Number of variables.

size_t _modelEvaluationCount

[Internal Use] Keeps track on the number of calls to the computational model.

size_t _maxModelEvaluations

[Termination Criteria] Specifies the maximum allowed evaluations of the computational model.

size_t _maxGenerations

[Termination Criteria] Determines how many solver generations to run before stopping execution. Execution can be resumed at a later moment.

std::vector<std::string> _terminationCriteria

Stores termination criteria for the module.

class korali::distribution::Specific : public korali::Distribution
#include <specific.hpp>

Class declaration for module: Specific.

Subclassed by korali::distribution::specific::Multinomial

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

class korali::problem::SupervisedLearning : public korali::Problem
#include <supervisedLearning.hpp>

Class declaration for module: SupervisedLearning.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

void verifyData()

Checks whether the input data has the correct shape.

Public Members

size_t _trainingBatchSize

Stores the batch size of the training dataset.

size_t _inferenceBatchSize

Stores the batch size of the inference dataset.

size_t _maxTimesteps

Stores the length of the sequence for recurrent neural networks.

std::vector<std::vector<std::vector<float>>> _inputData

Provides the input data with layout T*N*IC, where T is the sequence length, N is the batch size and IC is the vector size of the input.

size_t _inputSize

Indicates the vector size of the input (IC).

std::vector<std::vector<float>> _solutionData

Provides the solution for one-step ahead prediction with layout N*OC, where N is the batch size and OC is the vector size of the output.

size_t _solutionSize

Indicates the vector size of the output (OC).

class korali::problem::hierarchical::Theta : public korali::problem::Hierarchical
#include <theta.hpp>

Class declaration for module: Theta.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void evaluateLogLikelihood(korali::Sample &sample) override

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

knlohmann::json _subExperiment

Results from one previously executed Bayesian experiment.

knlohmann::json _psiExperiment

Results from the hierarchical problem (Psi).

Private Members

korali::Experiment _psiExperimentObject

Stores the actual Korali object for the psi experiment.

korali::Experiment _subExperimentObject

Stores the actual Korali object for the theta experiment.

size_t _psiVariableCount

Stores the number of variables defined in the Psi problem.

size_t _psiProblemSampleCount

Stores the number of samples in the Psi problem experiment to use as input.

std::vector<std::vector<double>> _psiProblemSampleCoordinates

Stores the sample coordinates of the Psi Problem.

std::vector<double> _psiProblemSampleLogLikelihoods

Stores the sample logLikelihoods of the Psi Problem.

std::vector<double> _psiProblemSampleLogPriors

Stores the sample logPriors of the Psi Problem.

korali::problem::hierarchical::Psi *_psiProblem

Stores the Problem module of the Psi problem experiment to use as input.

size_t _subProblemVariableCount

Stores the number of variables defined in the Sub problem.

size_t _subProblemSampleCount

Stores the number of samples in the sub problem experiment to use as input.

std::vector<std::vector<double>> _subProblemSampleCoordinates

Stores the sample coordinates of the sub Problem.

std::vector<double> _subProblemSampleLogLikelihoods

Stores the sample logLikelihoods of the sub Problem.

std::vector<double> _subProblemSampleLogPriors

Stores the sample logPriors of the sub Problem.

std::vector<double> _precomputedLogDenominator

Stores the precomputed log denomitator to speed up calculations.

class korali::problem::hierarchical::ThetaNew : public korali::problem::Hierarchical
#include <thetaNew.hpp>

Class declaration for module: ThetaNew.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual void evaluateLogLikelihood(korali::Sample &sample) override

Evaluates the log likelihood of the given sample, and stores it in sample[“Log Likelihood”].

Parameters

sample – A Korali Sample

void evaluateThetaLikelihood(korali::Sample &sample)

Evaluates the theta log likelihood of the given sample.

Parameters

sample – A Korali Sample

virtual void initialize() override

Initializes Module upon creation. May allocate memory, set initial states, and initialize external code.

Public Members

knlohmann::json _psiExperiment

Results from the hierarchical Psi experiment.

Private Members

korali::Experiment _psiExperimentObject

Stores the actual Korali object for the psi experiment.

size_t _psiProblemSampleCount

Stores the number of samples in the Psi problem experiment to use as input.

std::vector<std::vector<double>> _psiProblemSampleCoordinates

Stores the sample coordinates of the Psi Problem.

std::vector<double> _psiProblemSampleLogLikelihoods

Stores the sample logLikelihoods of the Psi Problem.

std::vector<double> _psiProblemSampleLogPriors

Stores the sample logPriors of the Psi Problem.

class korali::solver::sampler::TMCMC : public korali::solver::Sampler
#include <TMCMC.hpp>

Class declaration for module: TMCMC.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void setBurnIn()

Sets the burn in steps per generation.

void prepareGeneration()

Prepare Generation before evaluation.

void processGeneration()

Process Generation after receiving all results.

void minSearch(double const *fj, size_t fn, double pj, double objTol, double &xmin, double &fmin)

Helper function for annealing exponent update/.

Parameters
  • fj – Pointer to exponentiated probability values.

  • fn – Current exponent.

  • pj – Number of values in fj array.

  • objTol – Tolerance

  • xmin – Location of minimum, the new exponent.

  • fmin – Found minimum in search.

void processCandidate(const size_t sampleId)

Collects results after sample evaluation.

Parameters

sampleId – Id of the sample to process

void calculateGradients(std::vector<Sample> &samples)

Calculate gradients of loglikelihood (only relevant for mTMCMC).

Parameters

samples – Samples to calculate gradients for

void calculateProposals(std::vector<Sample> &samples)

Calculate sample wise proposal distributions (only relevant for mTMCMC).

Parameters

samples – Samples to calculate proposal distributions for

void generateCandidate(const size_t sampleId)

Generate candidate from leader.

Parameters

sampleId – Id of the sample to generate

void updateDatabase(const size_t sampleId)

Add leader into sample database.

Parameters

sampleId – Id of the sample to update the database with

double calculateAcceptanceProbability(const size_t sampleId)

Calculate acceptance probability.

Parameters

sampleId – Id of the sample to calculate acceptance probability

Returns

The acceptance probability of the given sample

virtual void setInitialConfiguration() override

Configures TMCMC.

virtual void runGeneration() override

Main solver loop.

virtual void printGenerationBefore() override

Console Output before generation runs.

virtual void printGenerationAfter() override

Console output after generation.

virtual void finalize() override

Final console output at termination.

Public Members

std::string _version

Indicates which variant of the TMCMC algorithm to use.

size_t _populationSize

Specifies the number of samples drawn from the posterior distribution at each generation.

size_t _maxChainLength

Chains longer than Max Chain Length will be broken and samples will be duplicated (replacing samples associated with a chain length of 0). Max Chain Length of 1 corresponds to the BASIS algorithm [Wu2018].

size_t _burnIn

Specifies the number of additional TMCMC steps per chain per generation (except for generation 0 and 1).

std::vector<size_t> _perGenerationBurnIn

Specifies the number of additional TMCMC steps per chain at specified generations (this property will overwrite Default Burn In at specified generations). The first entry of the vector corresponds to the 2nd TMCMC generation.

double _targetCoefficientOfVariation

Target coefficient of variation of the plausibility weights to update the annealing exponent :math:\rho (by default, this value is 1.0 as suggested in [Ching2007]).

double _covarianceScaling

Scaling factor :math:\beta^2 of Covariance Matrix (by default, this value is 0.04 as suggested in [Ching2007]).

double _minAnnealingExponentUpdate

Minimum increment of the exponent :math:\rho. This parameter prevents TMCMC from stalling.

double _maxAnnealingExponentUpdate

Maximum increment of the exponent :math:\rho (by default, this value is 1.0 (inactive)).

double _stepSize

Scaling factor of gradient and proposal distribution (only relevant for mTMCMC).

double _domainExtensionFactor

Defines boundaries for eigenvalue adjustments of proposal distribution (only relevant for mTMCMC).

korali::distribution::specific::Multinomial *_multinomialGenerator

[Internal Use] Random number generator with a multinomial distribution.

korali::distribution::multivariate::Normal *_multivariateGenerator

[Internal Use] Random number generator with a multivariate normal distribution.

korali::distribution::univariate::Uniform *_uniformGenerator

[Internal Use] Random number generator with a uniform distribution.

size_t _currentBurnIn

[Internal Use] Actual placeholder for burn in steps per generation, calculated from Burn In Default, Burn In and Current Generation.

std::vector<int> _chainPendingEvaluation

[Internal Use] Indicates that the model evaluation for the chain is pending.

std::vector<int> _chainPendingGradient

[Internal Use] Indicates that the gradient evaluation for the chain is pending (only relevant for mTMCMC).

std::vector<std::vector<double>> _chainCandidates

[Internal Use] All candidates of all chains to evaluate in order to advance the markov chains.

std::vector<double> _chainCandidatesLogLikelihoods

[Internal Use] The loglikelihoods of the chain candidates.

std::vector<double> _chainCandidatesLogPriors

[Internal Use] The logpriors of the chain candidates.

std::vector<std::vector<double>> _chainCandidatesGradients

[Internal Use] Candidate gradient of statistical model wrt. sample variables.

std::vector<int> _chainCandidatesErrors

[Internal Use] Shows if covariance calculation successfully terminated for candidate (only relevant for mTMCMC).

std::vector<std::vector<double>> _chainCandidatesCovariance

[Internal Use] Candidates covariance of normal proposal distribution.

std::vector<std::vector<double>> _chainLeaders

[Internal Use] Leading parameters of all chains to be accepted.

std::vector<double> _chainLeadersLogLikelihoods

[Internal Use] The loglikelihoods of the chain leaders.

std::vector<double> _chainLeadersLogPriors

[Internal Use] The logpriors of the chain leaders.

std::vector<std::vector<double>> _chainLeadersGradients

[Internal Use] Leader gradient of statistical model wrt. sample variables.

std::vector<int> _chainLeadersErrors

[Internal Use] Shows if covariance calculation successfully terminated for leader (only relevant for mTMCMC).

std::vector<std::vector<double>> _chainLeadersCovariance

[Internal Use] Leader covariance of normal proposal distribution.

size_t _finishedChainsCount

[Internal Use] Number of finished chains.

std::vector<size_t> _currentChainStep

[Internal Use] The current execution step for every chain.

std::vector<size_t> _chainLengths

[Internal Use] Lengths for each of the chains.

double _coefficientOfVariation

[Internal Use] Actual coefficient of variation after :math:\rho has beed updated.

size_t _chainCount

[Internal Use] Unique selections after resampling stage.

double _annealingExponent

[Internal Use] Exponent of the likelihood. If :math:\rho equals 1.0, TMCMC converged.

double _previousAnnealingExponent

[Internal Use] Previous Exponent of the likelihood. If :math:\rho equals 1.0, TMCMC converged.

size_t _numFinitePriorEvaluations

[Internal Use] Number of finite prior evaluations per gerneration.

size_t _numFiniteLikelihoodEvaluations

[Internal Use] Number of finite likelihood evaluations per gerneration.

size_t _acceptedSamplesCount

[Internal Use] Accepted candidates after proposal.

double _logEvidence

[Internal Use] Calculated logEvidence of the model.

double _proposalsAcceptanceRate

[Internal Use] Acceptance rate calculated from accepted samples.

double _selectionAcceptanceRate

[Internal Use] Acceptance rate calculated from unique samples (chain count) after recombination.

std::vector<double> _covarianceMatrix

[Internal Use] Sample covariance of the current leaders updated at every generation.

double _maxLoglikelihood

[Internal Use] Max Loglikelihood found in current generation.

std::vector<double> _meanTheta

[Internal Use] Mean of the current leaders updated at every generation.

std::vector<std::vector<double>> _sampleDatabase

[Internal Use] Parameters stored in the database (taken from the chain leaders).

std::vector<double> _sampleLogLikelihoodDatabase

[Internal Use] LogLikelihood Evaluation of the parameters stored in the database.

std::vector<double> _sampleLogPriorDatabase

[Internal Use] Log priors of the samples stored in the database.

std::vector<std::vector<double>> _sampleGradientDatabase

[Internal Use] Gradients stored in the database (taken from the chain leaders, only mTMCMC).

std::vector<int> _sampleErrorDatabase

[Internal Use] Shows if covariance calculation successfully terminated for sample (only relevant for mTMCMC).

std::vector<std::vector<double>> _sampleCovariancesDatabase

[Internal Use] Gradients stored in the database (taken from the chain leaders, only mTMCMC).

std::vector<double> _upperExtendedBoundaries

[Internal Use] Calculated upper domain boundaries (only relevant for mTMCMC).

std::vector<double> _lowerExtendedBoundaries

[Internal Use] Calculated lower domain boundaries (only relevant for mTMCMC).

size_t _numLUDecompositionFailuresProposal

[Internal Use] Number of failed LU decompositions (only relevan for mTMCMC).

size_t _numEigenDecompositionFailuresProposal

[Internal Use] Number of failed Eigenvalue problems (only relevan for mTMCMC).

size_t _numInversionFailuresProposal

[Internal Use] Number of failed FIM inversions (only relevan for mTMCMC).

size_t _numNegativeDefiniteProposals

[Internal Use] Number of Fisher information matrices with negative eigenvalues (only relevan for mTMCMC).

size_t _numCholeskyDecompositionFailuresProposal

[Internal Use] Number of failed chol. decomp. during proposal step (only relevant for mTMCMC).

size_t _numCovarianceCorrections

[Internal Use] Number of covariance adaptions (only relevant for mTMCMC).

double _targetAnnealingExponent

[Termination Criteria] Determines the annealing exponent :math:\rho to achieve before termination. TMCMC converges if :math:\rho equals 1.0.

size_t N

Number of variables to sample.

Public Static Functions

static double calculateSquaredCVDifference(double x, const double *loglike, size_t Ns, double exponent, double targetCV)

Helper function to calculate the squared difference between (CVaR) for min search.

Parameters
  • x – Alternative exponent

  • loglike – Vector of loglikelihood values

  • Ns – Size of loglike array

  • exponent – Current rho

  • targetCV – Target CV

Returns

The squared CV difference

static double calculateSquaredCVDifferenceOptimizationWrapper(const gsl_vector *v, void *param)

Helper function for minimization procedure to find the target CV.

Parameters
  • v – Input GSL vector containing loglikelihood values

  • param – Input parameter for method ‘calculateSquaredCVDifference’

Returns

The squared CV difference

struct korali::solver::sampler::TreeHelper
#include <tree_helper_base.hpp>

Abstract helper class for long argument list of buildTree.

Subclassed by korali::solver::sampler::TreeHelperEuclidean, korali::solver::sampler::TreeHelperRiemannian

Public Functions

virtual bool computeCriterion(const Hamiltonian &hamiltonian) const = 0

Computes No U-Turn Sampling (NUTS) criterion.

Parameters

hamiltonianHamiltonian object of system.

Returns

Returns of tree should be built further.

virtual bool computeCriterion(const Hamiltonian &hamiltonian, const std::vector<double> &momentumStart, const std::vector<double> &momentumEnd, const std::vector<double> &inverseMetric, const std::vector<double> &rho) const = 0

Purely virtual function, computes No U-Turn Sampling (NUTS) criterion.

Parameters
  • hamiltonianHamiltonian object of system.

  • momentumStart – Starting momentum of trajectory.

  • momentumEnd – Ending momentum of trajectory.

  • inverseMetric – Inverse of current metric.

  • rho – Sum of momenta encountered in trajectory.

Returns

Returns of tree should be built further.

virtual ~TreeHelper() = default

Default destructor.

Public Members

std::vector<double> qIn

Position input.

std::vector<double> pIn

Momentum input.

double logUniSampleIn

Log of uni sample input.

int directionIn

Direction in which to propagate input.

double rootHIn

Energy of root of binary tree (i.e. starting position) input.

std::vector<double> qLeftOut

Leftmost position output.

std::vector<double> pLeftOut

Leftmost momentum output.

std::vector<double> qRightOut

Rightmost position output.

std::vector<double> pRightOut

Rightmost momentum output.

std::vector<double> qProposedOut

Proposed position output.

double numValidLeavesOut

Number of valid leaves output (needed for acceptance probability).

bool buildCriterionOut

No U-Turn Termination Sampling (NUTS) criterion output.

double alphaOut

Acceptance probability output.

size_t numLeavesOut

Number of valid leaves encountererd (needed for adaptive time stepping).

struct korali::solver::sampler::TreeHelperEuclidean : public korali::solver::sampler::TreeHelper
#include <tree_helper_euclidean.hpp>

Euclidean helper class for long argument list of buildTree.

Public Functions

inline virtual bool computeCriterion(const Hamiltonian &hamiltonian) const override

Computes No U-Turn Sampling (NUTS) criterion.

Parameters

hamiltonianHamiltonian object of system

Returns

Returns of tree should be built further.

inline virtual bool computeCriterion(const Hamiltonian &hamiltonian, const std::vector<double> &momentumStart, const std::vector<double> &momentumEnd, const std::vector<double> &inverseMetric, const std::vector<double> &rho) const override

Computes No U-Turn Sampling (NUTS) criterion.

Parameters
  • hamiltonianHamiltonian object of system.

  • momentumStart – Starting momentum of trajectory.

  • momentumEnd – Ending momentum of trajsectory.

  • inverseMetric – Inverse of current metric.

  • rho – Sum of momenta encountered in trajectory.

Returns

Returns of tree should be built further.

struct korali::solver::sampler::TreeHelperRiemannian : public korali::solver::sampler::TreeHelper
#include <tree_helper_riemannian.hpp>

Riemmanian helper class for long argument list of buildTree.

Public Functions

inline virtual bool computeCriterion(const Hamiltonian &hamiltonian) const override

Computes No U-Turn Sampling (NUTS) criterion.

Parameters

hamiltonianHamiltonian object of system.

Returns

Returns of tree should be built further.

inline virtual bool computeCriterion(const Hamiltonian &hamiltonian, const std::vector<double> &momentumStart, const std::vector<double> &momentumEnd, const std::vector<double> &inverseMetric, const std::vector<double> &rho) const override

Computes No U-Turn Sampling (NUTS) criterion.

Parameters
  • hamiltonianHamiltonian object of system.

  • momentumStart – Starting momentum of trajectory.

  • momentumEnd – Ending momentum of trajsectory.

  • inverseMetric – Inverse of current metric.

  • rho – Sum of momenta encountered in trajectory.

Returns

Returns of tree should be built further.

class korali::distribution::univariate::TruncatedNormal : public korali::distribution::Univariate
#include <truncatedNormal.hpp>

Class declaration for module: TruncatedNormal.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _mu

[Conditional Variable Value]

std::string _muConditional

[Conditional Variable Reference]

double _sigma

[Conditional Variable Value]

std::string _sigmaConditional

[Conditional Variable Reference]

double _minimum

[Conditional Variable Value]

std::string _minimumConditional

[Conditional Variable Reference]

double _maximum

[Conditional Variable Value]

std::string _maximumConditional

[Conditional Variable Reference]

Private Members

double _normalization
double _logNormalization
class korali::distribution::univariate::Uniform : public korali::distribution::Univariate
#include <uniform.hpp>

Class declaration for module: Uniform.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _minimum

[Conditional Variable Value]

std::string _minimumConditional

[Conditional Variable Reference]

double _maximum

[Conditional Variable Value]

std::string _maximumConditional

[Conditional Variable Reference]

class korali::distribution::Univariate : public korali::Distribution
#include <univariate.hpp>

Class declaration for module: Univariate.

Subclassed by korali::distribution::univariate::Beta, korali::distribution::univariate::Cauchy, korali::distribution::univariate::Exponential, korali::distribution::univariate::Gamma, korali::distribution::univariate::Geometric, korali::distribution::univariate::Igamma, korali::distribution::univariate::Laplace, korali::distribution::univariate::LogNormal, korali::distribution::univariate::Normal, korali::distribution::univariate::TruncatedNormal, korali::distribution::univariate::Uniform, korali::distribution::univariate::Weibull

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double getDensity(const double x) const = 0

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(const double x) const = 0

Gets the log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

inline virtual double getLogDensityGradient(const double x) const

Gets the gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

inline virtual double getLogDensityHessian(const double x) const

Gets the second derivative of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate H(log(P(x)))

Returns

Hessian of log of probability density.

virtual double getRandomNumber() = 0

Draws and returns a random number from the distribution.

Returns

Random real number.

class korali::solver::agent::continuous::VRACER : public korali::solver::agent::Continuous
#include <VRACER.hpp>

Class declaration for module: VRACER.

Public Functions

virtual bool checkTermination() override

Determines whether the module can trigger termination of an experiment run.

Returns

True, if it should trigger termination; false, otherwise.

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

void updateVtbc(size_t expId)

Update the V-target or current and previous experiences in the episode.

Parameters

expId – Current Experience Id

void calculatePolicyGradients(const std::vector<size_t> &miniBatch)

Calculates the gradients for the policy/critic neural network.

Parameters

miniBatch – The indexes of the experience mini batch

virtual std::vector<policy_t> runPolicy(const std::vector<std::vector<std::vector<float>>> &stateBatch) override

Function to pass a state time series through the NN and calculates the action probabilities, along with any additional information.

Parameters

stateBatch – The batch of state time series (Format: BxTxS, B is batch size, T is the time series lenght, and S is the state size)

Returns

A JSON object containing the information produced by the policies given the current state series

virtual knlohmann::json getAgentPolicy() override

Obtains the policy hyperaparamters from the learner for the agent to generate new actions.

Returns

The current policy hyperparameters

virtual void setAgentPolicy(const knlohmann::json &hyperparameters) override

Updates the agent’s hyperparameters.

Parameters

hyperparameters – The hyperparameters to update the agent.

virtual void trainPolicy() override

Trains the Agent’s policy, based on the new experiences.

virtual void printAgentInformation() override

Prints information about the training policy.

virtual void initializeAgent() override

Initializes the internal state of the policy.

Public Members

std::vector<float> _statisticsAverageActionSigmas

[Internal Use] Standard deviation of the actions in the minibatch.

learner::DeepSupervisor *_criticPolicyLearner

Pointer to training the actor network.

korali::Experiment _criticPolicyExperiment

Korali experiment for obtaining the agent’s action.

problem::SupervisedLearning *_criticPolicyProblem

Pointer to actor’s experiment problem.

std::vector<float> _maxMiniBatchPolicyMean

[Statistics] Keeps track of the max policy mu of the current minibatch for each action variable

std::vector<float> _maxMiniBatchPolicyStdDev

[Statistics] Keeps track of the max policy sigma of the current minibatch for each action variable

std::vector<float> _minMiniBatchPolicyMean

[Statistics] Keeps track of the min policy mu of the current minibatch for each action variable

std::vector<float> _minMiniBatchPolicyStdDev

[Statistics] Keeps track of the min policy sigma of the current minibatch for each action variable

class korali::distribution::univariate::Weibull : public korali::distribution::Univariate
#include <weibull.hpp>

Class declaration for module: Weibull.

Public Functions

virtual void getConfiguration(knlohmann::json &js) override

Obtains the entire current state and configuration of the module.

Parameters

js – JSON object onto which to save the serialized state of the module.

virtual void setConfiguration(knlohmann::json &js) override

Sets the entire state and configuration of the module, given a JSON object.

Parameters

js – JSON object from which to deserialize the state of the module.

virtual void applyModuleDefaults(knlohmann::json &js) override

Applies the module’s default configuration upon its creation.

Parameters

js – JSON object containing user configuration. The defaults will not override any currently defined settings.

virtual void applyVariableDefaults() override

Applies the module’s default variable configuration to each variable in the Experiment upon creation.

virtual double *getPropertyPointer(const std::string &property) override

Retrieves the pointer of a conditional value of a distribution property.

Parameters

property – Name of the property to find.

Returns

The pointer to the property..

virtual void updateDistribution() override

Updates the parameters of the distribution based on conditional variables.

virtual double getDensity(const double x) const override

Gets the probability density of the distribution at point x.

Parameters

x – point to evaluate P(x)

Returns

Value of the probability density.

virtual double getLogDensity(double x) const override

Gets the Log probability density of the distribution at point x.

Parameters

x – point to evaluate log(P(x))

Returns

Log of probability density.

virtual double getLogDensityGradient(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getLogDensityHessian(double x) const override

Gets the Gradient of the log probability density of the distribution wrt. to x.

Parameters

x – point to evaluate grad(log(P(x)))

Returns

Gradient of log of probability density.

virtual double getRandomNumber() override

Draws and returns a random number from the distribution.

Returns

Random real number.

Public Members

double _shape

[Conditional Variable Value]

std::string _shapeConditional

[Conditional Variable Reference]

double _scale

[Conditional Variable Value]

std::string _scaleConditional

[Conditional Variable Reference]

namespace agent

Namespace declaration for modules of type: agent.

namespace bayesian

Namespace declaration for modules of type: bayesian.

namespace conduit

Namespace declaration for modules of type: conduit.

namespace continuous

Namespace declaration for modules of type: continuous.

namespace discrete

Namespace declaration for modules of type: discrete.

namespace distribution

Namespace declaration for modules of type: distribution.

namespace Eigen
namespace hierarchical

Namespace declaration for modules of type: hierarchical.

namespace Korali

The Korali namespace includes all Korali-specific functions, variables, and modules.

namespace korali

The Korali namespace includes all Korali-specific functions, variables, and modules.

Namespace declaration for modules of type: korali.

Typedefs

typedef uint8_t crc

Special type for CRC calculation.

typedef long int MPI_Comm

Dummy communicator storage for the current Korali Worker.

Enums

enum SampleState

Execution states of a given sample.

Values:

enumerator uninitialized
enumerator initialized
enumerator running
enumerator waiting
enumerator finished

Functions

void mkdir(const std::string dirPath)

Creates a new folder and builds the entire path, if necessary.

Parameters

dirPath – relative path to the new folder.

bool dirExists(const std::string dirPath)

Lists all files within within a given folder path.

Parameters

dirPath – relative path to the folder to list.

Returns

A list with the path of all files found.

bool isEmpty(const knlohmann::json &js)

Checks whether the JSON object is empty.

Parameters

js – The JSON object to check.

Returns

true, if it’s empty; false, otherwise.

bool isElemental(const knlohmann::json &js)

Checks whether the JSON object is of elemental type (number or string).

Parameters

js – The JSON object to check.

Returns

true, if it’s elemental; false, otherwise.

void mergeJson(knlohmann::json &dest, const knlohmann::json &defaults)

Merges the values of two JSON objects recursively and applying priority.

Parameters
  • dest – the JSON object onto which the changes will be made. Values here have priority (are not replaced).

  • defaults – the JSON object that applies onto the other. Values here have no priority (they will not replace)

bool loadJsonFromFile(knlohmann::json &dst, const char *fileName)

Loads a JSON object from a file.

Parameters
  • dst – The JSON object to overwrite.

  • fileName – The path to the json file to load and parse.

Returns

true, if file was found; false, otherwise.

int saveJsonToFile(const char *fileName, const knlohmann::json &js)

Saves a JSON object to a file.

Parameters
  • fileName – The path to the file onto which to save the JSON object.

  • js – The input JSON object.

Returns

0 if successful, otherwise if not.

template<typename T>
T *getPointer(T &x)

Function made exclusively made to avoid warnings on getting the last element of variadic template arguments.

Parameters

x – is the element to get the pointer from

Returns

The element’s pointer

template<typename T, typename ...Key>
void eraseValue(T &js, const Key&... key)

Deletes a value on a given JS given a string containing the full path.

Parameters
  • js – The JSON object to modify.

  • key – a list of keys describing the full path to traverse

template<typename T, typename ...Key>
bool isDefined(T &js, const Key&... key)

Checks whether a given key is present in the JSON object.

Parameters
  • js – The JSON object to check.

  • key – a list of keys describing the full path to traverse

Returns

true, if the path defined by settings is found; false, otherwise.

template<typename T, typename ...Key>
T getValue(T &js, const Key&... key)

Returns a value on a given object given a string containing the full path.

Parameters
  • js – The source object to read from.

  • key – a list of keys describing the full path to traverse

Returns

Object of the requested path

template<typename ...Key>
std::string getPath(const Key&... key)

Returns a string out of a list of keys showing.

Parameters

key – a list of keys describing the full path to traverse

Returns

The string with a printed key sequence

std::string toLower(const std::string &input)

Generates lower case string of provided string.

Parameters

input – Input string

Returns

The lower case varient of the string

bool iCompare(const std::string &a, const std::string &b)

Generates upper case string of provided string.

Parameters
  • a – Input string

  • b – Input string

Returns

The upper case variant of the string

bool isanynan(const std::vector<double> &x)

Checks whether at least one of the elements in the vector is not a number.

Parameters

x – vector of xi values

Returns

True, if found at least one NaN: false, otherwise.

double vectorNorm(const std::vector<double> &x)

Computes the L2 norm of a vector.

Parameters

x – vector of xi values

Returns

The L2 norm of the vector.

std::string getTimestamp()

Obtains the timestamp containing the current data and time.

Returns

String containing the timestamp.

size_t getTimehash()

Obtains the hash function of timestamp containing the current data and time, for seed initialization purposes.

Returns

Unsigned integer containing the hashed timestamp.

char decimalToHexChar(const uint8_t byte)

Converts a decimal byte to its hexadecimal equivalent.

Parameters

byte – single byte containing a number from 0 to 15

Returns

The hexadecimal letter/number for the value

uint8_t hexCharToDecimal(const char x)

Converts a hexadecimal letter/number to integer.

Parameters

x – the letter/number to convert

Returns

A byte with the corresponding integer from 0 to 15

uint8_t hexPairToByte(const char *src)

Converts a hexadecimal string pair to integer.

Parameters

src – the source hexadecimal string format 0xFF to convert

Returns

A byte with the corresponding integer from 0 to 255

void byteToHexPair(char *dst, const uint8_t byte)

Converts an integer to its equivalent hexadecimal string.

Parameters
  • dst – pointer to string to save the hex string with format 0xFF.

  • byte – integer containing values from 0 to 255.

template<typename T>
double sign(T val)

Returns the sign of a given signed item.

Parameters

val – The input signed item.

Returns

-1, if val is negative; +1, if val is positive; 0, if neither.

template<typename T>
bool approximatelyEqual(T a, T b, T epsilon)

Check if both arguments are approximately equal up to given precision.

Parameters
  • a – Value a

  • b – Value b

  • epsilon – Precision parameter

Returns

The inverse of the error function

template<typename T>
bool definitelyGreaterThan(T a, T b, T epsilon)

Check if the first argument is surely greater than the second argument up to given precision.

Parameters
  • a – First argument, to be checked if greater than b

  • b – Value b

  • epsilon – Precision parameter

Returns

The inverse of the error function

template<typename T>
bool definitelyLessThan(T a, T b, T epsilon)

Check if the first argument is surely smaller than the second argument up to given precision.

Parameters
  • a – First argument, to be checked if smaller than b

  • b – Value b

  • epsilon – Precision parameter

Returns

The inverse of the error function

template<typename T>
T ierf(T x)

Approximates the inverse of the error function.

Parameters

x – Argument to the inverse error function

Returns

The inverse of the error function

template<typename T>
T safeLogPlus(T x, T y)

Safely computes log(exp(x)+exp(y)) and avoids overflows.

Parameters
  • x – a variable

  • y – a variable

Returns

The result of log(exp(x)+exp(y))

template<typename T>
T safeLogMinus(T x, T y)

Safely computes log(exp(x)-exp(y)) and avoids overflows.

Parameters
  • x – a variable, x > y

  • y – a variable

Returns

The result of log(exp(x)-exp(y))

template<typename T>
T logSumExp(const T *logValues, const size_t &n)

Computes: log sum_{i=1}^N x_i using the log-sum-exp trick: https://en.wikipedia.org/wiki/LogSumExp#log-sum-exp_trick_for_log-domain_calculations.

Parameters
  • logValues – vector of log(x_i) values

  • n – size of the vector

Returns

The LSE function of the input.

template<typename T>
T logSumExp(const std::vector<T> &logValues)

Computes: log sum_{i=1}^N x_i using the log-sum-exp trick: https://en.wikipedia.org/wiki/LogSumExp#log-sum-exp_trick_for_log-domain_calculations.

Parameters

logValues – vector of log(x_i) values

Returns

The LSE function of the input.

template<typename T>
T dotProduct(const std::vector<T> &x, const std::vector<T> &y)

Computes the dot product between two vectors.

Parameters
  • x – vector of xi values

  • y – vector of yi values

Returns

The x . y product

template<typename T>
T normalLogDensity(const T &x, const T &mean, const T &sigma)

Computes the log density of a normal distribution.

Parameters
  • x – denisty evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

Returns

The log density

template<typename T>
T normalCDF(const T &x, const T &mean, const T &sigma)

Computes the cumulative distribution function of a normal distribution.

Parameters
  • x – evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

Returns

The log of the CDF

template<typename T>
T normalLogCDF(const T &x, const T &mean, const T &sigma)

Computes the log of the cumulative distribution function of a normal distribution.

Parameters
  • x – evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

Returns

The log of the CDF

template<typename T>
T normalCCDF(const T &x, const T &mean, const T &sigma)

Computes the tail distribution of a normal distribution (complementary cumulative distribution).

Parameters
  • x – evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

Returns

The log of the CDF

template<typename T>
T normalLogCCDF(const T &x, const T &mean, const T &sigma)

Computes the log of the tail distribution of a normal distribution (complementary cumulative distribution).

Parameters
  • x – evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

Returns

The log of the CDF

template<typename T>
T squashedNormalLogDensity(const T &px, const T &mean, const T &sigma, const T &scale)

Computes the log density of a squashed normal distribution.

Parameters
  • px – density evaluation point

  • mean – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

  • scale – The scale used after the tanh normalization

Returns

The log density

template<typename T>
T truncatedNormalPdf(T x, T mu, T sigma, T a, T b)

Computes the density of the truncated normal distribution.

Parameters
  • x – density evaluation point

  • mu – Mean of normal distribution

  • sigma – Standard Deviation of normal distribution

  • a – Lower bound of truncated normal

  • b – Upper bound of truncated normal

Returns

The log density

template<typename T>
T betaLogDensity(const T &x, const T &alpha, const T &beta)

Computes the log density of the beta distribution.

Parameters
  • x – denisty evaluation point

  • alpha – Shape of Beta distribution

  • beta – Shape of Beta distribution

Returns

The log density

template<typename T>
std::tuple<T, T> betaParamTransformAlt(const T &mean, const T &varcof, const T &lb, const T &ub)

Transforms mean and varcof to alpha and beta for the shifted and scaled beta distribution.

Parameters
  • mean – Mean of beta distribution

  • varcof – Variance coefficient (var=mu*(1-mu)*varcof

  • lb – Lower bound of distribution

  • ub – Upper bound of distribution

Returns

tuple containing alpha and beta

template<typename T>
std::tuple<T, T, T, T> derivativesBetaParamTransformAlt(const T &mean, const T &varcof, const T &lb, const T &ub)

Calculates derivatives of Beta params (alpba,beta) wrt. the params of the alternative parametrization.

Parameters
  • mean – Mean of alt beta distribution

  • varcof – Variance coefficient (var=mu*(1-mu)*varcof

  • lb – Lower bound of distribution

  • ub – Upper bound of distribution

Returns

tuple containing dalpha/dmean, dalpha/dvarcof, dbeta/dmean, dbeta/dvarcof

template<typename T>
T betaLogDensityAlt(const T &x, const T &mean, const T &varcof, const T &lb, const T &ub)

Computes the log density of the shifted and scaled beta distribution using an alternative four param parametrization.

Parameters
  • x – denisty evaluation point

  • mean – Mean of beta distribution

  • varcof – Variance coefficient (var=mu*(1-mu)*varcof

  • lb – Lower bound of distribution

  • ub – Upper bound of distribution

Returns

The log density

template<typename T>
T ranBetaAlt(const gsl_rng *rng, const T &mean, const T &varcof, const T &lb, const T &ub)

Generates a random number from the shifted and scaled beta distribution using an alternative four param parametrization.

Parameters
  • rng – Gsl random number generator

  • mean – Mean of beta distribution

  • varcof – Variance coefficient (var=mu*(1-mu)*varcof

  • lb – Lower bound of distribution

  • ub – Upper bound of distribution

Returns

a random number

double vectorDistance(const std::vector<double> &x, const std::vector<double> &y)

Computes the norm of the difference between two vectors.

Parameters
  • x – vector of xi values

  • y – vector of yi values

Returns

The L2 norm of the distance of vectors x and y.

void crcInit(void)

Initializes the CRC function.

crc crcFast(uint8_t const message[], size_t nBytes)

Calculates CRC value of the given byte array.

Parameters
  • message – Pointer to the start of the byte array

  • nBytes – Size of the byte array

Returns

CRC value of the message

size_t checksum(void *buffer, size_t len, unsigned int seed)

Checksum function that takes an array of bytes and calculates its CRC given a specific initialization seed.

Parameters
  • buffer – pointer to the start of the byte array.

  • len – size of the buffer.

  • seed – initialization seed for the CRC calculation

Returns

The checksum (CRC) of the buffer.

int setKoraliMPIComm(...)

Error handler for when MPI is not defined.

Parameters

... – accepts any parameters since it will fail anyway

Returns

Error code -1

void *getWorkerMPIComm()

Error handler for when MPI is not defined.

Returns

A NULL pointer

void threadWrapper()

Function for the initialization of new coroutine threads.

Variables

const double NaN = std::numeric_limits<double>::quiet_NaN()

Korali’s definition of a non-number.

const double Inf = std::numeric_limits<double>::infinity()

Korali’s definition of Infinity.

const double Lowest = std::numeric_limits<double>::lowest()

Korali’s definition of lowest representable double.

const double Max = std::numeric_limits<double>::max()

Korali’s definition of maximum representable double.

const double Min = std::numeric_limits<double>::min()

Korali’s definition of minimum representable double.

const double Eps = std::numeric_limits<double>::epsilon()

Korali’s definition of minimum representable difference between two numbers.

std::stack<Engine*> _engineStack

Stack storing pointers to different Engine execution levels.

bool isPythonActive = 0

Flag indicating that Korali has been called from Korali.

Sample *_currentSample

Temporary storage to hold the pointer to the current sample to process.

Experiment *__expPointer

Pointer to the current experiment in execution.

cothread_t __returnThread

Pointer to the calling thread.

knlohmann::json __profiler

Storage for profiling information.

std::chrono::time_point<std::chrono::high_resolution_clock> _startTime

Start time for the current Korali run.

std::chrono::time_point<std::chrono::high_resolution_clock> _endTime

End time for the current Korali run.

double _cumulativeTime

Cumulative time for all Korali runs during the current application execution.

std::vector<std::function<void(Sample&)>*> _functionVector

Stores all functions inserted as parameters to experiment’s configuration.

namespace korali::conduit

Functions

void _workerWrapper()

Variables

Sequential *_currentConduit

Temporary storage to hold the pointer to the current conduit.

namespace distribution
namespace multivariate
namespace specific
namespace univariate
namespace neuralNetwork
namespace korali::neuralNetwork::layer

Enums

enum transformation_t

This enumerator details all possible transformations. It is used in lieu of string comparison to accelerate the application of this layer.

Values:

enumerator t_identity

No transformation.

enumerator t_absolute

Apply absolute mask.

enumerator t_softplus

Apply softplus mask.

enumerator t_tanh

Apply tanh mask.

enumerator t_sigmoid

Apply sigmoid mask.

namespace recurrent
namespace korali::problem

Functions

void __environmentWrapper()

Thread wrapper to run an environment.

Variables

Sample *__currentSample

Pointer to the current agent, it is immediately copied as to avoid concurrency problems.

size_t __envFunctionId

Identifier of the current environment function Id.

solver::Agent *_agent

Pointer to the agent (Korali solver module)

Conduit *_conduit

Pointer to the engine’s conduit.

cothread_t _envThread

Stores the environment thread (coroutine).

size_t _launchId

Stores the current launch Id for the current sample.

namespace bayesian
namespace hierarchical
namespace reinforcementLearning
namespace korali::solver

Enums

enum termination_t

This enumerator details all possible termination statuses for a given episode’s experience.

Values:

enumerator e_nonTerminal

The experience is non-terminal.

enumerator e_terminal

This is the terminal experience in a normally executed episode.

enumerator e_truncated

This is the terminal experience in a truncated episode (i.e., should have continued, but it was artificially truncated to limit running time)

namespace agent
namespace continuous
namespace discrete
namespace korali::solver::learner

Functions

Eigen::VectorXd toEigen(const std::vector<float> &v)

Converts a vector of floats to Eigen format.

Parameters

v – the vector to convert

Returns

An Eigen vector type

void runSample(Sample &sample, libgp::GaussianProcess *gp)

Model function to evaluate the error function of the GP.

Parameters
  • sample – The sample containing the proposal parameters

  • gp – Pointer to the GP

namespace optimizer
namespace korali::solver::sampler

Typedefs

typedef struct korali::solver::sampler::fparam_s fparam_t

Struct for TMCMC optimization operations.

Enums

enum Metric

Enum to set metric type.

Values:

enumerator Static

Static Metric type.

enumerator Euclidean

Euclidean Metric type.

enumerator Riemannian

Riemannian Metric type.

enumerator Riemannian_Const

Const Riemannian Metric type.

namespace layer

Namespace declaration for modules of type: layer.

namespace learner

Namespace declaration for modules of type: learner.

namespace multivariate

Namespace declaration for modules of type: multivariate.

namespace neuralNetwork

Namespace declaration for modules of type: neuralNetwork.

namespace optimizer

Namespace declaration for modules of type: optimizer.

namespace problem

Namespace declaration for modules of type: problem.

namespace recurrent

Namespace declaration for modules of type: recurrent.

namespace reinforcementLearning

Namespace declaration for modules of type: reinforcementLearning.

namespace Rtnorm
namespace sampler

Namespace declaration for modules of type: sampler.

namespace solver

Namespace declaration for modules of type: solver.

namespace specific

Namespace declaration for modules of type: specific.

namespace std
namespace univariate

Namespace declaration for modules of type: univariate.

file cbuffer.hpp
#include <memory>#include <vector>

Implements a circular buffer with automatic overwrite on full by Sergio Martin (2020), partially based on the implementation by Jose Herrera https://gist.github.com/xstherrera1987/3196485.

file cudaUtils.hpp

Contains auxiliar error reporting functions to CUDA and cuDNN Credits to Motoki Sato (https://gist.github.com/aonotas)

file fs.cpp
#include “auxiliar/fs.hpp”#include “string.h”#include <dirent.h>#include <string>#include <sys/stat.h>
file fs.hpp
#include <string>#include <vector>

Contains auxiliar code for file system (files and folders) manipulation.

file jsonInterface.cpp
#include “auxiliar/jsonInterface.hpp”#include “auxiliar/logger.hpp”#include <string>#include <iostream>

Contains auxiliar functions for JSON object manipulation.

file jsonInterface.hpp
#include “auxiliar/json.hpp”#include “auxiliar/logger.hpp”#include <string>

Contains auxiliar functions for JSON object manipulation.

file kcache.hpp
#include <functional>#include <map>

Implements an LRU cache that returns a pre-calculated value if it is not too old. Age is determined by an external timer. Mutual exclusion mechanisms have been added for thread-safe access. by Sergio Martin (2020)

file koraliJson.cpp
#include “auxiliar/koraliJson.hpp”#include “auxiliar/logger.hpp”#include “auxiliar/py2json.hpp”#include “sample/sample.hpp”
file koraliJson.hpp
#include “auxiliar/jsonInterface.hpp”#include <pybind11/functional.h>#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include <string>

Contains the koraliJson class, which supports JSON objects within Korali classes.

file kstring.cpp
#include “kstring.hpp”#include <algorithm>#include <cctype>#include <string>
file kstring.hpp
#include <string>

Auxiliary library for Korali’s essential string operations.

file logger.cpp
#include “logger.hpp”#include <stdarg.h>#include <stdexcept>#include <stdio.h>#include <stdlib.h>
file logger.hpp
#include <string>

Contains functions to manage file and console output, verbosity levels, and error reporting.

Defines

KORALI_LOG_ERROR(...)

Terminates execution, printing an error message and indicates file name and line number where the error occurred.

file math.cpp
#include “math.hpp”#include “auxiliar/logger.hpp”#include <algorithm>#include <chrono>#include <cmath>#include <unistd.h>
file math.hpp
#include <cmath>#include <gsl/gsl_sf.h>#include <gsl/gsl_math.h>#include <gsl/gsl_rng.h>#include <gsl/gsl_sf_gamma.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_sf_erf.h>#include <limits>#include <stdlib.h>#include <string>#include <tuple>#include <vector>

Auxiliary library for Korali’s essential math and time manipulation operations.

Defines

_USE_MATH_DEFINES

This definition enables the use of M_PI.

KORALI_EPSILON

Epsilon to add to log or division operations to prevent numerical instabilities.

POLYNOMIAL

Polynomial for CRC calculation.

WIDTH

Width of CRC calculation.

TOPBIT

Most significant bit of a CRC calculation.

file MPIUtils.cpp
#include <auxiliar/MPIUtils.hpp>#include <auxiliar/logger.hpp>

Contains the helper definitions for MPI.

file MPIUtils.hpp
#include <config.hpp>#include <pybind11/functional.h>#include <pybind11/pybind11.h>#include <pybind11/stl.h>

Contains the helper definitions for MPI.

file engine.cpp
#include “engine.hpp”#include “auxiliar/fs.hpp”#include “auxiliar/koraliJson.hpp”#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “modules/conduit/distributed/distributed.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/solver.hpp”#include “sample/sample.hpp”#include <omp.h>#include <sys/stat.h>#include <sys/types.h>

Functions

PYBIND11_MODULE(libkorali, m)
file engine.hpp
#include “config.hpp”#include “auxiliar/MPIUtils.hpp”#include “modules/conduit/conduit.hpp”#include “modules/conduit/distributed/distributed.hpp”#include “modules/experiment/experiment.hpp”#include <chrono>#include <map>#include <stack>#include <vector>

Include header for the Korali Engine.

file korali.hpp
#include “config.hpp”#include “engine.hpp”#include “modules/conduit/distributed/distributed.hpp”#include “modules/experiment/experiment.hpp”#include “sample/sample.hpp”

Include header for C++ applications linking with Korali.

file concurrent.cpp
#include “engine.hpp”#include “modules/conduit/concurrent/concurrent.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/solver.hpp”#include “sample/sample.hpp”#include <fcntl.h>#include <sched.h>#include <sys/types.h>#include <sys/wait.h>

Defines

BUFFERSIZE
file concurrent.hpp
#include “modules/conduit/conduit.hpp”#include <chrono>#include <map>#include <vector>

Header file for module: Concurrent.

file conduit.cpp
#include “engine.hpp”#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “sample/sample.hpp”#include <chrono>
file conduit.hpp
#include “modules/module.hpp”#include <queue>#include <vector>

Header file for module: Conduit.

file distributed.cpp
#include “auxiliar/MPIUtils.hpp”#include “engine.hpp”#include “modules/conduit/distributed/distributed.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/solver.hpp”#include “sample/sample.hpp”
file distributed.hpp
#include “auxiliar/MPIUtils.hpp”#include “config.hpp”#include “modules/conduit/conduit.hpp”#include <map>#include <queue>#include <vector>

Header file for module: Distributed.

file sequential.cpp
#include “engine.hpp”#include “modules/conduit/sequential/sequential.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/solver.hpp”#include “sample/sample.hpp”#include <fcntl.h>#include <sched.h>#include <sys/types.h>#include <sys/wait.h>
file sequential.hpp
#include “auxiliar/libco/libco.h”#include “modules/conduit/conduit.hpp”#include <chrono>#include <map>#include <queue>#include <vector>

Header file for module: Sequential.

file distribution.cpp
#include “modules/distribution/distribution.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_math.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_rng.h>#include <gsl/gsl_sf.h>
file distribution.hpp
#include “modules/module.hpp”#include <gsl/gsl_rng.h>#include <map>

Header file for module: Distribution.

file multivariate.cpp
#include “modules/distribution/multivariate/multivariate.hpp”#include “modules/experiment/experiment.hpp”
file multivariate.hpp
#include “modules/distribution/distribution.hpp”

Header file for module: Multivariate.

file normal.cpp
#include “modules/distribution/multivariate/normal/normal.hpp”#include “modules/experiment/experiment.hpp”#include <auxiliar/logger.hpp>#include <gsl/gsl_matrix.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_vector.h>
file normal.cpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_math.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file normal.hpp
#include “modules/distribution/multivariate/multivariate.hpp”#include <gsl/gsl_matrix.h>#include <gsl/gsl_vector.h>

Header file for module: Normal.

file normal.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Normal.

file multinomial.cpp
#include “modules/distribution/specific/multinomial/multinomial.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file multinomial.hpp
#include “modules/distribution/specific/specific.hpp”

Header file for module: Multinomial.

file specific.cpp
#include “modules/distribution/specific/specific.hpp”#include “modules/experiment/experiment.hpp”
file specific.hpp
#include “modules/distribution/distribution.hpp”

Header file for module: Specific.

file beta.cpp
#include “modules/distribution/univariate/beta/beta.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file beta.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Beta.

file cauchy.cpp
#include “modules/distribution/univariate/cauchy/cauchy.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file cauchy.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Cauchy.

file exponential.cpp
#include “modules/distribution/univariate/exponential/exponential.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file exponential.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Exponential.

file gamma.cpp
#include “modules/distribution/univariate/gamma/gamma.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file gamma.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Gamma.

file geometric.cpp
#include “modules/distribution/univariate/geometric/geometric.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file geometric.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Geometric.

file igamma.cpp
#include “modules/distribution/univariate/igamma/igamma.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>
file igamma.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Igamma.

file laplace.cpp
#include “modules/distribution/univariate/laplace/laplace.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file laplace.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Laplace.

file logNormal.cpp
#include “modules/distribution/univariate/logNormal/logNormal.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file logNormal.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: LogNormal.

file truncatedNormal.cpp
#include “modules/distribution/univariate/truncatedNormal/truncatedNormal.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_math.h>#include <gsl/gsl_sf.h>#include “auxiliar/rtnorm/rtnorm.hpp”
file truncatedNormal.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: TruncatedNormal.

file uniform.cpp
#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file uniform.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Uniform.

file univariate.cpp
#include “modules/distribution/univariate/univariate.hpp”#include “modules/experiment/experiment.hpp”
file univariate.hpp
#include “modules/distribution/distribution.hpp”

Header file for module: Univariate.

file weibull.cpp
#include “modules/distribution/univariate/weibull/weibull.hpp”#include “modules/experiment/experiment.hpp”#include <gsl/gsl_randist.h>#include <gsl/gsl_sf.h>
file weibull.hpp
#include “modules/distribution/univariate/univariate.hpp”

Header file for module: Weibull.

file experiment.cpp
#include “auxiliar/fs.hpp”#include “auxiliar/koraliJson.hpp”#include “engine.hpp”#include “modules/conduit/conduit.hpp”#include “modules/conduit/distributed/distributed.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/agent/agent.hpp”#include “modules/solver/learner/learner.hpp”#include “modules/solver/solver.hpp”#include “sample/sample.hpp”#include <chrono>#include <cstdio>#include <map>#include <stdlib.h>
file experiment.hpp
#include “auxiliar/koraliJson.hpp”#include “auxiliar/libco/libco.h”#include “config.hpp”#include “modules/module.hpp”#include “variable/variable.hpp”#include <chrono>#include <functional>#include <vector>

Header file for module: Experiment.

file module.cpp
#include “module.hpp”#include “conduit/concurrent/concurrent.hpp”#include “conduit/distributed/distributed.hpp”#include “conduit/sequential/sequential.hpp”#include “distribution/distribution.hpp”#include “distribution/multivariate/normal/normal.hpp”#include “distribution/specific/multinomial/multinomial.hpp”#include “distribution/specific/specific.hpp”#include “distribution/univariate/beta/beta.hpp”#include “distribution/univariate/cauchy/cauchy.hpp”#include “distribution/univariate/exponential/exponential.hpp”#include “distribution/univariate/gamma/gamma.hpp”#include “distribution/univariate/geometric/geometric.hpp”#include “distribution/univariate/igamma/igamma.hpp”#include “distribution/univariate/laplace/laplace.hpp”#include “distribution/univariate/logNormal/logNormal.hpp”#include “distribution/univariate/normal/normal.hpp”#include “distribution/univariate/truncatedNormal/truncatedNormal.hpp”#include “distribution/univariate/uniform/uniform.hpp”#include “distribution/univariate/weibull/weibull.hpp”#include “experiment/experiment.hpp”#include “neuralNetwork/layer/activation/activation.hpp”#include “neuralNetwork/layer/input/input.hpp”#include “neuralNetwork/layer/layer.hpp”#include “neuralNetwork/layer/linear/linear.hpp”#include “neuralNetwork/layer/output/output.hpp”#include “neuralNetwork/layer/recurrent/gru/gru.hpp”#include “neuralNetwork/layer/recurrent/lstm/lstm.hpp”#include “neuralNetwork/neuralNetwork.hpp”#include “problem/bayesian/custom/custom.hpp”#include “problem/bayesian/reference/reference.hpp”#include “problem/hierarchical/psi/psi.hpp”#include “problem/hierarchical/theta/theta.hpp”#include “problem/hierarchical/thetaNew/thetaNew.hpp”#include “problem/integration/integration.hpp”#include “problem/optimization/optimization.hpp”#include “problem/problem.hpp”#include “problem/propagation/propagation.hpp”#include “problem/reinforcementLearning/continuous/continuous.hpp”#include “problem/reinforcementLearning/discrete/discrete.hpp”#include “problem/sampling/sampling.hpp”#include “problem/supervisedLearning/supervisedLearning.hpp”#include “solver/agent/continuous/VRACER/VRACER.hpp”#include “solver/agent/continuous/continuous.hpp”#include “solver/agent/discrete/dVRACER/dVRACER.hpp”#include “solver/agent/discrete/discrete.hpp”#include “solver/executor/executor.hpp”#include “solver/integrator/integrator.hpp”#include “solver/learner/deepSupervisor/deepSupervisor.hpp”#include “solver/learner/gaussianProcess/gaussianProcess.hpp”#include “solver/optimizer/AdaBelief/AdaBelief.hpp”#include “solver/optimizer/Adam/Adam.hpp”#include “solver/optimizer/CMAES/CMAES.hpp”#include “solver/optimizer/DEA/DEA.hpp”#include “solver/optimizer/MADGRAD/MADGRAD.hpp”#include “solver/optimizer/MOCMAES/MOCMAES.hpp”#include “solver/optimizer/Rprop/Rprop.hpp”#include “solver/optimizer/gridSearch/gridSearch.hpp”#include “solver/optimizer/optimizer.hpp”#include “solver/sampler/HMC/HMC.hpp”#include “solver/sampler/MCMC/MCMC.hpp”#include “solver/sampler/Nested/Nested.hpp”#include “solver/sampler/TMCMC/TMCMC.hpp”#include “solver/sampler/sampler.hpp”
file module.hpp
#include “auxiliar/koraliJson.hpp”#include “auxiliar/kstring.hpp”#include “auxiliar/logger.hpp”#include “auxiliar/math.hpp”#include <chrono>

Header file for the base Korali Module class.

file activation.cpp
#include “modules/neuralNetwork/layer/activation/activation.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file activation.hpp
#include “modules/neuralNetwork/layer/layer.hpp”

Header file for module: Activation.

file input.cpp
#include “modules/neuralNetwork/layer/input/input.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file input.hpp
#include “modules/neuralNetwork/layer/layer.hpp”

Header file for module: Input.

file layer.cpp
#include “modules/neuralNetwork/layer/layer.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file layer.hpp
#include “config.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/module.hpp”

Header file for module: Layer.

file linear.cpp
#include “modules/neuralNetwork/layer/linear/linear.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file linear.hpp
#include “modules/neuralNetwork/layer/layer.hpp”

Header file for module: Linear.

file output.cpp
#include “modules/neuralNetwork/layer/output/output.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file output.hpp
#include “modules/neuralNetwork/layer/layer.hpp”

Header file for module: Output.

file gru.cpp
#include “modules/neuralNetwork/layer/recurrent/gru/gru.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file gru.hpp
#include “modules/neuralNetwork/layer/recurrent/recurrent.hpp”

Header file for module: GRU.

file lstm.cpp
#include “modules/neuralNetwork/layer/recurrent/lstm/lstm.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>

Defines

LSTM_LINEAR_LAYERS
file lstm.hpp
#include “modules/neuralNetwork/layer/recurrent/recurrent.hpp”

Header file for module: LSTM.

file recurrent.cpp
#include “modules/neuralNetwork/layer/recurrent/recurrent.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include <Eigen/Dense>
file recurrent.hpp
#include “modules/neuralNetwork/layer/layer.hpp”

Header file for module: Recurrent.

file neuralNetwork.cpp
#include “modules/experiment/experiment.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”
file neuralNetwork.hpp
#include “config.hpp”#include “modules/experiment/experiment.hpp”#include “modules/module.hpp”#include “modules/neuralNetwork/layer/layer.hpp”#include “modules/solver/solver.hpp”

Header file for module: NeuralNetwork.

file bayesian.cpp
#include “modules/problem/bayesian/bayesian.hpp”#include “sample/sample.hpp”
file bayesian.hpp
#include “modules/problem/problem.hpp”

Header file for module: Bayesian.

file custom.cpp
#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/bayesian/custom/custom.hpp”#include “sample/sample.hpp”
file custom.hpp
#include “modules/problem/bayesian/bayesian.hpp”

Header file for module: Custom.

file reference.cpp
#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/bayesian/reference/reference.hpp”#include “sample/sample.hpp”#include <gsl/gsl_blas.h>#include <gsl/gsl_cdf.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_sf_gamma.h>#include <gsl/gsl_sf_psi.h>

Defines

STDEV_EPSILON
file reference.hpp
#include “modules/problem/bayesian/bayesian.hpp”#include <vector>

Header file for module: Reference.

file hierarchical.cpp
#include “modules/problem/hierarchical/hierarchical.hpp”#include “sample/sample.hpp”
file hierarchical.hpp
#include “modules/problem/problem.hpp”

Header file for module: Hierarchical.

file psi.cpp
#include “modules/conduit/conduit.hpp”#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/hierarchical/psi/psi.hpp”#include “sample/sample.hpp”
file psi.hpp
#include “modules/distribution/distribution.hpp”#include “modules/problem/hierarchical/hierarchical.hpp”

Header file for module: Psi.

file theta.cpp
#include “modules/conduit/conduit.hpp”#include “modules/problem/hierarchical/theta/theta.hpp”#include “sample/sample.hpp”
file theta.hpp
#include “modules/problem/bayesian/bayesian.hpp”#include “modules/problem/hierarchical/psi/psi.hpp”

Header file for module: Theta.

file thetaNew.cpp
#include “modules/conduit/conduit.hpp”#include “modules/problem/hierarchical/thetaNew/thetaNew.hpp”#include “sample/sample.hpp”
file thetaNew.hpp
#include “modules/problem/hierarchical/hierarchical.hpp”#include “modules/problem/hierarchical/psi/psi.hpp”

Header file for module: ThetaNew.

file integration.cpp
#include “modules/problem/integration/integration.hpp”#include “sample/sample.hpp”
file integration.hpp
#include “modules/problem/problem.hpp”

Header file for module: Integration.

file optimization.cpp
#include “modules/problem/optimization/optimization.hpp”#include “sample/sample.hpp”
file optimization.hpp
#include “modules/problem/problem.hpp”

Header file for module: Optimization.

file problem.cpp
#include “modules/problem/problem.hpp”
file problem.hpp
#include “modules/experiment/experiment.hpp”#include “modules/module.hpp”

Header file for module: Problem.

file propagation.cpp
#include “modules/problem/propagation/propagation.hpp”#include “sample/sample.hpp”
file propagation.hpp
#include “modules/problem/problem.hpp”

Header file for module: Propagation.

file continuous.cpp
#include “modules/problem/reinforcementLearning/continuous/continuous.hpp”#include “modules/solver/agent/continuous/continuous.hpp”#include “sample/sample.hpp”
file continuous.cpp
#include “engine.hpp”#include “modules/solver/agent/continuous/continuous.hpp”#include “sample/sample.hpp”#include <gsl/gsl_sf_psi.h>
file continuous.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/problem/reinforcementLearning/reinforcementLearning.hpp”

Header file for module: Continuous.

file continuous.hpp
#include “modules/distribution/univariate/beta/beta.hpp”#include “modules/problem/reinforcementLearning/continuous/continuous.hpp”#include “modules/solver/agent/agent.hpp”

Header file for module: Continuous.

file discrete.cpp
#include “modules/problem/reinforcementLearning/discrete/discrete.hpp”#include “modules/solver/agent/discrete/discrete.hpp”#include “sample/sample.hpp”
file discrete.cpp
#include “engine.hpp”#include “modules/solver/agent/discrete/discrete.hpp”#include “sample/sample.hpp”
file discrete.hpp
#include “modules/problem/reinforcementLearning/reinforcementLearning.hpp”

Header file for module: Discrete.

file discrete.hpp
#include “modules/problem/reinforcementLearning/discrete/discrete.hpp”#include “modules/solver/agent/agent.hpp”

Header file for module: Discrete.

file reinforcementLearning.cpp
#include “engine.hpp”#include “modules/problem/reinforcementLearning/reinforcementLearning.hpp”#include “modules/solver/agent/agent.hpp”#include “sample/sample.hpp”
file reinforcementLearning.hpp
#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include “modules/problem/problem.hpp”

Header file for module: ReinforcementLearning.

file sampling.cpp
#include “modules/problem/sampling/sampling.hpp”#include “sample/sample.hpp”
file sampling.hpp
#include “modules/problem/problem.hpp”

Header file for module: Sampling.

file supervisedLearning.cpp
#include “modules/problem/supervisedLearning/supervisedLearning.hpp”
file supervisedLearning.hpp
#include “modules/problem/problem.hpp”

Header file for module: SupervisedLearning.

file agent.cpp
#include “auxiliar/fs.hpp”#include “engine.hpp”#include “modules/solver/agent/agent.hpp”#include “sample/sample.hpp”#include <chrono>
file agent.hpp
#include “auxiliar/cbuffer.hpp”#include “modules/problem/reinforcementLearning/reinforcementLearning.hpp”#include “modules/problem/supervisedLearning/supervisedLearning.hpp”#include “modules/solver/learner/deepSupervisor/deepSupervisor.hpp”#include “sample/sample.hpp”#include <algorithm>#include <random>

Header file for module: Agent.

file VRACER.cpp
#include “engine.hpp”#include “modules/solver/agent/continuous/VRACER/VRACER.hpp”#include “omp.h”#include “sample/sample.hpp”#include <gsl/gsl_sf_psi.h>
file VRACER.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/problem/reinforcementLearning/continuous/continuous.hpp”#include “modules/solver/agent/continuous/continuous.hpp”

Header file for module: VRACER.

file dVRACER.cpp
#include “engine.hpp”#include “modules/solver/agent/discrete/dVRACER/dVRACER.hpp”#include “omp.h”#include “sample/sample.hpp”
file dVRACER.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/problem/reinforcementLearning/discrete/discrete.hpp”#include “modules/solver/agent/discrete/discrete.hpp”

Header file for module: dVRACER.

file executor.cpp
#include “engine.hpp”#include “modules/solver/executor/executor.hpp”#include “sample/sample.hpp”
file executor.hpp
#include “modules/solver/solver.hpp”

Header file for module: Executor.

file integrator.cpp
#include “engine.hpp”#include “modules/solver/integrator/integrator.hpp”#include “sample/sample.hpp”
file integrator.hpp
#include “modules/solver/solver.hpp”

Header file for module: Integrator.

file deepSupervisor.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/solver/learner/deepSupervisor/deepSupervisor.hpp”#include “sample/sample.hpp”#include <omp.h>
file deepSupervisor.hpp
#include “modules/experiment/experiment.hpp”#include “modules/neuralNetwork/neuralNetwork.hpp”#include “modules/problem/supervisedLearning/supervisedLearning.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fAdaBelief.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fAdagrad.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fAdam.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fGradientBasedOptimizer.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fMadGrad.hpp”#include “modules/solver/learner/deepSupervisor/optimizers/fRMSProp.hpp”#include “modules/solver/learner/learner.hpp”

Header file for module: DeepSupervisor.

file fAdaBelief.cpp
#include “fAdaBelief.hpp”#include <cmath>#include <cstdlib>#include <stdio.h>#include <stdexcept>
file fAdaBelief.hpp
#include “fAdam.hpp”
file fAdagrad.cpp
#include “fAdagrad.hpp”#include <cmath>#include <cstdlib>#include <stdio.h>#include <stdexcept>
file fAdagrad.hpp
#include “fAdam.hpp”
file fAdam.cpp
#include “fAdam.hpp”#include <cmath>#include <cstdlib>#include <stdio.h>#include <stdexcept>
file fAdam.hpp
#include “fGradientBasedOptimizer.hpp”#include <vector>
file fCMAES.cpp
#include “fCMAES.hpp”#include <algorithm>#include <numeric>#include <stdio.h>#include <stdexcept>
file fCMAES.hpp
#include <cstddef>#include <gsl/gsl_math.h>#include <gsl/gsl_sf.h>#include <random>#include <vector>
file fGradientBasedOptimizer.hpp
#include <cstddef>#include <vector>
file fMadGrad.cpp
#include “fMadGrad.hpp”#include <cmath>#include <cstdlib>#include <stdio.h>#include <stdexcept>
file fMadGrad.hpp
#include “fGradientBasedOptimizer.hpp”
file fRMSProp.cpp
#include “fRMSProp.hpp”#include <cmath>#include <cstdlib>#include <stdio.h>#include <stdexcept>
file fRMSProp.hpp
#include “fGradientBasedOptimizer.hpp”
file gaussianProcess.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/solver/learner/gaussianProcess/gaussianProcess.hpp”#include “sample/sample.hpp”#include <Eigen/Dense>
file gaussianProcess.hpp
#include “engine.hpp”#include “auxiliar/libgp/gp.h”#include “modules/experiment/experiment.hpp”#include “modules/problem/supervisedLearning/supervisedLearning.hpp”#include “modules/solver/learner/learner.hpp”#include <memory>

Header file for module: GaussianProcess.

file learner.cpp
#include “modules/solver/learner/learner.hpp”
file learner.hpp
#include “modules/solver/solver.hpp”

Header file for module: Learner.

file AdaBelief.cpp
#include “engine.hpp”#include “modules/solver/optimizer/AdaBelief/AdaBelief.hpp”#include “sample/sample.hpp”
file AdaBelief.hpp
#include “modules/solver/optimizer/optimizer.hpp”

Header file for module: AdaBelief.

file Adam.cpp
#include “engine.hpp”#include “modules/solver/optimizer/Adam/Adam.hpp”#include “sample/sample.hpp”
file Adam.hpp
#include “modules/solver/optimizer/optimizer.hpp”

Header file for module: Adam.

file CMAES.cpp
#include “engine.hpp”#include “modules/solver/optimizer/CMAES/CMAES.hpp”#include “sample/sample.hpp”#include <algorithm>#include <chrono>#include <gsl/gsl_eigen.h>#include <numeric>#include <stdio.h>#include <unistd.h>
file CMAES.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/optimizer/optimizer.hpp”#include <vector>

Header file for module: CMAES.

file DEA.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/optimizer/DEA/DEA.hpp”#include “sample/sample.hpp”#include <algorithm>#include <chrono>#include <numeric>#include <stdio.h>#include <unistd.h>
file DEA.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/optimizer/optimizer.hpp”#include <vector>

Header file for module: DEA.

file gridSearch.cpp
#include “engine.hpp”#include “modules/solver/optimizer/gridSearch/gridSearch.hpp”#include “sample/sample.hpp”
file gridSearch.hpp
#include “modules/solver/optimizer/optimizer.hpp”

Header file for module: GridSearch.

file MADGRAD.cpp
#include “engine.hpp”#include “modules/solver/optimizer/MADGRAD/MADGRAD.hpp”#include “sample/sample.hpp”
file MADGRAD.hpp
#include “modules/solver/optimizer/optimizer.hpp”

Header file for module: MADGRAD.

file MOCMAES.cpp
#include “engine.hpp”#include “modules/problem/optimization/optimization.hpp”#include “modules/solver/optimizer/MOCMAES/MOCMAES.hpp”#include “sample/sample.hpp”#include <gsl/gsl_linalg.h>
file MOCMAES.hpp
#include “modules/distribution/multivariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/optimizer/optimizer.hpp”#include <vector>

Header file for module: MOCMAES.

file optimizer.cpp
#include “modules/solver/optimizer/optimizer.hpp”
file optimizer.hpp
#include “modules/solver/solver.hpp”

Header file for module: Optimizer.

file Rprop.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/optimizer/Rprop/Rprop.hpp”#include “sample/sample.hpp”#include <stdio.h>
file Rprop.hpp
#include “modules/solver/optimizer/optimizer.hpp”#include <vector>

Header file for module: Rprop.

file hamiltonian_base.hpp
#include “modules/conduit/conduit.hpp”#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/bayesian/bayesian.hpp”#include “modules/problem/bayesian/reference/reference.hpp”#include “modules/problem/problem.hpp”#include “modules/problem/sampling/sampling.hpp”#include “sample/sample.hpp”
file hamiltonian_euclidean_base.hpp
#include “hamiltonian_base.hpp”#include “modules/conduit/conduit.hpp”#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/sampler/MCMC/MCMC.hpp”#include “sample/sample.hpp”
file hamiltonian_euclidean_dense.hpp
#include “hamiltonian_euclidean_base.hpp”#include “modules/distribution/multivariate/normal/normal.hpp”#include <gsl/gsl_linalg.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_multimin.h>#include <gsl/gsl_sort_vector.h>#include <gsl/gsl_statistics.h>
file hamiltonian_euclidean_diag.hpp
#include “hamiltonian_euclidean_base.hpp”#include “modules/distribution/univariate/normal/normal.hpp”
file hamiltonian_riemannian_base.hpp
#include “hamiltonian_base.hpp”#include “modules/conduit/conduit.hpp”#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/sampler/MCMC/MCMC.hpp”#include “sample/sample.hpp”
file hamiltonian_riemannian_const_dense.hpp
#include “hamiltonian_riemannian_base.hpp”#include “modules/distribution/multivariate/normal/normal.hpp”#include <gsl/gsl_blas.h>#include <gsl/gsl_eigen.h>
file hamiltonian_riemannian_const_diag.hpp
#include “hamiltonian_riemannian_base.hpp”#include “modules/distribution/univariate/normal/normal.hpp”
file hamiltonian_riemannian_diag.hpp
#include “hamiltonian_riemannian_base.hpp”#include “modules/distribution/univariate/normal/normal.hpp”
file leapfrog_base.hpp
#include “hamiltonian_base.hpp”#include <iostream>#include <vector>
file leapfrog_explicit.hpp
#include “hamiltonian_base.hpp”#include “leapfrog_base.hpp”
file leapfrog_implicit.hpp
#include “engine.hpp”#include “hamiltonian_base.hpp”#include “hamiltonian_riemannian_base.hpp”#include “leapfrog_base.hpp”#include <limits>
file tree_helper_base.hpp
#include <vector>
file tree_helper_euclidean.hpp
#include “tree_helper_base.hpp”
file tree_helper_riemannian.hpp
#include “tree_helper_base.hpp”
file HMC.cpp
#include “auxiliar/math.hpp”#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/sampler/HMC/HMC.hpp”#include <chrono>#include <limits>#include <numeric>#include <gsl/gsl_linalg.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_multimin.h>#include <gsl/gsl_sort_vector.h>#include <gsl/gsl_statistics.h>
file HMC.hpp
#include “modules/distribution/multivariate/normal/normal.hpp”#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/sampler/sampler.hpp”#include <string>#include <vector>#include “modules/solver/sampler/HMC/helpers/hamiltonian_euclidean_dense.hpp”#include “modules/solver/sampler/HMC/helpers/hamiltonian_euclidean_diag.hpp”#include “modules/solver/sampler/HMC/helpers/hamiltonian_riemannian_const_dense.hpp”#include “modules/solver/sampler/HMC/helpers/hamiltonian_riemannian_const_diag.hpp”#include “modules/solver/sampler/HMC/helpers/hamiltonian_riemannian_diag.hpp”#include “modules/solver/sampler/HMC/helpers/leapfrog_explicit.hpp”#include “modules/solver/sampler/HMC/helpers/leapfrog_implicit.hpp”#include “modules/solver/sampler/HMC/helpers/tree_helper_euclidean.hpp”#include “modules/solver/sampler/HMC/helpers/tree_helper_riemannian.hpp”

Header file for module: HMC.

file MCMC.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/sampler/MCMC/MCMC.hpp”#include “sample/sample.hpp”#include <chrono>#include <limits>#include <numeric>#include <gsl/gsl_linalg.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_multimin.h>#include <gsl/gsl_sort_vector.h>#include <gsl/gsl_statistics.h>
file MCMC.hpp
#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/sampler/sampler.hpp”#include <vector>

Header file for module: MCMC.

file Nested.cpp
#include “engine.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/experiment/experiment.hpp”#include “modules/solver/sampler/Nested/Nested.hpp”#include “sample/sample.hpp”#include <gsl/gsl_eigen.h>#include <gsl/gsl_linalg.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_vector.h>#include <algorithm>#include <chrono>#include <limits>#include <math.h>#include <numeric>#include <random>
file Nested.hpp
#include “modules/distribution/multivariate/normal/normal.hpp”#include “modules/distribution/univariate/normal/normal.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/sampler/sampler.hpp”#include <vector>

Header file for module: Nested.

file sampler.cpp
#include “modules/solver/sampler/sampler.hpp”
file sampler.hpp
#include “modules/solver/solver.hpp”

Header file for module: Sampler.

file TMCMC.cpp
#include “engine.hpp”#include “modules/experiment/experiment.hpp”#include “modules/solver/sampler/TMCMC/TMCMC.hpp”#include “sample/sample.hpp”#include <chrono>#include <limits>#include <numeric>#include <gsl/gsl_cdf.h>#include <gsl/gsl_eigen.h>#include <gsl/gsl_linalg.h>#include <gsl/gsl_matrix.h>#include <gsl/gsl_multimin.h>#include <gsl/gsl_randist.h>#include <gsl/gsl_sort_vector.h>#include <gsl/gsl_statistics.h>#include <math.h>
file TMCMC.hpp
#include “modules/distribution/distribution.hpp”#include “modules/distribution/multivariate/normal/normal.hpp”#include “modules/distribution/specific/multinomial/multinomial.hpp”#include “modules/distribution/univariate/uniform/uniform.hpp”#include “modules/solver/sampler/sampler.hpp”#include <gsl/gsl_vector.h>

Header file for module: TMCMC.

file solver.cpp
#include “modules/solver/solver.hpp”
file solver.hpp
#include “auxiliar/libco/libco.h”#include “modules/experiment/experiment.hpp”#include “modules/module.hpp”#include “sample/sample.hpp”#include <string>#include <vector>

Header file for module: Solver.

Defines

KORALI_START(SAMPLE)

Macro to start the processing of a sample.

KORALI_WAIT(SAMPLE)

Macro to wait for the finishing of a sample.

KORALI_WAITANY(SAMPLES)

Macro to wait for any of the given samples.

KORALI_WAITALL(SAMPLES)

Macro to wait for all of the given samples.

KORALI_SEND_MSG_TO_SAMPLE(SAMPLE, MSG)

Macro to send a message to a sample.

KORALI_RECV_MSG_FROM_SAMPLE(SAMPLE)

Macro to receive a message from a sample (blocking)

KORALI_LISTEN(SAMPLES)

(Blocking) Receives all pending incoming messages (at least one) and stores them into the corresponding sample’s message queue.

file sample.cpp
#include “config.hpp”#include “sample/sample.hpp”#include “auxiliar/py2json.hpp”#include “engine.hpp”#include “modules/conduit/conduit.hpp”#include “modules/experiment/experiment.hpp”#include “modules/problem/problem.hpp”#include “modules/solver/solver.hpp”#include <vector>
file sample.hpp
#include “auxiliar/koraliJson.hpp”#include “auxiliar/libco/libco.h”#include “auxiliar/logger.hpp”#include “auxiliar/py2json.hpp”#include <queue>#include <string>

Contains the definition of a Korali Sample.

Defines

KORALI_GET(TYPE, SAMPLE, ...)

Macro to get information from a sample. Checks for the existence of the path and produces detailed information on failure.

KORALI_SEND_MSG_TO_ENGINE(MESSAGE)

Macro to send message updates to the engine.

KORALI_RECV_MSG_FROM_ENGINE()

Macro to recv message updates from the engine.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/activation

Contains code, documentation, and scripts for module: Activation.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/AdaBelief

Contains code, documentation, and scripts for module: AdaBelief.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/Adam

Contains code, documentation, and scripts for module: Adam.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/agent

Contains code, documentation, and scripts for module: Agent.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/auxiliar

Contains auxiliar libraries and tools to run Korali.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/bayesian

Contains code, documentation, and scripts for module: Bayesian.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/beta

Contains code, documentation, and scripts for module: Beta.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/cauchy

Contains code, documentation, and scripts for module: Cauchy.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/CMAES

Contains code, documentation, and scripts for module: CMAES.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/conduit/concurrent

Contains code, documentation, and scripts for module: Concurrent.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/conduit

Contains code, documentation, and scripts for module: Conduit.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/reinforcementLearning/continuous

Contains code, documentation, and scripts for module: Continuous.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/agent/continuous

Contains code, documentation, and scripts for module: Continuous.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/bayesian/custom

Contains code, documentation, and scripts for module: Custom.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/DEA

Contains code, documentation, and scripts for module: DEA.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/learner/deepSupervisor

Contains code, documentation, and scripts for module: DeepSupervisor.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/reinforcementLearning/discrete

Contains code, documentation, and scripts for module: Discrete.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/agent/discrete

Contains code, documentation, and scripts for module: Discrete.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/conduit/distributed

Contains code, documentation, and scripts for module: Distributed.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution

Contains code, documentation, and scripts for module: Distribution.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/agent/discrete/dVRACER

Contains code, documentation, and scripts for module: dVRACER.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/executor

Contains code, documentation, and scripts for module: Executor.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/experiment

Contains code, documentation, and scripts for module: Experiment.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/exponential

Contains code, documentation, and scripts for module: Exponential.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/gamma

Contains code, documentation, and scripts for module: Gamma.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/learner/gaussianProcess

Contains code, documentation, and scripts for module: GaussianProcess.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/geometric

Contains code, documentation, and scripts for module: Geometric.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/gridSearch

Contains code, documentation, and scripts for module: GridSearch.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/recurrent/gru

Contains code, documentation, and scripts for module: GRU.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler/HMC/helpers
dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/hierarchical

Contains code, documentation, and scripts for module: Hierarchical.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler/HMC

Contains code, documentation, and scripts for module: HMC.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/igamma

Contains code, documentation, and scripts for module: Igamma.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/input

Contains code, documentation, and scripts for module: Input.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/integration

Contains code, documentation, and scripts for module: Integration.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/integrator

Contains code, documentation, and scripts for module: Integrator.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/laplace

Contains code, documentation, and scripts for module: Laplace.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer

Contains code, documentation, and scripts for module: Layer.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/learner

Contains code, documentation, and scripts for module: Learner.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/linear

Contains code, documentation, and scripts for module: Linear.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/logNormal

Contains code, documentation, and scripts for module: LogNormal.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/recurrent/lstm

Contains code, documentation, and scripts for module: LSTM.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/MADGRAD

Contains code, documentation, and scripts for module: MADGRAD.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler/MCMC

Contains code, documentation, and scripts for module: MCMC.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/MOCMAES

Contains code, documentation, and scripts for module: MOCMAES.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules

Contains all the modules upon which a Korali application is created.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/specific/multinomial

Contains code, documentation, and scripts for module: Multinomial.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/multivariate

Contains code, documentation, and scripts for module: Multivariate.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler/Nested

Contains code, documentation, and scripts for module: Nested.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork

Contains code, documentation, and scripts for module: NeuralNetwork.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/multivariate/normal

Contains code, documentation, and scripts for module: Normal.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/normal

Contains code, documentation, and scripts for module: Normal.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/optimization

Contains code, documentation, and scripts for module: Optimization.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer

Contains code, documentation, and scripts for module: Optimizer.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/learner/deepSupervisor/optimizers
dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/output

Contains code, documentation, and scripts for module: Output.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem

Contains code, documentation, and scripts for module: Problem.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/propagation

Contains code, documentation, and scripts for module: Propagation.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/hierarchical/psi

Contains code, documentation, and scripts for module: Psi.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/neuralNetwork/layer/recurrent

Contains code, documentation, and scripts for module: Recurrent.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/bayesian/reference

Contains code, documentation, and scripts for module: Reference.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/reinforcementLearning

Contains code, documentation, and scripts for module: ReinforcementLearning.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/optimizer/Rprop

Contains code, documentation, and scripts for module: Rprop.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/sample

Contains the definition of a Korali Sample.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler

Contains code, documentation, and scripts for module: Sampler.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/sampling

Contains code, documentation, and scripts for module: Sampling.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/conduit/sequential

Contains code, documentation, and scripts for module: Sequential.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver

Contains code, documentation, and scripts for module: Solver.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source

Contains source code for the Korali engine, experiment, and its modules.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/specific

Contains code, documentation, and scripts for module: Specific.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/supervisedLearning

Contains code, documentation, and scripts for module: SupervisedLearning.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/hierarchical/theta

Contains code, documentation, and scripts for module: Theta.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/problem/hierarchical/thetaNew

Contains code, documentation, and scripts for module: ThetaNew.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/sampler/TMCMC

Contains code, documentation, and scripts for module: TMCMC.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/truncatedNormal

Contains code, documentation, and scripts for module: TruncatedNormal.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/uniform

Contains code, documentation, and scripts for module: Uniform.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate

Contains code, documentation, and scripts for module: Univariate.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/solver/agent/continuous/VRACER

Contains code, documentation, and scripts for module: VRACER.

dir /home/docs/checkouts/readthedocs.org/user_builds/korali/checkouts/v3.0.1/source/modules/distribution/univariate/weibull

Contains code, documentation, and scripts for module: Weibull.