Crates.io | dvcompute_gpss_branch |
lib.rs | dvcompute_gpss_branch |
version | 2.0.0 |
source | src |
created_at | 2022-01-05 11:22:56.288445 |
updated_at | 2024-06-29 10:48:42.827066 |
description | Discrete event simulation library (support of GPSS-like DSL language for nested simulation) |
homepage | https://gitflic.ru/project/dsorokin/dvcompute |
repository | https://gitflic.ru/project/dsorokin/dvcompute |
max_upload_size | |
id | 508326 |
size | 180,731 |
This crate is a part of discrete event simulation framework DVCompute Simulator (registration
number 2021660590 of Rospatent). The dvcompute_gpss_branch
crate defines a GPSS-like DSL for
nested simulation, but the same code base is shared by the dvcompute_gpss_dist
crate
destined for optimistic 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.
Here is an example, where each student arrival is modeled by some transact. These transacts are processed by the block computations:
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 examples in the author's repository.
Copyright 2020-2024 David Sorokin davsor@mail.ru, based in Yoshkar-Ola, Russia
This software 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 http://mozilla.org/MPL/2.0/.