Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/11 00:04:03 (14 years ago)
Author:
bfarka
Message:

added ecj and custom statistics to communicate with the okb services #1441

Location:
branches/OKBJavaConnector/ECJClient/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/ECJClient/src/com/heuristiclab/okb/ecj/OKBStatistics.java

    r6152 r6326  
    1010import com.heuristiclab.okb.service.administration.Platform;
    1111
     12import java.util.Map;
    1213
    1314import ec.EvolutionState;
    1415import ec.Statistics;
    1516import ec.util.Parameter;
    16 import ec.util.ParameterDatabase;
     17
     18import java.beans.XMLEncoder;
     19import java.io.ByteArrayOutputStream;
     20import java.util.HashMap;
    1721
    1822/**
     
    2226public class OKBStatistics extends Statistics{
    2327
    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";
    2531    private Platform ecjPlatform;
    26     private Algorithm algorithm;
     32   
    2733
    2834
     
    4046    public void postInitializationStatistics(EvolutionState state) {
    4147        super.postInitializationStatistics(state);
     48    }
    4249
    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);
    5359
    5460
     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;
    5593    }
    5694   
    5795   
    5896   
    59    
    60    
    6197}
  • branches/OKBJavaConnector/ECJClient/src/tutorial1.params

    r6152 r6326  
    5252print-all-params = true
    5353eval.problem    = ec.app.tutorial1.MaxOnes
     54
     55
     56okb.parameter = pop.subpop.0.size; pop.subpop.0.duplicate-retrie
     57okb.parameter.seed = seed.0
Note: See TracChangeset for help on using the changeset viewer.