Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Audrius_S_
Beginner
108 Views

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 = rtParameter;

// Initialize precisions for stop-criteria
for (int i = 0; i != 6; i++)
epsMKL = 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.

}

0 Kudos
4 Replies
Zhang_Z_Intel
Employee
108 Views

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.

Audrius_S_
Beginner
108 Views

Realized this after posting ;-)

Thank you for your prompt answer.

Yoon__JAEGOON
Beginner
108 Views

Hi Zhang, I'm having same problem as above. I understood that m has to be same or larger than n. But in case, my fuction actually has smaller m than n, how should I handle? Should I just copy existing function vector to make the size o n? Or should I just set to zero for the remaining fvec array?
mecej4
Black Belt
108 Views

The problem as described by you is ill-posed.

Consider the following counterexample:

         x2 + y2 = 9

There are two variables, x and y, and one "data" point. What criterion would you use to certify a candidate point (x, y) as a "solution"? 

Any point on the circle with center at the origin and radius = 3 satisfies the equation. How then, would you pick just one such point as "the solution"?

Reply