-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.h
153 lines (129 loc) · 3.53 KB
/
structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* structs.h
*
* Created on: 10/23/2016
* Author: Thiago Borges de Oliveira
*/
#ifndef STRUCTS_H
#define STRUCTS_H
#include <stdio.h>
#include <ogr_api.h>
#include <stdbool.h>
#include <assert.h>
#include <emmintrin.h>
#include "glibwrap.h"
#define GET_GRID_HISTOGRAM_CELL(h, x, y) (&((h)->hcells[(x)*(h)->yqtd + (y)]))
#define SET_IN_PLACE(var, place) (var |= (1<<(place-1)))
#define SET_IN_PLACE64(var, place) (var |= ((uint64_t)1<<(uint64_t)(place-1)))
#define IS_IN_PLACE(var, place) (((var) >> (place-1)) & 1)
#define GET_ROD_ID(cell) ((cell)->xr + ((cell)->yr << 16))
#ifdef __MACH__
#define decl_qsort_p_cmp(fname, x, y, thunk) int fname(void *thunk, const void *x, const void *y)
#define qsort_p(base, nmemb, size, compar, thunk) qsort_r(base, nmemb, size, thunk, compar)
#elif __linux__
#define decl_qsort_p_cmp(fname, x, y, thunk) int fname(const void *x, const void *y, void *thunk)
#define qsort_p(base, nmemb, size, compar, thunk) qsort_r(base, nmemb, size, compar, thunk)
#endif
#define g_new(ptype, count) (ptype*)malloc(sizeof(ptype) * (count))
#define g_new0(ptype, count) (ptype*)calloc(count, sizeof(ptype))
#define g_renew(ptype, pointer, count) (ptype*)realloc(pointer, sizeof(ptype) * (count))
struct Envelope {
/* union {
struct {
__m128d Min;
__m128d Max;
};
struct {*/
double MinX;
double MinY;
double MaxX;
double MaxY;
/* };
};*/
};
typedef struct Envelope Envelope;
#define AVGL_HISTO_SIZE 4
typedef struct {
unsigned short qtd_x;
float avg_x;
unsigned short qtd_y[AVGL_HISTO_SIZE];
float avg_y[AVGL_HISTO_SIZE];
} avglength2d;
typedef struct {
unsigned short x;
unsigned short y;
double cardin;
double points;
unsigned place;
unsigned copies;
double objcount;
float prep_cost;
float areasum;
Envelope usedarea;
avglength2d len[AVGL_HISTO_SIZE];
void *extra_data;
} histogram_cell;
enum HistogramType {
HIST_GRID,
HIST_MINSKEW,
};
typedef struct {
enum HistogramType htype;
Envelope mbr;
char extra_data[1];
} dataset_histogram_persist;
typedef struct dataset_head_ dataset;
typedef struct dataset_histogram dataset_histogram;
typedef struct dataset_histogram {
enum HistogramType htype;
OGRwkbGeometryType geom_type;
void *extra_data;
int (*free)(dataset *ds);
void (*print_geojson)(dataset *ds);
void (*distribute)(dataset *ds);
GList* (*intersects)(dataset *ds, Envelope ev);
void (*clone_histogram)(dataset *dh, dataset_histogram *result);
Envelope (*get_cell_envelope)(dataset_histogram *dh, histogram_cell *cell);
histogram_cell *(*get_cell)(dataset_histogram *dh, unsigned short x, unsigned short y);
histogram_cell *(*get_reference_cell)(dataset *ds, double x, double y);
dataset_histogram_persist *(*get_data)(dataset *dh, int *size);
void (*set_data)(dataset *dh, dataset_histogram_persist *data);
} dataset_histogram;
typedef struct {
int xqtd;
int yqtd;
double xsize;
double ysize;
double *xtics;
double *ytics;
histogram_cell *hcells;
} grid_histogram_data;
typedef struct dataset_head_ {
struct {
Envelope mbr;
struct dataset_histogram hist;
} metadata;
} dataset;
typedef struct {
int xr;
int yr;
histogram_cell *cell;
} right_opt_data;
typedef struct {
int xl;
int yl;
histogram_cell *lcell;
double pnts;
double *comm;
size_t rcells_size;
right_opt_data *rcells;
} optimization_data_s;
typedef struct {
double to_pnts;
double io_objs;
double io_pnts;
double io_save;
double inters;
} multiway_histogram_estimate;
void print_instance_and_solution_fo_file(optimization_data_s *opt_data, int opt_atu, int servers, int map[opt_atu][servers+1]);
#endif