nucleic / kiwi

Efficient C++ implementation of the Cassowary constraint solving algorithm
https://kiwisolver.readthedocs.io/en/latest/
Other
692 stars 88 forks source link

about duplicate constraints #160

Closed zsombi closed 1 year ago

zsombi commented 1 year ago

Hi,

The following code snippet does not throw DumplicateConstraint:

kiwi::Variable v1("var1");
kiwi::Solver solver;

solver.addConstraint(v1 >= 0);
solver.addConstraint(v1 >= 0);

From the implementation I can see why it doesn't throw, but I wonder whether should this scenario also be considered as a duplicate constraint?

MatthieuDartiailh commented 1 year ago

@sccolbert may have a better intuition on this one...

I will try to look into it though, but feel free to ping if you see by the end of may.

sccolbert commented 1 year ago

The solver only tries to protect you from adding the same constraint object more than once, because the internal data pointer they hold needs to be unique in the system.

It doesn't try to figure out whether two different constraints are the same equivalent constraint, because that would take a lot of extra processing for little gain, and it will not affect the solution to the system.

On Sat, Apr 29, 2023 at 11:16 AM Matthieu Dartiailh < @.***> wrote:

@sccolbert https://github.com/sccolbert may have a better intuition on this one...

I will try to look into it though, but feel free to ping if you see by the end of may.

— Reply to this email directly, view it on GitHub https://github.com/nucleic/kiwi/issues/160#issuecomment-1528822206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBQSNKRMZNGANOVSGMDL3XDU5GVANCNFSM6AAAAAAXJJGDMU . You are receiving this because you were mentioned.Message ID: @.***>

MatthieuDartiailh commented 1 year ago

Thanks @sccolbert