Examples of Evolution


Examples of algorithms.genetic.Evolution

  }

  @Override
  public void deal(Card[] deck) {
    Log.write("Starting HandGA algorithm with parameters:" + popSize + "," + generationSize + "," + mutProb + "," + crossProb);
    Evolution evolution = new HandEvolution(deck, this.pointsLimits, this.cardLimits, popSize, generationSize, mutProb, crossProb);
    for (int i=0;i<num;i++){
      evolution.reset();
      evolution.evolve();
      HandIndividual best = (HandIndividual)evolution.getBest();
      if (best.isIdeal())
        answers[i] = this.putInMatrix(best.toHand());
      else
        i--;
    }
View Full Code Here

Examples of play.db.evolutions.Evolution

        System.out.println("~ Connected to " + EvolutionQuery.getDatasource().getConnection().getMetaData().getURL());

        for(Entry<String, VirtualFile> moduleRoot : modulesWithEvolutions.entrySet()) {      

            /** Sumary **/
            Evolution database = listDatabaseEvolutions(moduleRoot.getKey()).peek();
            Evolution application = listApplicationEvolutions(moduleRoot.getKey(), moduleRoot.getValue()).peek();

            if ("resolve".equals(System.getProperty("mode"))) {
                try {
                    checkEvolutionsState();
                    System.out.println("~");
View Full Code Here

Examples of play.db.evolutions.Evolution

        return script;
    }

    public synchronized static Stack<Evolution> listApplicationEvolutions(String moduleKey, VirtualFile evolutionsDirectory) {
        Stack<Evolution> evolutions = new Stack<Evolution>();
        evolutions.add(new Evolution("", 0, "", "", true));
        if (evolutionsDirectory.exists()) {
            for (File evolution : evolutionsDirectory.getRealFile().listFiles()) {
                if (evolution.getName().matches("^[0-9]+[.]sql$")) {
                    if (Logger.isTraceEnabled()) {
                        Logger.trace("Loading evolution %s", evolution);
                    }

                    int version = Integer.parseInt(evolution.getName().substring(0, evolution.getName().indexOf(".")));
                    String sql = IO.readContentAsString(evolution);
                    StringBuffer sql_up = new StringBuffer();
                    StringBuffer sql_down = new StringBuffer();
                    StringBuffer current = new StringBuffer();
                    for (String line : sql.split("\r?\n")) {
                        if (line.trim().matches("^#.*[!]Ups")) {
                            current = sql_up;
                        } else if (line.trim().matches("^#.*[!]Downs")) {
                            current = sql_down;
                        } else if (line.trim().startsWith("#")) {
                            // skip
                        } else if (!StringUtils.isEmpty(line.trim())) {
                            current.append(line).append("\n");
                        }
                    }
                    evolutions.add(new Evolution(moduleKey, version, sql_up.toString(), sql_down.toString(), true));
                }
            }
            Collections.sort(evolutions);
        }
        return evolutions;
View Full Code Here

Examples of play.db.evolutions.Evolution

        return evolutions;
    }

    public synchronized static Stack<Evolution> listDatabaseEvolutions(String moduleKey) {
        Stack<Evolution> evolutions = new Stack<Evolution>();
        evolutions.add(new Evolution("", 0, "", "", false));
        Connection connection = null;
        try {
            connection = EvolutionQuery.getNewConnection();
            String tableName = "play_evolutions";
            boolean tableExists = true;
            ResultSet rs = connection.getMetaData().getTables(null, null, tableName, null);

            if (!rs.next()) {
   
                // Table in lowercase does not exist
                // oracle gives table names in upper case
                tableName = tableName.toUpperCase();
                Logger.trace("Checking " + tableName);
                rs.close();
                rs = connection.getMetaData().getTables(null, null, tableName, null);
                // Does it exist?
                if (!rs.next() ) {
                    // did not find it in uppercase either
                    tableExists = false;
                }
            }

            // Do we have a
            if (tableExists) {
               
                checkAndUpdateEvolutionsForMultiModuleSupport(connection);                   

                ResultSet databaseEvolutions = EvolutionQuery.getEvolutions(connection, moduleKey);
                               
                while (databaseEvolutions.next()) {
                    Evolution evolution = new Evolution(moduleKey, databaseEvolutions.getInt(1), databaseEvolutions.getString(3), databaseEvolutions.getString(4), false);
                    evolutions.add(evolution);
                }
           
            } else {
                EvolutionQuery.createTable();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.