Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Resources #20

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[![Build](https://github.com/primitivefinance/aika/actions/workflows/build.yaml/badge.svg)](https://github.com/primitivefinance/aika/actions/workflows/build.yaml)
[![Rust](https://github.com/primitivefinance/aika/actions/workflows/rust.yaml/badge.svg)](https://github.com/primitivefinance/aika/actions/workflows/rust.yaml)

Discrete event simulator built in Rust 🦀 . Designed to have a similar syntax to SimPy with a particular focus on configurability for complex simulation environments.
Discrete event simulation manager built in Rust 🦀 . Aika is designed to have a similar base syntax to [SimPy](https://gitlab.com/team-simpy/simpy), however, has the addition of a `Manager` to improve focus on large, repetitive, data intensive simulations.

This simulator utilizes `generators`, currently an expiremental feature of Rust nightly version 1.71.0.

![](/assets/aika-clock.png)
21 changes: 20 additions & 1 deletion aika/src/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Distributions must enforce a sampling of only positive real numbers, as this describes a time delta moving forward.

use rand::Rng;
use rand_distr::{Gamma as GammaDistribution, Poisson as PoissonDistribution};
use rand_distr::{Gamma as GammaDistribution, Poisson as PoissonDistribution, LogNormal as LogNormalDistribution};

/// The `Distribution` trait allows for the creation of custom distributions to be used in the `ProcessExecution::Stochastic` variant.
pub trait Distribution {
Expand Down Expand Up @@ -47,3 +47,22 @@ impl Distribution for Gamma {
rng.sample(self.distribution)
}
}

/// The `LogNormal` struct implements the `Distribution` trait for the LogNormal distribution.
pub struct LogNormal {
pub distribution: LogNormalDistribution<f64>,
}

impl LogNormal {
pub fn new(mean: f64, std_dev: f64) -> LogNormal {
Self {
distribution: LogNormalDistribution::new(mean, std_dev).unwrap(),
}
}
}

impl Distribution for LogNormal {
fn sample(&self, rng: &mut rand::rngs::StdRng) -> f64 {
rng.sample(self.distribution)
}
}
Loading