summaryrefslogtreecommitdiff
path: root/opendc-core
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-core')
-rw-r--r--opendc-core/build.gradle8
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Bootstrap.kt64
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt184
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Entity.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Entity.kt)12
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Process.kt27
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Time.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Time.kt)2
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Kernel.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt)57
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/KernelFactory.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt)16
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/platform/Experiment.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/platform/Experiment.kt)18
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt120
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Interrupt.kt32
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt50
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Process.kt51
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt50
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt75
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Receipt.kt53
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt54
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt40
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Clock.kt79
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/TickClock.kt60
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt258
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Component.kt33
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Edge.kt59
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/MutableTopology.kt62
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Topology.kt48
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt40
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyContext.kt48
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyListener.kt61
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt41
29 files changed, 322 insertions, 1380 deletions
diff --git a/opendc-core/build.gradle b/opendc-core/build.gradle
index 92cdb2c4..f1eac0da 100644
--- a/opendc-core/build.gradle
+++ b/opendc-core/build.gradle
@@ -24,7 +24,7 @@
/* Build configuration */
buildscript {
- ext.kotlin_version = '1.1.4-3'
+ ext.kotlin_version = '1.2.10'
ext.dokka_version = '0.9.15'
repositories {
@@ -68,8 +68,8 @@ dokka {
}
/* Project configuration */
-group 'nl.atlarge.opendc'
-version '1.0'
+group 'com.atlarge.opendc'
+version '1.1'
repositories {
jcenter()
@@ -78,7 +78,7 @@ repositories {
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
- compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.18"
+ compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.21"
testCompile "org.junit.jupiter:junit-jupiter-api:5.0.0-RC3"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.0.0-RC3"
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Bootstrap.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Bootstrap.kt
new file mode 100644
index 00000000..199e1701
--- /dev/null
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Bootstrap.kt
@@ -0,0 +1,64 @@
+package com.atlarge.opendc.simulator
+
+/**
+ * A bootstrapping interface for a conceptual model that is a logical representation of some system of entities,
+ * relationships and processes, as a basis for simulations.
+ *
+ * @param M The shape of the model that is bootstrapped.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+interface Bootstrap<M> {
+ /**
+ * Bootstrap a model `M` for a kernel in the given context.
+ *
+ * @param context The context to bootstrap to model in.
+ * @return The initialised model for the simulation.
+ */
+ fun bootstrap(context: Context<M>): M
+
+ /**
+ * A context for the bootstrap of some model type `M` that allows the model to register the entities of the model to
+ * the simulation kernel.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+ interface Context<out M> {
+ /**
+ * Register the given entity to the simulation kernel.
+ *
+ * @param entity The entity to register.
+ * @return `true` if the entity had not yet been registered, `false` otherwise.
+ */
+ fun register(entity: Entity<*, M>): Boolean
+
+ /**
+ * Deregister the given entity from the simulation kernel.
+ *
+ * @param entity The entity to deregister.
+ * @return `true` if the entity had not yet been unregistered, `false` otherwise.
+ */
+ fun deregister(entity: Entity<*, M>): Boolean
+
+ /**
+ * Schedule a message for processing by a [Context].
+ *
+ * @param message The message to schedule.
+ * @param destination The destination of the message.
+ * @param sender The sender of the message.
+ * @param delay The amount of time to wait before processing the message.
+ */
+ fun schedule(message: Any, destination: Entity<*, *>, sender: Entity<*, *>? = null, delay: Duration = 0)
+ }
+
+ companion object {
+ /**
+ * Create a [Bootstrap] procedure using the given block to produce a bootstrap for a model of type `M`.
+ *
+ * @param block The block to produce the bootstrap.
+ * @return The bootstrap procedure that has been built.
+ */
+ fun <M> create(block: (Context<M>) -> M): Bootstrap<M> = object : Bootstrap<M> {
+ override fun bootstrap(context: Context<M>) = block(context)
+ }
+ }
+}
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt
new file mode 100644
index 00000000..c4e906dd
--- /dev/null
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Context.kt
@@ -0,0 +1,184 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 atlarge-research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.atlarge.opendc.simulator
+
+import java.util.Queue
+
+/**
+ * This interface provides a context for simulation of [Entity] instances, by defining the environment in which the
+ * simulation is run and provides means of communicating with other entities in the environment and control its own
+ * behaviour.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+interface Context<S, out M> {
+ /**
+ * The model of simulation in which the entity exists.
+ */
+ val model: M
+
+ /**
+ * The current point in simulation time.
+ */
+ val time: Instant
+
+ /**
+ * The duration between the current point in simulation time and the last point in simulation time where the
+ * [Entity] has done some work. This means the `run()` co-routine has been resumed.
+ */
+ val delta: Duration
+
+ /**
+ * The observable state of the entity bound to this scope.
+ */
+ var state: S
+
+ /**
+ * The observable state of an [Entity] in simulation, which is provided by the simulation context.
+ */
+ val <E : Entity<S, *>, S> E.state: S
+
+ /**
+ * Interrupt an [Entity] process in simulation.
+ *
+ * If an [Entity] process has been suspended, the suspending call will throw an [Interrupt] object as a result of
+ * this call.
+ * Make sure the [Entity] process actually has error handling in place, so it won't take down the whole [Entity]
+ * process as result of the interrupt.
+ */
+ suspend fun Entity<*, *>.interrupt()
+
+ /**
+ * Suspend the [Context] of the [Entity] in simulation for the given duration of simulation time before resuming
+ * execution and drop all messages that are received during this period.
+ *
+ * A call to this method will not make the [Context] sleep for the actual duration of time, but instead suspend
+ * the process until the no more messages at an earlier point in time have to be processed.
+ *
+ * @param duration The duration of simulation time to hold before resuming execution.
+ */
+ suspend fun hold(duration: Duration)
+
+ /**
+ * Suspend the [Context] of the [Entity] in simulation for the given duration of simulation time before resuming
+ * execution and push all messages that are received during this period to the given queue.
+ *
+ * A call to this method will not make the [Context] sleep for the actual duration of time, but instead suspend
+ * the process until the no more messages at an earlier point in time have to be processed.
+ *
+ * @param duration The duration of simulation time to wait before resuming execution.
+ * @param queue The mutable queue to push the messages to.
+ */
+ suspend fun hold(duration: Duration, queue: Queue<Any>)
+
+ /**
+ * Retrieve and remove a single message from the instance's mailbox, suspending the function if the mailbox is
+ * empty. The execution is resumed after the head of the mailbox is removed after which the message [Envelope] is
+ * transformed through `transform` to return the transformed result.
+ *
+ * @param transform The block to transform the message with in an envelope context, providing access to the sender
+ * of the message.
+ * @return The transformed message.
+ */
+ suspend fun <T> receive(transform: suspend Envelope<*>.(Any) -> T): T
+
+ /**
+ * Retrieve and remove a single message from the instance's mailbox, suspending the function if the mailbox is
+ * empty. The execution is either resumed after the head of the mailbox is removed after which the message
+ * [Envelope] is transformed through `transform` to return the transformed result or the timeout has been reached.
+ *
+ * @param timeout The duration to wait before resuming execution.
+ * @param transform The block to transform the message with in an envelope context, providing access to the sender
+ * of the message.
+ * @return The processed message or `null` if the timeout was reached.
+ */
+ suspend fun <T> receive(timeout: Duration, transform: suspend Envelope<*>.(Any) -> T): T?
+
+ /**
+ * Retrieve and remove a single message from the instance's mailbox, suspending the function if the mailbox is
+ * empty. The execution is resumed after the head of the mailbox is removed and returned.
+ *
+ * @return The received message.
+ */
+ suspend fun receive(): Any = receive { it }
+
+ /**
+ * Retrieve and remove a single message from the instance's mailbox, suspending the function if the mailbox is
+ * empty. The execution is either resumed after the head of the mailbox is removed and returned or when the timeout
+ * has been reached.
+ *
+ * @return The received message or `null` if the timeout was reached.
+ */
+ suspend fun receive(timeout: Duration): Any? = receive(timeout) { it }
+
+ /**
+ * Send the given message to the specified entity, without providing any guarantees about the actual delivery of
+ * the message.
+ *
+ * @param msg The message to send.
+ * @param delay The amount of time to wait before the message should be received by the entity.
+ */
+ suspend fun Entity<*, *>.send(msg: Any, delay: Duration = 0)
+
+ /**
+ * Send the given message to the specified entity, without providing any guarantees about the actual delivery of
+ * the message.
+ *
+ * @param msg The message to send.
+ * @param sender The sender of the message.
+ * @param delay The amount of time to wait before the message should be received by the entity.
+ */
+ suspend fun Entity<*, *>.send(msg: Any, sender: Entity<*, *>, delay: Duration = 0)
+}
+
+/**
+ * The message envelope that is sent to an [Entity], also containing the metadata of the message.
+ *
+ * @param T The shape of the message inside the envelope.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+interface Envelope<out T: Any> {
+ /**
+ * The message in this envelope.
+ */
+ val message: T
+
+ /**
+ * The sender of the message.
+ */
+ val sender: Entity<*, *>?
+
+ /**
+ * The destination of the message.
+ */
+ val destination: Entity<*, *>
+}
+
+/**
+ * An [Interrupt] message is sent to a [Entity] process in order to interrupt its suspended state.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+object Interrupt: Throwable("The entity process has been interrupted by another entity")
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Entity.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Entity.kt
index 66a31d77..800f2f1d 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Entity.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Entity.kt
@@ -22,21 +22,21 @@
* SOFTWARE.
*/
-package nl.atlarge.opendc.topology
+package com.atlarge.opendc.simulator
/**
- * An entity within a cloud network, represented as a node within a topology.
+ * An entity in some model `M`.
*
- * <p>A [Entity] contains immutable properties given by the topology configuration at the start of a simulation and
- * remain unchanged during simulation.
+ * <p>A [Entity] directly contains its immutable properties that remain unchanged during simulation.
*
- * <p>In addition, other entities in a simulation have direct, immutable access to the observable state of this entity.
+ * <p>In addition, other entities in simulation have direct, immutable access to the observable state of this entity.
*
* @param S The shape of the observable state of this entity, which is directly accessible by other components within
* a simulation.
+ * @param M The shape of the model in which the entity exists.
* @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
*/
-interface Entity<out S> : Component {
+interface Entity<out S, in M> {
/**
* The initial state of the entity.
*/
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Process.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Process.kt
new file mode 100644
index 00000000..30280657
--- /dev/null
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Process.kt
@@ -0,0 +1,27 @@
+package com.atlarge.opendc.simulator
+
+/**
+ * A process is dynamic entity within a simulation, that interacts with the model environment by the interchange of
+ * messages.
+ *
+ * @param S The shape of the observable state of the process.
+ * @param M The shape of the model in which the process exists.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+interface Process<S, in M>: Entity<S, M> {
+ /**
+ * This method is invoked to start the simulation a process.
+ *
+ * This method is assumed to be running during a simulation, but should hand back control to the simulator at
+ * some point by suspending the process. This allows other processes to do work at the current point in time of the
+ * simulation.
+ * Suspending the process can be achieved by calling suspending method in the context:
+ * - [Context.hold] - Hold for `n` units of time before resuming execution.
+ * - [Context.receive] - Wait for a message to be received in the mailbox of the [Entity] before resuming
+ * execution.
+ *
+ * If this method exits early, before the simulation has finished, the entity is assumed to be shutdown and its
+ * simulation will not run any further.
+ */
+ suspend fun Context<S, M>.run()
+}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Time.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Time.kt
index af9d547b..64e3cb80 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Time.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/Time.kt
@@ -22,7 +22,7 @@
* SOFTWARE.
*/
-package nl.atlarge.opendc.kernel.time
+package com.atlarge.opendc.simulator
/**
* An instantaneous point on the time-line, used to record event time-stamps in a simulation.
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Kernel.kt
index d07c3ba0..3eee0f67 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/Kernel.kt
@@ -22,49 +22,39 @@
* SOFTWARE.
*/
-package nl.atlarge.opendc.kernel
+package com.atlarge.opendc.simulator.kernel
-import nl.atlarge.opendc.kernel.messaging.Receipt
-import nl.atlarge.opendc.kernel.time.Clock
-import nl.atlarge.opendc.kernel.time.Duration
-import nl.atlarge.opendc.kernel.time.Instant
-import nl.atlarge.opendc.topology.Entity
-import nl.atlarge.opendc.topology.Topology
-import java.lang.Process
+import com.atlarge.opendc.simulator.Bootstrap
+import com.atlarge.opendc.simulator.Instant
+import com.atlarge.opendc.simulator.Entity
/**
- * A message based discrete event simulation facilitated by a simulation [Kernel].
+ * A message based discrete event simulation kernel.
*
- * In order for the simulation to run, the simulation kernel needs to bootstrapped by an set of messages to be processed
- * initially by entities in the topology of the simulation. Otherwise, the simulation will immediately exit.
- * Bootstrapping can be achieved by scheduling messages before running the simulation via [Simulation.schedule]:
+ * The kernel is created by bootstrapping some model `M` (see [Bootstrap]) to simulate and controls the simulation by
+ * allowing the user to step over cycles in the simulation and inspect the internal state using [Entity.state].
*
- * `val simulation = kernel.create(topology).apply {
- * schedule(Boot, entity)
- * }`
+ * A kernel should provide additionally a [KernelFactory] to create new kernel instances given a certain model
+ * [Bootstrap].
*
+ * @param M The shape of the model over which the simulation runs.
* @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
*/
-interface Simulation {
+interface Kernel<out M> {
/**
- * The [Kernel] that facilitates the simulation.
+ * The model in which the simulation runs.
*/
- val kernel: Kernel
+ val model: M
/**
- * The [Topology] over which the simulation is run.
+ * The simulation time.
*/
- val topology: Topology
-
- /**
- * The [Clock] instance that keeps track of simulation time.
- */
- val clock: Clock
+ var time: Instant
/**
* The observable state of an [Entity] in simulation, which is provided by the simulation context.
*/
- val <E : Entity<S>, S> E.state: S
+ val <E : Entity<S, *>, S> E.state: S
/**
* Step through one cycle in the simulation. This method will process all events in a single tick, update the
@@ -73,28 +63,17 @@ interface Simulation {
fun step()
/**
- * Run a simulation over the specified [Topology].
+ * Run a simulation over the specified model.
* This method will step through multiple cycles in the simulation until no more message exist in the queue.
*/
fun run()
/**
- * Run a simulation over the specified [Topology], stepping through cycles until the specified clock tick has
+ * Run a simulation over the specified model, stepping through cycles until the specified clock tick has
* occurred. The control is then handed back to the user.
*
* @param until The point in simulation time at which the simulation should be paused and the control is handed
* back to the user.
*/
fun run(until: Instant)
-
- /**
- * Schedule a message for processing by a [Process].
- *
- * @param message The message to schedule.
- * @param destination The destination of the message.
- * @param sender The sender of the message.
- * @param delay The amount of time to wait before processing the message.
- * @return A [Receipt] of the message that has been scheduled.
- */
- fun schedule(message: Any, destination: Entity<*>, sender: Entity<*>? = null, delay: Duration = 0): Receipt
}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/KernelFactory.kt
index 42b30a94..93667eb8 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/kernel/KernelFactory.kt
@@ -22,19 +22,21 @@
* SOFTWARE.
*/
-package nl.atlarge.opendc.topology
+package com.atlarge.opendc.simulator.kernel
+
+import com.atlarge.opendc.simulator.Bootstrap
/**
- * An interface for producing [Topology] instances. Implementors of this interface provide a way of generating a
- * topology based on the state of the factory.
+ * A factory for bootstrapping simulation [Kernel] instances.
*
* @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
*/
-interface TopologyFactory {
+interface KernelFactory {
/**
- * Create a [MutableTopology] instance.
+ * Create a simulation over the given model facilitated by this simulation kernel.
*
- * @return A mutable topology.
+ * @param bootstrap The bootstrap procedure to bootstrap the simulation with.
+ * @return A [Kernel] instance to control the simulation.
*/
- fun create(): MutableTopology
+ fun <M> create(bootstrap: Bootstrap<M>): Kernel<M>
}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/platform/Experiment.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/platform/Experiment.kt
index 6aed5364..88b606fd 100644
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/platform/Experiment.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/platform/Experiment.kt
@@ -22,10 +22,10 @@
* SOFTWARE.
*/
-package nl.atlarge.opendc.platform
+package com.atlarge.opendc.simulator.platform
-import nl.atlarge.opendc.kernel.Kernel
-import nl.atlarge.opendc.kernel.time.Duration
+import com.atlarge.opendc.simulator.kernel.KernelFactory
+import com.atlarge.opendc.simulator.Duration
/**
* A blueprint for a reproducible simulation in a pre-defined setting.
@@ -34,19 +34,19 @@ import nl.atlarge.opendc.kernel.time.Duration
*/
interface Experiment<out T> {
/**
- * Run the experiment on the specified simulation [Kernel].
+ * Run the experiment on the specified kernel implementation.
*
- * @param kernel The simulation kernel to run the experiment.
+ * @param factory The factory to create the simulation kernel with.
* @return The result of the experiment.
*/
- fun run(kernel: Kernel): T
+ fun run(factory: KernelFactory): T
/**
- * Run the experiment on the specified simulation [Kernel].
+ * Run the experiment on the specified kernel implementation.
*
- * @param kernel The simulation kernel to run the experiment.
+ * @param factory The factory to create the simulation kernel with.
* @param timeout The maximum duration of the experiment before returning to the caller.
* @return The result of the experiment or `null`.
*/
- fun run(kernel: Kernel, timeout: Duration): T?
+ fun run(factory: KernelFactory, timeout: Duration): T?
}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt
deleted file mode 100644
index 83a7c4fb..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel
-
-import nl.atlarge.opendc.kernel.messaging.Readable
-import nl.atlarge.opendc.kernel.messaging.Writable
-import nl.atlarge.opendc.kernel.time.Clock
-import nl.atlarge.opendc.kernel.time.Duration
-import nl.atlarge.opendc.kernel.time.Instant
-import nl.atlarge.opendc.topology.Entity
-import nl.atlarge.opendc.topology.MutableTopology
-import nl.atlarge.opendc.topology.Topology
-import nl.atlarge.opendc.topology.TopologyContext
-import java.lang.Process
-import java.util.*
-
-/**
- * This interface provides a context for simulation [Process]es, which defines the environment in which the simulation
- * is run and provides means of communicating with other entities in the environment and control its own behaviour.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Context<out E : Entity<*>> : Readable, Writable, TopologyContext {
- /**
- * The [Entity] in simulation by the [Process].
- */
- val entity: E
-
- /**
- * The [Topology] over which the simulation is run.
- */
- val topology: MutableTopology
-
- /**
- * The current point in simulation time.
- */
- val time: Instant
-
- /**
- * The duration between the current point in simulation time and the last point in simulation time where the
- * [Process] has executed some work. This means the `run()` co-routine has been resumed.
- */
- val delta: Duration
-
- /**
- * The observable state of an [Entity] in simulation, which is provided by the simulation context.
- */
- val <E : Entity<S>, S> E.state: S
-
- /**
- * Update the observable state of the entity being simulated.
- *
- * Instead of directly mutating the entity, we create a new instance of the entity to prevent other objects
- * referencing the old entity having their data changed.
- *
- * @param next The next state of the entity.
- */
- suspend fun <C : Context<E>, E : Entity<S>, S> C.update(next: S)
-
- /**
- * Interrupt the [Process] of an [Entity] in simulation.
- *
- * If a [Process] has been suspended, the suspending call will throw an [Interrupt] object as a result of this call.
- * Make sure the [Process] actually has error handling in place, so it won't take down the whole [Process].
- */
- suspend fun Entity<*>.interrupt()
-
- /**
- * Suspend the [Process] of the [Entity] in simulation for the given duration of simulation time before resuming
- * execution and drop all messages that are received during this period.
- *
- * A call to this method will not make the [Process] sleep for the actual duration of time, but instead suspend
- * the process until the no more messages at an earlier point in time have to be processed.
- *
- * @param duration The duration of simulation time to wait before resuming execution.
- */
- suspend fun wait(duration: Duration)
-
- /**
- * Suspend the [Process] of the [Entity] in simulation for the given duration of simulation time before resuming
- * execution and push all messages that are received during this period to the given queue.
- *
- * A call to this method will not make the [Process] sleep for the actual duration of time, but instead suspend
- * the process until the no more messages at an earlier point in time have to be processed.
- *
- * @param duration The duration of simulation time to wait before resuming execution.
- * @param queue The mutable queue to push the messages to.
- */
- suspend fun wait(duration: Duration, queue: Queue<Any>)
-
- /**
- * Suspend the [Process] of the [Entity] in simulation for one tick in simulation time which is defined by the
- * [Clock].
- *
- * @return `true` to allow usage in while statements.
- */
- suspend fun tick(): Boolean
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Interrupt.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Interrupt.kt
deleted file mode 100644
index de7c5c6c..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Interrupt.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel
-
-/**
- * An [Interrupt] message is sent to a [Process] in order to interrupt its suspended state.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-object Interrupt: Throwable("The process has been interrupted by another entity")
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt
deleted file mode 100644
index ffb6299c..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel
-
-import nl.atlarge.opendc.topology.MutableTopology
-import nl.atlarge.opendc.topology.Topology
-
-/**
- * A message-based discrete event simulator (DES). This interface allows running simulations over a [Topology].
- * This discrete event simulator works by having entities in a [Topology] interchange messages between each other and
- * updating their observable state accordingly.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Kernel {
- /**
- * The name of the kernel.
- */
- val name: String
-
- /**
- * Create a new [Simulation] of the given [Topology] that is facilitated by this simulation kernel.
- *
- * @param topology The [Topology] to create a [Simulation] of.
- * @return A [Simulation] instance.
- */
- fun create(topology: MutableTopology): Simulation
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Process.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Process.kt
deleted file mode 100644
index 40fbefbf..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Process.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel
-
-import nl.atlarge.opendc.topology.Entity
-
-/**
- * A [Process] defines the behaviour of an [Entity] within simulation.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Process<in E : Entity<*>> {
- /**
- * This method is invoked to start the simulation an [Entity] associated with this [Process].
- *
- * This method is assumed to be running during a simulation, but should hand back control to the simulator at
- * some point by suspending the process. This allows other processes to do work in the current tick of the
- * simulation.
- * Suspending the process can be achieved by calling suspending method in the context:
- * - [Context.tick] - Wait for the next tick to occur
- * - [Context.wait] - Wait for `n` amount of ticks before resuming execution.
- * - [Context.receive] - Wait for a message to be received in the mailbox of the [Entity] before resuming
- * execution.
- *
- * If this method exits early, before the simulation has finished, the entity is assumed to be shutdown and its
- * simulation will not run any further.
- */
- suspend fun Context<E>.run()
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt
deleted file mode 100644
index 608d325f..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.messaging
-
-import nl.atlarge.opendc.topology.Entity
-
-/**
- * The envelope of a message that is sent to an [Entity], also containing the metadata of the message.
- *
- * @param T The shape of the message inside the envelope.
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Envelope<out T: Any> {
- /**
- * The message in this envelope.
- */
- val message: T
-
- /**
- * The sender of the message.
- */
- val sender: Entity<*>?
-
- /**
- * The destination of the message.
- */
- val destination: Entity<*>
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt
deleted file mode 100644
index 398e9697..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.messaging
-
-import nl.atlarge.opendc.kernel.time.Duration
-
-
-/**
- * A [Readable] instance has a mailbox associated with the instance to which objects can send messages, which can be
- * received by the class.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Readable {
- /**
- * Retrieve and removes a single message from the entity's mailbox, suspending the function if the mailbox is empty.
- * The execution is resumed after the message has landed in the entity's mailbox after which the message [Envelope]
- * is mapped through `block` to generate a processed message.
- *
- * @param block The block to process the message with.
- * @return The processed message.
- */
- suspend fun <T> receive(block: suspend Envelope<*>.(Any) -> T): T
-
- /**
- * Retrieve and removes a single message from the entity's mailbox, suspending the function if the mailbox is empty.
- * The execution is resumed after the message has landed in the entity's mailbox or the timeout was reached,
- *
- * If the message has been received, the message [Envelope] is mapped through `block` to generate a processed
- * message. If the timeout was reached, `block` is not called and `null` is returned.
- *
- * @param timeout The duration to wait before resuming execution.
- * @param block The block to process the message with.
- * @return The processed message or `null` if the timeout was reached.
- */
- suspend fun <T> receive(timeout: Duration, block: suspend Envelope<*>.(Any) -> T): T?
-
- /**
- * Retrieve and removes a single message from the entity's mailbox, suspending the function until a message has
- * landed in the entity's mailbox.
- *
- * @return The message that was received from the entity's mailbox.
- */
- suspend fun receive(): Any = receive { it }
-
- /**
- * Retrieve and removes a single message from the entity's mailbox, suspending the function until a message has
- * landed in the entity's mailbox or the timeout has been reached.
- *
- * @return The message that was received from the entity's mailbox or `null` if the timeout was reached.
- */
- suspend fun receive(timeout: Duration): Any? = receive(timeout) { it }
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Receipt.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Receipt.kt
deleted file mode 100644
index 74433f5e..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Receipt.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.messaging
-
-import nl.atlarge.opendc.kernel.Kernel
-import nl.atlarge.opendc.topology.Entity
-
-/**
- * A receipt of a message that has been scheduled by a simulation [Kernel]. This interface allows the cancellation of a
- * message that has been scheduled for delivery and for checking the status of a delivery.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Receipt {
- /**
- * A flag to indicate the message has been canceled.
- */
- val canceled: Boolean
-
- /**
- * A flag to indicate the message has been delivered.
- */
- val delivered: Boolean
-
- /**
- * Cancel the message to prevent it from being received by an [Entity].
- *
- * @throws IllegalStateException if the message has already been delivered.
- */
- fun cancel()
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt
deleted file mode 100644
index 0d2b2725..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.messaging
-
-import nl.atlarge.opendc.kernel.time.Duration
-import nl.atlarge.opendc.topology.Entity
-
-/**
- * A [Writable] instance allows entities to send messages.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Writable {
- /**
- * Send the given message to the specified entity.
- *
- * @param msg The message to send.
- * @param delay The amount of time to wait before the message should be received.
- * @return A [Receipt] of the message that has been sent.
- */
- suspend fun Entity<*>.send(msg: Any, delay: Duration = 0): Receipt
-
- /**
- * Send the given message to the specified entity.
- *
- * @param msg The message to send.
- * @param sender The sender of the message.
- * @param delay The amount of time to wait before the message should be received.
- * @return A [Receipt] of the message that has been sent.
- */
- suspend fun Entity<*>.send(msg: Any, sender: Entity<*>, delay: Duration = 0): Receipt
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt
deleted file mode 100644
index 66c33341..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.sampler
-
-/**
- * A sampler generates data points (samples) of the simulation based on the events that occur to [Entity] instances that
- * are part of the simulation.
- *
- * <p>[Sampler]s work by observing [Entity] instances in the simulation and transforming this stream of events into a
- * stream of data points.
- *
- * <p>An example would be a sampler that tracks [Machine] occupation per time unit, which is achieved by observing the
- * [Entity]'s event stream and filtering for [JobAssignment] events.
- *
- * @param <T> The data type of result generated by this sampler.
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Sampler<out T>
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Clock.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Clock.kt
deleted file mode 100644
index f03a98fa..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/Clock.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.time
-
-import nl.atlarge.opendc.kernel.Simulation
-
-/**
- * A clock controls and provides access to the simulation time of a [Simulation].
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Clock {
- /**
- * The moment in time the clock is currently at.
- */
- val now: Instant
-
- /**
- * The duration of a tick in this clock. This is an arbitrary duration of time in which entities in simulation
- * perform some defined amount of work.
- */
- val tick: Duration
-
- /**
- * Advance the clock by the given duration.
- *
- * @param duration The duration to advance the clock by.
- */
- fun advance(duration: Duration) {
- require(duration >= 0) { "The duration to advance the clock must not be a negative number" }
- advanceTo(now + duration)
- }
-
- /**
- * Rewind the clock by the given duration.
- *
- * @param duration The duration to rewind the clock by.
- */
- fun rewind(duration: Duration) {
- require(duration >= 0) { "The duration to rewind the clock must not be a negative number" }
- rewindTo(now - duration)
- }
-
- /**
- * Rewind the clock to the given point in time.
- *
- * @param instant The point in time to rewind the clock to.
- */
- fun rewindTo(instant: Instant)
-
- /**
- * Advance the clock to the given point in time.
- *
- * @param instant The point in time to advance the clock to.
- */
- fun advanceTo(instant: Instant)
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/TickClock.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/TickClock.kt
deleted file mode 100644
index d960f454..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/time/TickClock.kt
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.kernel.time
-
-/**
- * A tick based clock which divides time into a discrete interval of points.
- *
- * @param initial The initial point in time of the clock.
- * @param tick The duration of a tick.
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-class TickClock(initial: Instant = 0, override val tick: Duration = 1) : Clock {
- /**
- * The moment in time the clock is currently at.
- */
- override var now: Instant = initial
- private set
-
- /**
- * Advance the clock to the given point in time.
- *
- * @param instant The moment in time to advance the clock to.
- */
- override fun advanceTo(instant: Instant) {
- require(instant >= now) { "The point to advance to must be at the same point or further than now" }
- now = instant
- }
-
- /**
- * Rewind the clock to the given point in time.
- *
- * @param instant The point in time to rewind the clock to.
- */
- override fun rewindTo(instant: Instant) {
- require(now >= instant) { "The point to rewind to must be before the current point in time" }
- now = instant
- }
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt
deleted file mode 100644
index 74b046de..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-import nl.atlarge.opendc.topology.Edge as BaseEdge
-import java.util.concurrent.atomic.AtomicInteger
-
-/**
- * This module provides a [Topology] implementation backed internally by an adjacency list.
- *
- * This implementation is best suited for sparse graphs, where an adjacency matrix would take up too much space with
- * empty cells.
- *
- * *Note that this implementation is not synchronized.*
- */
-object AdjacencyList {
- /**
- * Return a [TopologyBuilder] that constructs the topology represents as an adjacency list.
- *
- * @return A [TopologyBuilder] instance.
- */
- fun builder(): TopologyBuilder = AdjacencyListTopologyBuilder()
-}
-
-/**
- * A builder for [Topology] instances, which is backed by an adjacency list.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-internal class AdjacencyListTopologyBuilder : TopologyBuilder {
- /**
- * Build a [Topology] instance from the current state of this builder.
- *
- * @return The graph built from this builder.
- */
- override fun create(): MutableTopology = AdjacencyListTopology()
-}
-
-/**
- * A [Topology] whose graph is represented as adjacency list.
- */
-internal class AdjacencyListTopology : MutableTopology {
- /**
- * The identifier for the next node in the graph.
- */
- private var nextId: AtomicInteger = AtomicInteger(0)
-
- /**
- * A mapping of nodes to their internal representation with the edges of the nodes.
- */
- private var nodes: MutableMap<Entity<*>, Node> = HashMap()
-
- // Topology
-
- /**
- * The listeners of this topology.
- */
- override val listeners: MutableSet<TopologyListener> = HashSet()
-
- /**
- * A unique identifier of this node within the topology.
- */
- override val Entity<*>.id: Int
- get() = nodes[this]!!.id
-
- /**
- * The set of ingoing edges of this node.
- */
- override val Entity<*>.ingoingEdges: MutableSet<BaseEdge<*>>
- get() = nodes[this]!!.ingoingEdges
-
- /**
- * The set of outgoing edges of this node.
- */
- override val Entity<*>.outgoingEdges: MutableSet<BaseEdge<*>>
- get() = nodes[this]!!.outgoingEdges
-
- // MutableTopology
-
- /**
- * Create a directed edge between two [Node]s in the topology.
- *
- * @param from The source of the edge.
- * @param to The destination of the edge.
- * @param label The label of the edge.
- * @param tag The tag of the edge that uniquely identifies the relationship the edge represents.
- * @return The edge that has been created.
- */
- override fun <T> connect(from: Entity<*>, to: Entity<*>, label: T, tag: String?): BaseEdge<T> {
- if (!contains(from) || !contains(to))
- throw IllegalArgumentException("One of the entities is not part of the topology")
- val edge = Edge(label, tag, from, to)
- from.outgoingEdges.add(edge)
- to.ingoingEdges.add(edge)
- listeners.forEach { it.run { this@AdjacencyListTopology.onEdgeAdded(edge) } }
- return edge
- }
-
- // Cloneable
-
- /**
- * Create a copy of the graph.
- *
- * @return A new [Topology] instance with a copy of the graph.
- */
- override public fun clone(): Topology {
- val copy = AdjacencyListTopology()
- copy.nextId = AtomicInteger(nextId.get())
- copy.nodes = HashMap(nodes)
- return copy
- }
-
- // Set
-
- /**
- * Returns the size of the collection.
- */
- override val size: Int = nodes.size
-
- /**
- * Checks if the specified element is contained in this collection.
- */
- override fun contains(element: Entity<*>): Boolean = nodes.contains(element)
-
- /**
- * Checks if all elements in the specified collection are contained in this collection.
- */
- override fun containsAll(elements: Collection<Entity<*>>): Boolean = elements.all { nodes.containsKey(it) }
-
- /**
- * Returns `true` if the collection is empty (contains no elements), `false` otherwise.
- */
- override fun isEmpty(): Boolean = nodes.isEmpty()
-
- // MutableSet
-
- /**
- * Add a node to the graph.
- *
- * @param element The element to add to this graph.
- * @return `true` if the graph has changed, `false` otherwise.
- */
- override fun add(element: Entity<*>): Boolean {
- if (nodes.putIfAbsent(element, Node(nextId.getAndIncrement())) == null) {
- listeners.forEach { it.run { this@AdjacencyListTopology.onNodeAdded(element) } }
- return true
- }
- return false
- }
-
- /**
- * Add all nodes in the specified collection to the graph.
- *
- * @param elements The nodes to add to this graph.
- * @return `true` if the graph has changed, `false` otherwise.
- */
- override fun addAll(elements: Collection<Entity<*>>): Boolean = elements.any { add(it) }
-
- /**
- * Remove all nodes and their respective edges from the graph.
- */
- override fun clear() = nodes.clear()
-
- /**
- * Remove the given node and its edges from the graph.
- *
- * @param element The element to remove from the graph.
- * @return `true` if the graph has changed, `false` otherwise.
- */
- override fun remove(element: Entity<*>): Boolean {
- nodes[element]?.ingoingEdges?.forEach {
- it.from.outgoingEdges.remove(it)
- }
- nodes[element]?.outgoingEdges?.forEach {
- it.to.ingoingEdges.remove(it)
- }
- if (nodes.keys.remove(element)) {
- listeners.forEach { it.run { this@AdjacencyListTopology.onNodeRemoved(element) } }
- return true
- }
- return false
- }
-
-
- /**
- * Remove all nodes in the given collection from the graph.
- *
- * @param elements The elements to remove from the graph.
- * @return `true` if the graph has changed, `false` otherwise.
- */
- override fun removeAll(elements: Collection<Entity<*>>): Boolean = elements.any(this::remove)
-
- /**
- * Remove all nodes in the graph, except those in the specified collection.
- *
- * Take note that this method currently only guarantees a maximum runtime complexity of O(n^2).
- *
- * @param elements The elements to retain in the graph.
- */
- override fun retainAll(elements: Collection<Entity<*>>): Boolean {
- val iterator = nodes.keys.iterator()
- var changed = false
- while (iterator.hasNext()) {
- val entity = iterator.next()
-
- if (entity !in elements) {
- iterator.remove()
- changed = true
- }
- }
- return changed
- }
-
- /**
- * Return a mutable iterator over the nodes of the graph.
- *
- * @return A [MutableIterator] over the nodes of the graph.
- */
- override fun iterator(): MutableIterator<Entity<*>> = nodes.keys.iterator()
-
- /**
- * The internal representation of a node within the graph.
- */
- internal data class Node(val id: Int) {
- val ingoingEdges: MutableSet<BaseEdge<*>> = HashSet()
- val outgoingEdges: MutableSet<BaseEdge<*>> = HashSet()
- }
-
- /**
- * The internal representation of an edge within the graph.
- */
- internal class Edge<out T>(override val label: T,
- override val tag: String?,
- override val from: Entity<*>,
- override val to: Entity<*>) : BaseEdge<T>
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Component.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Component.kt
deleted file mode 100644
index 3c383892..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Component.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * A component within a [Topology], which is either a node or an [Edge] representing the relationship between
- * entities within a logical topology of a cloud network.
- **
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Component
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Edge.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Edge.kt
deleted file mode 100644
index 3be14dec..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Edge.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * An edge that represents a directed relationship between exactly two nodes in a logical topology of a cloud network.
- *
- * @param T The relationship type the edge represents within a logical topology.
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Edge<out T> : Component {
- /**
- * The label of this edge.
- */
- val label: T
-
- /**
- * A tag to uniquely identify the relationship this edge represents.
- */
- val tag: String?
-
- /**
- * The source of the edge.
- *
- * This property is not guaranteed to have a runtime complexity of <code>O(1)</code>, but must be at least
- * <code>O(n)</code>, with respect to the size of the topology.
- */
- val from: Entity<*>
-
- /**
- * The destination of the edge.
- *
- * This property is not guaranteed to have a runtime complexity of <code>O(1)</code>, but must be at least
- * <code>O(n)</code>, with respect to the size of the topology.
- */
- val to: Entity<*>
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/MutableTopology.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/MutableTopology.kt
deleted file mode 100644
index 10a55e5b..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/MutableTopology.kt
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * A subinterface of [Topology] which adds mutation methods. When mutation is not required, users
- * should prefer the [Topology] interface.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface MutableTopology : Topology, MutableSet<Entity<*>> {
- /**
- * Create a directed, labeled edge between two nodes in the topology.
- *
- * @param from The source of the edge.
- * @param to The destination of the edge.
- * @param label The label of the edge.
- * @param tag The tag of the edge that uniquely identifies the relationship the edge represents.
- * @return The edge that has been created.
- */
- fun <T> connect(from: Entity<*>, to: Entity<*>, label: T, tag: String? = null): Edge<T>
-
- /**
- * Create a directed, unlabeled edge between two nodes in the topology.
- *
- * @param from The source of the edge.
- * @param to The destination of the edge.
- * @param tag The tag of the edge that uniquely identifies the relationship the edge represents.
- * @return The edge that has been created.
- */
- fun connect(from: Entity<*>, to: Entity<*>, tag: String? = null): Edge<Unit> = connect(from, to, Unit, tag)
-
- /**
- * Create a directed, unlabeled edge between two nodes in the topology.
- *
- * @param dest The destination of the edge.
- * @return The edge that has been created.
- */
- infix fun Entity<*>.to(dest: Entity<*>): Edge<Unit> = connect(this, dest)
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Topology.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Topology.kt
deleted file mode 100644
index 27c1c889..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Topology.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * A graph data structure which represents the logical topology of a cloud network consisting of one or more
- * datacenters.
- *
- * A topology is [Iterable] and allows implementation-dependent iteration of the nodes in the topology.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface Topology : TopologyContext, Cloneable, Set<Entity<*>> {
- /**
- * The listeners of this topology.
- */
- val listeners: MutableSet<TopologyListener>
-
- /**
- * Create a copy of the topology.
- *
- * @return A new [Topology] with a copy of the graph.
- */
- public override fun clone(): Topology
-}
-
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt
deleted file mode 100644
index bb9c7e8e..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * A builder for [Topology] instances.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface TopologyBuilder : TopologyFactory {
- /**
- * Construct a [Topology] from the given block and return it.
- *
- * @param block The block to construct the topology.
- * @return The topology that has been built.
- */
- fun construct(block: MutableTopology.() -> Unit): MutableTopology = create().apply(block)
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyContext.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyContext.kt
deleted file mode 100644
index 22e7dd94..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyContext.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * A [TopologyContext] represents the context for entities in a specific topology, providing access to the identifier
- * and ingoing and outgoing edges of the [Entity] within a [Topology].
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface TopologyContext {
- /**
- * A unique identifier of an [Entity] within the topology.
- */
- val Entity<*>.id: Int
-
- /**
- * The set of ingoing edges of an [Entity].
- */
- val Entity<*>.ingoingEdges: Set<Edge<*>>
-
- /**
- * The set of outgoing edges of an [Entity].
- */
- val Entity<*>.outgoingEdges: Set<Edge<*>>
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyListener.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyListener.kt
deleted file mode 100644
index b5062709..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyListener.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology;
-
-/**
- * A listener interface for [Topology] instances. The methods of this interface are invoked on
- * mutation of the topology the listener is listening to.
- *
- * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
- */
-interface TopologyListener {
- /**
- * This method is invoked when an [Entity] is added to the [Topology].
- *
- * @param node The entity that has been added to the [Topology].
- */
- fun Topology.onNodeAdded(node: Entity<*>) {}
-
- /**
- * This method is invoked when an [Entity] is removed from the [Topology].
- *
- * @param node The entity that has been removed from the [Topology].
- */
- fun Topology.onNodeRemoved(node: Entity<*>) {}
-
- /**
- * This method is invoked when an [Edge] is added to the [Topology].
- *
- * @param edge The edge that has been added to the [Topology].
- */
- fun Topology.onEdgeAdded(edge: Edge<*>) {}
-
- /**
- * This method is invoked when an [Edge] is removed from the [Topology].
- *
- * @param edge The entity that has been removed from the [Topology].
- */
- fun Topology.onEdgeRemoved(edge: Edge<*>) {}
-}
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt
deleted file mode 100644
index e57060ed..00000000
--- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 atlarge-research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package nl.atlarge.opendc.topology
-
-/**
- * Filter a [Set] of [Edge]s based on the tag of the edges and return the origin nodes casted to type `T`.
- *
- * @param tag The tag of the edges to get.
- * @return An [Iterable] of the specified type `T` with the given tag.
- */
-inline fun <reified T> Set<Edge<*>>.origins(tag: String) = filter { it.tag == tag }.map { it.from as T }
-
-/**
- * Filter a [Set] of [Edge]s based on the tag of the edges and return the destination nodes casted to type `T`.
- *
- * @param tag The tag of the edges to get.
- * @return An [Iterable] of the specified type `T` with the given tag.
- */
-inline fun <reified T> Set<Edge<*>>.destinations(tag: String) = filter { it.tag == tag }.map { it.to as T }