Cassowary.js currently defaults to Required Constraints. After a little experience in common layout situations using Cassowary in GSS, it became increasingly clear that a default Required Strength too easily leads to unsolvable solver states & can frustrate debugging.
I recently had a pow-wow with Badros, and he confirmed my suspicion. From what I now understand, Required Constraints are special cases that shouldn't run rampant, that they are more like aliases than a level above Strong.
The question is, what should the default Strength & Weight be? Are the defaults in a layout system a special case? I'm assuming defaults ought to be configurable per SimplexSolver...
Another point, for a given collection of constraints, Cassowary's weighted-sum-better solution can be confusing when dealing with many Equality Constraints of the same Strength, as with:
var s = new c.SimplexSolver();
var x = new c.Variable({ name: 'x' });
var strength = c.Strength.strong;
s.addConstraint(new c.Equation(x, 1, strength))
.addConstraint(new c.Equation(x, 2, strength))
.addConstraint(new c.Equation(x, 3, strength))
.addConstraint(new c.Equation(x, 4, strength))
.addConstraint(new c.Equation(x, 5, strength));
assert.isTrue(c.approx(x.value, 3.0)); // hmm... not so straight forward...
Throw in some random Weights, and it becomes hard to mentally compute how the error functions will be minimized & reason this to humans:
var s = new c.SimplexSolver();
var x = new c.Variable({ name: 'x' });
var strength = c.Strength.strong;
s.addConstraint(new c.Equation(x, 1, strength, 1))
.addConstraint(new c.Equation(x, 2, strength, 2))
.addConstraint(new c.Equation(x, 3, strength, 3))
.addConstraint(new c.Equation(x, 4, strength, 4))
.addConstraint(new c.Equation(x, 5, strength, 5));
assert.isTrue(c.approx(x.value, 4.0)); // those tricky error functions
This makes Required defaults seem attractive, but maybe the above examples are too contrived. After all, constraint satisfaction is not all or nothing, and it should be well documented how an optional a == b
is treated...
With GSS I added a configurable defaultStrength & defaultWeight, and I've been liking a default of Medium & Weak for layouts, so at least Strong Constraints will completely overcome defaults without resorting to Required and without any potential Weighted error function confusion - allows for more "responsive" layouts. It probably makes sense to have a default Weight, but not sure about that one... need more practice with it...
Depending on such defaults, different gotchas & best practices emerge, would love to hear y'alls thoughts on this...
--
You received this message because you are subscribed to the Google Groups "overconstrained" group.
To unsubscribe from this group and stop receiving emails from it, send an email to overconstrain...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.