huashi3483 发表于 2009-11-14 05:16

【转载】GAMS中文使用手册连载07

下面接受一下变量:
变量是组成模型的最基本的元素。最好是先声明变量,再进行初始化。
任何不加以约束的变量可以写成variables 或者是 free variables。
另外还可以因需要定义:positive, nonnegative, negative, binary and integer 变量。
这里需要提醒的是 binary variable,只能有0,1两个值。通常用来做决策的。
还有integer variable的默认范围是从0到100。改动它的上下限已后会详细介绍。
其实,整数变量可以由01变量通过线性组合得到。这里就不介绍了。
另外,gams还支持另外两个特殊变量:
SOS1和SOS2变量。SOS1变量值在一组变量里面,只有一个变量可以是非零的。但不一定是1。
SOS2指一组变量里面,只有两个相邻的变量是非零的。
这两个变量在比较高级的MILP模型中会遇到。
变量声明方法示例:
Variables
  Tcost                        'Total Cost Of Shipping- All Routes';
Binary Variables  Build(Warehouse)Warehouse Construction Variables;
Positive Variables  Shipsw(Supplyl,Warehouse)Shipment to warehouse
  Shipwm(Warehouse,Market)Shipment from Warehouse
Nonnegative Variables  Shipsm(Supplyl,Market)Direct ship to Demand;

Semicont Variables
  X,y,z;

发表于 1970-1-1 08:00

页: [1]
查看完整版本: 【转载】GAMS中文使用手册连载07