-
Notifications
You must be signed in to change notification settings - Fork 0
/
scl_backend.h
245 lines (182 loc) · 7.4 KB
/
scl_backend.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* ball_worker.h
*
*
*/
#ifndef __ball_worker__
#define __ball_worker__
#include <gmp.h>
#include <gtk/gtk.h>
#include <semaphore.h>
#include "matrix.h"
#include "triangle_and_vertex.h"
enum scallop_lp_solver {GLPK_DOUBLE, GLPK_EXACT, QSOPT_EXACT, EXLP};
/*****************************************************************************/
/* these are the arc and polygon types */
/*****************************************************************************/
typedef struct {
int first_word;
int last_word;
int first;
int last;
} arc;
typedef struct {
int* arc;
int num_arcs;
} polygon;
/*****************************************************************************/
/* this describes an scl problem (the chains, words, weights, etc) */
/*****************************************************************************/
typedef struct {
char*** chains;
int num_chains;
int* chain_lens;
char** word_list;
int num_words;
int* weights; //this is a list through all the words
RatMat* constraints; //these are the basic constraints
int* equality_type; //
arc* arc_list;
int num_arcs;
polygon* poly_list;
int num_polys;
} scl_problem;
/*****************************************************************************/
/* this is a particular orthant calculation */
/*****************************************************************************/
typedef struct {
int orthant_num;
scl_problem* scl_prob;
tri_list* triangles;
vert_list* vertices;
double max_undone_triangle_area;
int is_complete;
} orthant_problem;
/*****************************************************************************/
/* this type holds the information about a particular unit ball calculation */
/*****************************************************************************/
typedef struct {
char*** chains; //duplicated inside the orthant_problems, but that's ok
//these are the chains for orthant 0
int num_chains;
int* chain_lens;
orthant_problem** orthants; //there are always 4 of these
int is_complete;
int current_working_orthant;
double tolerance;
} ball_problem;
/*****************************************************************************/
/* this is the information about a currently running (or paused) execution */
/*****************************************************************************/
typedef struct {
ball_problem* ball; //this is the problem we are working on
enum scallop_lp_solver solver;
sem_t running_sem; //this is so the worker can block if necessary;
sem_t message_sem; //this blocks for message passing
//message stuff (should be blocked by message_sem)
int one_step; //note really a message -- must be set at the beginning -- only do one step
int status; //1 means currently running, 0 means not
int status_message; //1 means stop, 0 means continue
int new_tolerance_check; //1 means there is a new tolerance 0 means nope
double new_tolerance;
int skip_orthant; //1 means yes, skip, 0 means no keep going
sem_t read_data_sem; //this tells the gui thread to read the data
//note that the worker thread is waiting for this
char* initial_arguments[3];
int maxjun; //whether or not we have -m5
int VERBOSE; //whether the execution should print lots of crap
GtkWidget* target_drawing_area; //this is the widget to draw to
} execution;
void init_lp();
void linear_program_from_ratmat(polygon* poly_list,
rvector* solution_vector,
mpq_t scl,
RatMat* constraints,
int* equality_type,
enum scallop_lp_solver solver);
void generate_arcs(arc** arc_list,
int* num_arcs,
char** word_list,
int word_list_len);
void generate_polygons(char** word_list,
int word_list_len,
arc* arc_list,
int num_arcs,
polygon** poly_list,
int* num_polys,
int maxjun);
void create_constraint_matrix(char*** chains,
int num_chains,
int* chain_lens,
arc* arc_list,
int num_arcs,
polygon* polygon_list,
int num_polys,
int* weights,
RatMat* constraints,
int** equalityType);
void scl_problem_init(scl_problem* scl_prob,
char*** chains,
int num_chains,
int* chain_lens,
char** word_list,
int num_words,
int* weights,
int maxjun,
int VERBOSE);
void point_scl(scl_problem* scl_prob,
rvector* point,
mpq_t scl,
enum scallop_lp_solver solver);
int min_scl_over_triangle(scl_problem* scl_prob,
vert_list* V,
triangle* t,
mpq_t scl,
rvector* new_vertex,
enum scallop_lp_solver solver,
int VERBOSE);
int find_undone_triangle(tri_list* T,
double tolerance);
void split_triangles(vert_list* V,
tri_list* T,
int split_ind,
int new_vert,
int VERBOSE);
int find_edge_for_vertex(vert_list* V, triangle* t, int new_vert);
int one_orthant_step(orthant_problem* orth,
double tolerance,
enum scallop_lp_solver solver,
int VERBOSE);
void one_computation_step(ball_problem* ball,
enum scallop_lp_solver solver,
int VERBOSE);
void* run_execution(void* E_void);
void orthant_problem_init(orthant_problem* orth,
int index,
char*** chains,
int* chain_lens,
int* weights,
int num_words,
mpq_t* predone_scls,
int maxjun,
enum scallop_lp_solver solver,
int VERBOSE);
void computation_init(execution* E,
char*** chains,
int* chain_lens,
int* weights,
int num_words,
double tolerance,
int maxjun,
enum scallop_lp_solver solver,
GtkWidget* target_drawing_area,
int VERBOSE);
void scl_problem_print(scl_problem* sp);
void orthant_problem_print(orthant_problem* orth);
void ball_problem_print(ball_problem* ball);
void execution_print(execution* E);
void scl_problem_free(scl_problem* sp);
void orthant_problem_free(orthant_problem* orth);
void ball_problem_free(ball_problem* ball);
void execution_free(execution* E);
#endif