PommaLabs.Dessert 3.2.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This package has a SemVer 2.0.0 package version: 3.2.0+852351c.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package PommaLabs.Dessert --version 3.2.0
NuGet\Install-Package PommaLabs.Dessert -Version 3.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PommaLabs.Dessert" Version="3.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PommaLabs.Dessert --version 3.2.0
#r "nuget: PommaLabs.Dessert, 3.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PommaLabs.Dessert as a Cake Addin
#addin nuget:?package=PommaLabs.Dessert&version=3.2.0

// Install PommaLabs.Dessert as a Cake Tool
#tool nuget:?package=PommaLabs.Dessert&version=3.2.0

Dessert

License: MIT Donate Docs NuGet version NuGet downloads

standard-readme compliant GitLab pipeline status Quality gate Code coverage Renovate enabled

Discrete event simulation (DES) engine heavily based on the paradigm introduced by Simula and SimPy.

The aim of project Dessert is to bring the "powerful simplicity" of the SimPy library to the .NET ecosystem; what we are trying to do is to keep the concepts introduced by SimPy, while offering much better performance, especially for large scale simulations.

Project was developed by Alessio Parma and Giovanni Lagorio. Since we do not have too much manpower and time to invest in this project, our current goals are to maintain a working "clone" of the release 3.0 of SimPy.

For the same reasons, documentation is pretty short: in any case, please refer to our working examples (C#, F#, Visual Basic .NET) to get a better insight of what you can do with Dessert, and how the code really resembles the one you could write with SimPy.

A scientific paper has been written on this project and, if you understand Italian, project development has been documented in a thesis (PDF, slides)

Table of Contents

Install

NuGet package PommaLabs.Dessert is available for download:

dotnet add package PommaLabs.Dessert

Usage

We will start by translating the first example exposed in the SimPy documentation, where we simulate the life of a simple clock. This is the original example:

import simpy

def clock(env, name, tick):
    while True:
        print(name, env.now)
        yield env.timeout(tick)

env = simpy.Environment()
env.process(clock(env, 'fast', 0.5))
env.process(clock(env, 'slow', 1))
env.run(until=2)

And this is its output:

fast 0.0
slow 0.0
fast 0.5
slow 1.0
fast 1.0
fast 1.5

C#

Compared to Python, C# is far more verbose and full of unnecessary characters, like semicolons and brackets. However, we tried to mimic SimPy APIs as well as we could, in order to reduce to the minimum the syntactic "noise" coming from the usage of C#.

Let's see how the clock example gets translated into that language:

using System;
using System.Collections.Generic;
using PommaLabs.Dessert;

static class ClockExample
{
    static IEnumerable<IEvent> Clock(IEnvironment env, string name, double tick)
    {
        while (true) 
        {
            Console.WriteLine("{0} {1:0.0}", name, env.Now);
            yield return env.Timeout(tick);
        }
    }

    static void Run()
    {
        var env = Sim.Environment();
        env.Process(Clock(env, "fast", 0.5));
        env.Process(Clock(env, "slow", 1.0));
        env.Run(until: 2);
    }
}

F#

F#, thanks to a lean syntax and to its functional principles, lets us write code which is considerably shorter than the one written in C# or in Visul Basic .NET. However, there are a few "quirks" caused by the stricter typing, but they do not hamper too much the usage of Dessert.

The following is the translation in F# of the clock example:

open PommaLabs.Dessert

let rec clock(env: IEnvironment, name, tick) = seq<IEvent> { 
    printfn "%s %.1f" name env.Now 
    yield upcast env.Timeout(tick)
    yield! clock(env, name, tick)
}

let run() =
    let env = Sim.Environment() 
    env.Process(clock(env, "fast", 0.5)) |> ignore
    env.Process(clock(env, "slow", 1.0)) |> ignore
    env.Run(until = 2)

Visual Basic .NET

Visual Basic .NET is enormously more verbose than Python and C#, but the original simplicity of SimPy is preserved:

Module ClockExample
    Iterator Function Clock(env As IEnvironment, name As String, tick As Double) _
    As IEnumerable(Of IEvent)
        While True
            Console.WriteLine("{0} {1:0.0}", name, env.Now)
            Yield env.Timeout(tick)
        End While
    End Function

    Sub Run()
        Dim env = Sim.Environment()
        env.Process(Clock(env, "fast", 0.5))
        env.Process(Clock(env, "slow", 1.0))
        env.Run(until:=2)
    End Sub
End Module

Dessert or SimPy?

This question often pops up in messages we receive, so we think its better to answer it here. First of all, let's start with a quick side to side comparison of the two projects:

Dessert SimPy
License MIT MIT
Language C#, F#, Visual Basic .NET Python
Status Working and tested Production ready
Documentation Samples, tests Samples, tests and proper docs
OS Windows, GNU/Linux Windows, GNU/Linux
Performance Fast Can be vastly improved with PyPy
Support Very limited, best effort Not known, never tried

If you need a stable project, documented and maintained, then SimPy is the right choice, at least as of April 2016. When coupled with PyPy, SimPy can offer more than decent performance and its readability is unmatched.

Dessert, on the other hand, is a working project, but, as of April 2016, it has been nearly 30 months since the last "important" commits. Project has received minor fixes during those months, but no work has been done to ensure that functionality is still aligned to the one offered by SimPy. That might, and probably will, happen, but there is not a proper timeline.

Summing up, you can use Dessert for practical purposes, but be prepared to face some issues. Should you find them, please report them through GitHub, so that they will be handled as soon as possible. However, since both maintainers can work on Dessert only during their spare time, answers or fixes might take a few days to be prepared.

Maintainers

@pomma89.

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2012-2021 Alessio Parma

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated