LINGO软件介绍之一维数组型变量段的概述基本集合与属性变量段的概述LINGO中建立的优化模型可以由六个部分组成,或称为六“段”。(1)集合段:用于定义数组型性变量SETS:……ENDSETS(2)数据段:用于变量赋值与数据传递DATA:……ENDDATA(3)目标与约束段:用于列出目标与约束唯一一个没有段的开始和结束标记段的概述(4)计算段:用于数据初始整理计算CALC:……ENDCALC(5)初始段:用于变量赋初值迭代寻优INIT:……ENDINIT(6)子模型段:用于表达子模型进行调用@SUBMODELmymodel:可执行语句(约束+目标)ENDSUBMODEL基本集合与属性变量100sets:!集合段;s/1..100/:x;!基本集合,集合名与属性变量;endsets!目标与约束段;@sum(s(i):x(i))90;!循环求和函数;1.怎样表示:xi90?i1基本集合与属性变量2.怎样赋值:b65,b72,b86,b91,b102?b11,b20,b31;b42,b53,sets:!集合段;ss/1..10/:b;endsetsdata:!数据段;b=1012352612;enddata基本集合与属性变量yj取整数,j1,2,..,200xi为0-1变量,i1,2,,100sets:!集合段;a/1..100/:x;b/1..200/:y;Endsets!目标与约束段;@for(b(j):@gin(y(j)));@for(a(i):@bin(x(i));3.怎样表示:基本集合与属性变量实例“超市大赢家”提供了50件商品作为奖品供中奖顾客选择,车的容量为1000dm3,奖品i占用的空间为widm3,价值为vi元,怎样选择价值最大?具体的数据如下:vi={220,208,198,192,180,180,165,162,160,158,155,130,125,122,120,118,115,110,105,101,100,100,98,96,95,90,88,82,80,77,75,73,72,70,69,66,65,63,60,58,56,50,30,20,15,10,8,5,3,1}wi={80,82,85,70,72,70,66,50,55,25,50,55,40,48,50,32,22,60,30,32,40,38,35,32,25,28,30,22,50,30,45,30,60,50,20,65,20,25,30,10,20,25,15,10,10,10,4,4,2,1}。5050ii1iix0or1maxfvixii1x1000基本集合与属性变量建立模型:Xi=1表示选择该物品,Xi=0表示不选择该物品基本集合与属性变量MODEL:TITLE超市大赢家;SETS:S/1..50/:W,V,X;ENDSETSDATA:V=220,208,198,192,180,180,165,162,160,158,155,130,125,122,120,118,115,110,105,101,100,100,98,96,95,90,88,82,80,77,75,73,72,70,69,66,65,63,60,58,56,50,30,20,15,10,8,5,3,1;W=80,82,85,70,72,70,66,50,55,25,50,55,40,48,50,32,22,60,30,32,40,38,35,32,25,28,30,22,50,30,45,30,60,50,20,65,20,25,30,10,20,25,15,10,10,10,4,4,2,1;ENDDATAMAX=@SUM(S(I):V(I)*X(I));@SUM(S(I):W(I)*X(I))1000;@FOR(S(I):@BIN(X(I)));END5050ii1x0or1maxfvixii1ixi1000思考:如果一件物品可以拿多件呢,怎么修改程序?