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