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 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;
324  unsigned int mBifurcations;
325  unsigned int nBifurcations;
326  unsigned int npBifurcations;
331  #if (USE_ATLAS_TREE)
332  TBTree tree;
333  #endif
334 } Tatlas;
335 
352 void InitAtlas(Tparameters *pr,boolean parallel,boolean simpleChart,
353  unsigned int k,double e,double ce, double r,TAtlasBase *w,
354  Tatlas *a);
355 
386 unsigned int AddChart2Atlas(Tparameters *pr,double *ps,unsigned int parentID,
387  boolean *singularity,Tatlas *a);
388 
416 unsigned int AddTrustedChart2Atlas(Tparameters *pr,double *ps,unsigned int parentID,
417  boolean *singularity,Tatlas *a);
418 
437 boolean InitAtlasFromPoint(Tparameters *pr,boolean parallel,boolean simpleChart,double *p,
438  TAtlasBase *w,Tatlas *a);
439 
440 
463 void BuildAtlasFromPoint(Tparameters *pr,double *p,boolean simpleChart,
464  TAtlasBase *w,Tatlas *a);
465 
492 boolean MinimizeOnAtlas(Tparameters *pr,char *fname,double *p,TAtlasBase *w,
493  unsigned int maxSteps,
494  double (*costF)(Tparameters*,boolean,double*,void*),
495  void (*costG)(Tparameters*,boolean,double*,double**,void*),
496  void *costData,
497  Tatlas *a);
498 
508 double GetAtlasRadius(Tatlas *a);
509 
519 double GetAtlasError(Tatlas *a);
520 
531 double GetAtlasErrorCurv(Tatlas *a);
532 
544 
554 unsigned int GetAtlasAmbientDim(Tatlas *a);
555 
565 unsigned int GetAtlasManifoldDim(Tatlas *a);
566 
588 boolean Newton2ManifoldPlane(Tparameters *pr,double *point,double *vector,
589  double *pInit,double *p,Tatlas *a);
590 
613 boolean ExtendAtlasFromPoint(Tparameters *pr,unsigned int parentID,double *t,
614  TAtlasStatistics *st,Tatlas *a);
638 boolean ExtendAtlasTowardPoint(Tparameters *pr,unsigned int parentID,double *t,
639  boolean collisionStops,
640  TAtlasStatistics *st,Tatlas *a);
641 
659 boolean AtlasAStar(Tparameters *pr,double *p,double *time,
660  double *pl,unsigned int *ns,double ***path,Tatlas *a);
661 
679 boolean AtlasGBF(Tparameters *pr,double *p,double *time,
680  double *pl,unsigned int *ns,double ***path,Tatlas *a);
681 
691 void AtlasTree(Tparameters *pr,unsigned int nNodes,Tatlas *a);
692 
702 unsigned int GetAtlasNumCharts(Tatlas *a);
703 
717 Tchart *GetAtlasChart(unsigned int id,Tatlas *a);
718 
741 boolean RandomPointInAtlas(Tparameters *pr,double scale,double *w,
742  unsigned int *nm,
743  double *t,double *p,Tatlas *a);
744 
757 double AtlasVolume(Tparameters *pr,boolean collisionFree,Tatlas *a);
758 
775 void SaveAtlasGraph(char *fname,Tatlas *a);
776 
789 void SaveChartCenters(Tparameters *pr,char *fname,
790  boolean saveWithDummies,Tatlas *a);
791 
805 void SaveSingularCharts(Tparameters *pr,char *fname,
806  boolean saveWithDummies,Tatlas *a);
807 
839 void PlotAtlas(char *fname,int argc,char **arg,Tparameters *pr,FILE *fcost,
840  unsigned int xID,unsigned int yID,unsigned int zID,Tatlas *a);
841 
883 void TriangulateAtlas(char *fname,int argc,char **arg,Tparameters *pr,FILE *fcost,
884  unsigned int xID,unsigned int yID,unsigned int zID,Tatlas *a);
885 
895 unsigned int AtlasMemSize(Tatlas *a);
896 
908 void SaveAtlas(Tparameters *pr,Tfilename *fname,Tatlas *a);
909 
923 void LoadAtlas(Tparameters *pr,Tfilename *fname,TAtlasBase *w,Tatlas *a);
924 
933 void DeleteAtlas(Tatlas *a);
934 
935 #endif
double GetAtlasRadius(Tatlas *a)
Radius used in the charts.
Definition: atlas.c:3415
boolean ExtendAtlasTowardPoint(Tparameters *pr, unsigned int parentID, double *t, boolean collisionStops, TAtlasStatistics *st, Tatlas *a)
Tries to expand the atlas from a chart toward a given point.
Definition: atlas.c:1281
unsigned int nImpossible
Definition: atlas.h:118
unsigned int d2
Definition: atlas.h:163
unsigned int d1
Definition: atlas.h:161
double ce
Definition: atlas.h:296
unsigned int nLargeError
Definition: atlas.h:121
Definition of the THessian type and the associated functions.
unsigned int nSmallAngle
Definition: atlas.h:136
void TriangulateAtlas(char *fname, int argc, char **arg, Tparameters *pr, FILE *fcost, unsigned int xID, unsigned int yID, unsigned int zID, Tatlas *a)
Pots the triangular mesh defined by the an atlas.
Definition: atlas.c:4387
TJacobian J
Definition: atlas.h:315
unsigned int m
Definition: atlas.h:292
void SaveSingularCharts(Tparameters *pr, char *fname, boolean saveWithDummies, Tatlas *a)
Stores the centers of the singular charts.
Definition: atlas.c:4171
Data structure to hold the information about the name of a file.
Definition: filename.h:271
Tbox * ambient
Definition: atlas.h:320
Structure used for the elements of the heap of charts.
Definition: atlas.h:176
unsigned int chartID
Definition: atlas.h:177
Definition binary tree of charts.
Definition of the TJacobian type and the associated functions.
unsigned int npCharts
Definition: atlas.h:308
unsigned int * tp
Definition: atlas.h:304
boolean AtlasGBF(Tparameters *pr, double *p, double *time, double *pl, unsigned int *ns, double ***path, Tatlas *a)
Expands the atlas to reach a given point.
Definition: atlas.c:3781
void SaveChartCenters(Tparameters *pr, char *fname, boolean saveWithDummies, Tatlas *a)
Stores the centers of the charts.
Definition: atlas.c:4117
Definition of the Tfilename type and the associated functions.
double r
Definition: atlas.h:297
void SaveAtlasGraph(char *fname, Tatlas *a)
Saves the graph structure of the atlas.
Definition: atlas.c:4091
Tchart * GetAtlasChart(unsigned int id, Tatlas *a)
Gets one of the charts of the chart.
Definition: atlas.c:4040
TAtlasBase * GetAtlasWorld(Tatlas *a)
Gets the world structure on which the atlas is defined.
Definition: atlas.c:3430
unsigned int nInCollision
Definition: atlas.h:130
Representation of a bifurcation.
Definition: atlas.h:159
unsigned int mBifurcations
Definition: atlas.h:324
void SaveAtlas(Tparameters *pr, Tfilename *fname, Tatlas *a)
Stores the atlas information on a file.
Definition: atlas.c:3946
boolean simpleChart
Definition: atlas.h:298
A chart on a manifold.
Definition: chart.h:70
unsigned int AddChart2Atlas(Tparameters *pr, double *ps, unsigned int parentID, boolean *singularity, Tatlas *a)
Defines a new chart and adds it to the atlas.
Definition: atlas.c:2871
unsigned int nQRSVDError
Definition: atlas.h:127
unsigned int nrJ
Definition: atlas.h:313
boolean RandomPointInAtlas(Tparameters *pr, double scale, double *w, unsigned int *nm, double *t, double *p, Tatlas *a)
Samples a random point on the atlas.
Definition: atlas.c:4048
unsigned int nNonRegularPoint
Definition: atlas.h:123
unsigned int nFarFromParent
Definition: atlas.h:129
unsigned int maxCharts
Definition: atlas.h:306
unsigned int n
Definition: atlas.h:294
Definition of a binary heap used to implement priority queues.
double e
Definition: atlas.h:295
unsigned int k
Definition: atlas.h:293
Tbifurcation ** bifurcation
Definition: atlas.h:329
void LoadAtlas(Tparameters *pr, Tfilename *fname, TAtlasBase *w, Tatlas *a)
Defines an atlas from the information on a file.
Definition: atlas.c:3973
void CopyAtlasHeapElement(void *he1, void *he2)
Copy constructor.
Definition: atlas.c:2650
boolean parallel
Definition: atlas.h:301
void PenalizeAtlasHeapElement(TAtlasHeapElement *he)
Penalized the cost stored in a atlas heap element.
Definition: atlas.c:2683
Definition of the Tbox type and the associated functions.
unsigned int nSingImpossible
Definition: atlas.h:119
Tchart ** charts
Definition: atlas.h:311
unsigned int GetAtlasManifoldDim(Tatlas *a)
Manifold dimensionality.
Definition: atlas.c:3440
unsigned int nBoundaryAttempts
Definition: atlas.h:112
unsigned int nNoSingularEnough
Definition: atlas.h:139
THessian * H
Definition: atlas.h:318
unsigned int nExtensions
Definition: atlas.h:116
void PlotAtlas(char *fname, int argc, char **arg, Tparameters *pr, FILE *fcost, unsigned int xID, unsigned int yID, unsigned int zID, Tatlas *a)
Pots a projection of an atlas.
Definition: atlas.c:4227
unsigned int nBifurcations
Definition: atlas.h:325
A table of parameters.
double GetAtlasErrorCurv(Tatlas *a)
Maximum curvature error for all the charts.
Definition: atlas.c:3425
unsigned int nCores
Definition: atlas.h:300
void DeleteAtlasHeapElement(void *he)
Atlas heap element destructor.
Definition: atlas.c:2688
void InitAtlasHeapElement(unsigned int mID, double c, double beta, TAtlasHeapElement *he)
Constructor of TAtlasHeapElement.
Definition: atlas.c:2640
Type defining the equations on which the atlas is defined.
Definition: wcs.h:30
Definition of a local chart on a manifold.
boolean AtlasAStar(Tparameters *pr, double *p, double *time, double *pl, unsigned int *ns, double ***path, Tatlas *a)
Expands the atlas to reach a given point.
Definition: atlas.c:3445
boolean ExtendAtlasFromPoint(Tparameters *pr, unsigned int parentID, double *t, TAtlasStatistics *st, Tatlas *a)
Tries to expand the atlas from a chart from a given point.
Definition: atlas.c:1050
boolean InitAtlasFromPoint(Tparameters *pr, boolean parallel, boolean simpleChart, double *p, TAtlasBase *w, Tatlas *a)
Initializes an atlas from a given point.
Definition: atlas.c:2782
unsigned int mID2
Definition: atlas.h:162
A atlas on a manifold.
Definition: atlas.h:289
A box.
Definition: box.h:83
unsigned int nPenalized
Definition: atlas.h:180
double cost
Definition: atlas.h:178
void DeleteAtlas(Tatlas *a)
Destructor.
Definition: atlas.c:4634
void BuildAtlasFromPoint(Tparameters *pr, double *p, boolean simpleChart, TAtlasBase *w, Tatlas *a)
Defines an atlas from a given point.
Definition: atlas.c:2954
unsigned int nRadiousChange
Definition: atlas.h:131
The Jacobian of a set of equations.
Definition: jacobian.h:23
Hessian of a set of equations.
Definition: hessian.h:24
Binary tree of charts.
Definition: btree.h:42
unsigned int currentChart
Definition: atlas.h:307
boolean Newton2ManifoldPlane(Tparameters *pr, double *point, double *vector, double *pInit, double *p, Tatlas *a)
Finds a point in the intersection of the manifold and a plane.
Definition: atlas.c:2290
unsigned int GetAtlasNumCharts(Tatlas *a)
Number of charts in the atlas.
Definition: atlas.c:4035
double GetAtlasHeapElementCost(TAtlasHeapElement *he)
Gets the cost.
Definition: atlas.c:2663
unsigned int AddTrustedChart2Atlas(Tparameters *pr, double *ps, unsigned int parentID, boolean *singularity, Tatlas *a)
Defines a new chart and adds it to the atlas.
Definition: atlas.c:2905
Data about the atlas construction.
Definition: atlas.h:111
unsigned int ncJ
Definition: atlas.h:314
double beta
Definition: atlas.h:179
unsigned int nGoodExtension
Definition: atlas.h:133
double * p
Definition: atlas.h:164
unsigned int AtlasMemSize(Tatlas *a)
Memory used by a given atlas.
Definition: atlas.c:3935
boolean MinimizeOnAtlas(Tparameters *pr, char *fname, double *p, TAtlasBase *w, unsigned int maxSteps, double(*costF)(Tparameters *, boolean, double *, void *), void(*costG)(Tparameters *, boolean, double *, double **, void *), void *costData, Tatlas *a)
Gradient minimization on an manifold.
Definition: atlas.c:3153
void AtlasTree(Tparameters *pr, unsigned int nNodes, Tatlas *a)
Defines a tree of charts on a manifold.
boolean LessThanAtlasHeapElement(void *he1, void *he2, void *userData)
Comparison between atlas heap elements.
Definition: atlas.c:2668
double AtlasVolume(Tparameters *pr, boolean collisionFree, Tatlas *a)
Approximates the volume of the manifold.
Definition: atlas.c:4070
TAtlasBase * w
Definition: atlas.h:290
unsigned int nNotInBoundary
Definition: atlas.h:114
unsigned int mID1
Definition: atlas.h:160
unsigned int nNotInManifold
Definition: atlas.h:125
double GetAtlasError(Tatlas *a)
Maximum error for all the charts.
Definition: atlas.c:3420
unsigned int GetAtlasAmbientDim(Tatlas *a)
Ambient dimensionality.
Definition: atlas.c:3435
unsigned int GetAtlasHeapElementID(TAtlasHeapElement *he)
Gets the chart identifier.
Definition: atlas.c:2658
unsigned int npBifurcations
Definition: atlas.h:326
void InitAtlas(Tparameters *pr, boolean parallel, boolean simpleChart, unsigned int k, double e, double ce, double r, TAtlasBase *w, Tatlas *a)
Constructor.
Definition: atlas.c:2716
unsigned int nSPMissed
Definition: atlas.h:138
unsigned int nBifurcations
Definition: atlas.h:135
unsigned int nNoJumpBranch
Definition: atlas.h:140