2

Using SAS proc IML, I have a function: CVF(m,p,h,pi,e);

I would like to guess h which minimizes this function. Is there some built-in subroutine to minimize it? Or how can I construct an iterative process for it? Every other variables are defined.

Will
  • 11,276
  • 9
  • 68
  • 76
  • As mentioned below, you can use NLPQN or NLPNRA. No matter what optimization routine you choose, you will have to supply an initial guess for the solution. If you don't already have an approximate guess, you might want to evaluate the objective function on a uniform grid, as described in this article: http://blogs.sas.com/content/iml/2014/06/11/initial-guess-for-optimization/ – Rick Jun 30 '14 at 13:55

2 Answers2

0

You can build your own optimization routine with IML language, of course, but you have also optimization routines built-in, see chapter 11 of IML User's Guide, Nonlinear Optimization Examples.

0

Use call nlpqn();. The function you pass needs to have only 1 parameter, the vector you want to optimize over. So here I define a quadratic function where the a, b, and c parameters are also able to be defined. Use the GLOBAL statement and define the non-moving variables before the call.

Alternatively, you can put everything in the input vector, and then add constraints to keep those values from moving.

proc iml;

start myfun(x) global(a, b, c);
    out = a*x**2 + b*x + c;
    return (out);
finish myfun;

a = 1;
b = 2;
c = 4;

optn = {0, /* option 1: 0 -> MIN, 1 -> MAX*/
        0  /* Print options 0-5 0 least, 5 most*/
        };

init = 0;
call nlpqn(rc, res, "myfun", init);

/*rc > 0 means success*/
print rc res;
quit;

Returns:

                                  The SAS System           08:59 Friday, June 27, 2014   3

                                      rc       res

                                       3        -1
DomPazz
  • 12,415
  • 17
  • 23
  • How could I limit the range of solutions? in this particular case I would like to limit x>0. – user3787851 Jul 24 '14 at 12:05
  • Look at the documentation. You build a constraint matrix and pass it to the nlpqn() function. – DomPazz Jul 24 '14 at 15:17
  • Here are details on the linear constraint matrix. http://support.sas.com/documentation/cdl/en/imlug/66845/HTML/default/viewer.htm#imlug_nonlinearoptexpls_sect015.htm – DomPazz Jul 24 '14 at 15:23