Changeset 109 for trunk/CrossPare
- Timestamp:
- 05/27/16 16:21:15 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/GPTraining.java
r108 r109 45 45 * Genetic Programming Trainer 46 46 * 47 * 47 * Implementation according to Liu et al. Evolutionary Optimization of Software Quality Modeling with Multiple Repositories. 48 * 48 49 * - GPRun is a Run of a complete Genetic Programm Evolution, we want several complete runs. 49 50 * - GPVClassifier is the Validation Classifier 50 51 * - GPVVClassifier is the Validation-Voting Classifier 51 52 * 52 * config: <setwisetrainer name="GPTraining" param=" GPVVClassifier" />53 * config: <setwisetrainer name="GPTraining" param="populationSize=1000" /> 53 54 */ 54 55 public class GPTraining implements ISetWiseTrainingStrategy, IWekaCompatibleTrainer { 55 56 56 private GPV Classifier classifier = null;57 private GPVVClassifier classifier = null; 57 58 59 // default values from the paper 58 60 private int populationSize = 1000; 59 61 private int initMinDepth = 2; … … 62 64 private int maxGenerations = 50; 63 65 private double errorType2Weight = 15; 64 private int numberRuns = 1; // 200 in the paper66 private int numberRuns = 20; // im paper 20 per errorType2Weight then additional 20 65 67 private int maxDepth = 20; // max depth within one program 66 68 private int maxNodes = 100; // max nodes within one program … … 69 71 public void setParameter(String parameters) { 70 72 71 // todo: split parameters to get classifier and the configuration variables for the gprun 72 if(parameters.equals("GPVVClassifier")) { 73 this.classifier = new GPVVClassifier(); 74 ((GPVVClassifier)this.classifier).configure(populationSize, initMinDepth, initMaxDepth, tournamentSize, maxGenerations, errorType2Weight, numberRuns, maxDepth, maxNodes); 75 }else if(parameters.equals("GPVClassifier")) { 76 this.classifier = new GPVClassifier(); 77 ((GPVClassifier)this.classifier).configure(populationSize, initMinDepth, initMaxDepth, tournamentSize, maxGenerations, errorType2Weight, numberRuns, maxDepth, maxNodes); 78 }else { 79 // default 80 this.classifier = new GPVVClassifier(); 81 ((GPVVClassifier)this.classifier).configure(populationSize, initMinDepth, initMaxDepth, tournamentSize, maxGenerations, errorType2Weight, numberRuns, maxDepth, maxNodes); 82 } 73 String[] params = parameters.split(","); 74 String[] keyvalue = new String[2]; 75 76 for(int i=0; i < params.length; i++) { 77 keyvalue = params[i].split(":"); 78 79 switch(keyvalue[0]) { 80 case "populationSize": 81 this.populationSize = Integer.parseInt(keyvalue[1]); 82 break; 83 84 case "initMinDepth": 85 this.initMinDepth = Integer.parseInt(keyvalue[1]); 86 break; 87 88 case "tournamentSize": 89 this.tournamentSize = Integer.parseInt(keyvalue[1]); 90 break; 91 92 case "maxGenerations": 93 this.maxGenerations = Integer.parseInt(keyvalue[1]); 94 break; 95 96 case "errorType2Weight": 97 this.errorType2Weight = Double.parseDouble(keyvalue[1]); 98 break; 99 100 case "numberRuns": 101 this.numberRuns = Integer.parseInt(keyvalue[1]); 102 break; 103 104 case "maxDepth": 105 this.maxDepth = Integer.parseInt(keyvalue[1]); 106 break; 107 108 case "maxNodes": 109 this.maxNodes = Integer.parseInt(keyvalue[1]); 110 break; 111 } 112 } 113 114 this.classifier = new GPVVClassifier(); 115 ((GPVClassifier)this.classifier).configure(populationSize, initMinDepth, initMaxDepth, tournamentSize, maxGenerations, errorType2Weight, numberRuns, maxDepth, maxNodes); 83 116 } 84 117
Note: See TracChangeset
for help on using the changeset viewer.