/*
* use of GSL
*/
/* We want to do multidimensional minimisation.
*
* We don't think there are any local minima. Or at least, if there
* are, the local minimum which will be found from the starting
* state is the one we want.
*
* We don't want to try to provide a derivative of the cost
* function. That's too tedious (and anyway the polynomial
* approximation to our our cost function sometimes has high degree
* in the inputs which means the quadratic model implied by most of
* the gradient descent minimisers is not ideal).
*
* This eliminates most of the algorithms. Nelder and Mead's
* simplex algorithm is still available and we will try that.
*
* In our application we are searching for the optimal locations of
* N actualvertices in D3 (3) dimensions - ie, we are searching for
* the optimal metapoint in an N*D3-dimensional space.
*
* So eg with X=Y=100, the simplex will contain 300 metavertices
* each of which is an array of 300 doubles for the actualvertex
* coordinates. Hopefully this won't be too slow ...
*/
#include "common.h"
#include
#include
#include
#include
#include "half.h"
#include "minimise.h"
const char *input_file, *best_file;
char *best_file_tmp;
long long evaluations;
double stop_epsilon= 1e-20;
static void printing_init(void);
static gsl_multimin_fminimizer *minimiser;
static const char *final_file;
static char *final_file_tmp;
static double minfunc_f(const gsl_vector *x, void *params) {
struct Vertices vs;
assert(x->size == DIM);
assert(x->stride == 1);
map_dimensions(x->data, vs.a);
return compute_energy(&vs);
}
static void badusage(void) {
fputs("usage: minimise [-i] -o