全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1445 0
2013-06-20
I once tried "solve with QP", but the calculated result is wrong. (I use matlab fmincon to solve the same problem, the optimal ojs is zero. The matlab result is much more convincing, and I believe the result given by matlab is correct).  However, when I tried "solve;" in my code, the SAS just can not solve it. In the note, it indicated that The SAS System stopped processing this step because of errors. Can someone help me check my code? Thanks so much. My version is SAS 9.2.


---------------------------------------------------

























data data_read;
input x1 x2 y1 dmu_id;
datalines;
20.22 1 85 1
95.51 1 25 2
1662.98 5 22 3
;
/*---------solve QP--------*/
proc optmodel printlevel=0;
set x_num=1..2;    * set dimension of X ;
set y_num=1..1;
set <num>DMU_ID;
num X{DMU_ID,x_num};
num Y{DMU_ID,y_num};
read data data_read into DMU_ID=[dmu_id]
{r in x_num}<X[dmu_id,r]=col("x"||r)>
{s in y_num}<Y[dmu_id,s]=col("y"||s)>;
var epi{DMU_ID}>=0;
var alpha{DMU_ID};
var beta{DMU_ID,x_num}>=0;
num epi_sol{DMU_ID};
num alpha_sol{DMU_ID};
num beta_sol{DMU_ID,x_num};
min obj=sum{q in DMU_ID}epi[q]**2;
con regression{q in DMU_ID,s in y_num}:Y[q,s]=alpha[q]-epi[q]+sum{r in x_num}X[q,r]*beta[q,r];
con concave{q in DMU_ID,h in DMU_ID}:alpha[q]+sum{r in x_num}X[q,r]*beta[q,r]<=alpha[h]+sum{r in x_num}X[q,r]*beta[h,r];
solve;
for{q in DMU_ID}epi_sol[q]=epi[q].sol;
for{q in DMU_ID}alpha_sol[q]=alpha[q].sol;
for{q in DMU_ID,r in x_num}beta_sol[q,r]=beta[q,r].sol;
create data epi_sol from [dmu_id]epi_sol;
create data alpha_sol from [dmu_id]alpha_sol;
create data beta_sol from [dmu_id x_num]beta_sol;
quit;
run;

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群