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 /// spacing for one line.
31 class Spacing_problem {
32 Array<const Idealspacing*> ideals;
35 /// the index of #c# in #cols#
36 int col_id(const PCol *c) const;
38 /// generate an (nonoptimal) solution
39 Vector find_initial_solution() const;
41 /// check if problem is too tight
42 bool check_feasible() const;
43 /// does #this# contain the column #w#?
44 bool contains(const PCol *w);
46 /// make the energy function
47 void make_matrices(Matrix &quad, Vector &lin,Real&) const;
49 /// generate the LP constraints
50 void make_constraints(Mixed_qp& lp) const;
53 /// solve the spacing problem
54 Array<Real> solve() const;
56 return the column positions, and the energy (last element)
58 /// add a idealspacing to the problem.
59 void add_ideal(const Idealspacing *i);
62 One pair of columns can have no, one or more idealspacings,
63 since they can be "summed" if the columns to which #i# refers are
64 not in this problem, the spacing is ignored.
68 /// add a col to the problem
69 void add_column(const PCol *, bool fixed=false, Real fixpos=0.0);
70 /** columns have to be added left to right. The column contains
71 info on it's minimum width.
75 bool check_constraints(Vector v) const;
77 Vector try_initial_solution() const;
80 void print_ideal(const Idealspacing*)const;
84 /** the problem, given by the columns (which include constraints) and
85 intercolumn spacing. The problem is:
87 Generate a spacing which
90 Satisfies spacing constraints (notes can't be printed through each other)
92 Looks good, ie tries to conform to an ideal spacing as much as possible.
94 This is converted by regarding idealspacing as "springs" attached
95 to columns. The equilibrium of one spring is the ideal
96 distance. The columns have a size, this imposes "hard" constraints
97 on the distances. This transforms the problem into a quadratic
98 programming problem with linear constraints.
100 The quality is given by the total potential energy in the
101 springs. The lower the energy, the better the configuration.