Parameters of the objective function for the nonlinear fitting routine

Parameters of the objective function for the nonlinear fitting routine

I want to conduct a nonlinear least square fitting using MKL. However, I don't know how I can introduce some additional parameters for the objective function. Does anybody have some ideas?

This is the introduction of the routine: https://software.intel.com/en-us/node/471086

This is one example code for the routine: https://software.intel.com/en-us/node/471540

How can I past some parameters for the objective function (the f(x) function in the introduction or the extendet_powell() function in the example code)? Thanks very much.

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

One way is to add an array containing the parameters to the argument list of the vector function that is being optimized. You declare and initialize the array in the caller of the optimizer routine, and take care to modify the DJACOBI routine if you are using numerical evaluation of the Jacobian.

Alternatively, in Fortran, put your parameters declarations and initializations into a module, and USE that module in the callback subroutine. For example:

MODULE PARAMETERS
   IMPLICIT NONE
   DOUBLE PRECISION :: P(5) = [ 10.D0, 2.2360679774998D0, -2.D0, &
                                3.1622776601684D0, -1D0 ]
END MODULE PARAMETERS

SUBROUTINE EXTENDED_POWELL (M, N, X, F)
  USE PARAMETERS
  IMPLICIT NONE
  INTEGER M, N
  DOUBLE PRECISION X (*), F (*)
  INTEGER I

  DO I = 1, N/4
      F (4*I-3) = X(4*I - 3) + P(1) * X(4*I - 2)
      F (4*I-2) = P(2)*(X(4*I-1) - X(4*I))
      F (4*I-1) = (X(4*I-2) + P(3)*X(4*I-1))**2
      F (4*I)   = P(4)*(X(4*I-3) +P(5)* X(4*I))**2
  ENDDO

END SUBROUTINE EXTENDED_POWELL

Similarly, in C, you can use global variables to contain the parameter values.

Thank you for the suggestions! I'd like to try both ways.

 

Cita:

mecej4 escribió:

One way is to add an array containing the parameters to the argument list of the vector function that is being optimized. You declare and initialize the array in the caller of the optimizer routine, and take care to modify the DJACOBI routine if you are using numerical evaluation of the Jacobian.

Alternatively, in Fortran, put your parameters declarations and initializations into a module, and USE that module in the callback subroutine. For example:

MODULE PARAMETERS
   IMPLICIT NONE
   DOUBLE PRECISION :: P(5) = [ 10.D0, 2.2360679774998D0, -2.D0, &
                                3.1622776601684D0, -1D0 ]
END MODULE PARAMETERS

SUBROUTINE EXTENDED_POWELL (M, N, X, F)
  USE PARAMETERS
  IMPLICIT NONE
  INTEGER M, N
  DOUBLE PRECISION X (*), F (*)
  INTEGER I

  DO I = 1, N/4
      F (4*I-3) = X(4*I - 3) + P(1) * X(4*I - 2)
      F (4*I-2) = P(2)*(X(4*I-1) - X(4*I))
      F (4*I-1) = (X(4*I-2) + P(3)*X(4*I-1))**2
      F (4*I)   = P(4)*(X(4*I-3) +P(5)* X(4*I))**2
  ENDDO

END SUBROUTINE EXTENDED_POWELL

Similarly, in C, you can use global variables to contain the parameter values.

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya