Cassowary

From Wikipedia:

Cassowary is an incremental constraint solver that efficiently solves systems of linear equalities and inequalities. Constraints may be either requirements or preferences. Client code specifies the constraints to be maintained, and the solver updates the constrained variables to have values that satisfy the constraints.

As far as I can tell, the Cassowary solver has been in existence for almost 20 years but there is – as yet – no modern, idiomatic .NET port available.

I felt that it was about time to change to that.

On the shoulders of…

There is an existing .NET port of the Cassowary solver, however from its readme:

Cassowary.net [1] is a port of the Cassowary constraint solving toolkit [2] to the .NET platform. It is based on the Java version by Greg J. Badros, which in turn is based on the Smalltalk version by Alan Borning.

A port of a port of a port. Examining the code we find that it appears to have been ported directly/naively from Java, which has resulted in a lot of non-idiomatic code: no use of of generic data structures, direct manipulation of enumerators, et cetera. That’s not to say that it’s a bad port, simply one that isn’t written in modern C# (forgiveable since it was written almost 10 years ago); and for me, one that I don’t think I’d particularly enjoy interacting with.

So this is my starting point for creating a clean, modern, idiomatic, tested .NET Cassowary constraint solver.

A fork has been created, now the real work begins…

Leave a Reply