Class ComputationalAssemblerBasic

java.lang.Object
  extended by swarm.BaseImpl
      extended by swarm.objectbase.SwarmObjectImpl
          extended by ComputationalAssemblerBasic
All Implemented Interfaces:
swarm.defobj.Create, swarm.defobj.CreateS, swarm.defobj.Customize, swarm.defobj.CustomizeS, swarm.defobj.DefinedObject, swarm.defobj.DefinedObjectS, swarm.defobj.Drop, swarm.defobj.DropS, swarm.defobj.GetName, swarm.defobj.GetNameS, swarm.objectbase.SwarmObject, swarm.objectbase.SwarmObjectS
Direct Known Subclasses:
ComputationalAssembler

public class ComputationalAssemblerBasic
extends swarm.objectbase.SwarmObjectImpl

The ComputationalAssemblerBasic class instances make computational processes; we have a computationa assembler instance for each unit THIS CLASS IS NOT USED DIRECTLY, BUT VIA THE INHERITING CLASS ComputationalAssembler.java

Author:
Pietro Terna; Carlo Desotgiu made the steps 1001 and 1002; Alessandro Balla and Roberto Crosetto discovered a severe bug in 1002

Field Summary
 int addendum
          the optional addendum for the production phases copying units
 int cd
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 boolean checkMatrixNumber
          a flag to avoid the control of the number of matrixes this flag has to be used from a computational step using an existing step and modifying on the fly the memory matrix number of the used computational step
 boolean done
          the status of a specific computation
 int layer
          the current layer
 Unit myUnit
          the unit for which we are assembling for
 int rd
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int ucd
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int ucd0
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int ucd1
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int urd
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int urd0
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 int urd1
          internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

 swarm.collections.ListImpl waitingList
          the list of the order requiring computations
 Unit whichUnit
          whichUnit is used to set the unit the order is in from outside (look to 1110 as an example)
 
Constructor Summary
ComputationalAssemblerBasic(swarm.defobj.Zone aZone, OrderDistiller od, ESFrameModelSwarm mo)
          the constructor for ComputationalAssembler
 
Method Summary
 void c1001()
          computational operations with code -1001 this computational code places the numbers of the recipes to launch from other recipes, via the c step 1002, in position 0,0 of the received matrixes and set the status to done.
 void c1002()
           
 void c1100()
          computational operations with code -1100 (a code for the jES Open Foundation extension)

this computational step acts as generalized matrix loader that places the values found in unitData0/memoryMatrixContents.txt file in the matrixex and rows and cols reported in the same file the number of the matrixes used here must be less or equal to totalMemoryMatrixNumber (the first m matrixes of these ones); beside this, m has to be less than 10 it is mandatory to enter all the defined matrixes in their original in the c 1100 m m1 m2 ...
 Unit c1101()
          computational operations with code -1101 (a code for the jES Open Foundation extension)

this computational code creates a new random unit in the model stratum reported in position 0,1 of the unique received matrix, with the probability set in position 0,0 of the same matrix; it chose randomly a unit in the proforma unit list, generated from the stratum unitBasicData.txt file, from the top to the 'potentialUnitTypes-1' row; finally it changes the status to done it returns the new unit address, to be used, if necessary, in ComputationalAssembler.java
 void c1102()
          computational operations with code -1102 (a code for the jES Open Foundation extension)

