Changeset 6326
- Timestamp:
- 05/28/11 00:04:03 (13 years ago)
- Location:
- branches/OKBJavaConnector/ECJClient/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKBJavaConnector/ECJClient/src/com/heuristiclab/okb/ecj/OKBStatistics.java
r6152 r6326 10 10 import com.heuristiclab.okb.service.administration.Platform; 11 11 12 import java.util.Map; 12 13 13 14 import ec.EvolutionState; 14 15 import ec.Statistics; 15 16 import ec.util.Parameter; 16 import ec.util.ParameterDatabase; 17 18 import java.beans.XMLEncoder; 19 import java.io.ByteArrayOutputStream; 20 import java.util.HashMap; 17 21 18 22 /** … … 22 26 public class OKBStatistics extends Statistics{ 23 27 24 public static final String ECJ_PLATFORM_NAME = "Unknown"; 28 public static final String ECJ_PLATFORM_NAME = "ECJ"; 29 public static final String OKB_PARAMETER_NAME = "okb.parameter"; 30 public static final String OKB_PARAMETER_SEED = "okb.parameter.seed"; 25 31 private Platform ecjPlatform; 26 private Algorithm algorithm;32 27 33 28 34 … … 40 46 public void postInitializationStatistics(EvolutionState state) { 41 47 super.postInitializationStatistics(state); 48 } 42 49 43 ecjPlatform = AdministrationServiceUtil.getPlattform(ECJ_PLATFORM_NAME); 44 algorithm = RunCreationUtil.getAlgorithm(state.evaluator.getClass().getName(), ecjPlatform.getName()); 45 Object o = state.parameters; 46 while(state.parameters.elements().hasMoreElements()) 47 System.out.print(state.parameters.elements().nextElement()); 48 49 ; 50 state.parameters.getProperty("state.parameters.entrySet()"); 51 state.parameters.getString(new Parameter("print-params"),new Parameter("")); 52 50 @Override 51 public void finalStatistics(EvolutionState state, int result) { 52 super.finalStatistics(state, result); 53 54 ecjPlatform = AdministrationServiceUtil.getPlattform(ECJ_PLATFORM_NAME); 55 Algorithm algorithm = RunCreationUtil.getAlgorithm(state.evaluator.getClass().getName(), ecjPlatform.getName()); 56 Map<String, String> parameters = getParametersToSend(state); 57 ByteArrayOutputStream o = new ByteArrayOutputStream(); 58 new XMLEncoder(o).writeObject(state); 53 59 54 60 61 62 RunCreationUtil.createRun(parameters,result,new String(o.toByteArray()),getSeed(state),algorithm.getId() , ecjPlatform.getId()); 63 64 } 65 66 private int getSeed(EvolutionState state) 67 { 68 int returnValue = 0; 69 String seedName = state.parameters.getString(new Parameter(OKB_PARAMETER_SEED),null); 70 if(seedName == null) 71 throw new IllegalArgumentException("no seed given!"); 72 73 returnValue = state.parameters.getInt(new Parameter(seedName),null); 74 75 return returnValue; 76 } 77 78 79 private Map<String, String> getParametersToSend(EvolutionState state) 80 { 81 Map<String, String> returnValue = new HashMap<String, String>(); 82 for(String name : state.parameters.getString(new Parameter(OKB_PARAMETER_NAME),null).split(";")) 83 { 84 String tmp = state.parameters.getString(new Parameter(name.trim()),null); 85 if(tmp == null) 86 returnValue.put(name, name); 87 else 88 returnValue.put(name, tmp); 89 90 } 91 92 return returnValue; 55 93 } 56 94 57 95 58 96 59 60 61 97 } -
branches/OKBJavaConnector/ECJClient/src/tutorial1.params
r6152 r6326 52 52 print-all-params = true 53 53 eval.problem = ec.app.tutorial1.MaxOnes 54 55 56 okb.parameter = pop.subpop.0.size; pop.subpop.0.duplicate-retrie 57 okb.parameter.seed = seed.0
Note: See TracChangeset
for help on using the changeset viewer.