Esempio n. 1
0
  //    int frame = 0;
  public void paint(Graphics g) {
    // System.out.println("frame: " + (frame++));
    lStatus.setText(
        "t = "
            + df.format(md.dt * md.step)
            + ", "
            + "N = "
            + md.N
            + ", "
            + "E/N = "
            + df.format(md.E / md.N)
            + ", "
            + "U/N = "
            + df.format(md.U / md.N)
            + ", "
            + "K/N = "
            + df.format(md.K / md.N)
            + ", "
            + "p = "
            + df.format(md.p)
            + ";");
    tAvK.setText(df.format(md.avK.getAve() / md.N) + "  ");
    tAvU.setText(df.format(md.avU.getAve() / md.N) + "  ");
    tTemp.setText(df.format((2 * md.K) / (3 * (md.N - 1))) + "  ");
    tAvp.setText(df.format(md.avp.getAve()) + "  ");
    canvas.refresh(md.getXWrap(), md.N, true, false);
    cpnl.repaint();
    spnl.repaint();

    try {

      PrintWriter wavefunc =
          new PrintWriter(new FileOutputStream(new File("energyData.txt"), true));
      wavefunc.print(md.E / md.N + " " + md.K / md.N + " " + md.U / md.N);
      wavefunc.println();
      wavefunc.close();
    } catch (IOException ex) {
    }

    try {

      PrintWriter tempwriter =
          new PrintWriter(new FileOutputStream(new File("tempData.txt"), true));
      tempwriter.print(df.format((2 * md.K) / (3 * (md.N - 1))));
      tempwriter.println();
      tempwriter.close();
    } catch (IOException ex) {
    }
  }
Esempio n. 2
0
  /** @param args */
  public static void main(String[] args) throws Exception {
    File file = new File("B-small-practice.in");
    if (file.exists()) {
      System.setIn(new BufferedInputStream(new FileInputStream(file)));
    }
    sc = new Scanner(System.in);
    FileWriter fw = new FileWriter(new File("output.txt"));
    out = new PrintWriter(fw);

    Bsmall b = new Bsmall();
    int T = sc.nextInt();
    int t = 1;
    while (t <= T) {
      out.print("Case #" + t + ": ");
      b.solve();
      t++;
    }
    out.close();
    fw.close();
  }
