⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stochasticadaptiverungekuttaharness.cpp

📁 dysii is a C++ library for distributed probabilistic inference and learning in large-scale dynamical
💻 CPP
字号:
#include "DoubleWell.hpp"#include "indii/ml/sde/StochasticAdaptiveRungeKutta.hpp"#include <iostream>#include <fstream>namespace aux = indii::ml::aux;/** * @file StochasticAdaptiveRungeKuttaHarness.cpp * * Test of StochasticAdaptiveRungeKutta with DoubleWell model. * * This test simulates a number of trajectories from DoubleWell using * indii::ml::sde::StochasticAdaptiveRungeKutta, plotting each. * * Results are as follows: * * \image html StochasticAdaptiveRungeKuttaHarness.png "Results" * \image latex StochasticAdaptiveRungeKuttaHarness.eps "Results" *//** * Dimensionality of the process. */const unsigned int M = 1;/** * Number of sample trajectories. */const unsigned int N = 1;/** * Time length of each trajectory. */const double LENGTH = 600.0;/** * Run tests. */int main(int argc, const char* argv[]) {  double t;  aux::vector y(M);  unsigned int i;  std::ofstream fout("results/StochasticAdaptiveRungeKuttaHarness.out");  DoubleWell model;  indii::ml::sde::StochasticAdaptiveRungeKutta<> solver(&model);  solver.setErrorBounds(1.0e-3, 1.0e-2);  for (i = 0; i < N; i++) {    t = 0.0;    y(0) = aux::Random::uniform(-1.0, 1.0);    solver.setTime(t);    solver.setState(y);    solver.setStepSize(1.0e-4);    while (t < LENGTH) {      t = solver.step(LENGTH);      y = solver.getState();      fout << t << '\t' << y(0) << std::endl;    }    fout << std::endl;  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -