10 /// helper struct for #Spacing_problem#
18 void operator=(Colinfo
const&);
19 Colinfo(Colinfo
const&);
21 Colinfo(const PCol
*,const Real
*);
23 bool fixed() const { return fixpos
;}
24 Real
fixed_position()const { return *fixpos
; }
25 Real
minright() const { return width
.right
; }
26 Real
minleft() const { return -width
.left
; }
30 /** the problem, given by the columns (which include constraints) and
31 intercolumn spacing. The problem is:
33 Generate a spacing which
36 Satisfies spacing constraints (notes can't be printed through each other)
38 Looks good, ie tries to conform to an ideal spacing as much as possible.
40 This is converted by regarding idealspacing as "springs" attached
41 to columns. The equilibrium of one spring is the ideal
42 distance. The columns have a size, this imposes "hard" constraints
43 on the distances. This transforms the problem into a quadratic
44 programming problem with linear constraints.
46 The quality is given by the total potential energy in the
47 springs. The lower the energy, the better the configuration.
49 class Spacing_problem
{
50 Array
<const Idealspacing
*> ideals
;
53 /// the index of #c# in #cols#
54 int col_id(const PCol
*c
) const;
56 /// generate an (nonoptimal) solution
57 Vector
find_initial_solution() const;
59 /// check if problem is too tight
60 bool check_feasible() const;
62 /// does #this# contain the column #w#?
63 bool contains(const PCol
*w
);
65 /// make the energy function
66 void make_matrices(Matrix
&quad
, Vector
&lin
,Real
&) const;
68 /// generate the LP constraints
69 void make_constraints(Mixed_qp
& lp
) const;
72 /** solve the spacing problem
74 @return the column positions, and the energy (last element)
77 Array
<Real
> solve() const;
81 add a idealspacing to the problem.
83 One pair of columns can have no, one or more idealspacings,
84 since they can be "summed" if the columns to which #i# refers are
85 not in this problem, the spacing is ignored.
87 void add_ideal(const Idealspacing
*i
);
90 /** add a col to the problem. columns have to be added left to right. The column contains
91 info on it's minimum width.
93 void add_column(const PCol
*, bool fixed
=false, Real fixpos
=0.0);
97 bool check_constraints(Vector v
) const;
99 Vector
try_initial_solution() const;
102 void print_ideal(const Idealspacing
*)const;