help-gsl
[Top][All Lists]

## [Help-gsl] Multidimensional Minimizer nmsimplex 2 : How to ignore certai

 From: Philipp Basler Subject: [Help-gsl] Multidimensional Minimizer nmsimplex 2 : How to ignore certain outputs during the Minimization Date: Wed, 8 Jul 2015 16:58:08 +0200

```Hello and thanks for reading this.

I have a Function which receives 2 variables v1 and v2 and 13 Parameters. I
want to minimize it in respect to v1 and v2 and the other parameters stay
constant during the process. I can't derive this Function as one can not
give an closed analytical form.

During the Function I have 4 4x4 Matrices from which I need the
Eigenvalues. I calculate these with the Eigen package. As I need the square
roots of these Eigenvalues, these can not be negative in which case the
tested v1,v2 does not interest me for my search of the minimum.

My Question:
Is there a Method so that the Minimization Routine just ignores these
cases? Maybe as an Option or just as an Output Parameter I can implement in
my function.

My Minimization Method is similiar to the one in the Manual and shown below.

Kind regards,
Philipp Basler.

const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex2;
gsl_multimin_fminimizer *s = NULL;
gsl_vector *ss, *x;
gsl_multimin_function minex_func;

size_t iter = 0;
int status;
double size;

/* Starting point */
x = gsl_vector_alloc (2);
gsl_vector_set (x, 0, v1Start);
gsl_vector_set (x, 1, v2Start);

/* Set initial step sizes to 1 */
ss = gsl_vector_alloc (2);
gsl_vector_set_all (ss, 1.0);

/* Initialize method and iterate */
minex_func.n = 2;
minex_func.f = my_f;
minex_func.params = par;

s = gsl_multimin_fminimizer_alloc (T, 2);
gsl_multimin_fminimizer_set (s, &minex_func, x, ss);

do
{
iter++;
status = gsl_multimin_fminimizer_iterate(s);

if (status)
break;

size = gsl_multimin_fminimizer_size (s);
status = gsl_multimin_test_size (size, C_MinTOL);

if (status == GSL_SUCCESS)
{
printf
<http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>
("converged
to minimum at\n");
printf
<http://www.opengroup.org/onlinepubs/009695399/functions/printf.html> ("%5d
%10.3e %10.3e f() = %7.3f size = %.3f\n",
iter,
gsl_vector_get (s->x, 0),
gsl_vector_get (s->x, 1),
s->fval, size);
printf
<http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>(" at
Temperature %lf \n " , Temptmp);

}

}
while (status == GSL_CONTINUE && iter < 1000);

```