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++
// Intel MKL
. . .
( std::array<double,_6D>& rtParameter )
int byteAlignment = 64;
// 1: Initialization
MKL_INT n = 6; // x has 6 d.o.f.
MKL_INT m = 1; // f(x): scalar function
double* rtPrmtrMKL = NULL;
double epsMKL; // 6 precision stop-criteria array [see MKL manual for definitions]
MKL_INT nMaxIter = 1000;
MKL_INT nMaxTrialIter = 100;
double stepBound = 0.0;
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;
// 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
, &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;
if (taskStatus == TR_OUT_OF_MEMORY)
std::cout << "dtrnlsp_init: memory error" << std::endl;
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.
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"?