{"id":19863634,"url":"https://github.com/sandialabs/neural-random-walker","last_synced_at":"2025-07-11T12:07:13.073Z","repository":{"id":217969449,"uuid":"733670549","full_name":"sandialabs/Neural-Random-Walker","owner":"sandialabs","description":"A suite of codes for performing discrete time Markov chain random walks with neuromorphic hardware and simulators.","archived":false,"fork":false,"pushed_at":"2024-06-13T19:57:16.000Z","size":57,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T21:43:53.597Z","etag":null,"topics":["markov-chains","scr-2798","simulation","snl-applications","snl-other","stochastic-differential-equations"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandialabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-19T21:25:09.000Z","updated_at":"2025-03-29T19:05:13.000Z","dependencies_parsed_at":"2025-01-11T15:24:30.568Z","dependency_job_id":"b2e76288-a20b-4f47-93ad-bb2acad7633e","html_url":"https://github.com/sandialabs/Neural-Random-Walker","commit_stats":null,"previous_names":["sandialabs/neural-random-walker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sandialabs/Neural-Random-Walker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FNeural-Random-Walker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FNeural-Random-Walker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FNeural-Random-Walker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FNeural-Random-Walker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandialabs","download_url":"https://codeload.github.com/sandialabs/Neural-Random-Walker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandialabs%2FNeural-Random-Walker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264803698,"owners_count":23666512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markov-chains","scr-2798","simulation","snl-applications","snl-other","stochastic-differential-equations"],"created_at":"2024-11-12T15:15:33.477Z","updated_at":"2025-07-11T12:07:13.054Z","avatar_url":"https://github.com/sandialabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Installation\nHere are instructions to setup a python environment to run the Random Walk program using Anaconda. The instructions below will create a stand alone environment capable of running the random walk code. To install in an exhisting environment, manually install the packages found inside `rw_requirements.yml`.\n\n## Part 1 Pull Fugu Repository\nThis repository comes with the Fugu repository. Before we can setup the python environment, we must pull from the fugu repository. This task is accomplish by running the below commands from a terminal.\n```\ngit submodule init\ngit submodule update\n```\n\n## Part 2 Create Conda Environment\nWe assume that you have anaconda distribution already installed on your machine. Again from a terminal run these commands from inside the random walk repository root directory.\n```\nconda env create --file rw_requirements.yml\nconda activate rwalk-fugu\nconda develop $PWD/Fugu\n```\nThis part creates a `rwalk-fugu` conda environment and installs the necessary packages for the Fugu submodule. Additionally, it adds the Fugu submodule to the `rwalk-fugu` conda environment path.\n\nNote: The `rw_requirments.yml` creates an environment called `rwalk-fugu` by default. To change this behavior modify the `name` property to the desired environment name.\n\n## Part 3 NxSDK Install (Optional)\nThis part is required if you plan to run the program on Loihi hardware. It requires the NxSDK python package. From a terminal, run these commands\n```\ntar -xvf nxsdk-\u003cversion\u003e.tar.gz\nnxsdk-apps-\u003cversion\u003e.tar.gz\n```\nUpdate `/PATH/TO/nxsdk-\u003cversion\u003e/requirements.txt` file to:\n```\nattrdict\u003e=2.0.1\nnumpy==1.15.*\npandas==1.0.*\nmatplotlib\u003e=2.2.2\nimageio\u003e=2.6.1\nscikit-image\u003e=0.14.2\nscipy==1.5.*\nscikit-learn\u003e=0.19.2\njinja2\u003e=2.10\ncoloredlogs\u003e=10.0\ngrpcio\u003e=1.19.0\nprotobuf==3.19.*\ngrpcio_tools\u003e=1.19.0\nmemory_profiler\u003e=0.55\nbitstring\u003e=3.1.6\n```\n\nFinally, run pip to install the necessary python packages and set appropriate paths for the conda environment.\n```\npython -m pip install /PATH/TO/nxsdk-\u003cversion\u003e/\nconda develop /PATH/TO/nxsdk-\u003cversion\u003e/nxsdk/\nconda develop /PATH/TO/nxsdk-apps-\u003cversion\u003e/nxsdk_modules/\n```\n\n# Fluence Miniapp\n\nThis miniapp approximates the fluence for a 2D particle transport problem. The miniapp's main purpose is to demonstrate some functions of the Neural Random Walker codebase.  It calculates the integrated-over-time particle flux for a one-dimensional particle traveling at various effective velocities.  The dimensions of the problem are space and direction.\n\nIt creates a transition matrix for particles transitioning among various (space, direction) coordinates and saves the matrix as $matrix_filename. Once the matrix is created, random walkers are simulated starting on every coordinate pair in the mesh.\n\nThere are several options, described below.  Some variables are required for the simulation to run.  These are M, dt, da, v, SigS, SigA, and L.  M is the number of walkers to start on each position in the mesh.  dt is the time discretization size.  da is the angular discritization size - this corresponds to the different 'direction' values the random walkers can assume.  v is the maximum velocity of the particle, achieved only when the particle has an angle of 1 (or -v when the particle has an angle of -1). SigS is the scattering cross-section (or rate) and SigA is the absorption cross-section (or rate).  L specifies the interval [-L,L] that the particle is allowed to exist in.\n\nThis problem has been adapted from the Nature Electronics paper here: https://www.nature.com/articles/s41928-021-00705-7. The default parameters have been altered to reduce the number of walkers simulated per location and to provide a more interesting source term.\n```\n  M = 1000\n  dt = 0.01\n  da = 0.0666667 (=1/15)\n  v = 200\n  SigS = 0.15\n  SigA = 0\n  L = 1\n```\nIn addition, the Nature Electronics paper used a different source term. Specifically, S(x,w)=0.015 whenever |x|\u003c0.5.  Here, x is position and w is angle.  The source term in this miniapp is coded as a separate function in the fluence_mini_app.py file.\n\nVariables are taken as options from the command line and are parsed using argparse. The details and defaults of these variables are described below in the Usage section. Please note that balancing and optimizng the parameters is a challenging process. They must be selected so that the discrete time Markov chain well approximates the underling stochastic process and selected so that the lower precision probability on Loihi introduces negligible error.\n\n## Usage\n```\nusage: fluence_mini_app.py [-h] [-r {fugu,loihi,spinnaker,pc}] [-M NUM_WALKS]\n                           [-dt TIMESTEP] [-da ANGLESTEP] [-v VELOCITY]\n                           [-ss SIGS] [-sa SIGA] [-L INTERVAL_LENGTH]\n                           [-nt NEURAL_TIMESTEPS] [-d] [--verbose]\n                           [--matrix_filename MATRIX_FILENAME]\n                           [--results_filename RESULTS_FILENAME]\n                           [--fugu_backend {snn}] [--plot_results]\n                           [--log_file LOG_FILE] [--runclean RUNCLEAN]\n                           [--rand_seed RAND_SEED] [--use_sinks]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -r {fugu,loihi,spinnaker,pc}, --run_mode {fugu,loihi,spinnaker,pc}\n                        The mode specifies how the random walks are ran. Must\n                        be one of fugu, loihi, spinnaker, or pc. The default\n                        is fugu. Specifying pc gives a python implementation.\n  -M NUM_WALKS, --num_walks NUM_WALKS\n                        The number of walkers to start on each location in the\n                        mesh. The default is 100.\n  -dt TIMESTEP, --timestep TIMESTEP\n                        The time step of the simulation. The default is 0.01.\n  -da ANGLESTEP, --anglestep ANGLESTEP\n                        The angular discretization step size. The default is\n                        1/15.\n  -v VELOCITY, --velocity VELOCITY\n                        The maximum velocity of the particle. The default is\n                        200.\n  -ss SIGS, --SigS SIGS\n                        The scattering cross-section of the particle. This is\n                        the rate at which scattering events occur. The default\n                        is 0.15.\n  -sa SIGA, --SigA SIGA\n                        The absorption cross-section. This is the rate at\n                        which particles are absorbed. The default is zero.\n  -L INTERVAL_LENGTH, --interval_length INTERVAL_LENGTH\n                        The length of the spatial interval [-L,L] the particle\n                        is allowed to travel through. The default is 1.\n  -nt NEURAL_TIMESTEPS, --neural_timesteps NEURAL_TIMESTEPS\n                        The number of neural timesteps the simulation is run\n                        for. This should be MUCH greater than the number of\n                        model time steps desired. The default is 30000. For pc\n                        run mode, this is the number of model timesteps.\n  -d, --debug           Print logging DEBUG statements.\n  --verbose             Print logging INFO statements.\n  --matrix_filename MATRIX_FILENAME\n                        Filename for temporary storage of transition matrix.\n  --results_filename RESULTS_FILENAME\n                        Filename to record the results.\n  --fugu_backend {snn}  Runs a spiking simulator using Fugu.\n  --plot_results        Plots the results after finishing.\n  --log_file LOG_FILE   Location of the log file.\n  --runclean RUNCLEAN   Run probe-free replicate in a Loihi run.\n  --rand_seed RAND_SEED\n                        Sets the seed for the random number generator.\n                        Otherwise uses a time-based 'random' RNG seed.\n  --use_sinks           Include sinks in a fugu simulation; default is False.\n  ```\n\n# Simple Flux Miniapp\n\nThis miniapp is a simplified particle flux problem. The miniapp's main purpose is to demonstrate some functions of the Neural Random Walker codebase. This miniapp will run much faster than the larger Fluence Miniapp. It calculates particle flux over time for a two state problem. Particles can be in one of two directions states: positive or negative.\n\nIt creates a transition matrix for the probability of a particle changing between the two states based on input variables and saves the matrix as $matrix_filename. Once the matrix is created, random walkers will be simulated starting on every position of the mesh. These will be simulated according to user specification.\n\nThere are several options, described below.  Some variables are required for the simulation to run.  These are M, dt, ip, in, SigS, and SigA.  M is the number of walkers to start on each position in the mesh.  dt is the time discretization size.  ip and in are the initial condition for the positive and negative solutions respectively. SigS is the scattering cross-section (or rate) and SigA is the absorption cross-section (or rate).\n\nThe problem approximates the fluence for two states in a two state problem over time.  It can be though of as providing a function F(t,1) and F(t,-1) where 1 is the positive direction state and -1 is the negative direction state. It is based off of SN3.8 from the Nature Electronics paper located here: https://www.nature.com/articles/s41928-021-00705-7\n    \nThe default values in this simulation are different from the referenced paper. They have been selected to best approximate the solution with the Loihi hardware.\n\nVariables are taken as options from the command line and are parsed using argparse. The details and defaults of these variables are described below in the Usage section. Please note that balancing and optimizng the parameters is a challenging process. They must be selected so that the discrete time Markov chain well approximates the underling stochastic process and selected so that the lower precision probability on Loihi introduces negligible error.\n\n## Usage\n```\nusage: simple_flux_miniapp.py [-h] [-r {fugu,loihi,spinnaker,pc}]\n                              [-M NUM_WALKS] [-dt TIMESTEP] [-ip INIT_POS]\n                              [-in INIT_NEG] [-ss SIGS] [-sa SIGA]\n                              [-mt MAX_TIME] [-nt NEURAL_TIMESTEPS] [--debug]\n                              [--verbose] [--matrix_filename MATRIX_FILENAME]\n                              [--results_filename RESULTS_FILENAME]\n                              [--fugu_backend {snn}] [--plot_results]\n                              [--log_file LOG_FILE] [--rand_seed RAND_SEED]\n                              [--use_sinks]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -r {fugu,loihi,spinnaker,pc}, --run_mode {fugu,loihi,spinnaker,pc}\n                        The mode specifies how the random walks are ran. Must\n                        be one of fugu, loihi, spinnaker, or pc. The default\n                        is fugu. Specifying pc gives a python implementation.\n  -M NUM_WALKS, --num_walks NUM_WALKS\n                        The number of walkers to start on each location in the\n                        mesh. The default is 500.\n  -dt TIMESTEP, --timestep TIMESTEP\n                        The time step of the simulation. The default is 0.005.\n  -ip INIT_POS, --init_pos INIT_POS\n                        The initial value for the positive direction solution.\n                        The default is 5.\n  -in INIT_NEG, --init_neg INIT_NEG\n                        The initial value for the negative direction solution.\n                        The default is 3.\n  -ss SIGS, --SigS SIGS\n                        The scattering cross-section of the particle. This is\n                        the rate at which scattering events occur. The default\n                        is 8.0.\n  -sa SIGA, --SigA SIGA\n                        The absorption cross-section. This is the rate at\n                        which particles are absorbed. The default is 2.0.\n  -mt MAX_TIME, --max_time MAX_TIME\n                        The absolute max model time of simulation. This is the\n                        largest value of time that could be displayed in the\n                        solution. The actual largest model time of simulation\n                        may be smaller than this value if the neural timestep\n                        is too small for Loihi or Fugu-\u003eLoihi simulations. For\n                        conventional (pc) simulations, the actual time may be\n                        smaller if dt*nt\u003cmt.\n  -nt NEURAL_TIMESTEPS, --neural_timesteps NEURAL_TIMESTEPS\n                        The number of neural timesteps the simulation is run\n                        for. This should be MUCH greater than the number of\n                        model time steps desired. The default is 500000. For\n                        pc, this is the number of model timesteps.\n  --debug               Print logging DEBUG statements.\n  --verbose             Print logging INFO statements.\n  --matrix_filename MATRIX_FILENAME\n                        Filename for temporary storage of transition matrix.\n  --results_filename RESULTS_FILENAME\n                        Filename to record the results.\n  --fugu_backend {snn}  Runs a spiking simulator using Fugu.\n  --plot_results        Plots the results after finishing.\n  --log_file LOG_FILE   Location of the log file.\n  --rand_seed RAND_SEED\n                        Sets the seed for the random number generator.\n                        Otherwise uses a time-based 'random' RNG seed.\n  --use_sinks           Include sinks in a fugu simulation; default is False.\n  ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandialabs%2Fneural-random-walker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandialabs%2Fneural-random-walker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandialabs%2Fneural-random-walker/lists"}