Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 190

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

$
0
0

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.

}


Viewing all articles
Browse latest Browse all 190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>