Package eu.scape_project.planning.model.values

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


    @Test
    public void testTransformThresholdStepping_increasingOrder() {
        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


    @Test
    public void testTransformThresholdStepping_decreasingOrder() {
        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

    @Test
    public void testTransformLinear_increasingOrder() {
        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

    public void testTransformLinear_decreasingOrder() {
        NumericTransformer numTran = new NumericTransformer();
        numTran.setMode(TransformationMode.LINEAR);
        numTran.defaults(0.8, 1.2);

        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

    /**
     * @see eu.scape_project.planning.model.scales.Scale#createValue()
     */
    @Override
    public Value createValue() {
        Value v = new FloatValue();
        v.setScale(this);
        return v;
    }
View Full Code Here

     */
    @Override
    public boolean isEvaluated(Value value) {
        boolean evaluated = false;
        if ((value != null) && (value instanceof FloatValue)) {
            FloatValue v = (FloatValue)value;

            evaluated = v.isChanged();
        }
        return evaluated;
    }
View Full Code Here

        // set scale
        PositiveFloatScale scale = new PositiveFloatScale();
        leaf.setScale(scale);

        // valueMap
        FloatValue v0 = new FloatValue();
        v0.setValue(0d);
        FloatValue v1 = new FloatValue();
        v1.setValue(1d);
        FloatValue v2 = new FloatValue();
        v2.setValue(2d);
        FloatValue v3 = new FloatValue();
        v3.setValue(3d);
        FloatValue v4 = new FloatValue();
        v4.setValue(4d);
        FloatValue v5 = new FloatValue();
        v5.setValue(5d);

        Values valuesAlternative1 = new Values();
        Values valuesAlternative2 = new Values();
        valuesAlternative1.add(v0);
        valuesAlternative1.add(v0);
View Full Code Here

public class FloatValueTest {

    @Test
    public void testFormattedValue() {
        FloatValue fv = new FloatValue();

        double d = 1.234567890123450;
        double d2 = d;

        for (int i = 1; i < 30; i++) {
            fv.setValue(d);
            // System.out.println(fv.getFormattedValue());
            fv.setValue(-d);
            // System.out.println(fv.getFormattedValue());
            fv.setValue(d2);
            // System.out.println(fv.getFormattedValue());
            fv.setValue(-d2);
            // System.out.println(fv.getFormattedValue());
            d = d * 10;
            d2 = d2 / 10.;
        }

View Full Code Here

TOP

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

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.