Package eu.scape_project.planning.model.transform

Examples of eu.scape_project.planning.model.transform.NumericTransformer


        for (Leaf leaf : tree.getRoot().getAllLeaves()) {
            Transformer t = leaf.getTransformer();
            if (t instanceof NumericTransformer) {
                // calculate min, max
                // set min,max
                NumericTransformer nt = (NumericTransformer) t;

                // A very specific assumption: the lower the better (!)
                // obviously often not true, e.g. for format/numberOfTools

                double min = Long.MAX_VALUE;
                double max = Long.MIN_VALUE;

                for (Alternative a : alternativesDefinition.getConsideredAlternatives()) {
                    for (Value v : leaf.getValues(a.getName()).getList()) {
                        INumericValue value = (INumericValue) v;
                        if (value.value() > max) {
                            max = value.value();
                        }
                        if (value.value() < min) {
                            min = value.value();
                        }
                    }
                }
                nt.defaults(min, max);
                nt.setMode(TransformationMode.LINEAR);
            } else {
                OrdinalTransformer ot = (OrdinalTransformer) t;
                if (leaf.getScale() instanceof BooleanScale) {

                    ot.getMapping().put("Yes", new TargetValueObject(5));
View Full Code Here


                assertEl.addAttribute("test", test);
                assertEl.setText(explanation);
            }
          
        } else if (leaf.getTransformer() instanceof NumericTransformer){
            NumericTransformer numericT = (NumericTransformer)leaf.getTransformer();
            String explanation = leaf.getMeasure().getName() + " must be ";
            String operator;
            if (numericT.hasIncreasingOrder()) {
                explanation = explanation + " greater than or equal to " + numericT.getThreshold1();
                operator = " >= ";
            } else {
                explanation = explanation + " less than or equal to " + numericT.getThreshold1();
                operator = " <= ";               
            }
            String test = " . " + operator + " " + numericT.getThreshold1();

            Element rule = parent.addElement("rule");
            rule.addAttribute("context", CONTEXT_MEASURE.replace("${MEASURE}", leaf.getMeasure().getUri()));
            Element assertEl = rule.addElement("assert");
            assertEl.addAttribute("test", test);
View Full Code Here

                    // CHECK NUMERIC TRANSFORMER THRESHOLDS
                    for (Leaf l : plan.getTree().getRoot().getAllLeaves()) {
                        eu.scape_project.planning.model.transform.Transformer t = l.getTransformer();
                        if (t != null && t instanceof NumericTransformer) {
                            NumericTransformer nt = (NumericTransformer) t;
                            if (!nt.checkOrder()) {
                                StringBuffer sb = new StringBuffer("NUMERICTRANSFORMER THRESHOLD ERROR ");
                                sb.append(l.getName()).append("::NUMERICTRANSFORMER:: ");
                                sb.append(nt.getThreshold1()).append(" ").append(nt.getThreshold2()).append(" ")
                                    .append(nt.getThreshold3()).append(" ").append(nt.getThreshold4()).append(" ")
                                    .append(nt.getThreshold5());
                                log.error(sb.toString());
                            }
                        }
                    }
View Full Code Here

                table.addTargetValue(2.0);
                table.addTargetValue(3.0);
                table.addTargetValue(4.0);
                table.addTargetValue(5.0);

                NumericTransformer nTrans = (NumericTransformer) trans;
                Map<Double, String> tableMapping = new HashMap<Double, String>();
                tableMapping.put(1.0, nTrans.getThreshold1().toString());
                tableMapping.put(2.0, nTrans.getThreshold2().toString());
                tableMapping.put(3.0, nTrans.getThreshold3().toString());
                tableMapping.put(4.0, nTrans.getThreshold4().toString());
                tableMapping.put(5.0, nTrans.getThreshold5().toString());

                TransformationMode tMode = nTrans.getMode();
                table.addTransformerMapping(tableMapping, "thresholds (" + tMode.getName().toLowerCase() + ")");
            }
        }

        return table;
View Full Code Here

                log.info(prefix + "1st " + planInfo.getWinningAlternative() + ", 2nd : " + sndAlternative
                    + " in plan: " + planInfo.getId());
                // this criterion could be a game changer - map it back to the
                // measurement scale
                if (pLeaf.getTransformer() instanceof NumericTransformer) {
                    NumericTransformer numTransformer = (NumericTransformer) pLeaf.getTransformer();
                    // For numeric values: The percentage that we can change the
                    // value on the (overally!) winning candidate
                    // without the output range changing so much as to make the
                    // winning candidate lose its winning rank

                    // TODO: CHECK: Do we have a problem here? the values of an
                    // alternative are first transformed, then aggregated
                    // therefore we have to transform this winning value also
                    // back ...
                    double winnerMeasuredValue = numTransformer.transformBack(winnerTargetValue);
                    double minMeasuredValue = numTransformer.transformBack(minTargetValue);

                    // TODO: what if the measured value was 0.0?
                    if (winnerMeasuredValue != 0.0) {
                        leafFactor = (winnerMeasuredValue - minMeasuredValue) / winnerMeasuredValue;
                        if (!numTransformer.hasIncreasingOrder()) {
                            leafFactor *= -1.0;
                        }
                    }
                    log.info(prefix + " - numeric = " + leafFactor + intermediaryResults + ";  winnerMeasuredValue = "
                        + winnerMeasuredValue + "; minMeasuredValue = " + minMeasuredValue + "; plan id "
View Full Code Here

                                .addAttribute("target",
                                    floatFormatter.formatFloatPrecisly(mapping.get(ordinal).getValue()));
                        }
                    }
                    if (l.getTransformer() instanceof NumericTransformer) {
                        NumericTransformer nt = (NumericTransformer) l.getTransformer();
                        transformer.addElement("mode").addAttribute("value", nt.getMode().name());
                        Element thresholds = transformer.addElement("thresholds");
                        thresholds.addElement("threshold1").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold1()));
                        thresholds.addElement("threshold2").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold2()));
                        thresholds.addElement("threshold3").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold3()));
                        thresholds.addElement("threshold4").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold4()));
                        thresholds.addElement("threshold5").setText(
                            floatFormatter.formatFloatPrecisly(nt.getThreshold5()));

                    }
                    addChangeLog(l.getTransformer().getChangeLog(), transformer);
                }
View Full Code Here

      Measure meas = leaf.getMeasure();
      Question q = null;
        if (leaf.getTransformer() instanceof OrdinalTransformer) {
          // TODO
        } else if (leaf.getTransformer() instanceof NumericTransformer){
            NumericTransformer numericT = (NumericTransformer)leaf.getTransformer();
           
            String name = meas.getName();
            String operator;
            if (numericT.hasIncreasingOrder()) {
              // values must be greater or equal threshold 1, therefore we watch for smaller values
                operator = " < ";
            } else {
              // values must be smaller or equal threshold 1, therefore we watch for higher values
                operator = " > ";
            }
           
        if ("http://purl.org/DP/quality/measures#11".equals(meas.getUri())) {
          // this value is accumulated, we check for min/max
         
              if (numericT.hasIncreasingOrder()) {
                  name = "Minimum " + name;
              } else {
                  name = "Maximum " + name;
              }
              String threshold = "" + numericT.getThreshold1();
          String sparql = String.format(
              "?p rdf:type watch:Property. " +
                "?p watch:name ?n . " +
                "?v watch:property ?p. " +
                "?v watch:floatValue ?fv. " +
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.transform.NumericTransformer

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.