Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- MKL 10.2 Update 1 Optimization Solver

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

Highlighted
##

Hi,

I am trying to optimize an exponential multivariable function using the TR solver (dtrnlsp_solve). I have been going over it for a week and the solver fails miserably. All I get everytime is "NaN" for the coefficients. The same problem is optimized in C# NI libraries.

The function is sometime like F(x) = a0 + sum(ai*exp(-x/ti)) (i=1 to 6)

'ai' and 'ti' are my design variables. (Vector X)

I understand it's difficult to gague without further details? Generally, any ideas of what's wrong? Is it normal for the solver to behave this way at times for certain equations? I have successfully used the solver for optimizing other equations.

Also, I can't seem to find good examples for the central differences solver (DJACOBI_SOLVE). The one described in the manual is very limited and has a lot of errors. Can anyone point me to certain examples using the central differences solver?

Thanks,

Shriram

--

Mechanica Engineer - FEA Development

Moore Nanotechnology Systems

Swanzey, NH - 03431

shriisall

Beginner

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

07-22-2010
08:25 AM

9 Views

MKL 10.2 Update 1 Optimization Solver

I am trying to optimize an exponential multivariable function using the TR solver (dtrnlsp_solve). I have been going over it for a week and the solver fails miserably. All I get everytime is "NaN" for the coefficients. The same problem is optimized in C# NI libraries.

The function is sometime like F(x) = a0 + sum(ai*exp(-x/ti)) (i=1 to 6)

'ai' and 'ti' are my design variables. (Vector X)

I understand it's difficult to gague without further details? Generally, any ideas of what's wrong? Is it normal for the solver to behave this way at times for certain equations? I have successfully used the solver for optimizing other equations.

Also, I can't seem to find good examples for the central differences solver (DJACOBI_SOLVE). The one described in the manual is very limited and has a lot of errors. Can anyone point me to certain examples using the central differences solver?

Thanks,

Shriram

--

Mechanica Engineer - FEA Development

Moore Nanotechnology Systems

Swanzey, NH - 03431

8 Replies

Highlighted
##

Hi Shriram,

As I understood, F(x) is not differentiableif t = 0. Moreover, if t approaches 0 then the objective function is unbounded. I would recommend changing aninitial point or using solver for problems with boundary constraints (where X > 0).

Please let me know how it works.

Thank you!

--Nikita

Nikita_S_Intel

Employee

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

07-22-2010
09:04 PM

9 Views

As I understood, F(x) is not differentiableif t = 0. Moreover, if t approaches 0 then the objective function is unbounded. I would recommend changing aninitial point or using solver for problems with boundary constraints (where X > 0).

Please let me know how it works.

Thank you!

--Nikita

Highlighted
##

Hey Nikita,

Thanks for the reply.

I am not sure if the function should cause any problem. The same function is optimized very well using National Instruments curvefit library. That however uses the Leverberg-Marquardt algorithm and Intel uses the Trust-Region algorithm.

- I am not sure what you mean by an unbounded function. As t nears zero, the exponential term nears 1 and the function returns a constant value. At t=0, the exponential terms are all equal to 1. The function values are still finite.

- I was under the impression that the Trust-Region algorithm was a derivative free method. If t = 0, the function value is a constant and hence the derivative is zero.

However, I tried assigning lower bounds and changing initial guesses, but with little or no success to the results. After certain iterations, the design variables and function values suddenly become "NaN". I can't understand this unexpected behavior.

But, as you say, if I remove the data points which are equal to 0 or have very small values (like 1E-7, 1E-3) etc. then the solver does a much better job.

Thanks again,

Shriram

shriisall

Beginner

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

07-23-2010
08:17 AM

9 Views

Thanks for the reply.

I am not sure if the function should cause any problem. The same function is optimized very well using National Instruments curvefit library. That however uses the Leverberg-Marquardt algorithm and Intel uses the Trust-Region algorithm.

- I am not sure what you mean by an unbounded function. As t nears zero, the exponential term nears 1 and the function returns a constant value. At t=0, the exponential terms are all equal to 1. The function values are still finite.

- I was under the impression that the Trust-Region algorithm was a derivative free method. If t = 0, the function value is a constant and hence the derivative is zero.

However, I tried assigning lower bounds and changing initial guesses, but with little or no success to the results. After certain iterations, the design variables and function values suddenly become "NaN". I can't understand this unexpected behavior.

But, as you say, if I remove the data points which are equal to 0 or have very small values (like 1E-7, 1E-3) etc. then the solver does a much better job.

Thanks again,

Shriram

Highlighted
##

Nikita_S_Intel

Employee

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

07-25-2010
08:37 PM

9 Views

Hi Shriram,

Actually, TR solvers are not derivative free methods, users objective function F(x) = y f(x), where F(x): Rn ->Rm, m>=nshould bea twice differentiable function in Rn.

As of your function, it is unbounded, if t nears 0 and t < 0. Something likes that

F(x) = 1.935444e+44, t = -1.000000e-02

F(x) = 1.295015e+49, t = -9.000000e-03

F(x) = 1.393615e+55, t = -8.000000e-03

F(x) = 7.932340e+62, t = -7.000000e-03

F(x) = 1.736785e+73, t = -6.000000e-03

F(x) = 5.202701e+87, t = -5.000000e-03

F(x) = 2.697447e+109, t = -4.000000e-03

F(x) = 4.189477e+145, t = -3.000000e-03

F(x) = 1.010586e+218, t = -2.000000e-03

F(x) = inf, t = -1.000000e-03

F(x) = 1.200000e+00, t = 0.000000e+00

F(x) = 1.200000e+00, t = 1.000000e-03

F(x) = 1.200000e+00, t = 2.000000e-03

Did try to use solver for problems with boundary constraints [ T > 0] and use initial point [ T > 0 ]?

Thank you!

--Nikita

Highlighted
##

Oh ok. The domain of my design variables is all positive, so I didn't think about the solver attempting -ve design values.

I think I had tried with lower bounds greater than 0, and still had the same problems. However, I will still make sure once again as what you say makes good sense.

Thanks Nikita!

Shriram

shriisall

Beginner

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

07-27-2010
09:49 AM

9 Views

I think I had tried with lower bounds greater than 0, and still had the same problems. However, I will still make sure once again as what you say makes good sense.

Thanks Nikita!

Shriram

Highlighted
##

Hey Nikita,

I had a quick question. I can specify the lower and upper bounds and use the function 'dtrnlspbc_xxx' solver.

However, I have no upper bound and I cannot set an arbitrary number. Is it possible to set a lower bound and have upper bound, unbounded?

Thanks,

Shriram

shriisall

Beginner

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

07-27-2010
02:11 PM

9 Views

I had a quick question. I can specify the lower and upper bounds and use the function 'dtrnlspbc_xxx' solver.

However, I have no upper bound and I cannot set an arbitrary number. Is it possible to set a lower bound and have upper bound, unbounded?

Thanks,

Shriram

Highlighted
##

Hi Shriram,

Alexander_K_Intel2

Employee

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

07-27-2010
07:17 PM

9 Views

Thedtrnlspbc_xxx solver is the solver with boundaries so you need to put some upper boundaries conditions. Nevertheless you could put some boundary estimation that certainly greater than exact solution.

With best regards,

Alexander Kalinkin

Highlighted
##

Nikita_S_Intel

Employee

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

07-27-2010
08:52 PM

9 Views

Hi Shriram,

Or you can use max. value of double precision as upper bound.

Thank you!

--Nikita

Or you can use max. value of double precision as upper bound.

Thank you!

--Nikita

Highlighted
##

I have a similar problem. We are using the optimizer from C# code to minimize an error function; we are using the approximate jacobi calculator as well (although we are likely to switch to an analyic formula soon). The outcome is non-deterministic; most of the time, the optimization works well and converges to a reasonable answer that is repeatable, while at random other times, the optimizer's step algorithm fills the "x" array with NaN. This always occurs when the "RCI_Request" variable is set to 1, indicating that a function evaluation is requested; we have a NaN check in the function evaluation that realizes this and throws an exception whenever the array has a NaN in it - incidentally, whenever it has one NaN, it is entirely filled with NaN. We have checked that the function and jacobian evaluations that we pass into MKL have no NaNs. It seems that the step that the routine takes is sometimes filled with NaNs, but when it is not filled with NaN it is repeatable. Why would this happen?

It is difficult to repeat it; sequential calls with the same input will complete the optimization smoothly or have the NaN in a random fashion. Is there a threading problem?

It happens on different machines.

We've noticed that it usually happens more regualrly in Release mode than in Debug mode.

All of this has led us to suspect it was related to memory management, like the CLR's garbage collector, by Release mode optimizations performed by the compiler, or by Interop marshalling problems. I am not very familiar with all of these topics. We are pinning all 3 arrays ("x", "fec", and "fjac") as is necessary to send the arrays to MKL as pointers. In trying to fix the issue, I used GCHandle.Alloc (followed by GCHandle.Free at the end of the optimization call) to pin the arrays in another way, and it still fills the x array with NaN occasionally. I've also tried making a deep copy of the x array before function evaluations, also to no avail.

michaelkinnally

Beginner

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

08-16-2012
01:09 PM

9 Views

It is difficult to repeat it; sequential calls with the same input will complete the optimization smoothly or have the NaN in a random fashion. Is there a threading problem?

It happens on different machines.

We've noticed that it usually happens more regualrly in Release mode than in Debug mode.

All of this has led us to suspect it was related to memory management, like the CLR's garbage collector, by Release mode optimizations performed by the compiler, or by Interop marshalling problems. I am not very familiar with all of these topics. We are pinning all 3 arrays ("x", "fec", and "fjac") as is necessary to send the arrays to MKL as pointers. In trying to fix the issue, I used GCHandle.Alloc (followed by GCHandle.Free at the end of the optimization call) to pin the arrays in another way, and it still fills the x array with NaN occasionally. I've also tried making a deep copy of the x array before function evaluations, also to no avail.

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