Re: Auto layout semantics?
Re: Auto layout semantics?
- Subject: Re: Auto layout semantics?
- From: Kevin Cathey <email@hidden>
- Date: Mon, 09 Sep 2013 10:20:54 -0700
Exactly right.
And you can use the simplex behavior to your advantage. For example that's how you can build a "fitting size" method (or in other words this is how the system fitting size method works). Add a constraint with constant 0 with a lower priority and the system will crush the view as much as possible. You can use this kind of "get as close as possible" behavior in many cases.
Kevin
On 3 Sep 2013, at 13:36, Marcel Weiher <email@hidden> wrote:
> [this seems to have bounced earlier]
>
> Hi Kyle, Izak,
>
> On Aug 16, 2013, at 19:18 , Kyle Sluder <email@hidden> wrote:
>
>> As Ken Ferry described in his Auto Layout session at WWDC 2011, the specific solver used by Apple is based on the Cassowary constraint engine.
>
> Yes, the algorithm involved is a variant of the Simplex algorithm, optimized for incremental re-solves.
>
> http://www.badros.com/greg/papers/cassowary-tochi.pdf
>
>
>> So asking for the "algorithm" isn't really that helpful, because Auto Layout is not defined or implemented imperatively. There's an algorithm involved, but that algorithm is a general-purpose constraint solver that operates on linear equations. Strictly speaking it has nothing to do with views.
>
> True, the behavior has nothing to do with views in particular, but the algorithm in question does have an effect on the results, particularly…
>
> On Aug 16, 2013, at 19:06 , Izak van Langevelde <email@hidden> wrote:
>
>> I have only been able to sort this out by adding in code a constraint that explicitly constrains the two fields as having the same width. My main concern is that it feels too complicated for something this simple.
>
>
> …the simplex algorithm searches for optima in the “corners” of the multi-dimensional polyhedron (by walking along the edges).
>
> http://en.wikipedia.org/wiki/Cutting-plane_method
>
> This means that it will prefer solutions where one variable takes up all the slack over one where the slack is distributed equally between two variables. However, the fact that you are leaving this up to the algorithm does mean that your set of constraints is underconstrained and that adding the equality constraints is the right solution (probably with a lower priority than other constraints).
>
> So called “interior point” methods that do not follow the edges also exist, but despite the fact that these have theoretically better running times (polynomial, whereas the simplex is exponential), in practice the simplex is much faster, usually running in linear time.
>
> Cheers,
>
> Marcel
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden