楼主: dingcake
4232 2

[数据求助] GAMS程序输入为什么得出的结论与书上不一样 [推广有奖]

  • 0关注
  • 0粉丝

小学生

78%

还不是VIP/贵宾

-

威望
0
论坛币
3 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
42 点
帖子
5
精华
0
在线时间
13 小时
注册时间
2013-5-29
最后登录
2016-10-9

楼主
dingcake 发表于 2014-7-23 14:42:41 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
各位前辈好,我最近在研习GAMS软件。从GAMS官网上下载了GAMS windows64 24.2版本,然后根据几乎所有的GAMS教材入门使用的那个运输案例编码:
Sets
     i    canning plants / seattle, san-diego /
     j    markets        / new-york, chicago, topeka / ;
Parameters
     a(i) capacity of plant i in cases
       / seattle   350
         san-diego 600 /
     b(j) demand at market j in cases
       / new-york  325
         chicago   300
         topeka    275 / ;
Table d(i, j) distance in thousands of miles
                new-york    chicago   topeka
     seattle      2.5         1.7      1.8
     san-diego    2.5         1.8      1.4 ;
Scalar f freight in dollars per case per thousand miles /90/ ;
Parameter c(i, j) transport cost in thousands of dollars per case ;
               c(i, j) = f * d(i, j) / 1000 ;
Variables
      x(i, j) shipment quantities in cases
      z total transportation costs in thousands of dollars ;
Positive Variable x ;
Equations
      cost      define objective function
      supply(i) observe supply limit at plant i
      demand(j) satisfy demand at market j ;
cost..        z = e = sum((i, j), c(i, j)*x(i, j)) ;
supply(i)..   sum(j, x(i, j)) = l = a(i) ;
demand(j)..   sum(i, x(i, j)) = g = b(j) ;
Model transport /all/ ;
Solve transport using lp minimizing z ;
Display x. l, x. m ;

输入,但是得出的结果与书上不一样,显示“erro"具体内容为:
25        supply(i) observe supply limit at plant i
  26        demand(j) satisfy demand at market j ;
  27   cost..        z = e = sum((i, j), c(i, j)*x(i, j)) ;
****                     $140,37,409
  28   supply(i)..   sum(j, x(i, j)) = l = a(i) ;
****                                   $140,37,409
  29   demand(j)..   sum(i, x(i, j)) = g = b(j) ;
****                                   $140,37,409
  30   Model transport /all/ ;
  31   Solve transport using lp minimizing z ;
****                                         $257
  32   Display x. l, x. m ;
****            $342,329,141,409,342
GAMS 24.2.3  r46072 Released May 22, 2014 WEX-WEI x86_64/MS Windows 07/23/14 14:30:02 Page 2
G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Error Messages

37  '=l=' or '=e=' or '=g=' operator expected
140  Unknown symbol
141  Symbol neither initialized nor assigned
        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
257  Solve statement not checked because of previous errors
329  Wrong suffix on variable reference - allowable are
        l     level (activity)
        m     marginal (reduced cost)
        lo    lower bound
        up    upper bound
        scale variable scale
        prior priority for MIP
        slacklo,slackup,slack, slack values
        infeas infeasibility
342  Illegal suffix syntax - has to start with a letter
409  Unrecognizable item - skip to find a new statement
       looking for a ';' or a key word to get started again
**** 15 ERROR(S)   0 WARNING(S)

COMPILATION TIME     =        0.125 SECONDS      3 MB  24.2.3 r46072 WEX-WEI

USER: GAMS Development Corporation, Washington, DC   G871201/0000CA-ANY
      Free Demo,  202-342-0180,  sales@gams.com,  www.gams.com   DC0000

**** FILE SUMMARY
Input      C:\Users\1\Documents\gamsdir\projdir\Untitled_2.gms
Output     C:\Users\1\Documents\gamsdir\projdir\Untitled_2.lst
**** USER ERROR(S) ENCOUNTERED
我想请大家帮帮忙,帮我看看究竟是哪里出了问题?谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:GAMS程序 gams GAM AMS explanatory 程序

沙发
xmmxmm 在职认证  发表于 2014-8-1 04:10:59
=e=, =l=, =g=, 在方程中不能有空格
x.l, x.m 也不能有空格

藤椅
dingcake 发表于 2014-8-12 09:15:05
xmmxmm 发表于 2014-8-1 04:10
=e=, =l=, =g=, 在方程中不能有空格
x.l, x.m 也不能有空格
谢谢啊,我后来又重试了好几次,但是所有GAMS教材的第一案例(都是同一个),还是不行。但是第二个案例就可以了。看来还是要多加练习。谢谢您的热心回复!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2025-12-21 06:24