欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linggo:非线性规划

程序员文章站 2022-06-13 16:38:56
...

非线性规划

!模型求解;
!ABCD四类企业分开;
!302家企业;
model:
!准备求解变量;
!r是贷款利率,m是贷款金额,d是是否贷款,gra是信誉评级,y是守约率;
sets:
qiyeA/1..44/:rA,mA,dA,yA;qiyeB/1..82/:rB,mB,dB,yB;
qiyeC/1..133/:rC,mC,dC,yC;qiyeD/1..43/:rD,mD,dD,yD;
endsets
!准备数据;
data:
[email protected](lingo_data.xlsx,I2:I45);[email protected](lingo_data.xlsx,I46:I127);
[email protected](lingo_data.xlsx,I128:I260);[email protected](lingo_data.xlsx,I261:I303);
enddata
@free(Ac);@free(Ad);@free(Bc);@free(Bd);@free(Cc);@free(Cd);
Aa=0.7701;Ab=1.453;Ac=-2.306;Ad=-26.48;Ba=0.6866;Bb=1.976;Bc=-2.066;Bd=-25.93;Ca=0.7018;Cb=1.935;Cc=-1.936;Cd=-23.71;
Pmax=1845;Dmax=2701;Lmax=1702;Pmin=0;Dmin=0;Lmin=0;
alpha1=7; alpha2=1.2; alpha3=1.3;A=10000;
!目标函数;
[email protected](P);[email protected](D);[email protected](L);
[email protected](qiyeA(i):dA(i)*mA(i)*rA(i))[email protected](qiyeB(i):dB(i)*mB(i)*rB(i))[email protected](qiyeC(i):dC(i)*mC(i)*rC(i))[email protected](qiyeD(i):dD(i)*mD(i)*rD(i));
[email protected](qiyeA(i):dA(i)*mA(i)*(1-yA(i)))[email protected](qiyeB(i):dB(i)*mB(i)*(1-yB(i)))[email protected](qiyeC(i):dC(i)*mC(i)*(1-yC(i)))[email protected](qiyeD(i):dD(i)*mD(i)*(1-yD(i)));
[email protected](qiyeA(i):dA(i)*mA(i)*rA(i)*(Aa*@exp(Ab*rA(i))+Ac*@exp(Ad*rA(i))))[email protected](qiyeB(i):dB(i)*mB(i)*rB(i)*(Ba*@exp(Bb*rB(i))+Bc*@exp(Bd*rB(i))))[email protected](qiyeC(i):dC(i)*mC(i)*rC(i)*(Ca*@exp(Cb*rC(i))+Cc*@exp(Cd*rC(i))))[email protected](qiyeD(i):dD(i)*mD(i)*rD(i)*(Da*@exp(Db*rD(i))+Dc*@exp(Dd*rD(i))));
max = alpha1*(P/Pmax)-alpha2*(D/Dmax)-alpha3*(L/Lmax);
!贷款金额约束;
@for(qiyeA(i):mA(i)>=10);@for(qiyeA(i):mA(i)<=100);    !信誉评级为A的企业;
@for(qiyeB(i):mB(i)>=10);@for(qiyeB(i):mB(i)<=80);     !信誉评级为B的企业;
@for(qiyeC(i):mC(i)>=10);@for(qiyeC(i):mC(i)<=60);     !信誉评级为C的企业;
@for(qiyeD(i):mD(i)>= 0);@for(qiyeD(i):mD(i)<=0);       !信誉评级为D的企业;
!贷款利率约束;
@for(qiyeA(i):rA(i)<=0.15);@for(qiyeA(i):rA(i)>=0.04);  !信誉评价为A的企业;
@for(qiyeB(i):rB(i)<=0.15);@for(qiyeB(i):rB(i)>=0.07);  !信誉评级为B的企业;
@for(qiyeC(i):rC(i)<=0.15);@for(qiyeC(i):rC(i)>=0.1);   !信誉评级为C的企业;
@for(qiyeD(i):rD(i)<=0);@for(qiyeD(i):rD(i)>=0);        !信誉评级为D的企业;
!是否贷款(0-1约束);
@for(qiyeA(i):@BIN(dA(i)));@for(qiyeB(i):@BIN(dB(i)));@for(qiyeC(i):@BIN(dC(i)));
@for(qiyeD(i):@BIN(dD(i)));@for(qiyeD(i):dD(i)<=0);
!贷款总额约束;
[email protected](qiyeA(i):mA(i)*dA(i))<=2700;[email protected](qiyeB(i):mB(i)*dB(i))<=3800;[email protected](qiyeC(i):mC(i)*dC(i))<=3400;[email protected](qiyeD(i):mD(i)*dD(i))<=2400;
@sum(qiyeA(i):mA(i)*dA(i))[email protected](qiyeB(i):mB(i)*dB(i))[email protected](qiyeC(i):mC(i)*dC(i))[email protected](qiyeD(i):mD(i)*dD(i))<=10000;
@sum(qiyeA(i):mA(i)*dA(i))>=270;@sum(qiyeB(i):mB(i)*dB(i))>=380;@sum(qiyeC(i):mC(i)*dC(i))>=340;@sum(qiyeD(i):mD(i)*dD(i))>=0;
!非负约束;
!P-D-L>=0;
!将结果输出到excel文件;
data:
@ole('lingo_data.xlsx',K2:K45)=dA;@ole('lingo_data.xlsx',K46:K127)=dB;
@ole('lingo_data.xlsx',K128:K260)=dC;@ole('lingo_data.xlsx',K261:K303)=dD;
@ole('lingo_data.xlsx',L2:L45)=mA;@ole('lingo_data.xlsx',L46:L127)=mB;
@ole('lingo_data.xlsx',L128:L260)=mC;@ole('lingo_data.xlsx',L261:L303)=mD;
@ole('lingo_data.xlsx',M2:M45)=rA;@ole('lingo_data.xlsx',M46:M127)=rB;
@ole('lingo_data.xlsx',M128:M260)=rC;@ole('lingo_data.xlsx',M261:M303)=rD;
@ole('lingo_data.xlsx',N2)=P;@ole('lingo_data.xlsx',O2)=D;@ole('lingo_data.xlsx',P2)=L;[email protected]('lingo_data.xlsx',F2)=P-D-L;
enddata
end

相关标签: lingo python