{"id":32158111,"url":"https://github.com/kirui93/scentrees.jl","last_synced_at":"2026-02-21T15:02:54.106Z","repository":{"id":54192109,"uuid":"203182679","full_name":"kirui93/ScenTrees.jl","owner":"kirui93","description":"Julia Package for Generating Scenario Trees and Scenario Lattices for Multistage Stochastic Optimization","archived":false,"fork":false,"pushed_at":"2024-02-19T13:05:00.000Z","size":5083,"stargazers_count":27,"open_issues_count":6,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-18T12:47:41.695Z","etag":null,"topics":["julia","multistage-stochastic-optimization","scenario-lattice","scenario-tree","scenario-tree-generation","stochastic-data","stochastic-processes"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirui93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2019-08-19T13:52:27.000Z","updated_at":"2026-01-01T13:50:44.000Z","dependencies_parsed_at":"2024-02-26T07:00:30.233Z","dependency_job_id":null,"html_url":"https://github.com/kirui93/ScenTrees.jl","commit_stats":{"total_commits":400,"total_committers":5,"mean_commits":80.0,"dds":"0.10499999999999998","last_synced_commit":"0a1189b8628c52c11e3c094879bdee06ba97013e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/kirui93/ScenTrees.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirui93%2FScenTrees.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirui93%2FScenTrees.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirui93%2FScenTrees.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirui93%2FScenTrees.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirui93","download_url":"https://codeload.github.com/kirui93/ScenTrees.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirui93%2FScenTrees.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29684075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T14:31:22.911Z","status":"ssl_error","status_checked_at":"2026-02-21T14:31:22.570Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["julia","multistage-stochastic-optimization","scenario-lattice","scenario-tree","scenario-tree-generation","stochastic-data","stochastic-processes"],"created_at":"2025-10-21T12:57:50.210Z","updated_at":"2026-02-21T15:02:54.079Z","avatar_url":"https://github.com/kirui93.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Travis status](https://travis-ci.org/kirui93/ScenTrees.jl.svg?branch=master)](https://travis-ci.org/kirui93/ScenTrees.jl)\n[![Codecov](https://codecov.io/gh/kirui93/ScenTrees.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/kirui93/ScenTrees.jl)\n[![Coverage Status](https://coveralls.io/repos/github/kirui93/ScenTrees.jl/badge.svg?branch=master)](https://coveralls.io/github/kirui93/ScenTrees.jl?branch=master)\n[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://kirui93.github.io/ScenTrees.jl/dev/)\n[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://kirui93.github.io/ScenTrees.jl/stable/)\n[![Zenodo](https://zenodo.org/badge/DOI/10.5281/zenodo.3672205.svg)](https://doi.org/10.5281/zenodo.3672205)\n[![JOSS](https://joss.theoj.org/papers/10.21105/joss.01912/status.svg)](https://doi.org/10.21105/joss.01912)\n\n# ScenTrees.jl\n\nNote: See also the active fork at https://github.com/aloispichler/ScenTrees.jl.\n\n`ScenTrees.jl` is a Julia package for generating and improving scenario trees and scenario lattices for multistage stochastic optimization problems using _stochastic approximation_. It is totally written in the Julia programming language. This package provides functions for generating scenario trees and scenario lattices from stochastic processes and stochastic data.\n\nWe provide two important features at the moment:\n\n- Generation of scenario trees and scenario lattices using stochastic approximation procedure.\n    + Scenario trees are used in the case of discrete time and discrete state stochastic processes.\n    + Scenario lattices are a natural discretization of Markov processes and so if the stochastic process is Markovian, scenario lattices would approximate the process well.\n- Estimating trajectories from stochastic data using conditional density estimation.\n    + This is a non-parametric technique for generating trajectories from a given observed data whose distribution is unknown.\n    + The new trajectories estimated here can thus be used in stochastic approximation process to generate scenario trees and scenario lattices.\n\nStochastic approximation procedure in `ScenTrees.jl` library follows from the framework provided by [Pflug and Pichler(2015)](https://doi.org/10.1007/s10589-015-9758-0). The two main user inputs are a fixed branching structure and a function that generates samples from a stochastic process.\n\n*N/B* - _This package is actively developed and therefore new improvements and new features are continuously added._\n\n## Installation\n\nGet the latest stable release with Julia's package manager:\n\n```julia\n] add ScenTrees\n```\n\nTo use `ScenTrees.jl`, you need to have Julia \u003e= v1.0. This package was developed in Julia 1.0.4, and has been tested for Julia \u003e= v1.0 in Linux and OSX distributions.\n\n## Documentation\n\nThe STABLE documentation of ScenTrees.jl is available [here](https://kirui93.github.io/ScenTrees.jl/stable/). Here you can get the description of the various functions in the package and also different examples for the different features.\n\n## Example of Usage\n\nAfter installing the ScenTrees.jl package, you can use it as in the following examples:\n\n1. Consider the Gaussian random walk process in 4 stages. This process is already available in the package and can just be called by `gaussian_path1D()` for 1D and `gaussian_path2D()` for 2D. We want to approximate 1D process with a scenario tree as follows:\n\n```julia\njulia\u003e using ScenTrees\njulia\u003e gstree = tree_approximation!(Tree([1,2,2,2],1),gaussian_path1D,100000,2,2);\njulia\u003e tree_plot(gstree)\n```\n![Scenario Tree](docs/src/assets/gstree.png)\n\n2. We want to approximate running maximum process with a scenario lattice. It follows the same procedure as for scenario trees only that we use a different function as follows:\n\n```julia\njulia\u003e using ScenTrees\njulia\u003e rmlattice = lattice_approximation([1,2,3,4],running_maximum1D,100000,2,1);\njulia\u003e plot_lattice(rmlattice)\n```\n![Scenario Lattice](docs/src/assets/rmlattice.png)\n\n3. We also provide the conditional density estimation of trajectories given data. Given an `NxT` dataframe, we use the `kernel_scenarios()` function to generate a new and similar trajectory with length equal to `T`. This function can thus be used to generated trajectories for creating a scenario tree and a scenario lattice. Consider a Gaussian random walk data which can be generated by calling the function `gaussian_path1D()` many times and saving the result in a matrix form. We can use this data and the kernel density estimation method to generate new and similar trajectories as follows:\n\n```julia\njulia\u003e using ScenTrees\njulia\u003e using Distributions\njulia\u003e gsdata = Array{Float64}(undef,1000,4)\njulia\u003e for i = 1:1000\n           gsdata[i,:] = gaussian_path1D()\n       end\njulia\u003e gsGen = kernel_scenarios(gsdata,Logistic; Markovian = true)()\n4-element Array{Float64,1}:\n 6.3183e-16\n-1.8681\n-3.7719\n-3.5241\n```\n\nTo use the above samples for scenario trees or scenario lattice generation:\n\n```julia\njulia\u003e kerneltree = tree_approximation!(Tree([1,2,2,2],1),kernel_scenarios(gsdata,Logistic;Markovian=false),100000,2,2);\njulia\u003e tree_plot(kerneltree)\njulia\u003e kernelLattice = lattice_approximation([1,3,4,5],kernel_scenarios(gsdata,Logistic;Markovian=true),100000,2,1);\njulia\u003e plot_lattice(kernelLattice)\n```\n\n| [![Kernel Tree](docs/src/assets/kerneltree.png)](docs/src/assets/kerneltree.png)  | [![Kernel Lattice](docs/src/assets/kernelLattice.png)](docs/src/assets/kernelLattice.png) |\n|:---:|:---:|\n|Kernel Scenario Tree | Kernel Scenario Lattice  |\n\n## Contributing to ScenTrees.jl\n\nAs in [CONTRIBUTING.md](https://github.com/kirui93/ScenTrees.jl/blob/master/CONTRIBUTING.md), if you believe that you have found any bugs or if you need help or any questions regarding the library and any suggestions, please feel free to file a [new GitHub issue](https://github.com/kirui93/ScenTrees.jl/issues/new). You can also raise an issue or a pull request which fixes the issue as long as it doesn't affect performance.\n\n## Citing ScenTrees.jl\n\nWe ask that you please cite the following [paper](https://joss.theoj.org/papers/10.21105/joss.01912) if you use `ScenTrees.jl`:\n```\n@article{Kirui2020,\n        author = {Kirui, Kipngeno and Pichler, Alois and Pflug, Georg {\\relax Ch}.},\n        title = {ScenTrees.jl: A {J}ulia Package for Generating Scenario Trees and Scenario Lattices for Multistage Stochastic Programming},\n        journal = {Journal of Open Source Software},\n        publisher = {The Open Journal},\n        year = {2020},\n        volume = {5},\n        number = {46},\n        pages = {1912},\n        doi = {10.21105/joss.01912},\n        url = {https://doi.org/10.21105/joss.01912}\n}\n```\n## References\n\n+ Pflug, Georg Ch., and Alois Pichler, 2012. *A Distance for Multistage Stochastic Optimization Models*. SIAM Journal on Optimization 22(1) Doi: https://doi.org/10.1137/110825054\n\n+ Pflug, Georg Ch., and Alois Pichler,2015. *Dynamic Generation of Scenario Trees*. Computational Optimization and Applications 62(3): Doi: https://doi.org/10.1007/s10589-015-9758-0\n\n+ Pflug, Georg Ch., and Alois Pichler,2016. *From Empirical Observations to Tree Models for Stochastic Optimization : Convergence Properties : Convergence of the Smoothed Empirical Process in Nested Distance.* SIAM Journal on Optimization 26(3). Society for Industrial and Applied Mathematics (SIAM). Doi: https://doi.org/10.1137/15M1043376.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirui93%2Fscentrees.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirui93%2Fscentrees.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirui93%2Fscentrees.jl/lists"}