package com.srbenoit.math.optimizers;

/**
 * The computed value of an optimizable object, along with a flag indicating whether the parameters
 * were in range or not.
 */
public class OutputValue {

    /** the computed value */
    private double value = 0;

    /** true if the parameters were out of range; false if not */
    private boolean outOfRange = false;

    /**
     * Gets the current value.
     *
     * @return  the value
     */
    public double getValue() {

        return this.value;
    }

    /**
     * Sets the current value.
     *
     * @param  newValue  the new value
     */
    public void setValue(final double newValue) {

        this.value = newValue;
    }

    /**
     * Tests whether or not the value is out of range.
     *
     * @return  <code>true</code> if the value is out of range; <code>false</code> otherwise
     */
    public boolean isOutOfRange() {

        return this.outOfRange;
    }

    /**
     * Sets the flag that indicates whether or not the value is out of range.
     *
     * @param  outOfRange  <code>true</code> if the value is out of range; <code>false</code>
     *                     otherwise
     */
    public void setOutOfRange(final boolean outOfRange) {

        this.outOfRange = outOfRange;
    }

    /**
     * Generates the string representation of the value.
     *
     * @return  the <code>String</code>
     */
    @Override public String toString() {

        return Double.toString(this.value);
    }
}