Esempio n. 3
0
  public void nextTimeStep() {
    births = 0;
    deaths = 0;
    //		for (int i=0;i<o2perTS;i++) iterateOxygen();  // oh dear
    iterateCells();
    radiotherapy = false;
    stem_cells_this_TS = 0; // counter to track population dynamics
    non_stem_cells_this_TS = 0; // counter to track population dynamics

    // NEW
    int totalCells = 0;
    int totalHealthy = 0;
    int totalStem = 0;
    int totalProgenitor = 0;
    int totalMature = 0;
    for (int i = 0; i < size; i++)
      for (int j = 0; j < size; j++)
        if (Cells[i][j] < 4) {
          totalCells++;
          if (Cells[i][j] == 0) totalHealthy++;
          else if (Cells[i][j] == 1) totalStem++;
          else if (Cells[i][j] == 2) totalProgenitor++;
          else if (Cells[i][j] == 3) totalMature++;
          else System.err.println("wrong cell type");
        }

    // Not so new
    if (timestep == 0)
      System.out.println(
          +size
              + ", "
              + mutfreq
              + ", "
              + lengthGenome
              + ", "
              + asymmetricRatio); // print (parent,child) pair

    // System.out.println ("% Timestep\t Cells\t Stem Cells \t Progenitor\t Mature");
    if (timestep % dataReportStep == 0) {
      // System.out.println(timestep+"\t"+totalCells+"\t"+totalStem+"\t"+totalProgenitor+"\t"+totalMature+"\t"+births+"\t"+deaths+"\t"+((float)births/deaths));
      // System.err.println(asymmetricRatio+" "+maxProDivisions+" "+totalCells+" "+totalStem);}
      // System.err.println(mutationNum+" "+totalStem);
    }
    timestep++;

    // Finally let's write down the data
    if ((timestep % dataWriteStep == 0) && (timestep > dataWriteStartTime)) {
      try {
        File dir = new File("./text");
        dir.mkdir();

        // cell matrix
        FileWriter outFile1 = new FileWriter("./text/cells" + timestep);
        PrintWriter outCells = new PrintWriter(outFile1);

        // attempt at hashtable
        // FileWriter outFileHm = new FileWriter("./text/pairs"+timestep); // new
        // PrintWriter outTable = new PrintWriter(outFileHm);  // new

        // carriedGenome
        // FileWriter outFilecG = new FileWriter("./text/genomes"+timestep); // new
        // PrintWriter outcG = new PrintWriter(outFilecG);  // new

        // attempt at hashtable
        // FileWriter outFileHm2 = new FileWriter("./text/timepairs"+timestep); // new
        // PrintWriter outTable2 = new PrintWriter(outFileHm2);  // new

        // oxygen matrix
        // FileWriter outFile2 = new FileWriter("./text/oxygen"+timestep);
        // PrintWriter outO2 = new PrintWriter(outFile2);

        // stem age matrix
        // FileWriter outFile3 = new FileWriter("./text/stemBirthCounter"+timestep);
        // PrintWriter outSBC = new PrintWriter(outFile3);

        // carried mutation matrix
        FileWriter outFile2 = new FileWriter("./text/carriedmutation" + timestep);
        PrintWriter outCM = new PrintWriter(outFile2);
        /*
        		// stem total birth matrix
                        //FileWriter outFile4 = new FileWriter("./text/stemBirthsTotal"+timestep);
                        //PrintWriter outSBM = new PrintWriter(outFile4);

        		// stem death matrix
                        //FileWriter outFile5 = new FileWriter("./text/stemDeathCounter"+timestep);
                        //PrintWriter outSD = new PrintWriter(outFile5);

        		// TAC birth matrix
                        //FileWriter outFile6 = new FileWriter("./text/TACBirthCounter"+timestep);
                        //PrintWriter outTB = new PrintWriter(outFile6);

        		// TAC death matrix
                        //FileWriter outFile7 = new FileWriter("./text/TACDeathCounter"+timestep);
                        //PrintWriter outTD = new PrintWriter(outFile7);

                		//write hashtable
              			for (Integer key : tree.keySet()) {
              			outTable.print(+key+", "+tree.get(key)+"\r\n");
              			} //new
                		outTable.println(""); //new
                		outTable.close(); //new

                		//write hashtable
              			for (Integer value : tree.valueSet()) {
              			outTableNew.print(+tree.get(value)+", "+value+"\r\n");
              			} //new
                		outTableNew.println(""); //new
                		outTableNew.close(); //new


                		//write hashtable
                		for (Integer key : timeTree.keySet()) {
              			outTable2.print(+key+", "+timeTree.get(key)+"\r\n");
              			} //new
                		outTable2.println(""); //new
                		outTable2.close(); //new
        */
        for (int i = 0; i < size; i++) {
          for (int j = 0; j < size; j++) {
            outCells.print(Cells[i][j] + ", ");
            // outcG.print(carriedGenome[i][j]+", ");
            // outO2.print(Oxygen[i][j]+", ");
            // outSBC.print(stemBirthCounter[i][j]+", ");
            outCM.print(carriedmutation[i][j] + ", ");
            // outSBM.print(stemBirthsTotal[i][j]+", ");
            // outSD.print(stemDeathCounter[i][j]+", ");
            // outTB.print(TACBirthCounter[i][j]+", ");
            // outTD.print(TACDeathCounter[i][j]+", ");

          }
          outCells.println("");
          // outcG.println("");
          outCM.println("");
          // outO2.println("");
          // outSBC.println("");
          // outSBM.println("");
          // outSD.println("");
          // outTB.println("");
          // outTD.println("");

        }
        outCells.close();
        // outcG.close();
        outCM.close();
        // outO2.close();
        // outSBC.close();
        // outSBM.close();
        // outSD.close();
        // outTB.close();
        // outTD.close();

      } catch (IOException e) {
        e.printStackTrace();
        System.exit(-1);
      }
    }
  }
Esempio n. 4
0
 public void print(Object... objects) {
   for (int i = 0; i < objects.length; i++) {
     if (i != 0) writer.print(' ');
     writer.print(objects[i]);
   }
 }