升级到 Optaplanner 8.34.0.Final 时出现分数损坏。

huangapple go评论55阅读模式
英文:

Score Corruption when upgrading to Optaplanner 8.34.0.Final

问题

在尝试升级到 Optaplanner 9 时,我遇到了一些解决方案的更改。在运行带有完整断言的情况下,出现了一些之前不存在的分数损坏问题。追溯起来,问题似乎首次出现在版本 8.34.0 中。
问题似乎是特定于 Bavet,因为当我切换到 DROOLS CS 实现时,问题不再重现。
问题似乎可能与 Joiners 有关,因为通过将我的实现从类似以下的形式更改为使用过滤器

private static Constraint pegConstraint(final ConstraintFactory factory) {
    return factory.forEach(Thing.class).map(This::getName)
            .join(factory.forEach(Hole.class).map(Hole::getPeg)))
            .filter((name, hole) -> !hole.getPeg().isSquare())      
            .join(factory.forEach(Hole.class).map(Hole::getPeg))
            .map((name, peg1, peg2) -> someAccumulator())
            .penalizeLong(HardSoftLongScore.ofSoft(1L), p -> p).asConstraint("constraint");

得分损坏警告消失了,但流的速度显着较慢。我是否错误使用了 Joiners.filtering() 或还有其他原因?

英文:

When attempting to upgrade to Optaplanner 9 I encountered some changes in solutions. Running with full assert revealed some score corruption issues that had not previously been present. Tracing back it appears that the issue first appeared with Version 8.34.0.
The problem appears to be specific to Bavet as it does not reproduce when I switch to a DROOLS CS implementation.

It seems that the issue is possibly related to Joiners because by changing my implementation from something like

private static Constraint pegConstraint(final ConstraintFactory factory) {
        return factory.forEach(Thing.class).map(This::getName)
                .join(factory.forEach(Hole.class).map(Hole::getPeg),
                        Joiners.filtering((name, hole) -> !hole.getPeg().isSquare())
                .join(factory.forEach(Hole.class).map(Hole::getPeg))
	         .map((name, peg1, peg2) -> someAccumulator())
	        .penalizeLong(HardSoftLongScore.ofSoft(1L), p -> p).asConstraint("constraint");

to using a filter like

private static Constraint pegConstraint(final ConstraintFactory factory) {
        return factory.forEach(Thing.class).map(This::getName)
                .join(factory.forEach(Hole.class).map(Hole::getPeg)))
                .filter((name, hole) -> !hole.getPeg().isSquare())      
                .join(factory.forEach(Hole.class).map(Hole::getPeg))
	        .map((name, peg1, peg2) -> someAccumulator())
		.penalizeLong(HardSoftLongScore.ofSoft(1L), p -> p).asConstraint("constraint");

the score corruption warnings go away, but the streams are significantly slower. Am I misusing Joiners.filtering() or is something else at play?

答案1

得分: 1

这可能是一个错误,但由于我们到目前为止还没有注意到,很难复现。如果您能提供一个可执行的复现工具,将不胜感激。

英文:

It could very well be a bug, but since we haven't noticed so far, it'll be hard to reproduce. If you can provide an executable reproducer, that would be appreciated.

huangapple
  • 本文由 发表于 2023年7月14日 02:08:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76682167.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定