admin管理员组

文章数量:1123371

What is the Python equivalent class (SequenceChain) and method (getConsecutiveSequences()) for the following Java Timefold piece of code?

flattenLast(SequenceChain::getConsecutiveSequences)

This line of code is used in one of the Quickstart examples like this:

protected Constraint multipleConsecutiveHomeMatches(ConstraintFactory constraintFactory) {
        return constraintFactory.forEach(Match.class)
                .join(Team.class, equal(Match::getHomeTeam, Function.identity()))
                .groupBy((match, team) -> team,
                        ConstraintCollectors.toConsecutiveSequences((match, team) -> match.getRound(), Round::getIndex))
                .flattenLast(SequenceChain::getConsecutiveSequences)
                .filter((team, matches) -> matches.getCount() >= MAX_CONSECUTIVE_MATCHES)
                .penalize(HardSoftScore.ONE_HARD, (team, matches) -> matches.getCount())
                .asConstraint("4 or more consecutive home matches");
    }

What is the Python equivalent class (SequenceChain) and method (getConsecutiveSequences()) for the following Java Timefold piece of code?

flattenLast(SequenceChain::getConsecutiveSequences)

This line of code is used in one of the Quickstart examples like this:

protected Constraint multipleConsecutiveHomeMatches(ConstraintFactory constraintFactory) {
        return constraintFactory.forEach(Match.class)
                .join(Team.class, equal(Match::getHomeTeam, Function.identity()))
                .groupBy((match, team) -> team,
                        ConstraintCollectors.toConsecutiveSequences((match, team) -> match.getRound(), Round::getIndex))
                .flattenLast(SequenceChain::getConsecutiveSequences)
                .filter((team, matches) -> matches.getCount() >= MAX_CONSECUTIVE_MATCHES)
                .penalize(HardSoftScore.ONE_HARD, (team, matches) -> matches.getCount())
                .asConstraint("4 or more consecutive home matches");
    }
Share Improve this question edited 12 hours ago Mark Rotteveel 109k225 gold badges155 silver badges218 bronze badges asked 13 hours ago Diallo Francis PatrickDiallo Francis Patrick 14710 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

One of the tests suggests that it is SequenceChain.getConsecutiveSequences().

本文标签: optaplannerPython equivalent for SequnceChain class in TimefoldStack Overflow