数学建模社区-数学中国

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

作者: huashi3483    时间: 2009-11-14 05:16
标题: 【转载】GAMS中文使用手册连载07
下面接受一下变量:
0 F. T8 _, W0 n1 A* G0 t) V7 u变量是组成模型的最基本的元素。最好是先声明变量,再进行初始化。2 M& w- }2 R' G# S  M4 v; t
任何不加以约束的变量可以写成variables 或者是 free variables。4 U5 n8 s9 H3 Y
另外还可以因需要定义:positive, nonnegative, negative, binary and integer 变量。
: [3 `: R5 ?& F. N这里需要提醒的是 binary variable,只能有0,1两个值。通常用来做决策的。
# ^  r& b0 k. Y' @5 Z  n: K6 ]9 v+ |还有integer variable的默认范围是从0到100。改动它的上下限已后会详细介绍。( ?  ~) P5 L  e% [5 C
其实,整数变量可以由01变量通过线性组合得到。这里就不介绍了。0 K5 X+ l' Z+ P) E
另外,gams还支持另外两个特殊变量:
- b. u  _( y* w* T7 U6 a  W$ H) DSOS1和SOS2变量。SOS1变量值在一组变量里面,只有一个变量可以是非零的。但不一定是1。
% I( U) E, b4 p2 GSOS2指一组变量里面,只有两个相邻的变量是非零的。
0 Z3 V+ o% s7 t- D& m$ F4 R这两个变量在比较高级的MILP模型中会遇到。
+ F/ p2 Z+ x& p  q: E$ e7 |变量声明方法示例:
" O4 V+ i4 ~, \: h  Z% e2 d6 iVariables- s; [$ Y7 M2 j5 P' n1 Q/ \7 K
  Tcost                        'Total Cost Of Shipping- All Routes';
: @- s0 i' U5 X# X& aBinary Variables
  Build(Warehouse)Warehouse Construction Variables;
( i- Q; ^2 m- S* N% z

Positive Variables

  Shipsw(Supplyl,Warehouse)Shipment to warehouse

/ `0 c& s& z/ g* R; o. \+ v! Y* J
  Shipwm(Warehouse,Market)Shipment from Warehouse
7 k2 N' X, B2 U6 h" p0 i

Nonnegative Variables

  Shipsm(Supplyl,Market)Direct ship to Demand;
7 b- k6 e- R: b% W
8 d, _) q9 U4 T8 R  h" `
Semicont Variables
+ q6 n* m: ?# m+ [/ x$ G5 o1 f; W  X,y,z;




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