10 /// helper struct for #Spacing_problem#
18 void operator=(Colinfo const&);
19 Colinfo(Colinfo const&);
21 Colinfo(PCol const *,Real const *);
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 TODO: make item widths work per pstaff.
52 class Spacing_problem {
53 Array<Idealspacing const *> ideals;
56 /// the index of #c# in #cols#
57 int col_id(PCol const *c) const;
59 /// generate an (nonoptimal) solution
60 Vector find_initial_solution() const;
62 /// check if problem is too tight
63 bool check_feasible() const;
65 /// does #this# contain the column #w#?
66 bool contains(PCol const *w);
68 /// make the energy function
69 void make_matrices(Matrix &quad, Vector &lin,Real&) const;
71 /// generate the LP constraints
72 void make_constraints(Mixed_qp& lp) const;
75 /** solve the spacing problem
77 @return the column positions, and the energy (last element)
80 Array<Real> solve() const;
84 add a idealspacing to the problem.
86 One pair of columns can have no, one or more idealspacings,
87 since they can be "summed" if the columns to which #i# refers are
88 not in this problem, the spacing is ignored.
90 void add_ideal(Idealspacing const *i);
93 /** add a col to the problem. columns have to be added left to right. The column contains
94 info on it's minimum width.
96 void add_column(PCol const *, bool fixed=false, Real fixpos=0.0);
100 bool check_constraints(Vector v) const;
102 Vector try_initial_solution() const;
105 void print_ideal(Idealspacing const *)const;