public Chromosome calFitness(Chromosome ch, List<Datum> train, List<Datum> dev) throws IOException {
        Random r = new Random();

        FeatureFactory featureFactory = new FeatureFactory();
        String listFeature= util.Convert.convertToString(ch);
        List<Datum> computedTrain = featureFactory.computeFeature(train, listFeature);
        List<Datum> computedDev = featureFactory.computeFeature(dev, listFeature);
        String path = "temp/";


        String trainFile = path + String.valueOf(r.nextInt(1000000));
        String devFile = path + String.valueOf(r.nextDouble());
        try {
            featureFactory.writeToFeatureFile(computedTrain, trainFile, listFeature);
        } catch (IOException ex) {
            Logger.getLogger(GA_Krigg.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            featureFactory.writeToFeatureFile(computedDev, devFile, listFeature);
        } catch (IOException ex) {
            Logger.getLogger(GA_Krigg.class.getName()).log(Level.SEVERE, null, ex);
        }
        String result = null;
        try {
            result = runMaxent(trainFile, devFile);
        } catch (InterruptedException ex) {
            Logger.getLogger(GA_Krigg.class.getName()).log(Level.SEVERE, null, ex);
        }

        int start = 0;
   
        result = result.trim();
   
        for (int i = 0; i < result.length(); i++) {

            if (Character.isDigit(result.charAt(i))) {
                start = i;
                break;
            }

        }
        result = result.substring(start - 1, result.indexOf("%"));
        if (result == null) {
            System.out.println("NULL");
        }
        if (ch == null) {
            System.out.println("NULL fitnees");
        }
        if (ch.getEncodedFeature().cardinality() == 0) {
            System.out.println("Features null");
        }
//        if (featureNames == null) {
//            System.out.println("featureNames null");
//        }
        ch.setFitness(Double.valueOf(result));

        ch.setFitness_err(0);

        //add to fitnessValue
        fitnessValues.put(ch, ch.getFitness());

        //delete file
        File f = new File(trainFile);
        File f2 = new File(devFile);
        f.delete();
        f2.delete();
        if (ch.getFitness() >= 100) {
            ch.setFitness(0);
        }
        return ch;

    }