{"id":32637368,"url":"https://github.com/heal-research/simsharp","last_synced_at":"2025-10-31T01:56:30.207Z","repository":{"id":15552066,"uuid":"18287119","full_name":"heal-research/SimSharp","owner":"heal-research","description":"Sim# is a .NET port of SimPy, process-based discrete event simulation framework","archived":false,"fork":false,"pushed_at":"2023-06-09T13:45:35.000Z","size":593,"stargazers_count":141,"open_issues_count":6,"forks_count":31,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-08-01T01:37:01.725Z","etag":null,"topics":["c-sharp","discrete-event","simulation"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heal-research.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-31T08:52:04.000Z","updated_at":"2025-07-18T22:32:58.000Z","dependencies_parsed_at":"2024-11-09T22:27:47.148Z","dependency_job_id":null,"html_url":"https://github.com/heal-research/SimSharp","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/heal-research/SimSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heal-research%2FSimSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heal-research%2FSimSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heal-research%2FSimSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heal-research%2FSimSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heal-research","download_url":"https://codeload.github.com/heal-research/SimSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heal-research%2FSimSharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281914557,"owners_count":26583083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","discrete-event","simulation"],"created_at":"2025-10-31T01:56:24.702Z","updated_at":"2025-10-31T01:56:30.193Z","avatar_url":"https://github.com/heal-research.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![SimSharp Logo](docs/SimSharp_s.png)\n\nSim# (SimSharp) is a .NET port and extension of SimPy, process-based discrete event simulation framework\n\n[![Build status](https://ci.appveyor.com/api/projects/status/hyn83qegeiga81o2/branch/master?svg=true)](https://ci.appveyor.com/project/abeham/simsharp/branch/master)\n\n---\n\n*Disclaimer: Sim# is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Sim# is free software: Sim# can be redistributed and/or modified under the terms of the MIT License.*\n\n---\n\nThis is a short introduction, please refer to the [documentation](docs/README.md) for more information on working with Sim# and an overview of the sample models provided.\n\nSim# aims to port the concepts used in SimPy [1] to the .NET world. Sim# is implemented in C# and is available via Nuget for .NET Framework 4.5 and is also .NET Standard 2.0 compliant. Sim# uses an efficient event queue (adapted from [3]) that allows to compute models very quickly. Simulating 10 years of the MachineShop sample [4], that uses preemptive resources, requires less than 1.5s on a Core i7-7 2.7Ghz. This model generates more than 5 million events.\n\nSim# allows modeling processes easily and with little boiler plate code. A process is described as a method that yields events. When an event is yielded, the process waits on it. Processes are themselves events and so it is convenient to spawn sub-processes that can either be waited upon or that run next to each other. There is no need to inherit from classes or understand a complex object oriented design.\n\nTo demonstrate how simple models can be expressed with little code, consider a model of an m/m/1 queuing system as expressed in the current version of Sim#:\n\n```csharp\nusing static SimSharp.Distributions;\n\nExponentialTime ARRIVAL = EXP(TimeSpan.FromSeconds(...));\nExponentialTime PROCESSING = EXP(TimeSpan.FromSeconds(...));\nTimeSpan SIMULATION_TIME = TimeSpan.FromHours(...);\n\nIEnumerable\u003cEvent\u003e MM1Q(Simulation env, Resource server) {\n  while (true) {\n    yield return env.Timeout(ARRIVAL);\n    env.Process(Item(env, server));\n  }\n}\n\nIEnumerable\u003cEvent\u003e Item(Simulation env, Resource server) {\n  using (var s = server.Request()) {\n    yield return s;\n    yield return env.Timeout(PROCESSING);\n    Console.WriteLine(\"Duration {0}\", env.Now - s.Time);\n  }\n}\n\nvoid RunSimulation() {\n  var env = new Simulation(randomSeed: 42);\n  var server = new Resource(env, capacity: 1) {\n    QueueLength = new TimeSeriesMonitor(env, collect: true)\n  };\n  env.Process(MM1Q(env, server));\n  env.Run(SIMULATION_TIME);\n  Console.WriteLine(server.QueueLength.Summarize());\n}\n```\n\nThis model uses the monitoring capabilities introduced with Sim# 3.2. Monitoring allows describing certain variables in the model, e.g. the number of waiting items before the server. The monitor maintains a set of statistical properties such as mean, standard deviation, and can also print histograms. Monitors can be assigned to the variables exposed by resources or they can be used to track other variables.\n\nSim# tries to be as easy to use as SimPy, but also remains true to the .NET Framework. The most obvious difference between SimPy and Sim# is handling process interruptions. In Sim# a process that can be interrupted needs to call\n\n  ```csharp\nif (Environment.ActiveProcess.HandleFault()) {...}\n  ```\n\nafter each yield in which an interruption can occur and before continuing to yield further events. This is due to a limitation of the .NET Framework: In Python it is possible to put a try-except block around a yield statement, and an exception can be injected into the iterator. In .NET this is not possible.\n\nAlso in Sim# it was decided to base the unit for current time and delays on `DateTime` and `TimeSpan` in the simulation clock. There is however an API, called D-API (short for double-API) that allows you to use doubles as in SimPy, e.g. `env.Now` returns a `DateTime`, `env.NowD` returns a `double`, `env.Timeout(delay`) expects a `TimeSpan` as delay, `env.TimeoutD(delay)` expects a `double`, etc.. It is possible to initialize the Environment with a default timestep in case both APIs are used:\n\n  ```csharp\nvar env = new Simulation(defaultStep: TimeSpan.FromMinutes(1));\n  ```\n\nIn that environment, calling `env.TimeoutD(1)` would be equal to calling the more elaborate standard API `env.Timeout(TimeSpan.FromMinutes(1))`. In case timeouts are sampled from a distribution, it is important to distinguish the `TimeoutD(IDistribution\u003cdouble\u003e)`and `Timeout(IDistribution\u003cTimeSpan\u003e)` methods. Again, the former assumes the unit that is given in `defaultStep`, e.g., minutes as in the case above. For instance, `env.TimeoutD(new Exponential(2))` would indicate a mean of 2 minutes in the above environment, while `env.Timeout(new Exponential(TimeSpan.FromMinutes(2))` would always mean two minutes, regardless of the `defaultStep`. In generally, the `TimeSpan` API is preferred as it already expresses time in the appropriate units.\n\nFor shortcuts of the distribution classes a static class `Distributions` exists. You can put `using static SimSharp.Distributions;` in the using declarations and then use those methods without a qualifier. The following code snippet shows this feature.\n\n  ```csharp\nusing static SimSharp.Distributions;\n// ... additional code excluded\nyield return env.TimeoutD(UNIF(10, 20));\n  ```\n\n## References\n\n1. [Python Simpy Package](https://pypi.python.org/pypi/simpy)\n2. [Nuget package](https://www.nuget.org/packages/SimSharp/)\n3. [High speed priority queue](https://github.com/BlueRaja/High-Speed-Priority-Queue-for-C-Sharp)\n4. [Machine Shop Example](src/Samples/MachineShop.cs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheal-research%2Fsimsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheal-research%2Fsimsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheal-research%2Fsimsharp/lists"}