QGIS API Documentation  2.11.0-Master
problem.h
Go to the documentation of this file.
1 /*
2  * libpal - Automated Placement of Labels Library
3  *
4  * Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD
5  * University of Applied Sciences, Western Switzerland
6  * http://www.hes-so.ch
7  *
8  * Contact:
9  * maxence.laurent <at> heig-vd <dot> ch
10  * or
11  * eric.taillard <at> heig-vd <dot> ch
12  *
13  * This file is part of libpal.
14  *
15  * libpal is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * libpal is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with libpal. If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 
30 #ifndef _PROBLEM_H
31 #define _PROBLEM_H
32 
33 #include <list>
34 #include "pal.h"
35 #include "rtree.hpp"
36 
37 namespace pal
38 {
39 
40  class LabelPosition;
41  class Label;
42 
43  class Sol
44  {
45  public:
46  int *s;
47  double cost;
48  };
49 
50  typedef struct _subpart
51  {
55  int probSize;
56 
61 
65  int subSize;
66 
70  int *sub;
74  int *sol;
78  int seed;
79  } SubPart;
80 
81  typedef struct _chain
82  {
83  int degree;
84  double delta;
85  int *feat;
86  int *label;
87  } Chain;
88 
92  class CORE_EXPORT Problem
93  {
94 
95  friend class Pal;
96 
97  public:
98  Problem();
99 
100  //Problem(char *lorena_file, bool displayAll);
101 
102  ~Problem();
103 
105  // problem inspection functions
106  int getNumFeatures() { return nbft; }
107  // features counted 0...n-1
108  int getFeatureCandidateCount( int i ) { return featNbLp[i]; }
109  // both features and candidates counted 0..n-1
110  LabelPosition* getFeatureCandidate( int fi, int ci ) { return labelpositions[ featStartId[fi] + ci]; }
112 
113 
114  void reduce();
115 
119  void popmusic();
120 
124  void chain_search();
125 
126  std::list<LabelPosition*> * getSolution( bool returnInactive );
127 
128  PalStat * getStats();
129 
130  /* useful only for postscript post-conversion*/
131  //void toFile(char *label_file);
132 
133  SubPart *subPart( int r, int featseed, int *isIn );
134 
135  void initialization();
136 
137  double compute_feature_cost( SubPart *part, int feat_id, int label_id, int *nbOverlap );
138  double compute_subsolution_cost( SubPart *part, int *s, int * nbOverlap );
139 
143  double popmusic_chain( SubPart *part );
144 
145  double popmusic_tabu( SubPart *part );
146 
152  double popmusic_tabu_chain( SubPart *part );
153 
157  void init_sol_empty();
158  void init_sol_falp();
159 
160  static bool compareLabelArea( pal::LabelPosition* l1, pal::LabelPosition* l2 );
161 
162  private:
163 
167  int nbLabelledLayers;
168 
172  char **labelledLayersName;
173 
177  int nblp;
181  int all_nblp;
182 
186  int nbft;
187 
188 
192  bool displayAll;
193 
197  double bbox[4];
198 
202  double scale;
203 
204  double *labelPositionCost;
205  int *nbOlap;
206 
207  LabelPosition **labelpositions;
208 
209  RTree<LabelPosition*, double, 2, double> *candidates; // index all candidates
210  RTree<LabelPosition*, double, 2, double> *candidates_sol; // index active candidates
211  RTree<LabelPosition*, double, 2, double> *candidates_subsol; // idem for subparts
212 
213  //int *feat; // [nblp]
214  int *featStartId; // [nbft]
215  int *featNbLp; // [nbft]
216  double *inactiveCost; //
217 
218  Sol *sol; // [nbft]
219  int nbActive;
220 
221  double nbOverlap;
222 
223  int *featWrap;
224 
225  Chain *chain( SubPart *part, int seed );
226 
227  Chain *chain( int seed );
228 
229  Pal *pal;
230 
231  void solution_cost();
232  void check_solution();
233  };
234 
235 } // namespace
236 
237 #endif
int getFeatureCandidateCount(int i)
Definition: problem.h:108
int probSize
of features in problem
Definition: problem.h:55
double cost
Definition: problem.h:47
int degree
Definition: problem.h:83
Pal main class.
Definition: pal.h:121
int * label
Definition: problem.h:86
void seed(uint32_t value)
struct pal::_chain Chain
int * sol
sub solution
Definition: problem.h:74
struct pal::_subpart SubPart
int * sub
wrap bw sub feat and main feat
Definition: problem.h:70
int * s
Definition: problem.h:46
int * feat
Definition: problem.h:85
int getNumFeatures()
Definition: problem.h:106
int subSize
total # features (prob + border)
Definition: problem.h:65
Summury of problem.
Definition: palstat.h:40
LabelPosition is a candidate feature label position.
Definition: labelposition.h:50
Represent a problem.
Definition: problem.h:92
LabelPosition * getFeatureCandidate(int fi, int ci)
Definition: problem.h:110
int borderSize
of features bounding the problem
Definition: problem.h:60
double delta
Definition: problem.h:84
int seed
first feat in sub part
Definition: problem.h:78