dvcompute_gpss_branch/
lib.rs

1// Copyright (c) 2020-2022  David Sorokin <davsor@mail.ru>, based in Yoshkar-Ola, Russia
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
7//! This crate is a part of discrete event simulation framework DVCompute Simulator (registration
8//! number 2021660590 of Rospatent). The `dvcompute_gpss_dist` crate defines a GPSS-like DSL for
9//! optimistic distributed simulation, but the same code base is shared by the `dvcompute_gpss_branch`
10//! crate destined for nested simulation.
11//!
12//! The DSL language implements analogs of the following blocks: PREEMPT, RETURN, ASSEMBLE, GATHER,
13//! SPLIT, TRANSFER and others. The SELECT block is naturally expressed as a composition of computations.
14//! There are analogs of the facility and storage entities.
15//!
16//! There are the following main crates: `dvcompute` (sequential simulation),
17//! `dvcompute_dist` (optimistic distributed simulation),
18//! `dvcompute_cons` (conservative distributed simulation) and
19//! `dvcompute_branch` (nested simulation). All four crates are
20//! very close. They are based on the same method.
21//!
22//! In case of optimistic distributed simulation, you must satisfy the requirements that
23//! the `dvcompute_dist` crate imposes regarding the dynamic (shared) libraries.
24//!
25//! The simulation method is described in the author's article:
26//! Sorokin David. DVCompute Simulator for discrete event simulation.
27//! Prikladnaya informatika=Journal of Applied Informatics, 2021, vol.16, no.3, pp.93-108 (in Russian).
28//! DOI: 10.37791/2687-0649-2021-16-3-93-108
29//!
30//! Here is an example, where each student arrival is modeled by some transact. These transacts
31//! are processed by the block computations:
32//!
33//! ```rust,no_run
34//! # use dvcompute_utils::grc::Grc; 
35//! # use dvcompute_dist::prelude::*;
36//! # #[cfg(feature="dist_mode")]
37//! # use dvcompute_gpss_dist::prelude::*;
38//! # #[cfg(any(feature="branch_mode", feature="branch_wasm_mode"))]
39//! # use dvcompute_gpss_branch::prelude::*;
40//! fn student_chain(line: Grc<Queue>, prof: Grc<Facility<f64>>) -> BlockBox<Transact<f64>, ()> {
41//!     queue_block(line.clone(), 1)
42//!         .and_then(seize_block(prof.clone()))
43//!         .and_then(depart_block(line.clone(), 1))
44//!         .and_then({
45//!             advance_block(random_exponential_process_(1000.0))
46//!         })
47//!         .and_then(let_go_chain(line, prof))
48//!         .into_boxed()
49//! }
50//! 
51//! fn let_go_chain(_line: Grc<Queue>, prof: Grc<Facility<f64>>) -> BlockBox<Transact<f64>, ()> {
52//!     release_block(prof)
53//!         .and_then(terminate_block())
54//!         .into_boxed()
55//! }
56//! ```
57//! 
58//! These computations are arrows in terms of functional programming. They are combined with help of 
59//! composition. Such computations should be run later to take effect.
60//!
61//! You can find more examples in the author's repository: <https://gitflic.ru/project/dsorokin/dvcompute>.
62
63extern crate dvcompute_utils;
64extern crate dvcompute_dist;
65
66/// The main simulation module.
67pub mod simulation;
68
69/// The prelude module.
70pub mod prelude;
71
72#[cfg(test)]
73mod tests {
74    #[test]
75    fn it_works() {
76    }
77}