Obtaining minimum maximum output of a macro (function)

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:39:08

问题


I want to find to find extreme values produced by a macro as a function of input parameters:

For example purposes here is some data:

data Input_data;
    input X Y;
    cards;
    10 15
    20 18
    30 27
    33 41
    ;
run; 

The following is not the actual formula (as the minimum for this is easily found analytically.) and I want computational method. For examples sake I have semi-empirical rule, which takes three parameters in:

%macro Function(const1, const2 const3);
    data output;
        set input;
        X_eff1=((X > &const1.)*(X - &const1.)**2);
        X_eff2=((X > &const2.)*(X - &const2.)**2);
        X_eff3=((X > &const3.)*(X - &const3.)**2);
        Residual= Y - (1.3*X_eff1 - 2.7*X_eff2+ 3.1*X_eff3);
    run;
%mend;

I want the find const1, const2 const3 which produce the minimum value for variable 'Residual'. Can SAS do this? Few options that are to be considered:

a) Find global minimum

b) Find local minimum within boundary conditions, for example: const1[0,1] const2[10,17], const3[20, 22]

I could generate huge table and brute force feed it to the function. However, this is not feasible if the number of input parameter rise.

I could scratch program something?

I could do this in numpy (fmin from cipy.optimize comes to mind)or R if it proves hard for SAS.

Any thoughts on how to solve it??

来源:https://stackoverflow.com/questions/42804051/obtaining-minimum-maximum-output-of-a-macro-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!