public Optional<Number> evaluate(final List<KiePMMLDefineFunction> defineFunctions,
                                     final List<KiePMMLDerivedField> derivedFields,
                                     final List<KiePMMLOutputField> outputFields,
                                     final Map<String, Object> inputData,
                                     final PMMLRuntimeContext context,
                                     final Number initialScore,
                                     final REASONCODE_ALGORITHM reasoncodeAlgorithm,
                                     final boolean useReasonCodes,
                                     final Number baselineScore) {
        Number accumulator = null;
        for (KiePMMLCharacteristic characteristic : characteristics) {
            final KiePMMLCharacteristic.ReasonCodeValue evaluation = characteristic.evaluate(defineFunctions,
                                                                                             derivedFields,
                                                                                             outputFields, inputData);
            if (evaluation != null) {
                final Number evaluationScore = evaluation.getScore();
                if (accumulator == null) {
                    accumulator = initialScore != null ? initialScore : 0;
                }
                accumulator = addNumbers(accumulator, evaluationScore);
                if (useReasonCodes && evaluation.getReasonCode() != null) {
                    populateReasonCodes(evaluation, characteristic, reasoncodeAlgorithm, context.getOutputFieldsMap()
                            , baselineScore);
                }
            }
        }
        return Optional.ofNullable(accumulator);
    }
@Test
    void evaluate() {
        Double initialScore = 25.23;
        KiePMMLCharacteristics kiePMMLCharacteristics = new KiePMMLCharacteristics("NAME", Collections.emptyList(),
                getKiePMMLCharacteristicList());
        PMMLRuntimeContextTest pmmlContextTest = new PMMLRuntimeContextTest();
        Optional<Number> retrieved = kiePMMLCharacteristics.evaluate(Collections.emptyList(), Collections.emptyList()
        , Collections.emptyList(), Collections.emptyMap(),
                pmmlContextTest,
                initialScore,
                REASONCODE_ALGORITHM.POINTS_BELOW,
                true,
                0);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved).isPresent();
        Double EVALUATION_20 = baselineScore - value2;
        Double EVALUATION_11 = baselineScore - value1;
        Double expected = initialScore + value2 + value1 + 1;
        assertThat(retrieved.get()).isEqualTo(expected);
        final Map<String, Object> outputFieldsMap = pmmlContextTest.getOutputFieldsMap();
        assertThat(outputFieldsMap).hasSize(2);
        assertThat(outputFieldsMap).containsKey("REASON_CODE_20");
        assertThat(outputFieldsMap.get("REASON_CODE_20")).isEqualTo(EVALUATION_20);
        assertThat(outputFieldsMap).containsKey("REASON_CODE_11");
        assertThat(outputFieldsMap.get("REASON_CODE_11")).isEqualTo(EVALUATION_11);
    }