@Override
    public void configureConstraintWeight(Rule rule, BendableScore constraintWeight) {
        super.configureConstraintWeight(rule, constraintWeight);
        BiConsumer<RuleContext, Integer> matchExecutor;
        if (constraintWeight.equals(BendableScore.zero(hardScores.length, softScores.length))) {
            matchExecutor = (RuleContext kcontext, Integer matchWeight) -> {};
        } else {
            Integer singleLevel = null;
            Integer singleLevelWeight = null;
            for (int i = 0; i < constraintWeight.getLevelsSize(); i++) {
                int levelWeight = constraintWeight.getHardOrSoftScore(i);
                if (levelWeight != 0) {
                    if (singleLevel != null) {
                        singleLevel = null;
                        singleLevelWeight = null;
                        break;
                    }
                    singleLevel = i;
                    singleLevelWeight = levelWeight;
                }
            }
            if (singleLevel != null) {
                int levelWeight = singleLevelWeight;
                if (singleLevel < constraintWeight.getHardLevelsSize()) {
                    int level = singleLevel;
                    matchExecutor = (RuleContext kcontext, Integer matchWeight)
                            -> addHardConstraintMatch(kcontext, level, levelWeight * matchWeight);
                } else {
                    int level = singleLevel - constraintWeight.getHardLevelsSize();
                    matchExecutor = (RuleContext kcontext, Integer matchWeight)
                            -> addSoftConstraintMatch(kcontext, level, levelWeight * matchWeight);
                }
            } else {
                matchExecutor = (RuleContext kcontext, Integer matchWeight)-> {
                    int[] hardWeights = new int[hardScores.length];
                    int[] softWeights = new int[softScores.length];
                    for (int i = 0; i < hardWeights.length; i++) {
                        hardWeights[i] = constraintWeight.getHardScore(i) * matchWeight;
                    }
                    for (int i = 0; i < softWeights.length; i++) {
                        softWeights[i] = constraintWeight.getSoftScore(i) * matchWeight;
                    }
                    addMultiConstraintMatch(kcontext, hardWeights, softWeights);
                };
            }
        }
        matchExecutorByNumberMap.put(rule, matchExecutor);
        matchExecutorByScoreMap.put(rule, (RuleContext kcontext, BendableScore weightMultiplier) -> {
            int[] hardWeights = new int[hardScores.length];
            int[] softWeights = new int[softScores.length];
            for (int i = 0; i < hardWeights.length; i++) {
                hardWeights[i] = constraintWeight.getHardScore(i) * weightMultiplier.getHardScore(i);
            }
            for (int i = 0; i < softWeights.length; i++) {
                softWeights[i] = constraintWeight.getSoftScore(i) * weightMultiplier.getSoftScore(i);
            }
            addMultiConstraintMatch(kcontext, hardWeights, softWeights);
        });
    }
