moonsim

A high-performance deterministic discrete-event and multi-agent systems simulation framework in MoonBit

simulation
des
deterministic
systems
queue
moon add wcx789ll/moonsim@0.1.2
Download zip
Author
Version
0.1.2
License
Apache-2.0
Last updated
17 hours ago
Downloads
6
README

#MoonSim

MoonSim is a deterministic discrete-event and distributed-network simulation framework written in MoonBit. It models virtual time, stable event ordering, resource contention, deadlines, packet loss, bandwidth queues, SLA metrics, and trace export.

#Quick start

The repository has no third-party runtime dependency. Install MoonBit CLI, then clone and update the module:

git clone https://github.com/wcx789ll/moonsim.git cd moonsim moon version --all moon update moon check moon test

Runnable scenarios are available under examples/, including examples/acceptance_benchmark.

The benchmark suite uses fixed inputs: 10,000 event callbacks, 2,000 network packets, and 1,000 scheduled jobs. It is intended for regression comparison, not as a claim about physical hardware or public-network performance.

The public API is exposed by the wcx789ll/moonsim module. The root license is Apache License 2.0; see LICENSE and THIRD_PARTY.md for compliance notes. SimPy (MIT) and ns-3 (GNU GPLv2) are reference projects only; no source code from them is included in MoonSim.

#
Simulation

pub(all) struct Simulation {
clock :
Clock

event_manager :
EventManager

// private fields
}

#
Simulation::active_event_count

fn Simulation::active_event_count(self : Simulation) -> Int

#
Simulation::create_network_topology

fn[T] Simulation::create_network_topology(self : Simulation, seed : Int) ->
NetworkTopology
[T]

#
Simulation::create_percentile_tracker

fn Simulation::create_percentile_tracker(self : Simulation, name : String) ->
PercentileTracker

#
Simulation::create_resource

fn Simulation::create_resource(self : Simulation, name : String, capacity : Int) ->
Resource

#
Simulation::create_rolling_summary

fn Simulation::create_rolling_summary(self : Simulation, name : String, window_size : Double) ->
RollingSummary

#
Simulation::create_scheduler

fn Simulation::create_scheduler(self : Simulation, name : String, executors : Int, discipline :
QueueDiscipline
, on_start : (
Job
) -> Unit, on_complete : (
Job
) -> Unit, on_cancel : (
Job
) -> Unit, on_deadline_miss : (
Job
) -> Unit) ->
Scheduler

#
Simulation::create_sla_monitor

fn Simulation::create_sla_monitor(self : Simulation, name : String, threshold : Double) ->
SlaMonitor

#
Simulation::create_summary

fn Simulation::create_summary(self : Simulation, name : String, initial_value : Double) ->
TimeWeightedSummary

#
Simulation::create_tracer

fn Simulation::create_tracer(self : Simulation, name : String) ->
Tracer

#
Simulation::get_resource

fn Simulation::get_resource(self : Simulation, name : String) ->
Resource
?

#
Simulation::get_summary

#
Simulation::new

fn Simulation::new() -> Simulation

#
Simulation::now

fn Simulation::now(self : Simulation) -> Double

#
Simulation::register_process

fn Simulation::register_process(self : Simulation, name : String, steps : Array[(
ProcessContext
) -> Double?]) -> Int

#
Simulation::reset

fn Simulation::reset(self : Simulation) -> Unit

#
Simulation::run

fn Simulation::run(self : Simulation) -> Unit

#
Simulation::run_until

fn Simulation::run_until(self : Simulation, target_seconds : Double) -> Unit

#
Simulation::schedule

fn Simulation::schedule(self : Simulation, delta_seconds : Double, priority : Int, action : () -> Unit) ->
EventId

#
Simulation::schedule_at

fn Simulation::schedule_at(self : Simulation, target_time : Double, priority : Int, action : () -> Unit) ->
EventId

#
Simulation::start_process

fn Simulation::start_process(self : Simulation, proc_id : Int, delay : Double, priority : Int) ->
EventId
?

#
Simulation::step

fn Simulation::step(self : Simulation) -> Bool

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io