Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

Questions about document of Optimization Solver Routines

simbalee
Beginner
1,268 Views
I am trying to use Optimization Solver Routines ( OSR ) of MKL 10.0.3.021.
No of the reference manual is: 630813-027US.
On page 2727, there are descriptions about "fvec" parameter of dtrnlsp_solve. It is said that:
fvec( i ) = yi - fi(x)
I understand that here "yi" is the i-th known values to be approximated through optimized values of "x",
and "fi(x)" is the i-th values that are computed with "x" of the current stage and a given calculate-routine.
So the fvec(i) here is a kind of residual error between approximate value "fi(x)" and expected value "yi" for me.
Am I correct?

However, on page 2726, it is also said that:
-------------------------------------------
RCI_Request= 1 that indicates the requirement to recalculate the function at vector X and put the result into fvec.
-------------------------------------------
It seems to me that instead of yi - fi(x), it is the fi(x) that should be put into fvec by following this instruction.

Now you may understand how confused I am.

The example given on page 2737 to page 2743 is consistent with the descriptions on page 2726.
Unfortunately the example itself is not quite self-explaining.
Say, the dimension of function value ( m ) is the same with number of function variables ( n ), which is atypical.
And the fucntion "extendet_powell" is too simple. The coefficents for calculating f(x) are all hard-coded in the "extendet_powell".
What if I need an array of un-redictable values to calculate f(x) ?
How do I pass pointer of the array to the calculating routine?
Is it impossible to do so?
Or do I need to attach the array behind f(x) and use a fixed shift in memory to access the array?

Your help will be deeply appreciated.








0 Kudos
35 Replies
ArturGuzik
Valued Contributor I
459 Views

is dtrnlsp_init returning OK? I can't spot it here.You called it outside the snippet. Don't you? There you can set stopping criteria.

Maybe your residual is just too big (and iterations don't improve it much, so algorithm stops as there is no progress made) and you just have no chance of converging to global minimum. Also approximate Jacobian maybe an issue. And RCI_requests are requests to YOU not yours to MKL. You can't set them, you just provide what MKL requires.

A.
0 Kudos
simbalee
Beginner
459 Views
Quoting - ArturGuzik

is dtrnlsp_init returning OK? I can't spot it here. You called it outside the snippet. Don't you? And RCI_requests are requests to YOU not yours to MKL. You can't set them, you just provide what MKL requires.

A.

Sorry I forget the part of dtrnlsp_init. It is with the same loop of solver as below

[cpp]if ( dtrnlsp_init( &handle, &n, &m, camtmp, eps, &iter1, &iter2, &rs ) != TR_SUCCESS ) {
	fprintf( stderr, "Failed to intialize Nonlinear Optimization Rutines of MKL with dtrnlsp_init!n" );
	ret = ERR_MKL_INIFAIL;
	goto DONE;
}

RCI_Req = 10;
success = 0;
loop = 0;
maxloop = MIN_MKL_SOLV_LOOP > iternum ? MIN_MKL_SOLV_LOOP : iternum;
[/cpp]
Value of RCI_Req is set to make sure that something actullay happened. I did it just for debugging.
0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - simbalee

Hi Nikita. I posted some code. Sorry that all spaces at the begining of each line are lost.


I didn't see any problem at first sight. I'll check it more carefully. But I want to note: in your case varibale loopdoesn't calculate iterations. It calculates the number of exits of *_solve routine :)

--Niktia
0 Kudos
simbalee
Beginner
459 Views

I didn't see any problem at first sight. I'll check it more carefully. But I want to note: in your case varibale loopdoesn't calculate iterations. It calculates the number of exits of *_solve routine :)

--Niktia

Thank you Nikita.
The "loop" is used to avoid endless loop, if it is possible.
I understand that times of iteration should be retrieved with the st_cr returned by dtrnlsp_get.
0 Kudos
ArturGuzik
Valued Contributor I
459 Views
My first check would be to verify Jacobian. If something is wrong there, you're solving something else what you think you do. Especially that Nikita didn't see anything wrong with the (external, Jacobian calling) code.

A.
0 Kudos
simbalee
Beginner
459 Views

I didn't see any problem at first sight. I'll check it more carefully. But I want to note: in your case varibale loopdoesn't calculate iterations. It calculates the number of exits of *_solve routine :)

--Niktia

I'd like to summarize my questions.

1. should 0 == RCI_Request be taken as a signal of success completion of RCI routines of dtrnlsp?
According to the manual, it is. It indicates successful completion of the task, as described in the manual.
However, in the example given in the manual, it is NOT taken as such a signal.
And from my experience, it is questionable.

2. st_cr of dtrnlsp_get returns 0 in some cases, which is not described in the manual.
This issue should be clarified.
0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - simbalee

Thank you Nikita.
The "loop" is used to avoid endless loop, if it is possible.
I understand that times of iteration should be retrieved with the st_cr returned by dtrnlsp_get.

I have problems with IE and didn't see you post correctly.

As I understood, if you remove RCI_req from jump out condition, it works fine. So it absolutely rigth. I've checked the documentation and figured out the missprint. If RCI_req == 0, it means that iteration finished successfuly in current trust-region radius (but it doesn't mean that value of X was changed).
Thank you, we'll fix the documentaion.

