edge_lengths[v1][e]= hypotD(vertices[v1],vertices[v2]);
}
+#include <pthread.h>
+
void compute_vertex_areas(const Vertices vertices, int section) {
int v0,v1,v2, e1,e2;
// int k;
double a[D3], b[D3], axb[D3];
double total_cost= 0;
+ if (quitting_last_iteration) {
+ char buf[100];
+ int n= sprintf(buf,
+ "section=%d thr=%#08lx qi=0x%03x START\n",
+ section,(unsigned long)pthread_self(), N);
+ write(2,buf,n);
+ quitting_reported_threads= 1;
+ }
+
FOR_EDGE(qi,e,ri, OUTER) {
+ if (quitting_last_iteration) {
+ char buf[100];
+ int n= sprintf(buf,
+ "section=%d thr=%#08lx qi=0x%03x,e=%d,ri=0x%03x\n",
+ section,(unsigned long)pthread_self(),qi,e,ri);
+ write(2,buf,n);
+ }
+
pi= EDGE_END2(qi,(e+3)%V6); if (pi<0) continue;
//if (!(qi&XMASK)) fprintf(stderr,"%02x-%02x-%02x (%d)\n",pi,qi,ri,e);
exit(8);
}
+static sig_atomic_t quit_requested;
+sig_atomic_t quitting_reported_threads;
+int quitting_last_iteration;
+
+static void sigint_handler(int ignored) {
+ quit_requested= 1;
+}
+
int main(int argc, const char *const *argv) {
gsl_multimin_function multimin_function;
double size;
FILE *initial_f;
gsl_vector initial_gsl, step_size_gsl;
int r, i, size_check_counter= 0;
+ struct sigaction sa;
if (argc==3) {
input_file= argv[1];
if (final_file)
if (asprintf(&final_file_tmp,"%s.new",final_file) <= 0) diee("asprintf");
+ memset(&sa,0,sizeof(sa));
+ sa.sa_handler= sigint_handler;
+ sa.sa_flags= SA_RESETHAND;
+ r= sigaction(SIGINT,&sa,0);
+ if (r) diee("sigaction SIGINT");
+
graph_layout_prepare();
printing_init();
energy_init();
&initial_gsl, &step_size_gsl) );
for (;;) {
+ if (quit_requested) {
+ fprintf(stderr,"SIGINT caught, quitting soon.\n");
+ quitting_last_iteration= 1;
+ }
+
GA( gsl_multimin_fminimizer_iterate(minimiser) );
if (!(size_check_counter++ % DIM)) {
if (r==GSL_SUCCESS) break;
assert(r==GSL_CONTINUE);
}
+
+ if (quitting_reported_threads)
+ exit(1);
}
if (final_file) {
extern char *best_file_tmp;
extern long long evaluations;
extern double stop_epsilon;
+extern int quitting_last_iteration;
+
+#include <signal.h>
+extern sig_atomic_t quitting_reported_threads;
enum printing_instance { pr_cost, pr_size, pr__max };
int printing_check(enum printing_instance, int indent);
/* used anamorphically: section, nsections */
#define OUTER_PERSECTION_BASE(zero,n, sect) \
- ((zero) + sect * (((n)-(zero) + NSECTIONS-1) / NSECTIONS))
-#define OUTER(v,zero,n, precomp) \
- for ((v)= OUTER_PERSECTION_BASE((zero),(n), section); \
- precomp, \
- (v) < OUTER_PERSECTION_BASE((zero),(n), section + 1) && (v) < (n); \
+ ((zero) + (sect) * (((n)-(zero) + NSECTIONS-1) / NSECTIONS))
+#define OUTER(v,zero,n, precomp) \
+ for ((v)= OUTER_PERSECTION_BASE((zero),(n), (section)); \
+ precomp, \
+ (v) < OUTER_PERSECTION_BASE((zero),(n), (section) + 1) && (v) < (n); \
(v)++)
/*