Package eu.scape_project.planning.model.values

Examples of eu.scape_project.planning.model.values.TargetValue


            List<Value> alternativeValues = valueMap.get(alternative).getList();
            List<Double> alternativeTransformedValues = new ArrayList<Double>();

            // collect alternativeTransformedValues
            for (Value alternativeValue : alternativeValues) {
                TargetValue targetValue;

                // do ordinal transformation
                if (transformer instanceof OrdinalTransformer) {
                    OrdinalTransformer ordTrans = (OrdinalTransformer) transformer;

                    if (alternativeValue instanceof IOrdinalValue) {
                        try {
                            targetValue = ordTrans.transform((IOrdinalValue) alternativeValue);
                        } catch (NullPointerException e) {
                            log.warn("Measurement of leaf doesn't match with OrdinalTransformer! Ignoring it!");
                            log.warn("MeasuredValue-id: " + alternativeValue.getId() + "; Transformer-id: "
                                + ordTrans.getId());
                            // FIXME: this is a workaround for a strange bug
                            // described in changeset 4342
                            skipAlternativeBecauseOfErrors = true;
                            continue;
                        }
                        alternativeTransformedValues.add(targetValue.getValue());
                    } else {
                        log.warn("getActualOutputRange(): INumericValue value passed to OrdinalTransformer - ignore value");
                    }
                }

                // do numeric transformation
                if (transformer instanceof NumericTransformer) {
                    NumericTransformer numericTrans = (NumericTransformer) transformer;

                    if (alternativeValue instanceof INumericValue) {
                        targetValue = numericTrans.transform((INumericValue) alternativeValue);
                        alternativeTransformedValues.add(targetValue.getValue());
                    } else {
                        log.warn("getActualOutputRange(): IOrdinalValue value passed to NumericTransformer - ignore value");
                    }
                }
            }
View Full Code Here


            List<Double> alternativeTransformedValues = new ArrayList<Double>();
            Boolean skipAlternativeBecauseOfErrors = false;

            // collect alternativeTransformedValues
            for (Value alternativeValue : alternativeValues) {
                TargetValue targetValue;

                // do ordinal transformation
                if (transformer instanceof OrdinalTransformer) {
                    OrdinalTransformer ordTrans = (OrdinalTransformer) transformer;

                    if (alternativeValue instanceof IOrdinalValue) {
                        try {
                            targetValue = ordTrans.transform((IOrdinalValue) alternativeValue);
                        } catch (NullPointerException e) {
                            log.warn("Measurement of leaf doesn't match with OrdinalTransformer! Ignoring it!");
                            log.warn("MeasuredValue-id: " + alternativeValue.getId() + "; Transformer-id: "
                                + ordTrans.getId());
                            // FIXME: this is a workaround for a strange bug
                            // described in changeset 4342
                            skipAlternativeBecauseOfErrors = true;
                            continue;
                        }
                        alternativeTransformedValues.add(targetValue.getValue());
                    } else {
                        log.warn("getActualOutputRange(): INumericValue value passed to OrdinalTransformer - ignore value");
                    }
                }

                // do numeric transformation
                if (transformer instanceof NumericTransformer) {
                    NumericTransformer numericTrans = (NumericTransformer) transformer;

                    if (alternativeValue instanceof INumericValue) {
                        targetValue = numericTrans.transform((INumericValue) alternativeValue);
                        alternativeTransformedValues.add(targetValue.getValue());
                    } else {
                        log.warn("getActualOutputRange(): IOrdinalValue value passed to NumericTransformer - ignore value");
                    }
                }
            }
View Full Code Here

    map.put("BAD", t2);
    map.put("HORRIBLE", t3);
    ord.setMapping(map);
    OrdinalValue value = new OrdinalValue();
    value.setValue("GOOD");
    TargetValue r = ord.transform(value);
    Assert.assertTrue(r.getValue()==1.4);
    //value.setValue("EXCELENT");
    //r = ord.transform(value);
    //Assert.assertTrue(r.getValue()==null);
  }
View Full Code Here

        NumericTransformer numTran = new NumericTransformer();
        numTran.setMode(TransformationMode.THRESHOLD_STEPPING);
        numTran.defaults(1.2, 0.8);
        FloatValue value = new FloatValue();
        value.setValue(1.12);
        TargetValue res = numTran.transform(value);
        Assert.assertTrue(res.getValue() == 4);
        value.setValue(0.81);
        res = numTran.transform(value);
        Assert.assertTrue(res.getValue() == 1);
    }
