2、DualPrice1.0000000.9090909E-010.5454545RowSlackorSurplus17.45454520.00000030.000000例2:LINGO模型构成的4个段:(1)集合段(2)数据段(3)初始段(4)F1标与约束段TitleLocationproblem;sets:demand/1..6/:a,b,c;supply/1..2/:x,y,e;link(demand,supply):d;endsetsdata:a=l.25,8.75,0.5,5.75,3,7.25;b=l.25,0.75,4.75,5,6.5,
3、7.75;c=3,5,4,7,6,ll;e=20,20;enddatainit:x,y=5,1,2,7;endinit[obj]min=@sum(link(izj):d(i,j)*((x(j)-a(i))人2+(y(j)-b(i))人2)人(1/2));@for(demand(i):[demand_con]@sum(supply(j):d(i,j)));@for(supply(i):[supply_con]@sum(demand(j):d(j,i))<=e(i));end例3:注意属性值的个数必须等于集成员的个数(!...;)。在数据声明中输入两个
4、相连的逗兮表示该位置对应的集成员的属忡值未知,两个逗兮间吋以冇空格。sets:setl/AzBzC/:X,Y;endsetsdata:X=l/2/3;y=4,5,6;EnddataFeasiblesolutionfound.Totalsolveriterations:0VariableValueX(A)1.000000X(B)2.000000X(C)3.000000Y(A)4.000000Y(B)5.000000Y(C)6.0000004:给定一个莨角三角形,求包含该三角形的最小正方形。则如图可推知:sets:CE=asmx,AD=bcosx,DE
5、=acosx+6sinx,object/l..3/:f;endsetsdata:a,b=3,4;enddataf(1)=a*@sin(x);f(2)=b*@cos(x);f(3)=a*@cos(x)+b*@sin(x);min=@smax(f(l),f(2),f(3));@bnd(0,x,1•57);Localoptimalsolutionfound.Objectivevalue:Objectivebound:Infeasibilities:3.8805703.8805700.5370432E-07Extendedsolversteps:Total
6、solveriterations:VariableABXF(1)138ValueReducedCost3.0000000.0000004.0000000.0000000.24497870.0000000.72760690.000000F(2)F(3)3.8805703.8805700.0000000.000000例5:求h'd兒[5,1,3,4,6,10]前5个数最小位,后3个数最人位。sets:number/1..6/:x;endsetsdata:x=5134610;enddataminv=@min(number(i)
7、i#le#5:x);!或芯
8、minv=®smin(xl(1),x(2),x(3),x(4),x(5));maxv=@max(number(i)
9、i#ge#4:x);endFeasiblesolutionfound.Totalsolveriterations:!maxv=@smax(x(4),x(5),x(6));VariableMINVMAXVX(1)X(2)x(3)X(4)x(5)x(6)Value1.00000010.000005.0000001.0000003.0000004.0000006.00000010.000006:加工奶制品的牛.产计划。获利24元/公斤获利1
10、6元/公斤每天:50桶牛奶时间480小时至多加工100公斤Aj制订生产计划,使每天获利最大则设:xl桶牛奶生产A1x2桶牛