Changeset 6327 for branches/OKBJavaConnector/ECJClient/src
- Timestamp:
- 05/28/11 10:03:00 (14 years ago)
- Location:
- branches/OKBJavaConnector/ECJClient/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKBJavaConnector/ECJClient/src/com/heuristiclab/okb/ecj/OKBStatistics.java
r6326 r6327 23 23 * 24 24 * @author fab 25 * Implementation of statics which are sending the parameters and results 26 * to the OKB Serverices 27 * 25 28 */ 26 public class OKBStatistics extends Statistics {29 public class OKBStatistics extends Statistics { 27 30 31 /** 32 * Plattformname which has to be in already in the service 33 */ 28 34 public static final String ECJ_PLATFORM_NAME = "ECJ"; 35 /** 36 * Name for parameters in the param file 37 */ 29 38 public static final String OKB_PARAMETER_NAME = "okb.parameter"; 39 /** 40 * name of the seed paramter in the params file 41 */ 30 42 public static final String OKB_PARAMETER_SEED = "okb.parameter.seed"; 43 /** 44 * username 45 */ 46 public static final String OKB_USER = "okb.username"; 47 /** 48 * password 49 */ 50 public static final String OKB_PASSWORD = "okb.password"; 51 /** 52 * current Platform 53 * */ 31 54 private Platform ecjPlatform; 32 55 /** 56 * current Alogrithm 57 */ 58 private Algorithm algorithm; 33 59 34 60 /** 61 * Setup of statistic, username and password are set 62 * 63 * platform an algorithm are fetched from the service 64 * if the platform or algorithm are missing a illegal arugement excption is thorwn 65 **/ 35 66 @Override 36 67 public void setup(EvolutionState state, Parameter base) { 37 68 super.setup(state, base); 38 39 69 handler.UserNameHandler.setUser(getUsername(state)); 70 handler.UserNameHandler.setPassword(getPassword(state)); 40 71 72 73 ecjPlatform = AdministrationServiceUtil.getPlattform(ECJ_PLATFORM_NAME); 74 algorithm = RunCreationUtil.getAlgorithm(state.evaluator.getClass().getName(), ecjPlatform.getName()); 41 75 } 42 76 43 44 45 @Override 46 public void postInitializationStatistics(EvolutionState state) { 47 super.postInitializationStatistics(state); 48 } 49 77 /** 78 * Submitting the results to the service 79 * @param state 80 * @param result 81 */ 50 82 @Override 51 83 public void finalStatistics(EvolutionState state, int result) { 52 84 super.finalStatistics(state, result); 53 85 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);59 86 60 61 62 RunCreationUtil.createRun(parameters,result,new String(o.toByteArray()),getSeed(state),algorithm.getId() , ecjPlatform.getId()); 87 Map<String, String> parameters = getParametersToSend(state); 88 ByteArrayOutputStream o = new ByteArrayOutputStream(); 89 new XMLEncoder(o).writeObject(state); 90 RunCreationUtil.createRun(parameters, result, new String(o.toByteArray()), getSeed(state), algorithm.getId(), ecjPlatform.getId()); 63 91 64 92 } 65 93 66 private int getSeed(EvolutionState state) 67 { 94 /** 95 * getting the username out of the config 96 **/ 97 protected final String getUsername(EvolutionState state) { 98 return state.parameters.getString(new Parameter(OKB_USER), null); 99 } 100 101 /** 102 * getting the password out of the config 103 * 104 */ 105 private String getPassword(EvolutionState state) { 106 return state.parameters.getString(new Parameter(OKB_PASSWORD), null); 107 } 108 109 /** 110 * getting the default seed out of the config 111 * @throws IllegalArgumentException if the seed is missing 112 */ 113 private int getSeed(EvolutionState state) { 68 114 int returnValue = 0; 69 String seedName = state.parameters.getString(new Parameter(OKB_PARAMETER_SEED), null);70 if (seedName == null)115 String seedName = state.parameters.getString(new Parameter(OKB_PARAMETER_SEED), null); 116 if (seedName == null) { 71 117 throw new IllegalArgumentException("no seed given!"); 118 } 72 119 73 returnValue = state.parameters.getInt(new Parameter(seedName), null);120 returnValue = state.parameters.getInt(new Parameter(seedName), null); 74 121 75 122 return returnValue; 76 123 } 77 124 78 79 private Map<String, String> getParametersToSend(EvolutionState state) 80 { 125 /** 126 * getting the parameters out of the config 127 **/ 128 private Map<String, String> getParametersToSend(EvolutionState state) { 81 129 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) 130 for (String name : state.parameters.getString(new Parameter(OKB_PARAMETER_NAME), null).split(";")) { 131 String tmp = state.parameters.getString(new Parameter(name.trim()), null); 132 if (tmp == null) { 86 133 returnValue.put(name, name); 87 else134 } else { 88 135 returnValue.put(name, tmp); 89 136 } 90 137 } 91 92 138 return returnValue; 93 139 } 94 95 96 97 140 } -
branches/OKBJavaConnector/ECJClient/src/tutorial1.params
r6326 r6327 53 53 eval.problem = ec.app.tutorial1.MaxOnes 54 54 55 55 stat = com.heuristiclab.okb.ecj.OKBStatistics 56 56 okb.parameter = pop.subpop.0.size; pop.subpop.0.duplicate-retrie 57 57 okb.parameter.seed = seed.0 58 okb.user = okbtester 59 okb.password = okbtester
Note: See TracChangeset
for help on using the changeset viewer.