- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Getting Results from Minimize function
I frequently use the Minimize function in JSL to solve a non-linear equation and one thing i have noticed is that occasionally, the function may fail to reach convergence. Is there a way to get those results from the script?
I am writing a script to solve the model for many different subsets of data and while I can get the parameters, minimized objective and number of iterations for each model that is solved, i don't know if it ended up on a result because it reached the max iterations, converged or failed to converge. Below is an example of the function and the results from a great post by Milo, from JMP.
https://community.jmp.com/t5/JMPer-Cable/Minimize-and-Maximize-Functions-in-JSL/ba-p/36355
x = 0;
y = 0;
{objVal, iters, gradient, hessian} =
Minimize(
((2 * x ^ 2 + 12 * x * y - y * 3)),
{x( -1, 1 ), y( -1, 1 )},
<<maxIter( 200 ),
<<tolerance( 10 ^ -6 ),
<<ShowDetails( True ),
//<<UseNumericDeriv( True ), /*rarely needed*/
//<<Gradient({4*x+12*y, 12*x-3}), /*rarely needed*/
//<<Hessian({{4,12},{0}}) /*rarely needed*/
);
Show( x, y, objVal, iters, gradient, hessian );
These details below are outputted into the log window, and i'd like to get the "Convergence SUCCESS" for the results of each model I run. Any suggestions would be appreciated.
nParm=2 Newton ******************************************************
Iter nFree Objective RelGrad NormGrad2 Ridge nObj nGrad nHess Parm0 Parm1
0 2 0 0.125 0.5 0 1 1 1 0 0
1 1 -0.23568 29.52863 0.514107 2048 16 1 1 0.282987 -1
2 1 -1.92154 26.15693 0.310463 16 1 1 1 0.442808 -1
3 1 -6.6297 16.7406 0.002094 4 1 1 1 0.954236 -1
4 0 -7 . 0 1 1 1 1 1 -1
Convergence SUCCESS: Gradient
Time: 0.0166666666627862
x = 1;
y = -1;
objVal = -7;
iters = 4;
gradient = [-8, 9];
hessian = [4 12, 12 0];
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting Results from Minimize function
After the Minimize() returns, you could call the Get Log() function. The syntax is list = Get Log( < n > ). The result is a list of lines from the Log window. The optional integer argument allows you to select the first n lines (n positive) or the last n lines (n negative).
Then you can examine the result of the convergence.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting Results from Minimize function
After the Minimize() returns, you could call the Get Log() function. The syntax is list = Get Log( < n > ). The result is a list of lines from the Log window. The optional integer argument allows you to select the first n lines (n positive) or the last n lines (n negative).
Then you can examine the result of the convergence.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting Results from Minimize function
thank @Mark_Bailey That is what i ended up doing. I clear the log, then use get log() to grab the window and then cycle through to pull out the item with the term "convergence". I am hoping there is a more direct way to get it though.