コード例 #1
0
  private static void runSimulationExecutive(
      int sim_duration,
      int simulation_time_interval,
      List<Cell> cell_population,
      int cell_doubling_rate) {
    int population_size = cell_population.size();
    int next_div_time = cell_doubling_rate;
    int[][][] diploid_genome =
        new int[haploid_number][2]
            [2]; // The genome, chromosome->homologous pair->complementary DNA strands

    // Progress through time at selected intervals for a specified duration
    for (int current_time = 0;
        current_time < sim_duration;
        current_time += simulation_time_interval) {
      Random rand = new Random();
      // Perform division of all cells that can divide as determined by a random number generator
      // and the set division threshhold
      // As new cells are being added to the list, only go through the cells in the population
      // before new cells are added i.e use the previous population size as max number of iterations
      for (int counter = 0; counter < population_size; counter++) {
        if (cell_population.get(counter).getDivisionStatus()) {
          // Random number generator, 0 = divide, 1 = don't divide

          double coin_flip = rand.nextDouble();
          // printString(Double.toString(coin_flip));
          if (coin_flip >= 0.5) {
            // Remove one cell from the current generation and add two to the next
            // by changing the generation of the dividing cell to current_gen + 1 and
            // create a new cell object for the next generation
            cell_population.get(counter).setGen(cell_population.get(counter).getGen() + 1);
            cell_population.add(
                new Cell(
                    id_of_last_created_cell + 1, newest_generation + 1, -1, true, diploid_genome));
            id_of_last_created_cell++;
          }
        } // if the cell can divide
      } // for all items in main population array

      population_size =
          cell_population.size(); // Update the population size after the round of division
      newest_generation++; // Update the value of the most recent generation after the division
      // round
      next_div_time +=
          cell_doubling_rate; // Set the next time of division by adding the doubling rate to the
      // current time

      printString(current_time + " " + population_size);
    } // for
  } // runSimulationExecutive
コード例 #2
0
ファイル: SNoise3.java プロジェクト: andreydevua/amber
 public SNoise3(Random rnd) {
   for (int i = 0; i < 256; i++) ptab[i] = (byte) i;
   for (int i = 0; i < 256; i++) {
     int r = rnd.nextInt(256);
     byte t = ptab[i];
     ptab[i] = ptab[r];
     ptab[r] = t;
   }
 }