--Nikita
0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - simbalee

I'd like to summarize my questions.

1. should 0 == RCI_Request be taken as a signal of success completion of RCI routines of dtrnlsp?
According to the manual, it is. It indicates successful completion of the task, as described in the manual.
However, in the example given in the manual, it is NOT taken as such a signal.
And from my experience, it is questionable.

2. st_cr of dtrnlsp_get returns 0 in some cases, which is not described in the manual.
This issue should be clarified.

I've answered on fisrt question in previouspost. There is some non-coordination:) If my answer isn't clear pls let me know.

str_cr variabe eq 0, or other variables has non-documented value, it means that RCI cycle was organized incorrectly.

--Nikita
0 Kudos
simbalee
Beginner
459 Views

I have problems with IE and didn't see you post correctly.

As I understood, if you remove RCI_req from jump out condition, it works fine. So it absolutely rigth. I've checked the documentation and figured out the missprint. If RCI_req == 0, it means that iteration finished successfuly in current trust-region radius (but it doesn't mean that value of X was changed).
Thank you, we'll fix the documentaion.

--Nikita

Well, you solved both my questions. I am going to fight with my own code.

I suppose that such a miss-print should not happen in document of a very popular soft. Can I take it as a hint that MKL does not performance on market very well?


Just kidding.
0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - simbalee

Well, you sloved both my questions. I am going to fight with my own code.

I suppose that such a miss-print should not happen in document of a very popular soft. Can I take it as a hint that MKL does not performance on market very well?


Just kidding.

I belive your question is rhetorical :)

--Nikita
0 Kudos
simbalee
Beginner
459 Views
The work has been completed. Compared with oour preivous code in which nonlinear optimization is done by our own code, the new program that utilizes MKL runs much faster and stable. Accuracy of results are also improved.
Artur & Nikita, thank you both for your kind help.



0 Kudos
ArturGuzik
Valued Contributor I
459 Views
Quoting - simbalee
The work has been completed. Compared with oour preivous code in which nonlinear optimization is done by our own code, the new program that utilizes MKL runs much faster and stable. Accuracy of results are also improved.
Artur & Nikita, thank you both for your kind help.



You're welcome.
It was Jacobian or something else?


Nikita -- will you manage the docs correction issue or I need to submit a support issue/report?

A.
0 Kudos
simbalee
Beginner
459 Views
Quoting - ArturGuzik
You're welcome.
It was Jacobian or something else?


Nikita -- will you manage the docs correction issue or I need to submit a support issue/report?

A.

There was a typo in a core routine that calculates projection positions. A "+" was mistyped as "*".
It is amazing that MKL still managed to get some results which are quite not nonsense.


0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - ArturGuzik
You're welcome.
It was Jacobian or something else?


Nikita -- will you manage the docs correction issue or I need to submit a support issue/report?

A.

Hi Artur,

I'm going to fix documentation for next release.
Thank you!

--Nikita
0 Kudos
Nikita_S_Intel
Employee
459 Views
Quoting - simbalee
The work has been completed. Compared with oour preivous code in which nonlinear optimization is done by our own code, the new program that utilizes MKL runs much faster and stable. Accuracy of results are also improved.
Artur & Nikita, thank you both for your kind help.




Hi simbalee,

You are welcome.
Thank you!

--Nikita
0 Kudos
Reply