Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My first thought was linear programming with the simplex algorithm, but I think this is either wrong or at least incomplete. Basically, most if not all of your rules are linear this-equals-that rules, where linear programming deals with this-is-less-than-that (or &lt;= or whatever) rules.</p> <p>The fix may be unification. That is, express your rules WRT as few variables as possible. Where you have a rule f(a) = g(b), you can effectively eliminate b by defining b=g'(f(a)) and substituting everywhere else you find the b. Since actually substituting is inefficient, you can just make a note of the relationship between a and b.</p> <p>With minor complications, the basic approach is union-find. In the exact-equality case, you would eliminate b by adding a link from b to a. When 'finding' b, you then identify a (or whatever it has been linked to) instead. So at any time, you can efficiently translate any rule to a form that uses only non-eliminated variables. The complication in this case - you need to keep a running track of the g'(f(a)) style stuff as you follow the links. As this is all linear, it shouldn't be that big a problem, but not trivial either.</p> <p>You might need to be able to backtrack the unification - make a note of the links you set on a stack, so you can null them again in the correct order as you unwind the stack.</p> <p>I'm not sure if you have any relative conditions at all (less than or whatever), but if so, once you've eliminated as many variables as possible, you'll still need some linear programming. If you have two remaining variables, this is conceptually simple. For each linear condition on those two variables, draw a line on a 2D graph such that one side of the line represents the valid region. The conditions are traditionally "normalised" so the valid side always includes the origin. Based on crossing points, the line-segments nearest the origin form a convex polygon. An optimal solution is on one of the corners, and is assessed using a linear scoring rule (the thing you're optimising) which would in your case be defined to give the "best" shape where there's some ambiguity or some conflict of priorities in your rules - e.g. you can't push a point all the way through a line, so things get blocked at certain points.</p> <p>If you have more than two variables remaining, you need a multi-dimensional equivalent of a convex polygon - and that is called a simplex. Practical implementation of the simplex algorithm involves matrices.</p> <p>This is already oversimplified to the point that it's probably wrong in some of the details, and it's about as far as I can explain. IIRC you can get good descriptions of these component techniques in Sedgewick, though Wikipedia may be just as good these days.</p> <p>Simplex solvers are sometimes used for Window layouts - I think wxWidgets uses one for resizing the controls in a window, for example. Unification is a defining feature of logic programming (Prolog etc), but the underlying union-find principles are simple enough. The key trick is figuring out how to translate a 2D figure into a set of rules expressing how it will change, and understanding how to represent and manipulate those rules, particularly in matrix form.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload