Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- dtrnlspbc_solve yields NaN

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Dimitris_Dakopoulos

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-19-2013
06:31 AM

62 Views

dtrnlspbc_solve yields NaN

Dear all,

For my application I use the bounded nonlinear solver almost identical to the examples provided in MKL.

I show sample of my code (unfortunately it's not possible to presend a more detailed compilable version).

So, in the main solver loop, after a couple of iterations I notice that **after running dtrnlsbc_solve optimization_vector**

**is all nans**. I am certain that no-one else messes with it in the meantime.

Also, fvec and fjac do not have any nans, infs or very small or large values. Does anybody have any idea why could this

happen? Maybe an improper initialization?

Note also, thatthis problematic case is unique. It runs fine in all other cases.

Thank you in advance

Dimitris

**System: Linux CentOS 4, gcc-4.7.2, MKL 11.0**

[cpp]

std::vector<double> eps = {1e-5, 1e-5, 1e-5, 1e-5, 1e-5, 1e-5};

std::vector<double> fvec(m, 0.);

std::vector<double> fjac(m * n, 0.);

_TRNSP_HANDLE_t handle;

int iter1 = 1000, iter2 = 100;

double rs = 0.0;

if(dtrnlspbc_init(&handle, &n, &m,

optimization_vector, lower_bounds

upper_bounds, eps.data(), &iter1, &iter2, &rs)

!= TR_SUCCESS)

{

exit(1);

}

int info[6];

if(dtrnlspbc_check(&handle, &n, &m, fjac.data(), fvec.data(),

lower_bounds, upper_bounds, eps.data(),

info) != TR_SUCCESS)

{

exit(1);

}

else if(info[0] || info[1] || info[2] || info[3])

{

exit(1);

}

int RCI_Request = 0;

// main solver loop

while(1)

{

// THE PROBLEM IS HERE

// I print optimization_vector, fvec, fjac and they look fine but afterwards

// optimization_vector is made into nans

if(dtrnlspbc_solve(&handle, fvec.data(), fjac.data(), &RCI_Request)

!= TR_SUCCESS)

{

exit(1);

}

if(RCI_Request == -1 || RCI_Request == -2 || RCI_Request == -3

|| RCI_Request == -4 || RCI_Request == -5 || RCI_Request == -6)

{

break; // success!

}

else if(RCI_Request == 1)

{

objective(&m, &n, optimization_vector, fvec.data(), this);

}

else if(RCI_Request == 2)

{

if(djacobix(objective, &n, &m, fjac.data(),

optimization_vector, eps.data(), this)

!= TR_SUCCESS)

{

exit(1);

}

}

}

double r1, r2;

int iter, st_cr;

if(dtrnlspbc_get(&handle, &iter, &st_cr, &r1, &r2) != TR_SUCCESS)

{

exit(1);

}

if(dtrnlspbc_delete(&handle) != TR_SUCCESS)

{

exit(1);

}

mkl_free_buffers();

[/cpp]

Link Copied

4 Replies

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2013
05:41 AM

62 Views

Dimitris_Dakopoulos

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2013
05:53 AM

62 Views

Exactly. I would be glad if I got comments:

* on the structure of the flow I am following

* by users having dealt with something similar

* theoritical hints on whether the solver is possible to fail and in which cases.

Unfortunately I cannot strip down the case from my application and/or provide more "usable" code.

UPDATE: After lots of debugging seems that there is a problem with my objective function

Dimitris_Dakopoulos

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2013
06:49 AM

62 Views

**UPDATE: **For some reason, the solver produces a solution vector value outside the boundaries I provided (0, inf), more precicely a negative one. My objective function contained a square root of that so it produced NaN.

Now, I guess, there is another question. Why did this happen?

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2013
10:42 AM

62 Views

In general, nonlinear constrained optimization methods do not visit only feasible points on the way to the optimum.

If you displayed the code for your objective function, at least, perhaps some progress could be made. Keep in mind that MKL is not open source, and giving answers to the questions you asked about the methodology may involve divulging proprietary information.

I think that it would be more productive to ensure that you have formulated the problem correctly and are invoking the MKL routines properly.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.