Package eu.planets_project.pp.plato.model

Examples of eu.planets_project.pp.plato.model.DetailedExperimentInfo


        }
        return toolExp;
    }
   
    public static DetailedExperimentInfo getAverage(ToolExperience toolExp){
        DetailedExperimentInfo averages = new DetailedExperimentInfo();
        for(String key:toolExp.getMeasurements().keySet()) {
            /* average can only calculated of numeric values */
            if (toolExp.getMeasurements().get(key). getList().get(0).getValue() instanceof INumericValue) {
               Measurement m = toolExp.getAverage(key);
               if (!Double.isInfinite(((INumericValue)m.getValue()).value()))
                  averages.getMeasurements().put(key, m);
            }
        }
        return averages;
    }
View Full Code Here


//                }
//            }
            // export detailed experiment info's
            Element detailedInfos = experiment.addElement("detailedInfos");
            for (SampleObject record : exp.getDetailedInfo().keySet()) {
                DetailedExperimentInfo dinfo = exp.getDetailedInfo().get(record);
                Element detailedInfo = detailedInfos.addElement("detailedInfo")
                .addAttribute("key", record.getShortName())
                .addAttribute("successful", ""+dinfo.getSuccessful());
                addStringElement(detailedInfo, "programOutput", dinfo.getProgramOutput());
                addStringElement(detailedInfo, "cpr", dinfo.getCpr());

                Element measurements = detailedInfo.addElement("measurements");
                for (Measurement m : dinfo.getMeasurements().values()) {
                    Element measurement = measurements.addElement("measurement");
                    // measurement.value:
                    String typename = deriveElementname(m.getValue().getClass());
                   
                    Element valueElem = measurement.addElement(typename);
View Full Code Here

               
                /* calculate average per experiment */
                /* put measurements of sample files to toolExp */
                toolExp = MeasurementStatistics.generateToolExperience(e.getResult());
                /* get calculated average per property */
                DetailedExperimentInfo average = MeasurementStatistics.getAverage(toolExp);
                accumulatedAvg.put(e.getAction().getShortname(), average);
                e.getAverages().clear();
                e.getAverages().put(average);

                /* a list of all properties to iterate over the values */
                allProperties.clear();
                allProperties.addAll(toolExp.getMeasurements().keySet());
                Collections.sort(allProperties);
                /*
                 * write all measurements of this experiment to a file
                 */
                String statistics = FileUtils.makeFilename(makeUniqueActionName(e.getAction()));
                File statisticsFile = new File(currentResultdir, statistics+".csv");
                try {
                    BufferedWriter out = new BufferedWriter(new FileWriter(statisticsFile));
                    StringBuffer header = new StringBuffer();
                    header.append("sample");
                    for (String key : allProperties) {
                       header.append(CSV_SEPARATOR).append(key);
                    }
                    /* write header */
                    out.append(header);                   
                    out.newLine();
                    List<String> keySet = new ArrayList<String>(e.getResult().keySet());
                    String[] toSort = keySet.toArray(new String[]{});
                    java.util.Arrays.sort(toSort,String.CASE_INSENSITIVE_ORDER);
                   
                    /* write measured values for all samples */
                    for (int i = 0; i<toSort.length; i++){
                       String sample = toSort[i];
                       /* 1. column: sample name */
                       out.append(sample);
                       /* followed by all properties */
                       DetailedExperimentInfo info = e.getResult().get(sample);
                       for(String prop: allProperties){
                          out.append(CSV_SEPARATOR);
                          Measurement m = info.getMeasurements().get(prop);
                          if (m != null) {
                             if (m.getValue() instanceof INumericValue) {
                                /* */
                                double value = ((INumericValue)m.getValue()).value();
                                out.append(format.format(value));
                             } else
                                out.append(m.getValue().toString());
                          }
                       }
                       out.newLine();
                    }
                    /* write header again */
                    out.append(header);                   
                    out.newLine();
                    /* and write calculated average */
                    out.append("average");
                    for (String key : allProperties) {
                       out.append(CSV_SEPARATOR);
                       Measurement m = e.getAverages().getMeasurements().get(key);
                       if (m != null) {
                            if (m.getValue() instanceof INumericValue) {
                                double value = ((INumericValue)m.getValue()).value();
                                out.append(format.format(value));
                            } else
                                out.append(m.getValue().toString());
                       }
                    }
                    out.newLine();
                    out.append("startupTime");
                    out.append(CSV_SEPARATOR);

                    try {
                        out.append(Double.toString(toolExp.getStartupTime()));
                    } catch (Exception ex) {
                        log.error("Error in calculating the startup time (linear regression): " + ex.getMessage());
                        out.append("Err");
                    }
                   
                    out.newLine();
                    out.close();
                } catch (IOException e1) {
                    log.error("Could not write statistics for: " + statistics, e1);
                }
            }
            /*
             * and write accumulated values
             */
            File statisticsFile = new File(currentResultdir, "accumulated.csv");
            allProperties.clear();
            allProperties.add(MigrationResult.MIGRES_ELAPSED_TIME_PER_MB);
            allProperties.add(MigrationResult.MIGRES_USED_TIME_PER_MB);
            allProperties.add(MigrationResult.MIGRES_ELAPSED_TIME);
            allProperties.add(MigrationResult.MIGRES_USED_TIME);
            //...
           
            try {
                BufferedWriter out = new BufferedWriter(new FileWriter(statisticsFile));
                /* write machine info */
                if (toolExp != null) {
                    // use machine info of last experiment!
                    for (String prop: toolExp.getMeasurements().keySet()) {
                        if (prop.startsWith("machine:")){
                            out.append(prop)
                            .append(CSV_SEPARATOR)
                            .append(toolExp.getMeasurements().get(prop).getList().get(0).getValue().getFormattedValue());
                            out.newLine();
                        }
                    }
                    out.newLine();
                }
                /* write header */
                out.append("tool");
                for (String key : allProperties) {
                   out.append(CSV_SEPARATOR).append(key);
                }
                out.newLine();
                /* write averaged values for all actions */
                for (String action: accumulatedAvg.keySet()){
                   /* 1. column: action name */
                   out.append(action);
                   /* followed by all properties */
                   DetailedExperimentInfo average = accumulatedAvg.get(action);
                   for(String prop: allProperties){
                      out.append(CSV_SEPARATOR);
                      Measurement m = average.getMeasurements().get(prop);
                      if (m != null) {
                         if (m.getValue() instanceof INumericValue) {
                            /* */
                            double value = ((INumericValue)m.getValue()).value();
                            out.append(format.format(value));
View Full Code Here

     * @param filename
     * @param data
     */
    private MigrationResult runExperiment(MassMigrationExperiment e, String filename, byte[] data) {
        IMigrationAction service = getService(e.getAction());
        DetailedExperimentInfo eInfo = e.getResult().get(filename);
        if (eInfo == null) {
            eInfo = new DetailedExperimentInfo();
            e.getResult().put(filename, eInfo);
        }
       
        // remove old results
        eInfo.getMeasurements().clear();
       
       
        // why does this expect an instance of SampleObject ??!!
        SampleObject r = new SampleObject();
        r.getData().setData(data);
        r.setFullname(filename);
       
        Measurement success = new Measurement();
        success.setProperty(new MeasurableProperty(new BooleanScale(), MigrationResult.MIGRES_SUCCESS));
        success.setValue(success.getProperty().getScale().createValue());
       
        Measurement report = new Measurement();
        report.setProperty(new MeasurableProperty(new FreeStringScale(), MigrationResult.MIGRES_REPORT));
        report.setValue(report.getProperty().getScale().createValue());
       
        try {
            MigrationResult result = service.migrate(e.getAction(), r);
            if (result.isSuccessful()) {
                /* put all info to toolExperience */
                eInfo.getMeasurements().putAll(result.getMeasurements());

                ((BooleanValue)success.getValue()).setValue("true");
                ((FreeStringValue)report.getValue()).setValue(result.getReport());
            } else {
                ((BooleanValue)success.getValue()).setValue("false");
View Full Code Here

        }
        double sampleSize = sample.getData().getSize()*(1024*1024);
       
        if (OBJECT_ACTION_ACTIVITYLOGGING_AMOUNT.equals(propertyURI)) {
            Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
            DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
            if ((detailedExperimentInfo != null) && (detailedExperimentInfo.getProgramOutput() != null)) {
                PositiveIntegerValue v = (PositiveIntegerValue) scale.createValue();
                v.setValue(detailedExperimentInfo.getProgramOutput().length());
                v.setComment("extracted from experiment details");
                return v;
            }
            return null;
        } else if (OBJECT_ACTION_ACTIVITYLOGGING_FORMAT.equals(propertyURI)) {
            Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
            DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
            if ((detailedExperimentInfo != null) && (detailedExperimentInfo.getProgramOutput() != null)) {
                FreeStringValue v = (FreeStringValue) scale.createValue();
                v.setValue(evaluateLogging(detailedExperimentInfo.getProgramOutput()));
                v.setComment("extracted from experiments details");
                return v;
            }
            return null;
        } else if (OBJECT_ACTION_RUNTIME_PERFORMANCE_THROUGHPUT.equals(propertyURI)) {
View Full Code Here

     */
    private Value extractMeasuredValue(Alternative alternative,
            SampleObject sample, String propertyURI) {
       
        Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
        DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
        if (detailedExperimentInfo != null) {
            // retrieve the key of minimee's measuredProperty
            String measuredProperty = propertyToMeasuredValues.get(propertyURI);
            Measurement m = detailedExperimentInfo.getMeasurements().get(measuredProperty);
            if (m != null) {
                return m.getValue();
            } else {
                return null;
            }
View Full Code Here

                        // set detailed infos depending on migration result
                        extractDetailedInfos(a.getExperiment(), record, migrationResult);

                    } else {
                        DetailedExperimentInfo info = a.getExperiment().getDetailedInfo().get(record);
                        if (info == null) {
                            info = new DetailedExperimentInfo();
                            a.getExperiment().getDetailedInfo().put(record,info);
                        }
                        info.setProgramOutput(
                                String.format("Applying action %s to sample %s failed.",
                                        a.getAction().getShortname(),
                                        record.getFullname()));
                    }
                }
View Full Code Here

    
     */
    private void setUniformProgramOutput(Alternative a, String msg, boolean successful) {
        List<SampleObject> sampleObjects = selectedPlan.getSampleRecordsDefinition().getRecords();
        for (SampleObject o : sampleObjects) {
            DetailedExperimentInfo info = a.getExperiment().getDetailedInfo().get(o);
           
            if (info == null) {
                info = new DetailedExperimentInfo();
                a.getExperiment().getDetailedInfo().put(o, info);
            }
           
            info.setProgramOutput(msg);
            info.setSuccessful(successful);
        }
    }
View Full Code Here

    /**
     * stores {@link MigrationResult migration results} for the given sample object in {@link DetailedExperimentInfo experiment info} of experiment <param>e</param>.
     */
    private void extractDetailedInfos(Experiment e, SampleObject rec, MigrationResult r) {
        DetailedExperimentInfo info = e.getDetailedInfo().get(rec);
        // remove previous results
        if (info != null) {
            info.getMeasurements().clear();
        } else {
            info = new DetailedExperimentInfo();
            e.getDetailedInfo().put(rec, info);
        }
        if (r == null) {
            // nothing to add
            return;
        }
        // write info of migration result to experiment's detailedInfo
        info.getMeasurements().putAll(r.getMeasurements());
        info.setSuccessful(r.isSuccessful());
       
        if (r.getReport() == null) {
            info.setProgramOutput("The tool didn't provide any output.");
        } else {
            info.setProgramOutput(r.getReport());
        }
       
        int sizeMigratedObject = (r.getMigratedObject() == null || r.getMigratedObject().getData() == null) ? 0 : r.getMigratedObject().getData().getSize();
       
        // if the executing programme claims to have migrated the object, but the result file has size 0 than something must have
        // gone wrong. so we set the migration result to 'false' and add some text to the program output.
        if (r.isSuccessful() && sizeMigratedObject == 0) {
           info.setSuccessful(false);
           String programOutput = info.getProgramOutput();
          
           programOutput += "\nSomething went wrong during migration. No result file has been generated.";
          
           info.setProgramOutput(programOutput);
        }
    }
View Full Code Here

//                            "Emulation actions are currently only supported on samples up to a size of 2,88 MB.");
//                    return;
//                }
                try {
                   
                    DetailedExperimentInfo info = a.getExperiment().getDetailedInfo().get(sample);
                    String sessionID = null;
                    if (info == null) {
                        info = new DetailedExperimentInfo();                           
                        a.getExperiment().getDetailedInfo().put(sample, info);
                    } else {
                        Value sid = info.getMeasurements().get("sessionid").getValue();
                        if (sid != null && (sid instanceof FreeStringValue)) {
                       //     sessionID = ((FreeStringValue)sid).getValue();
                        }
                    }
                   
                    // objectTomigrate is only being read, needs to be merged to lazily get the data out
                    SampleObject objectToView = em.merge(sample);
                   
                    byte[] b = objectToView.getData().getData();
                   
                    if (sessionID == null) {
                        sessionID = ((IEmulationAction)action).startSession(a.getAction(), objectToView);
                    }
                    a.getExperiment().getDetailedInfo().get(sample).setSuccessful(true);
                    // we cannot use SETTINGS here because settings are not PER SAMPLE OBJECT!
                    info.getMeasurements().put("sessionid", new Measurement("sessionID",sessionID));
                } catch (PlatoServiceException e) {
                    String errorMsg = "Could not start emulation service." + e.getMessage();
                    setUniformProgramOutput(a, errorMsg, false);
                    FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
                            "Could not start emulation service." + e.getMessage());
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.DetailedExperimentInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.