2020-12-27 02:55

[kiwijs] Constraint C Strength affects the priority at which constraint A beats constraint B

In this setup, there is initially one variable and two constraint. One Constraint (A) is an inequality, the other constraint (B) is an equality used to set a value on the variable. B can break A or not.

priority is a strength created like this : kiwi.Strength.create(0, 1, 0, priority).

A: variable >= 100 (priority 501)
B: variable = 90 (500)

After solving, the result is variable = 100 and is the expected result.

Now, if I add another equality constraint C with a very low priority

variable = 50 (10)
the variable value after solving is 90. It means that adding this constraint helps constraint B to break constraint A even if constraint B priority < A priority && C priority < A&B priority.

With the C constraint, the A priority needed to break constraint B is equal to (B + C).

A: variable >= 100 (501)
B: variable = 90 (500)
C: variable = 10 (10)

=> variable == 90 (Not expected)

A: variable >= 100 (511)
B: variable = 90 (500)
C: variable = 10 (10)

=> variable == 100 (Expected)

I also tried to suggestValue(variable, 90) instead of using constraint B and got the same results.

It seems that a third constraint affects the priority at which a constraint beats another , even if this third constraint priority is lower than the two other constraints fighting.

Is this a bug or the regular behavior ?

Test here: https://runkit.com/cacaodev/kiwi-bug (Hit the green button to run the test).


  • 点赞
  • 回答
  • 收藏
  • 复制链接分享