数学建模社区-数学中国

标题: 【转载】GAMS中文使用手册连载07 [打印本页]

作者: huashi3483    时间: 2009-11-14 05:16
标题: 【转载】GAMS中文使用手册连载07
下面接受一下变量:
/ Y6 K$ r; E$ s% H' b' B) v变量是组成模型的最基本的元素。最好是先声明变量,再进行初始化。
. W# I/ s' [; w+ B6 E8 P4 c任何不加以约束的变量可以写成variables 或者是 free variables。
+ w& Z* f! s& c  |( w$ g- v另外还可以因需要定义:positive, nonnegative, negative, binary and integer 变量。) e0 l' E) S! s. T
这里需要提醒的是 binary variable,只能有0,1两个值。通常用来做决策的。! u  |" P# w; V" ^
还有integer variable的默认范围是从0到100。改动它的上下限已后会详细介绍。
2 Z3 H% D' `) `/ ?/ C其实,整数变量可以由01变量通过线性组合得到。这里就不介绍了。8 K3 G7 M# A+ ]
另外,gams还支持另外两个特殊变量:. ^3 o, g" Q" M" y3 E
SOS1和SOS2变量。SOS1变量值在一组变量里面,只有一个变量可以是非零的。但不一定是1。
& j* s8 y7 |6 u8 v5 L2 ^SOS2指一组变量里面,只有两个相邻的变量是非零的。
1 ]+ k. q7 F5 @2 L5 p, u这两个变量在比较高级的MILP模型中会遇到。+ C6 r& H* a, ^5 V6 D/ Z& d% `
变量声明方法示例:
0 ?. m0 n- t  [8 }' WVariables8 W1 M5 |0 x- J0 F
  Tcost                        'Total Cost Of Shipping- All Routes';) N- V. R. x: b. ^- R  y* H4 l
Binary Variables
  Build(Warehouse)Warehouse Construction Variables;
+ t' q% k; z, N, O( q7 v

Positive Variables

  Shipsw(Supplyl,Warehouse)Shipment to warehouse
. k  M6 l9 f* S8 z* D5 W1 t( g
  Shipwm(Warehouse,Market)Shipment from Warehouse
4 J- u# u! v7 e' ?

Nonnegative Variables

  Shipsm(Supplyl,Market)Direct ship to Demand;
) T& k3 r) J4 Y7 ~' {( \* ^

4 L: E& a( c7 S: M+ c$ f3 k! \. NSemicont Variables
# C8 y; ~4 w5 A) N4 B' h% |1 r. D  X,y,z;




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5