Flask Basics

The core Flask objects and their subclasses are
  • Flask - the virtual reaction vessel
  • Atom - an abstract atom with virtual location
    • SpatialAtom - an atom with coordinates in 3-space
    • SpatialAtomInterface - an interface for making Atom subclasses spatial
    • AtomicMachine - an atom that performs some computations
  • Molecule - a collection of atoms that are bound together
  • Photon - an abstract photon used for signaling between AtomicMachines and the Flask
    • VisibleLight - used for simple signaling
    • Gamma - an abstract gamma ray used to randomly remove some number of atomic bonds based on its energy
    • Heat - abstract Heat used to break some bonds in pseudo-crystalline experiments
  • BindingSites - objects that contains atom binding rules
  • Bonds - objects that represent bonds between atoms
Atomic attributes are summarized in Table 1.

Table 1 - Atomic attributes
Name
Atom group name - All atoms with the same name have the same properties
ID
Numeric identifier - Name + ID uniquely identifies the atom
Mass
Abstract mass - Used to map a domain value from the problem at hand onto Flask model
Charge
Simple charge - Two charged atoms cannot bind.  Charge is always plus and should not be confused with electrostatic binding sites
Binding Sites
A list of binding sites that describe how the atom can form bonds
Location
(x, y, z) coordinates only for atoms that implement the SpatialAtomInterface interface or extend SpatialAtom

Atoms are diagrammed as circles with labels.  The format of the label is

                <name>[<id>]+[m]

<name> is a string representing the name of the atom, e.g., “a”.  Optional label items are enclosed in brackets ([ ]).  To refer to a group of similar atoms, the unique id can be omitted.  However, to specify an individual atom, the id must be included.  The optional plus sign indicates that the atom is charged, i.e., it will not bind with other atoms that are charged.  The charge concept is simple:  There is no negative charge. Finally, m is the mass of the atom.  Figure 1 shows some examples of atoms using this notation.




Figure 1 -Atom examples

Atoms can bind with other atoms to form molecules.   Each atom has zero or more binding sites that describe how it can bind to other atoms.  Unlike most artificial chemistries, the reaction rules for the Flask are defined by the binding sites associated with atoms.  Binding site attributes are given in Table 2.  Some of these are optional.

Table 2 - Binding Site Attributes
Name
The name of the binding site
Number
The number of bonds that can be made using this binding site.  "*" indicates the number is indefinite.
Strength
When atoms form molecules, strength is used to order binding sites of the same name from different atoms.
RefCount
The number of bonds formed using this binding site.  RefCount <= Number.
Type
Normal, onePer, or AndBond.  Normal means no restrictions on bonding.  onePer means at most one of all the onePer binding sites can form a bond with another atom in a collision.  All andBonds must form bonds to the same atom or molecule or no bonds are formed.
nOf
At most, only n of all the nOf binding sites associated with an atom can be used to from bonds
Electrostatic
Either + or -.  + binding sites only bond to - binding sites and vice versa.
BondLength
The abstract length of a binding site.  Used to encode problem data onto the Flask model
Conditional
Conditional binding sites are inactive until all the regular and AndBond binding sites are filled.  These binding sites will never fire if the atom has one or more binding sites with number "*".
IntraMolecular
Only binds with atoms already bond to this atom in a molecule
Location
(x, y, z) coordinates for subclass BindingSiteLocal.  Local binding sites only bind with other local binding sites that are adjacent.

Figure 2 illustrates the notation used for binding sites and their attributes.



Figure 2 - Binding site examples


In the Flask, there is a special type of atom called an atomic machine.  Atomic machines behave like regular Flask atoms; however, they also perform some useful task such as printing the configuration of the molecule to which they are attached, determining the better of two molecules representing problem solutions, and unbinding all the bonds in an attached molecule.  Atomic machines have a Run() method.   If an atomic machine forms a bond or is in a molecule that forms a bond, its Run() method is invoked.

The Reaction Vessel


A Flask simulation run is set up by defining atoms and their binding sites.  Atoms are normally defined using atom groups:  a set of atoms with the same name and properties but with a unique identifier.  Each Flask iteration is made up of a specified number of collision steps.  For each step, two atoms are selected.  Atoms that are not spatial are assumed to have virtual location, i.e., they are adjacent to the other atom for the duration of the given simulation step.  (One can think of atoms floating in the Flask and bumping into each other.)  If both atoms are spatial, then they have to be adjacent before they can react.

The selected atoms can be unbound (free) or part of a molecule.  Binding between two free atoms is described first.
  • If both atoms are charged, no bonds are made.
  • If both atoms have a simple binding site with the same name and if the number of each binding site has not been exceeded,  a bond is formed.
  • AndBond sites are then compared for binding.  All of the AndBonds in both atoms must form bonds or none of them do.
  • If all the binding sites have been used to make bonds, the conditional binding sites are activated.  A check is made to see if any bonds can be made between atoms in the newly created molecule as a result of the conditional bonds.  Any unused conditional bonds remain active for the next collision involving this molecule.
If one or both of the atoms to be collided are bound into a molecule, the reaction steps are
  • All binding sites of the same name from all the atoms in the molecule are grouped together.  Binding sites are ordered in these groups using the strength attribute, with higher strengths coming first in the list.
  • Regular bonds are performed between the molecule and the atom or molecule using the sorted list of binding sites.  If, for example, a molecule has three atoms with available "A" binding sites, it will make bonds with the one with the highest strength first, before trying the other atoms.  If all the binding sites of the same name have the same strength, the order is nondeterministic.
  • AndBond sites are tried next.  All the AndBonds must make bonds with atoms in the molecule or no AndBonds are formed.
  • The conditional binding sites of any atoms in the molecule whose regular and AndBond binding sites are filled will be activated.
There are a few Flask parameters that affect how binding occurs.  percentAdjacent affects how atoms are selected for collision.  The parameter gives the percentage of collisions in which the simulator attempts to select adjacent atoms for colliding.  In simulations that include many spatial atoms with local binding sites, this parameter can speed up the number of interactions per iteration.

If the internalBondingOrderSites boolean is set to true, then bonding between atoms in a molecule is processed by ordering the atoms by the number of free regular binding sites they have, with the atom with the most free binding sites going first when bonds are made.  This parameter helps to form the longest loops of atoms in certain problems.  (See the first Traveling Salesman Problem solution for an example.)

One experimental feature of the Flask revolves around "seed" atoms.  There are a number of parameters related to the reaction vessel in dealing with seed atoms that are discussed in the city growing problem.

The user of the Flask can define events that are triggered when some condition occurs in the virtual flask.  Events can be defined, among other things, in relation to the iteration number and the reaction rate.  When an event is triggered, some predefined action occurs, such as releasing selected atomic machines.  For example, a Flask simulation might run until there are no more bonds to be made without solving a particular problem.  The run designer could add a gamma ray event that says that if the reaction activity is low and a problem solution finder has not found a problem solution, then release an atomic machine that dissolves some random bonds.  This event would have the effect of discarding part of the current problem solution so that other solutions could be explored.

The next section discusses how the various binding site parameters are used and how to run the Flask.