atlas.h
Go to the documentation of this file.
1 #ifndef ATLASH
2 #define ATLASH
3 
4 #include "box.h"
5 #include "heap.h"
6 #include "chart.h"
7 #if (_KDTREE)
8  #include "btree.h"
9 #endif
10 #include "jacobian.h"
11 #include "hessian.h"
12 #include "filename.h"
13 
14 
29 #define ATLAS_VERBOSE (_DEBUG>4?1:0)
30 
39 #define PLOT_ATLAS_IN_COLORS 1
40 
53 #define PROJECT_WITH_PLANE 1
54 
55 
60 #define INIT_NUM_CHARTS 100
61 
66 #define INIT_NUM_BIFURCATIONS 100
67 
75 #if (_KDTREE)
76  #define USE_ATLAS_TREE 1
77 #else
78  #define USE_ATLAS_TREE 0
79 #endif
80 
85 #define SAMPLING_RADIUS_REDUCTION_FACTOR 0.9
86 
92 #define SIMPLE_BORDER 1
93 
102 #define INIT_NUM_CHARTS_IN_ATLAS_HEAP 100
103 
111 typedef struct {
112  unsigned int nBoundaryAttempts;
114  unsigned int nNotInBoundary;
116  unsigned int nExtensions;
118  unsigned int nImpossible;
119  unsigned int nSingImpossible;
121  unsigned int nLargeError;
123  unsigned int nNonRegularPoint;
125  unsigned int nNotInManifold;
127  unsigned int nQRSVDError;
129  unsigned int nFarFromParent;
130  unsigned int nInCollision;
131  unsigned int nRadiousChange;
133  unsigned int nGoodExtension;
135  unsigned int nBifurcations;
136  unsigned int nSmallAngle;
138  unsigned int nSPMissed;
139  unsigned int nNoSingularEnough;
140  unsigned int nNoJumpBranch;
142 
159 typedef struct {
160  unsigned int mID1;
161  unsigned int d1;
162  unsigned int mID2;
163  unsigned int d2;
164  double *p;
165 } Tbifurcation;
166 
176 typedef struct {
177  unsigned int chartID;
178  double cost;
179  double beta;
180  unsigned int nPenalized;
182 
193 void InitAtlasHeapElement(unsigned int mID,double c,double beta,TAtlasHeapElement *he);
194 
204 void CopyAtlasHeapElement(void *he1,void *he2);
205 
215 unsigned int GetAtlasHeapElementID(TAtlasHeapElement *he);
216 
227 
242 boolean LessThanAtlasHeapElement(void *he1,void *he2,void *userData);
243 
255 
263 void DeleteAtlasHeapElement(void *he);
264 
289 typedef struct {
292  unsigned int m;
293  unsigned int k;
294  unsigned int n;
295  double e;
296  double ce;
297  double r;
298  boolean simpleChart;
300  unsigned int nCores;
301  boolean parallel;
304  unsigned int *tp;
306  unsigned int maxCharts;
307  unsigned int currentChart;
308  unsigned int npCharts;
313  unsigned int nrJ;
314  unsigned int ncJ;
325  unsigned int mBifurcations;
326  unsigned int nBifurcations;
327  unsigned int npBifurcations;
332  #if (USE_ATLAS_TREE)
333  TBTree tree;
334  #endif
335 } Tatlas;
336 
353 void InitAtlas(Tparameters *pr,boolean parallel,boolean simpleChart,
354  unsigned int k,double e,double ce, double r,TAtlasBase *w,
355  Tatlas *a);
356 
387 unsigned int AddChart2Atlas(Tparameters *pr,double *ps,unsigned int parentID,
388  boolean *singularity,Tatlas *a);
389 
417 unsigned int AddTrustedChart2Atlas(Tparameters *pr,double *ps,unsigned int parentID,
418  boolean *singularity,Tatlas *a);
419 
438 boolean InitAtlasFromPoint(Tparameters *pr,boolean parallel,boolean simpleChart,double *p,
439  TAtlasBase *w,Tatlas *a);
440 
441 
464 void BuildAtlasFromPoint(Tparameters *pr,double *p,boolean simpleChart,
465  TAtlasBase *w,Tatlas *a);
466 
493 boolean MinimizeOnAtlas(Tparameters *pr,char *fname,double *p,TAtlasBase *w,
494  unsigned int maxSteps,
495  double (*costF)(Tparameters*,boolean,double*,void*),
496  void (*costG)(Tparameters*,boolean,double*,double**,void*),
497  void *costData,
498  Tatlas *a);
499 
509 double GetAtlasRadius(Tatlas *a);
510 
520 double GetAtlasError(Tatlas *a);
521 
532 double GetAtlasErrorCurv(Tatlas *a);
533 
545 
555 unsigned int GetAtlasAmbientDim(Tatlas *a);
556 
566 unsigned int GetAtlasManifoldDim(Tatlas *a);
567 
589 boolean Newton2ManifoldPlane(Tparameters *pr,double *point,double *vector,
590  double *pInit,double *p,Tatlas *a);
591 
614 boolean ExtendAtlasFromPoint(Tparameters *pr,unsigned int parentID,double *t,
615  TAtlasStatistics *st,Tatlas *a);
639 boolean ExtendAtlasTowardPoint(Tparameters *pr,unsigned int parentID,double *t,
640  boolean collisionStops,
641  TAtlasStatistics *st,Tatlas *a);
642 
660 boolean AtlasAStar(Tparameters *pr,double *p,double *time,
661  double *pl,unsigned int *ns,double ***path,Tatlas *a);
662 
680 boolean AtlasGBF(Tparameters *pr,double *p,double *time,
681  double *pl,unsigned int *ns,double ***path,Tatlas *a);
682 
692 void AtlasTree(Tparameters *pr,unsigned int nNodes,Tatlas *a);
693 
703 unsigned int GetAtlasNumCharts(Tatlas *a);
704 
718 Tchart *GetAtlasChart(unsigned int id,Tatlas *a);
719 
742 boolean RandomPointInAtlas(Tparameters *pr,double scale,double *w,
743  unsigned int *nm,
744  double *t,double *p,Tatlas *a);
745 
758 double AtlasVolume(Tparameters *pr,boolean collisionFree,Tatlas *a);
759 
776 void SaveAtlasGraph(char *fname,Tatlas *a);
777 
790 void SaveChartCenters(Tparameters *pr,char *fname,
791  boolean saveWithDummies,Tatlas *a);
792 
806 void SaveSingularCharts(Tparameters *pr,char *fname,
807  boolean saveWithDummies,Tatlas *a);
808 
840 void PlotAtlas(char *fname,int argc,char **arg,Tparameters *pr,FILE *fcost,
841  unsigned int xID,unsigned int yID,unsigned int zID,Tatlas *a);
842 
884 void TriangulateAtlas(char *fname,int argc,char **arg,Tparameters *pr,FILE *fcost,
885  unsigned int xID,unsigned int yID,unsigned int zID,Tatlas *a);
886 
896 unsigned int AtlasMemSize(Tatlas *a);
897 
909 void SaveAtlas(Tparameters *pr,Tfilename *fname,Tatlas *a);
910 
924 void LoadAtlas(Tparameters *pr,Tfilename *fname,TAtlasBase *w,Tatlas *a);
925 
936 double AverageNumNeighbours(Tatlas *a);
937 
947 void PrintAtlasDefines(FILE *f);
948 
957 void DeleteAtlas(Tatlas *a);
958 
959 #endif