View Full Code Here

        NumericTransformer numTran = new NumericTransformer();
        numTran.setMode(TransformationMode.THRESHOLD_STEPPING);
        numTran.defaults(0.8, 1.2);
        FloatValue value = new FloatValue();
        value.setValue(1.201);
        TargetValue res = numTran.transform(value);
        Assert.assertTrue(res.getValue() == 0);
        value.setValue(1.02);
        res = numTran.transform(value);
        Assert.assertTrue(res.getValue() == 2);
    }
View Full Code Here

        NumericTransformer numTran = new NumericTransformer();
        numTran.setMode(TransformationMode.LINEAR);
        numTran.defaults(1.2, 0.8);
        FloatValue value = new FloatValue();
        value.setValue(0.5);
        TargetValue res = numTran.transform(value);
        Assert.assertTrue(res.getValue() == 0);
        value.setValue(0.85);
        res = numTran.transform(value);
        // System.out.println(res.getValue());
        Assert.assertTrue(Math.abs(res.getValue() - 1.5) <= 10e-8);

        FloatValue x1 = new FloatValue();
        x1.setValue(0.91);
        FloatValue x2 = new FloatValue();
        x2.setValue(1.07);
        TargetValue y1 = numTran.transform(x1);
        TargetValue y2 = numTran.transform(x2);
        FloatValue xt = new FloatValue();
        xt.setValue(1.02);
        double expected = ((y2.getValue() - y1.getValue()) / (x2.getValue() - x1.getValue()))
            * (xt.getValue() - x1.getValue()) + y1.getValue();
        TargetValue rez = numTran.transform(xt);
        // System.out.println(expected + " " + rez.getValue());
        Assert.assertTrue(Math.abs(rez.getValue() - expected) <= 10e-8);
    }
View Full Code Here

        FloatValue x1 = new FloatValue();
        x1.setValue(0.91);
        FloatValue x2 = new FloatValue();
        x2.setValue(1.07);
        TargetValue y1 = numTran.transform(x1);
        TargetValue y2 = numTran.transform(x2);
        FloatValue xt = new FloatValue();
        xt.setValue(1.02);
        double expected = ((y2.getValue() - y1.getValue()) / (x2.getValue() - x1.getValue()))
            * (xt.getValue() - x1.getValue()) + y1.getValue();
        TargetValue rez = numTran.transform(xt);
        // System.out.println(expected + " " + rez.getValue());
        Assert.assertTrue(Math.abs(rez.getValue() - expected) <= 10e-8);
    }
View Full Code Here

        }

        // transform measured values
        List<Double> transformedValues = new ArrayList<Double>();
        for (Value val : valueList) {
            TargetValue targetValue;

            // do ordinal transformationCriterion
            if (transformer instanceof OrdinalTransformer) {
                OrdinalTransformer ordTrans = (OrdinalTransformer) transformer;

                if (val instanceof IOrdinalValue) {
                    try {
                        targetValue = ordTrans.transform((IOrdinalValue) val);
                    } catch (NullPointerException e) {
                        log.warn("Measurement of leaf doesn't match with OrdinalTransformer! Ignoring it!");
                        log.warn("MeasuredValue-id: " + val.getId() + "; Transformer-id: " + ordTrans.getId());
                        continue;
                    }
                    transformedValues.add(targetValue.getValue());
                } else {
                    log.warn("getActualOutputRange(): INumericValue value passed to OrdinalTransformer - ignore value");
                }
            }

            // do numeric transformation
            if (transformer instanceof NumericTransformer) {
                NumericTransformer numericTrans = (NumericTransformer) transformer;

                if (val instanceof INumericValue) {
                    targetValue = numericTrans.transform((INumericValue) val);
                    transformedValues.add(targetValue.getValue());
                } else {
                    log.warn("getActualOutputRange(): IOrdinalValue value passed to NumericTransformer - ignore value");
                }
            }
        }
View Full Code Here

     * @param v
     *            the ordinal value to be transformed
     * @return {@link TargetValue} transformed value.
     */
    public TargetValue transform(IOrdinalValue v) {
        TargetValue t = new TargetValue();
        TargetValueObject o = mapping.get(v.getValue());
        t.setValue(o.getValue());
        return t;
    }
View Full Code Here

     * @param d
     *            value to be transformed
     * @return transformed {@link TargetValue}
     */
    private TargetValue doTransform(double d) {
        TargetValue v = new TargetValue();
        switch (mode) {
            case THRESHOLD_STEPPING:
                v.setValue(thresholdstepping(d));
                break;
            case LINEAR:
                v.setValue(linear(d));
                break;
            default:
                LoggerFactory.getLogger(this.getClass()).error("TransformationMode is not set correctly.");
        }
        return v;
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.values.TargetValue

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.