@Override
    public void configureConstraintWeight(Rule rule, BendableScore constraintWeight) {
        super.configureConstraintWeight(rule, constraintWeight);
        BiConsumer<RuleContext, Integer> matchExecutor;
        if (constraintWeight.equals(BendableScore.zero(hardScores.length, softScores.length))) {
            matchExecutor = (RuleContext kcontext, Integer matchWeight) -> {};
        } else {
            Integer singleLevel = null;
            Integer singleLevelWeight = null;
            for (int i = 0; i < constraintWeight.getLevelsSize(); i++) {
                int levelWeight = constraintWeight.getHardOrSoftScore(i);
                if (levelWeight != 0) {
                    if (singleLevel != null) {
                        singleLevel = null;
                        singleLevelWeight = null;
                        break;
                    }
                    singleLevel = i;
                    singleLevelWeight = levelWeight;
                }
            }
            if (singleLevel != null) {
                int levelWeight = singleLevelWeight;
                if (singleLevel < constraintWeight.getHardLevelsSize()) {
                    int level = singleLevel;
                    matchExecutor = (RuleContext kcontext, Integer matchWeight)
                            -> addHardConstraintMatch(kcontext, level, levelWeight * matchWeight);
                } else {
                    int level = singleLevel - constraintWeight.getHardLevelsSize();
                    matchExecutor = (RuleContext kcontext, Integer matchWeight)
                            -> addSoftConstraintMatch(kcontext, level, levelWeight * matchWeight);
                }
            } else {
                matchExecutor = (RuleContext kcontext, Integer matchWeight)-> {
                    int[] hardWeights = new int[hardScores.length];
                    int[] softWeights = new int[softScores.length];
                    for (int i = 0; i < hardWeights.length; i++) {
                        hardWeights[i] = constraintWeight.getHardScore(i) * matchWeight;
                    }
                    for (int i = 0; i < softWeights.length; i++) {
                        softWeights[i] = constraintWeight.getSoftScore(i) * matchWeight;
                    }
                    addMultiConstraintMatch(kcontext, hardWeights, softWeights);
                };
            }
        }
        matchExecutorByNumberMap.put(rule, matchExecutor);
        matchExecutorByScoreMap.put(rule, (RuleContext kcontext, BendableScore weightMultiplier) -> {
            int[] hardWeights = new int[hardScores.length];
            int[] softWeights = new int[softScores.length];
            for (int i = 0; i < hardWeights.length; i++) {
                hardWeights[i] = constraintWeight.getHardScore(i) * weightMultiplier.getHardScore(i);
            }
            for (int i = 0; i < softWeights.length; i++) {
                softWeights[i] = constraintWeight.getSoftScore(i) * weightMultiplier.getSoftScore(i);
            }
            addMultiConstraintMatch(kcontext, hardWeights, softWeights);
        });
    }
@ Override public void configureConstraintWeight ( Rule rule , BendableScore constraintWeight ) { super . configureConstraintWeight ( rule , constraintWeight ) ; BiConsumer < RuleContext , Integer > matchExecutor ; if ( constraintWeight . equals ( BendableScore . zero ( hardScores . length , softScores . length ) ) ) { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> { } ; } else { Integer singleLevel = null ; Integer singleLevelWeight = null ; for ( int i = 0 ; i < constraintWeight . getLevelsSize ( ) ; i ++ ) { int levelWeight = constraintWeight . getHardOrSoftScore ( i ) ; if ( levelWeight != 0 ) { if ( singleLevel != null ) { singleLevel = null ; singleLevelWeight = null ; break ; } singleLevel = i ; singleLevelWeight = levelWeight ; } } if ( singleLevel != null ) { int levelWeight = singleLevelWeight ; if ( singleLevel < constraintWeight . getHardLevelsSize ( ) ) { int level = singleLevel ; matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addHardConstraintMatch ( kcontext , level , levelWeight * matchWeight ) ; } else { int level = singleLevel - constraintWeight . getHardLevelsSize ( ) ; matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> addSoftConstraintMatch ( kcontext , level , levelWeight * matchWeight ) ; } } else { matchExecutor = ( RuleContext kcontext , Integer matchWeight ) -> { int [ ] hardWeights = new int [ hardScores . length ] ; int [ ] softWeights = new int [ softScores . length ] ; for ( int i = 0 ; i < hardWeights . length ; i ++ ) { hardWeights [ i ] = constraintWeight . getHardScore ( i ) * matchWeight ; } for ( int i = 0 ; i < softWeights . length ; i ++ ) { softWeights [ i ] = constraintWeight . getSoftScore ( i ) * matchWeight ; } addMultiConstraintMatch ( kcontext , hardWeights , softWeights ) ; } ; } } matchExecutorByNumberMap . put ( rule , matchExecutor ) ; matchExecutorByScoreMap . put ( rule , ( RuleContext kcontext , BendableScore weightMultiplier ) -> { int [ ] hardWeights = new int [ hardScores . length ] ; int [ ] softWeights = new int [ softScores . length ] ; for ( int i = 0 ; i < hardWeights . length ; i ++ ) { hardWeights [ i ] = constraintWeight . getHardScore ( i ) * weightMultiplier . getHardScore ( i ) ; } for ( int i = 0 ; i < softWeights . length ; i ++ ) { softWeights [ i ] = constraintWeight . getSoftScore ( i ) * weightMultiplier . getSoftScore ( i ) ; } addMultiConstraintMatch ( kcontext , hardWeights , softWeights ) ; } ) ; }
************************************************************************
************************************************************************