Class

io.chymyst.jc

GuardPresent

Related Doc: package jc

Permalink

final case class GuardPresent(staticGuard: Option[() ⇒ Boolean], crossGuards: Array[CrossMoleculeGuard]) extends GuardPresenceFlag with Product with Serializable

Indicates whether guard conditions are required for this reaction to start.

The guard is parsed into a flat conjunction of guard clauses, which are then analyzed for cross-dependencies between molecules.

For example, consider the reaction

go { case a(x) + b(y) + c(z) if x > n && y > 0 && y > z && n > 1 => ...}

Here n is an integer value defined outside the reaction.

The conditions for starting this reaction is that a(x) has value x such that x > n; that b(y) has value y such that y > 0; that c(z) has value z such that y > z; and finally that n > 1, independently of any molecule values. The condition n > 1 is a static guard. The condition x > n restricts only the molecule a(x) and therefore can be moved out of the guard into the per-molecule conditional inside InputMoleculeInfo for that molecule. Similarly, the condition y > 0 can be moved out of the guard. However, the condition y > z relates two different molecule values; it is a cross-molecule guard.

Any guard condition given by the reaction code will be converted to the Conjunctive Normal Form, and split into a static guard, a set of per-molecule conditionals, and a set of cross-molecule guards.

staticGuard

The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

crossGuards

A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be an array with the single element

CrossMoleculeGuard(indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () })))
Linear Supertypes
Serializable, Serializable, Product, Equals, GuardPresenceFlag, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GuardPresent
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. GuardPresenceFlag
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new GuardPresent(staticGuard: Option[() ⇒ Boolean], crossGuards: Array[CrossMoleculeGuard])

    Permalink

    staticGuard

    The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

    crossGuards

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be an array with the single element

    CrossMoleculeGuard(indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () })))

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. val crossGuards: Array[CrossMoleculeGuard]

    Permalink

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard.

    A list of values of type CrossMoleculeGuard, each representing one cross-molecule clauses of the guard. The partial function Any => Unit should be called with the arguments representing the tuples of pattern variables from each molecule used by the cross guard. In the present example, the value of crossGuards will be an array with the single element

    CrossMoleculeGuard(indices = Array(1, 2), List((List('y, 'z), { case List(y: Int, z: Int) if y > z => () })))
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. val noCrossGuards: Boolean

    Permalink

    Checks whether the reaction has no cross-molecule guard conditions, that is, conditions that cannot be factorized as conjunctions of conditions that each constrain individual molecules.

    Checks whether the reaction has no cross-molecule guard conditions, that is, conditions that cannot be factorized as conjunctions of conditions that each constrain individual molecules.

    For example, go { case a(x) + b(y) if x > y => } has a cross-molecule guard condition, whereas go { case a(x) + b(y) if x > 1 && y < 2 => } has no cross-molecule guard conditions because its guard condition can be split into a conjunction of guard conditions that each constrain the value of one molecule.

    returns

    true if the reaction has no guard condition, or if it has guard conditions that can be split between molecules; false if the reaction has at least one cross-molecule guard condition.

    Definition Classes
    GuardPresentGuardPresenceFlag
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. val staticGuard: Option[() ⇒ Boolean]

    Permalink

    The conjunction of all the clauses of the guard that are independent of pattern variables.

    The conjunction of all the clauses of the guard that are independent of pattern variables. This closure can be called in order to determine whether the reaction should even be considered to start, regardless of the presence of molecules. In this example, the value of staticGuard will be Some(() => n > 1).

  16. def staticGuardHolds(): Boolean

    Permalink

    Calls a reaction's static guard to check whether the reaction is permitted to start, before examining any molecule values.

    Calls a reaction's static guard to check whether the reaction is permitted to start, before examining any molecule values.

    A static guard is a reaction guard that does not depend on molecule values. For example, go { case a(x) if n > 0 && x < n => ...} contains a static guard n > 0 and a non-static guard x < n. A static guard could depend on mutable global values, such as n, and so it is evaluated each time.

    Note that the static guard could be evaluated even if the reaction site does not have enough input molecules for the reaction to start. Avoid putting side effects into the static guard!

    returns

    true if the reaction's static guard returns true or is absent. false if the reaction has a static guard, and if the guard returns false.

    Definition Classes
    GuardPresentGuardPresenceFlag
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. val toString: String

    Permalink
    Definition Classes
    GuardPresent → AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from GuardPresenceFlag

Inherited from AnyRef

Inherited from Any

Ungrouped