예제 #1
0
  @Override
  public void update(Observable o, Object arg) {

    EvolutionaryAlgorithm algorithm = (EvolutionaryAlgorithm) o;
    BestIndividualSpecification bestSpec = new BestIndividualSpecification();
    Individual best;

    super.update(o, arg);

    if (algorithm.getState() == EvolutionaryAlgorithm.REPLACE_STATE && arg == null) {
      best = algorithm.getBestEverIndividual();
      super.getLog()
          .println(
              algorithm.getGenerations()
                  + " - "
                  + best.getFitness()
                  + " - "
                  + FitnessUtil.meanFitnessValue(algorithm.getPopulation().getIndividuals()));
    }
  }
 public static void saveToSDCard(String content) throws Exception {
   FileOutputStream fos = null;
   try {
     content += getDate();
     // 获取sd卡的路径
     logFile = new File(createLogPath());
     fos = new FileOutputStream(logFile, true);
     fos.write(content.getBytes());
   } catch (Exception e) {
     throw new Exception(Log.getStackTraceString(new Throwable()));
   } finally {
     try {
       fos.close();
       fos.flush();
     } catch (IOException e) {
       e.printStackTrace();
       LogTool.e("StorageUtils", Log.getStackTraceString(new Throwable()));
     }
   }
 }