public double defuzzify() {
        double result;
        boolean isValid = this.enabled && !this.fuzzyOutput.getTerms().isEmpty();
        if (isValid) {
            result = this.defuzzifier.defuzzify(fuzzyOutput, minimum, maximum);
        } else {
            //if a previous defuzzification was successfully performed and
            //and the output is supposed to not change when the output is empty
            if (this.lockValidOutput && !Double.isNaN(this.lastValidOutput)) {
                result = this.lastValidOutput;
            } else {
                result = this.defaultValue;
            }
        }
        if (this.lockOutputRange) {
            if (Op.isLt(result, minimum)) {
                result = minimum;
            }
            if (Op.isGt(result, maximum)) {
                result = maximum;
            }
        }
        if (isValid) {
            this.lastValidOutput = result;
        }
        return result;
    }