Packages

  • package root
    Definition Classes
    root
  • package se
    Definition Classes
    root
  • package sics
    Definition Classes
    se
  • package kompics
    Definition Classes
    sics
  • package sl

    This package contains the Scala DSL for Kompics.

    This package contains the Scala DSL for Kompics.

    It is recommended to import this as import se.sics.kompics.sl._, since it contains a number of implicit conversions and convenience methods that are good to have in scope.

    Definition Classes
    kompics
  • package simulator

    The Kompics Simulator DSL for Scala

    The Kompics Simulator DSL for Scala

    Definition Classes
    sl
    Example:
    1. case object SimpleSimulation {
      
        import Distributions._
        // needed for the distributions, but needs to be initialised after setting the seed
        implicit val random = JSimulationScenario.getRandom();
      
        private def intToAddress(i: Int): Address = {
          try {
            new TAddress(new InetSocketAddress(InetAddress.getByName("192.193.0." + i), 10000));
          } catch {
            case ex: UnknownHostException => throw new RuntimeException(ex);
          }
        }
      
        val startResultSetterOp = Op { (self: Integer) =>
          val selfAddr = intToAddress(self);
          StartNode(selfAddr, Init[ResultSetter](selfAddr))
        };
        val startPongerOp = Op { (self: Integer) =>
          val selfAddr = intToAddress(self)
          StartNode(selfAddr, Init[PongerParent](selfAddr))
        };
        val startPingerOp = Op { (self: Integer, ponger: Integer) =>
          val selfAddr = intToAddress(self);
          val pongerAddr = intToAddress(ponger);
          StartNode(selfAddr, Init[PingerParent](selfAddr, pongerAddr))
        };
      
        val scenario = raise(5, startPongerOp, 1.toN)
          .arrival(constant(1000.millis))
          .andThen(1000.millis)
          .afterTermination(raise(5, startPingerOp, 6.toN, 1.toN).arrival(constant(1000.millis)))
          .inParallel(raise(1, startResultSetterOp, 1.toN).arrival(constant(1000.millis)))
          .andThen(10000.millis)
          .afterTermination(Terminate);
      }
  • ChangeNetwork
  • Distributions
  • IntDistributions
  • KillNode
  • Op
  • Setup
  • SimulationResult
  • StartNode
  • StochasticProcess
  • StochasticProcessBuilder
  • StochasticProcessChain
  • Terminate
p

se.sics.kompics.sl

simulator

package simulator

The Kompics Simulator DSL for Scala

Example:
  1. case object SimpleSimulation {
    
      import Distributions._
      // needed for the distributions, but needs to be initialised after setting the seed
      implicit val random = JSimulationScenario.getRandom();
    
      private def intToAddress(i: Int): Address = {
        try {
          new TAddress(new InetSocketAddress(InetAddress.getByName("192.193.0." + i), 10000));
        } catch {
          case ex: UnknownHostException => throw new RuntimeException(ex);
        }
      }
    
      val startResultSetterOp = Op { (self: Integer) =>
        val selfAddr = intToAddress(self);
        StartNode(selfAddr, Init[ResultSetter](selfAddr))
      };
      val startPongerOp = Op { (self: Integer) =>
        val selfAddr = intToAddress(self)
        StartNode(selfAddr, Init[PongerParent](selfAddr))
      };
      val startPingerOp = Op { (self: Integer, ponger: Integer) =>
        val selfAddr = intToAddress(self);
        val pongerAddr = intToAddress(ponger);
        StartNode(selfAddr, Init[PingerParent](selfAddr, pongerAddr))
      };
    
      val scenario = raise(5, startPongerOp, 1.toN)
        .arrival(constant(1000.millis))
        .andThen(1000.millis)
        .afterTermination(raise(5, startPingerOp, 6.toN, 1.toN).arrival(constant(1000.millis)))
        .inParallel(raise(1, startResultSetterOp, 1.toN).arrival(constant(1000.millis)))
        .andThen(10000.millis)
        .afterTermination(Terminate);
    }
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. simulator
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. implicit class IntDistributions extends AnyRef

    Allow the creation of BasicIntSequentialDistribution via i.toN()

  2. class StochasticProcess extends AnyRef

    A sequence of operations with a distribution of time between them

  3. class StochasticProcessBuilder extends AnyRef

    A builder class for StochasticProcess instances

  4. class StochasticProcessChain extends Serializable

    A simulation is formed by a chain of stochastic processes

    A simulation is formed by a chain of stochastic processes

    It should end with a Terminate process.

    See also

    se.sics.kompics.sl.simulator for an example

