10 /// helper struct for #Spacing_problem#
17 Real
minright()const { return col
->width().max
; }
18 Real
minleft()const { return -col
->width().min
; }
22 /// spacing for one line.
23 class Spacing_problem
{
24 svec
<const Idealspacing
*> ideals
;
27 /// the index of #c# in #cols#
28 int col_id(const PCol
*c
) const;
30 /// generate an (nonoptimal) solution
31 Vector
find_initial_solution() const;
33 /// check if problem is too tight
34 bool check_feasible() const;
35 /// does #this# contain the column #w#?
36 bool contains(const PCol
*w
);
38 /// make the energy function
39 void make_matrices(Matrix
&quad
, Vector
&lin
,Real
&) const;
41 /// generate the LP constraints
42 void make_constraints(Mixed_qp
& lp
) const;
45 /// solve the spacing problem
46 svec
<Real
> solve() const;
48 return the column positions, and the energy (last element)
50 /// add a idealspacing to the problem.
51 void add_ideal(const Idealspacing
*i
);
54 One pair of columns can have no, one or more idealspacings,
55 since they can be "summed" if the columns to which #i# refers are
56 not in this problem, the spacing is ignored.
60 /// add a col to the problem
61 void add_column(const PCol
*, bool fixed
=false, Real fixpos
=0.0);
62 /** columns have to be added left to right. The column contains
63 info on it's minimum width.
67 bool check_constraints(Vector v
) const;
69 Vector
try_initial_solution() const;
72 void print_ideal(const Idealspacing
*)const;
76 /** the problem, given by the columns (which include constraints) and
77 intercolumn spacing. The problem is:
79 Generate a spacing which
82 Satisfies spacing constraints (notes can't be printed through each other)
84 Looks good, ie tries to conform to an ideal spacing as much as possible.
86 This is converted by regarding idealspacing as "springs" attached
87 to columns. The equilibrium of one spring is the ideal
88 distance. The columns have a size, this imposes "hard" constraints
89 on the distances. This transforms the problem into a quadratic
90 programming problem with linear constraints.
92 The quality is given by the total potential energy in the
93 springs. The lower the energy, the better the configuration.