Q: dtrnlsp_init for initializing the solver of a nonlinear least squares problem.

Q: dtrnlsp_init for initializing the solver of a nonlinear least squares problem.

Hello All,

We're replacing our current solver for a non-linear least squares problem without constraints with the MKL version.

First tried implementing it in a simple problem: F(x) : n = 6  → m = 1

Followed the example in ex_nlsqp_c_c.htm.

However, dtrnlsp_init returns TR_INVALID_OPTION instead of TR_SUCCESS.

After going through the code, still puzzled as to why given that this seems to be straightforward.

Any insight would be much appreciated.

__ System Config___

OS: Windows 7 x64

IDE: MS VS 2010 C++

Compiler: Intel Composer XE 2013 C++

MKL: 11.0.5

___Code fragment___

// Intel MKL
#include <mkl.h>
#include <mkl_rci.h>
#include <mkl_types.h>
#include <mkl_service.h>

. . .

double MyClass::SimpleTestMemberFunction
( std::array<double,_6D>& rtParameter )
{

int byteAlignment = 64;

// 1: Initialization
_TRNSP_HANDLE_t handle;

MKL_INT n = 6; // x has 6 d.o.f.
MKL_INT m = 1; // f(x): scalar function
double* rtPrmtrMKL = NULL;
double epsMKL[6]; // 6 precision stop-criteria array [see MKL manual for definitions]
MKL_INT nMaxIter = 1000;
MKL_INT nMaxTrialIter = 100;
double stepBound = 0.0;
MKL_INT taskStatus;

rtPrmtrMKL = static_cast<double*>(MKL_malloc( static_cast<size_t>(n) * sizeof(double), byteAlignment));

if (rtPrmtrMKL == NULL)
{
std::cout << "rtPrmtrMKL: mkl_malloc memory allocation failure " << std::endl;
return -1.0;
}

// Input parameter initialization

for (int i = 0; i != n; i++)
rtPrmtrMKL[i] = rtParameter[i];

// Initialize precisions for stop-criteria
for (int i = 0; i != 6; i++)
epsMKL[i] = 1.e-05;

// Initialize the nonlinear least squares solver
taskStatus = dtrnlsp_init
( &handle
, &n // Number of function variables
, &m // Dimension of function value
, rtPrmtrMKL // Solution vector: contains values x for f(x)
, epsMKL // Precisions for stop-criteria [see manual for details]
, &nMaxIter // Maximum number of iterations
, &nMaxTrialIter // Maximum number of iterations of calculation of trial-step
, &stepBound ); // Initial step bound

if (taskStatus != TR_SUCCESS)
{
if (taskStatus == TR_INVALID_OPTION)
{
std::cout << "dtrnlsp_init: error in the input parameters; taskStatus = TR_INVALID_OPTION " << TR_INVALID_OPTION << std::endl;
mkl_free_buffers();
mkl_free( rtPrmtrMKL);
return -1.0;
}
else
if (taskStatus == TR_OUT_OF_MEMORY)
{
std::cout << "dtrnlsp_init: memory error" << std::endl;
mkl_free_buffers();
mkl_free( rtPrmtrMKL);
return -1.0;
}
}

Etc.

}

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

MKL's trust-region solver solves nonlinear least square problems without boundary constraints defined as:

Note that m is larger than or equal to n. In your code, n = 6 and m = 1. This is the problem.

Realized this after posting ;-)

Thank you for your prompt answer.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui