### 5 stable releases

2.0.0 | Jun 29, 2024 |
---|---|

1.3.7 | Jan 16, 2022 |

1.3.5 | Jan 13, 2022 |

1.3.4 | Jan 6, 2022 |

1.3.3 | Jan 5, 2022 |

#**134** in Simulation

**22** downloads per month

Used in **3** crates

**MPL-2.0**license

665KB

16K
SLoC

# dvcompute_branch

This crate is a part of discrete event simulation framework DVCompute Simulator (registration
number 2021660590 of Rospatent). The

crate is destined for nested simulation,
but the same code base is shared by the `dvcompute_branch`

crate destined for optimistic
distributed simulation.`dvcompute_dist`

There are the following main crates:

(sequential simulation),
`dvcompute`

(optimistic distributed simulation),
`dvcompute_dist`

(conservative distributed simulation) and
`dvcompute_cons`

(nested simulation). All four crates are
very close. They are based on the same method.`dvcompute_branch`

## Simulation Method

The main idea is to use continuations for modeling discontinuous processes. Such continuations are themselves wrapped in the monad, for which there are easy-to-use combinators. This idea is inspired by two sources: (1) combinators for futures that were in Rust before introducing the async/await syntax and (2) the Aivika simulation library that I developed in Haskell before.

Here is an example that defines a model of the machine that breaks down and then it is repaired:

`const` `UP_TIME_MEAN``:` `f64` `=` `1.``0``;`
`const` `REPAIR_TIME_MEAN``:` `f64` `=` `0.``5``;`
`fn` `machine_process``(``total_up_time``:` `Grc``<`RefComp`<``f64``>``>``)`` ``->` `ProcessBox``<``(``)``>` `{`
`let` total_up_time2 `=` total_up_time`.``clone``(``)``;`
`random_exponential_process``(``UP_TIME_MEAN``)`
`.``and_then``(``move` `|`up_time`|` `{`
`RefComp``::`modify`(`total_up_time`,` `move` `|`total_up_time`|` `{`
total_up_time `+` up_time
`}``)`
`.``into_process``(``)`
`.``and_then``(``move` `|``(``)``|` `{`
`random_exponential_process_``(``REPAIR_TIME_MEAN``)`
`}``)`
`.``and_then``(``move` `|``(``)``|` `{`
`machine_process``(`total_up_time2`)`
`}``)`
`}``)`
`.``into_boxed``(``)`
`}`

These computations are combined with help of the monadic bind. Such computations should be run later to take effect.

## Examples

You can find examples in the author's repository.

## Documentation

## Tutorial

Also you can read the PDF document DVCompute Simulator Tutorial.

## Bibliography

- 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

## Licence

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/.

#### Dependencies

~0–600KB

~10K SLoC