this computational code drops the unit the order is in, with the probability set in position 0,0 of the first received matrix and increases the position 0,1 of the second received matrix by 1, to count the dropped units; this computational step must be in the last step of the order, because the dropped unit cannot send it to the successive one; the computational step, before setting the unit to be dropped, applies the orderDoneStep() method to the order, for accounting purposes; finally it changes the status to done
 void c1103()
          computational operations with code -1103 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in the model stratum of the original unit, near to it with the standard placement rule, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done
 void c1104()
          computational operations with code -1104 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the model stratum of the original unit, in a random position with the standard placement rule, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done
 Unit c1105()
          computational operations with code -1105 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the model stratum of the original unit, in the position near the original unit with the standard placement rule, in the direction stated by position 0,0 (x) and 0,1 (y) of the unit matrix, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done
 Unit c1110()
          computational operations with code -1110 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the same x,y place of the copied unit, but in another model stratum, with the probability set in position 0,0 of the unique received matrix; the created unit is set in the stratum indicated in position 0,1 of the unique received matrix; the unit is created, with the above probability, if the content of the unit memory matrix in position 0,0 is positive (the actual position can be modified via the calling step, e.g.
 Unit c1111()
          computational operations with code -1111 (a code for the jES Open Foundation extension)

this step acts exactly as c1110, but using an addendum to change the production phase
 void c1120()
          computational operations with code -1120 (a code for the jES Open Foundation extension)

this computational code modifies the position 0,0 both of the memory matrix of the unit the order is in and of the memory matrix of the unit the order come from; the amount of the two modifications is defined by two addenda stored in position 0,0 and 0,1 of the unique received matrix (the actual position can be modified via the calling computational step, of the class 12xx); also the position of the two memory matrixes can be modified via the via the 12xx calling computational step; in 0,0 the addendum 1 for the unit the order is in and addendum 2 for the unit the order come from; finally it changes the status to done;
 Unit c1130()
          computational operations with code -1130 (a code for the jES Open Foundation extension)

this computational code deletes a unit (if existing) in the same position of the unit the order is in, but in another model stratum, with the probability set in position 0,0 of the unique received matrix; the deleted unit is searched in the stratum indicated in position 0,1 of the unique received matrix; finally, the computational step changes the status to done;
 void c1199()
          computational operations with code -1199 (a code for the jES Open Foundation extension)

this highly usable computational code, when received by one unit in a stratum, acts vs.
 void c1995()
          computational operations with code -1995 (a code for the checking phase of the program

this computational code place a 1 in position 1,1 of the unique received matrix and set the status to done
 void c1996()
          computational operations with code -1996 (a code for the checking phase of the program

this computational code place a 1 in position 0,0 of the unique received matrix and set the status to done
 void c1997()
          computational operations with code -1997 (a code for the checking phase of the program

this computational code place a 1 in position 1,0 of the unique received matrix and set the status to done
 void c1998()
          computational operations with code -1998 (a code for the checking phase of the program

this computational code place a number in position 0,0 of the unique received matrix and set the status to done
 void c1999()
          computational operations with code -1999 (a code for the checking phase of the program

this computational code verifies position 0,0 of the three received matrixes; only if these positions are all not empty the code empties them and set the status to done
 void checkingComputationsAndFreeingOrders()
          making computations and eliminating the orders from our waitingList
 boolean checkingComputationsOnASpecificOrder(Order anOrder)
          making computations on a specific order
 int getWaitingListLength()
          return the waiting list length
 void init(swarm.defobj.Zone aZone, OrderDistiller od, ESFrameModelSwarm mo)
          managing the constructor content
 void removeThisOrderFromTheWaitingList(Order o)
          removing an order form the waintingList
 boolean setComputationalWaitingList(Order anOrder)
          adding an order to the waitingList
 void setUnit(Unit u)
          setting the unit we are assembling for
 boolean thisOrderIsInTheWaitingList(Order o)
          checking if an order is in the waitingList
 
Methods inherited from class swarm.objectbase.SwarmObjectImpl
compare, describe, describeID, drop, getCompleteProbeMap, getDisplayName, getName, getProbeForMessage, getProbeForVariable, getProbeMap, getTypeName, getZone, perform, perform$with, perform$with$with, perform$with$with$with, respondsTo, setDisplayName, xfprint, xfprintid, xprint, xprintid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layer

public int layer
the current layer


addendum

public int addendum
the optional addendum for the production phases copying units


myUnit

public Unit myUnit
the unit for which we are assembling for


whichUnit

public Unit whichUnit
whichUnit is used to set the unit the order is in from outside (look to 1110 as an example)


waitingList

public swarm.collections.ListImpl waitingList
the list of the order requiring computations


checkMatrixNumber

public boolean checkMatrixNumber
a flag to avoid the control of the number of matrixes this flag has to be used from a computational step using an existing step and modifying on the fly the memory matrix number of the used computational step


done

public boolean done
the status of a specific computation


rd

public int rd
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


cd

public int cd
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


urd

public int urd
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


ucd

public int ucd
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


urd0

public int urd0
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


ucd0

public int ucd0
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


urd1

public int urd1
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE


ucd1

public int ucd1
internal displacements of rows and cols to be used when invoking the methods of the BASIC computational steps via other computational steps

REMEMBER TO RESET ALWAYS TO ZERO THE DISPLACEMENTS AFTER THE USE

Constructor Detail

ComputationalAssemblerBasic

public ComputationalAssemblerBasic(swarm.defobj.Zone aZone,
                                   OrderDistiller od,
                                   ESFrameModelSwarm mo)
the constructor for ComputationalAssembler

Method Detail

init

public void init(swarm.defobj.Zone aZone,
                 OrderDistiller od,
                 ESFrameModelSwarm mo)
managing the constructor content


setUnit

public void setUnit(Unit u)
setting the unit we are assembling for


setComputationalWaitingList

public boolean setComputationalWaitingList(Order anOrder)
adding an order to the waitingList


checkingComputationsAndFreeingOrders

public void checkingComputationsAndFreeingOrders()
making computations and eliminating the orders from our waitingList


checkingComputationsOnASpecificOrder

public boolean checkingComputationsOnASpecificOrder(Order anOrder)
making computations on a specific order


getWaitingListLength

public int getWaitingListLength()
return the waiting list length


thisOrderIsInTheWaitingList

public boolean thisOrderIsInTheWaitingList(Order o)
checking if an order is in the waitingList


removeThisOrderFromTheWaitingList

public void removeThisOrderFromTheWaitingList(Order o)
removing an order form the waintingList


c1995

public void c1995()
computational operations with code -1995 (a code for the checking phase of the program

this computational code place a 1 in position 1,1 of the unique received matrix and set the status to done


c1996

public void c1996()
computational operations with code -1996 (a code for the checking phase of the program

this computational code place a 1 in position 0,0 of the unique received matrix and set the status to done


c1997

public void c1997()
computational operations with code -1997 (a code for the checking phase of the program

this computational code place a 1 in position 1,0 of the unique received matrix and set the status to done


c1998

public void c1998()
computational operations with code -1998 (a code for the checking phase of the program

this computational code place a number in position 0,0 of the unique received matrix and set the status to done


c1999

public void c1999()
computational operations with code -1999 (a code for the checking phase of the program

this computational code verifies position 0,0 of the three received matrixes; only if these positions are all not empty the code empties them and set the status to done


c1001

public void c1001()
computational operations with code -1001 this computational code places the numbers of the recipes to launch from other recipes, via the c step 1002, in position 0,0 of the received matrixes and set the status to done. the number of the matrixes used here must be less or equal to totalMemoryMatrixNumber (the first m matrixes of these ones); beside this, m has to be less than 10


c1002

public void c1002()

c1100

public void c1100()
computational operations with code -1100 (a code for the jES Open Foundation extension)

this computational step acts as generalized matrix loader that places the values found in unitData0/memoryMatrixContents.txt file in the matrixex and rows and cols reported in the same file the number of the matrixes used here must be less or equal to totalMemoryMatrixNumber (the first m matrixes of these ones); beside this, m has to be less than 10 it is mandatory to enter all the defined matrixes in their original in the c 1100 m m1 m2 ... command values in the unitData0/memoryMatrixContents.txt can be in any order finally it changes the status to done;


c1101

public Unit c1101()
computational operations with code -1101 (a code for the jES Open Foundation extension)

this computational code creates a new random unit in the model stratum reported in position 0,1 of the unique received matrix, with the probability set in position 0,0 of the same matrix; it chose randomly a unit in the proforma unit list, generated from the stratum unitBasicData.txt file, from the top to the 'potentialUnitTypes-1' row; finally it changes the status to done it returns the new unit address, to be used, if necessary, in ComputationalAssembler.java


c1102

public void c1102()
computational operations with code -1102 (a code for the jES Open Foundation extension)

this computational code drops the unit the order is in, with the probability set in position 0,0 of the first received matrix and increases the position 0,1 of the second received matrix by 1, to count the dropped units; this computational step must be in the last step of the order, because the dropped unit cannot send it to the successive one; the computational step, before setting the unit to be dropped, applies the orderDoneStep() method to the order, for accounting purposes; finally it changes the status to done


c1103

public void c1103()
computational operations with code -1103 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in the model stratum of the original unit, near to it with the standard placement rule, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done


c1104

public void c1104()
computational operations with code -1104 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the model stratum of the original unit, in a random position with the standard placement rule, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done


c1105

public Unit c1105()
computational operations with code -1105 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the model stratum of the original unit, in the position near the original unit with the standard placement rule, in the direction stated by position 0,0 (x) and 0,1 (y) of the unit matrix, with the probability set in position 0,0 of the first received matrix; the count of the created units is reported increasing by one the position 0+rd,1+cd of the second received matrix finally it changes the status to done


c1110

public Unit c1110()
computational operations with code -1110 (a code for the jES Open Foundation extension)

this computational code creates a copy of the unit the order is in, in the same x,y place of the copied unit, but in another model stratum, with the probability set in position 0,0 of the unique received matrix; the created unit is set in the stratum indicated in position 0,1 of the unique received matrix; the unit is created, with the above probability, if the content of the unit memory matrix in position 0,0 is positive (the actual position can be modified via the calling step, e.g. 1210 in tutorial step3c); if the destination position in the new stratum is occupied the new unit is not created, without any advice; the new unit is not created if the original one is in the destination stratum; the new unit has the same visibility of the old one; finally, the computational step changes the status to done; c1110 is not normally utilized directly but via a special computational step (i.e. 1210 in tutorial step3c) setting the position and content of the cell (<=0 or >0) indicated above; the memory matrix of the copied unit is shared among the original unit itself and its copies, avoiding the creation of new matrixes for the copies


c1111

public Unit c1111()
computational operations with code -1111 (a code for the jES Open Foundation extension)

this step acts exactly as c1110, but using an addendum to change the production phase


c1120

public void c1120()
computational operations with code -1120 (a code for the jES Open Foundation extension)

this computational code modifies the position 0,0 both of the memory matrix of the unit the order is in and of the memory matrix of the unit the order come from; the amount of the two modifications is defined by two addenda stored in position 0,0 and 0,1 of the unique received matrix (the actual position can be modified via the calling computational step, of the class 12xx); also the position of the two memory matrixes can be modified via the via the 12xx calling computational step; in 0,0 the addendum 1 for the unit the order is in and addendum 2 for the unit the order come from; finally it changes the status to done;


c1130

public Unit c1130()
computational operations with code -1130 (a code for the jES Open Foundation extension)

this computational code deletes a unit (if existing) in the same position of the unit the order is in, but in another model stratum, with the probability set in position 0,0 of the unique received matrix; the deleted unit is searched in the stratum indicated in position 0,1 of the unique received matrix; finally, the computational step changes the status to done;


c1199

public void c1199()
computational operations with code -1199 (a code for the jES Open Foundation extension)

this highly usable computational code, when received by one unit in a stratum, acts vs. all the units of the same type (i.e., with the same production phase) in all strata; actions: with the probability set in position 0,0 of the first received matrix, c1999 adds the value contained in 0,5 of the second received matrix to each unit memory matrix a row and column reported in pos 0,3 and 0,4 of the second matrix; if the resulting content is < the level contained in position 0,2 of the second matrix, the considered unit is dropped (if it is the unit the order is in, also the order is dropped), counting the dropped units in position 0,1 of the second matrix (obviously, first and second matrixes can be coincident) finally it changes the status to done