Re: Knuth algorithm problem
Jeremias Maerki wrote: I think I've just stumbled over a problem in the Knuth algorithm. I'm going to see what happens ... Regards Luca
Re: Knuth algorithm problem
Thank you so much for looking into it. From the sound of it I would have continued my search for a long time. On 06.10.2005 11:42:19 Luca Furini wrote: Luca Furini wrote: I'm going to see what happens ... I've found the bug! The width, stretch and shrink of the suppressed elements after a break is taken into account in BreakingAlgorithm.addBreaks(), but this method is called only if everythings goes well; in your test there is a restart (as the only created node is too short) and addBreaks() is not called, so the width (and stretch, and shrink) stored in the node is potentially wrong. I'm going to see the best way to fix this without duplicating lines of code. I think the for loop (over the elements that must be ignored) could be moved into createNode() ... In general, the restarting method is quite a critical phase: we are resurrecting a node which was not very good, and maybe not all the information stored inside it is always correct. Regards Luca Jeremias Maerki
Re: Knuth algorithm problem
It's easy after all: http://svn.apache.org/viewcvs?rev=295059view=rev On 05.10.2005 17:01:23 Jeremias Maerki wrote: snip/ Makes me wonder if it were very difficult to create JUnit test cases just testing the Knuth algorithm... Jeremias Maerki
Re: Knuth algorithm problem
The reference I found was in the section about avoiding psychologically bad breaks. AFAICS the auxiliary flag is used in line breaking in the hyphenation code, but the breaker algorithm actually doesn't care about it. For page breaking the meaning of the auxiliary flag is undefined, but I've used it to mark elements which are handled in a special way like the elements created by the space resolution. It was simply handy for them to stand out in debug output. There's no logic triggered by the flag and I don't have a problem removing the auxiliary flags if anyone prefers that I should not use them. On 05.10.2005 22:16:11 Simon Pepping wrote: I have never really understood the role of the aux flag on the elements. Is it only for the addAreas phase, or does it also play a role in the breaker algorithm? Jeremias Maerki