Value Members

  1. implicit def chainToScenario(spc: StochasticProcessChain): SimulationScenario

    Automatically convert a StochasticProcessChain into a SimulationScenario

    Automatically convert a StochasticProcessChain into a SimulationScenario

    spc

    the original process chain

    returns

    the new simulation scenario

    See also

    get

  2. def raise[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number, N5 <: Number](count: Int, op: Operation5[E, N, N2, N3, N4, N5], d: Distribution[N], d2: Distribution[N2], d3: Distribution[N3], d4: Distribution[N4], d5: Distribution[N5]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    N

    the type of the first operation argument

    N2

    the type of the second operation argument

    N3

    the type of the third operation argument

    N4

    the type of the fourth operation argument

    N5

    the type of the fifth operation argument

    count

    the number of events produce

    op

    the operation that creates the events

    d

    the distribution for the first operation argument

    d2

    the distribution for the second operation argument

    d3

    the distribution for the third operation argument

    d4

    the distribution for the fourth operation argument

    d5

    the distribution for the fifth operation argument

    returns

    a new StochasticProcessBuilder with the raise operation appended

  3. def raise[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number, N4 <: Number](count: Int, op: Operation4[E, N, N2, N3, N4], d: Distribution[N], d2: Distribution[N2], d3: Distribution[N3], d4: Distribution[N4]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    N

    the type of the first operation argument

    N2

    the type of the second operation argument

    N3

    the type of the third operation argument

    N4

    the type of the fourth operation argument

    count

    the number of events produce

    op

    the operation that creates the events

    d

    the distribution for the first operation argument

    d2

    the distribution for the second operation argument

    d3

    the distribution for the third operation argument

    d4

    the distribution for the fourth operation argument

    returns

    a new StochasticProcessBuilder with the raise operation appended

  4. def raise[E <: KompicsEvent, N <: Number, N2 <: Number, N3 <: Number](count: Int, op: Operation3[E, N, N2, N3], d: Distribution[N], d2: Distribution[N2], d3: Distribution[N3]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    N

    the type of the first operation argument

    N2

    the type of the second operation argument

    N3

    the type of the third operation argument

    count

    the number of events produce

    op

    the operation that creates the events

    d

    the distribution for the first operation argument

    d2

    the distribution for the second operation argument

    d3

    the distribution for the third operation argument

    returns

    a new StochasticProcessBuilder with the raise operation appended

  5. def raise[E <: KompicsEvent, N <: Number, N2 <: Number](count: Int, op: Operation2[E, N, N2], d: Distribution[N], d2: Distribution[N2]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    N

    the type of the first operation argument

    N2

    the type of the second operation argument

    count

    the number of events produce

    op

    the operation that creates the events

    d

    the distribution for the first operation argument

    d2

    the distribution for the second operation argument

    returns

    a new StochasticProcessBuilder with the raise operation appended

  6. def raise[E <: KompicsEvent, N <: Number](count: Int, op: Operation1[E, N], d: Distribution[N]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    N

    the type of the first operation argument

    count

    the number of events produce

    op

    the operation that creates the events

    d

    the distribution for the first operation argument

    returns

    a new StochasticProcessBuilder with the raise operation appended

  7. def raise[E <: KompicsEvent](count: Int, op: Operation[E]): StochasticProcessBuilder

    Raise a number of events produced by an operation

    Raise a number of events produced by an operation

    E

    the type of event to produce

    count

    the number of events produce

    op

    the operation that creates the events

    returns

    a new StochasticProcessBuilder with the raise operation appended

  8. implicit def stochasticProcessToChain(sp: StochasticProcess): StochasticProcessChain

    Automatically convert a StochasticProcess to a StochasticProcessChain

    Automatically convert a StochasticProcess to a StochasticProcessChain

    sp

    the starting process of the chain

    returns

    the new chain

    See also

    startWith

  9. object ChangeNetwork

    Construct instances of se.sics.kompics.simulator.events.system.ChangeNetworkModelEvent

  10. object Distributions

    Convenience DSL objects for building different kinds of distributions.

  11. object KillNode

    Construct instances of se.sics.kompics.simulator.events.system.KillNodeEvent

  12. object Op

    Operations of various arities, which produce a KompicsEvent

    Operations of various arities, which produce a KompicsEvent

    Arities from zero to five are provided.

    Use these to map parameters to simulator events using the various raise functions.

    Example:
    1. raise(5,
        Op { (self: Integer, other: Integer) =>
          val selfAddr = lookupAddress(self); /* Get an address instance for the id */
          val otherAddr = lookupAddress(ponger); /* Get an address instance for the id */
          StartNode(selfAddr, Init[NewComponent](selfAddr, otherAddr))
        },
        1.toN, 2.toN)
    See also

    se.sics.kompics.simulator.adaptor.Operation

  13. object Setup

    Construct setup events

  14. object SimulationResult

    A helper to share values between the simluation and the testing code

    A helper to share values between the simluation and the testing code

    Since simulations run with a different classloader than the code that spawns them, it is usually difficult to share values between them. This class allows doing so, using a string-indexed map.

    The underlying implementation is se.sics.kompics.simulator.result.SimulationResultSingleton.

    Example:
    1. SimulationResult += ("test" -> 1); /* Pass 1 to the simulation */
      SimpleSimulation.scenario.simulate(classOf[LauncherComp]); /* The simulation runs and sets "test" to 2 */
      SimulationResult[Int]("test") should be(2); /* Get the new value from the simulation */
  15. object StartNode

    Utilities to start a node in a simulation

    Utilities to start a node in a simulation

    All of them are simply conveniences to create an instance of se.sics.kompics.simulator.events.system.StartNodeEvent.

  16. object Terminate extends StochasticProcess with Product with Serializable

    A special process that marks the end of the simulation

Inherited from AnyRef

Inherited from Any

Ungrouped