Class CPUStreamPheromone

All Implemented Interfaces:
Pheromone<Float>
Direct Known Subclasses:
CPU_SobelPheromone

public class CPUStreamPheromone extends AbstractPheromoneGrid<Float>
A pheromone grid that uses a float array to store values. It is used for CPU computations.
  • Constructor Details

    • CPUStreamPheromone

      public CPUStreamPheromone(String name, TKEnvironment<?> environment, float evaporationCoeff, float diffusionCoeff)
  • Method Details

    • get

      public Float get(int index)
      Description copied from interface: Pheromone
      Returns the value at the specified index
      Specified by:
      get in interface Pheromone<Float>
      Specified by:
      get in class DataGrid<Float>
      Parameters:
      index - the index
      Returns:
      the value at the specified index
    • set

      public void set(int index, Float value)
      Specified by:
      set in interface Pheromone<Float>
      Specified by:
      set in class DataGrid<Float>
    • getMaxDirection

      public int getMaxDirection(int xcor, int ycor)
      Description copied from interface: Pheromone
      Returns the direction with the maximum value
      Parameters:
      xcor - x coordinate
      ycor - y coordinate
      Returns:
      the direction with the maximum value
    • getMinDirection

      public int getMinDirection(int xcor, int ycor)
      Description copied from interface: Pheromone
      Returns the direction with the minimum value
      Parameters:
      xcor - x coordinate
      ycor - y coordinate
      Returns:
      the direction with the minimum value
    • getMaxDirectionRandomWhenEquals

      public int getMaxDirectionRandomWhenEquals(int xcor, int ycor)
    • getMaxDirectionNoRandom

      public int getMaxDirectionNoRandom(int xcor, int ycor)
    • getMinDirectionRandomWhenEquals

      public int getMinDirectionRandomWhenEquals(int xcor, int ycor)
    • getMinDirectionNoRandom

      public int getMinDirectionNoRandom(int xcor, int ycor)
    • updateValuesFromTmpGridKernel

      public void updateValuesFromTmpGridKernel()
      Description copied from interface: Pheromone
      Update the values in the main grid from the temporary grid. This method is called after the Pheromone.diffuseValuesToTmpGridKernel() method.
    • diffusionAndEvaporationUpdateKernel

      public void diffusionAndEvaporationUpdateKernel()
      Description copied from interface: Pheromone
      Apply the diffusion update and evaporation processes at once. This method is called after the Pheromone.diffuseValuesToTmpGridKernel() method in the Pheromone.diffusionAndEvaporation() method.
    • diffuseValuesToTmpGridKernel

      public void diffuseValuesToTmpGridKernel()
      Description copied from interface: Pheromone
      Diffuse the values to a temporary grid. This method is called before the Pheromone.updateValuesFromTmpGridKernel() method.
    • evaporationKernel

      public void evaporationKernel()
      Description copied from interface: Pheromone
      Apply the evaporation process. It should be overridden by the implementing class to apply the evaporation which is about reducing the value of each cell by a certain percentage.
    • incValue

      public void incValue(int x, int y, float quantity)
    • incValue

      public void incValue(int index, float inc)
      Adds inc to the current value of the cell with the corresponding index
      Parameters:
      index - cell's index
      inc - how much to add
    • updateMaxValue

      public void updateMaxValue()
      Compute the maximum value in the grid