楼主: s20163111470
1481 2

[统计软件与数据分析] GAMS 空间均衡 [推广有奖]

  • 0关注
  • 0粉丝

本科生

26%

还不是VIP/贵宾

-

威望
0
论坛币
1004 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
65 点
帖子
7
精华
0
在线时间
163 小时
注册时间
2017-3-16
最后登录
2018-12-25

楼主
s20163111470 学生认证  发表于 2018-6-7 16:47:35 |AI写论文
200论坛币
求GAMS大神帮我看一下如下文献中看到的代码为啥在软件里跑不出来、持续报错。
$ontext

Simple Spatial Equilibrium Example
Primal or quantity formulation.
Erwin Kalvelagen, nov 2001
Data from:
Takayama and Judge,
Spatial and temporal price and allocation models
North Holland, 1971

$offtext
set i ’regions’ /region1,region2,region3/;
alias (i,j);
positive variables
d(j) ’demand’
s(i) ’supply’
pd(j) ’price (demand)’
ps(i) ’price (supply)’
x(i,j) ’shipments’
;
free variable
welfare ’quasi welfare’
;
equations
excess_demand(j)   ’no excess demand allowed’
excess_supply(i)     ’excess supply is possible’
objective                ’net quasi welfare function’
price_demand(j)    ’demand curve (inverse)’
price_supply(i)       ’supply curve (inverse)’
;
table data(i,*,*) ’data for inverse demand and supply equations’
                                                 intercept                  slope
region1.demand                              20                      -0.1
region1.supply                                   5                       0.1
region2.demand                              20                      -0.2
region2.supply                                2.5                     0.05
region3.demand                              20                  -0.125
region3.supply                                  5                        0.1
;
table c(i,j) ’transportation costs’
                                  region1 region2 region3
region1                                        2          2
region2                           2                       1
region3                           2           1
;
parameters zeta(j),eta(j),theta(i),lambda(i);
zeta(j) = data(j,’demand’,’intercept’);
eta(j) = data(j,’demand’,’slope’);
theta(i) = data(i,’supply’,’intercept’);
lambda(i) = data(i,’supply’,’slope’);
price_demand(j).. pd(j) =e= zeta(j)+eta(j)*d(j);
price_supply(i).. ps(i) =e= theta(i)+lambda(i)*s(i);
objective.. welfare =e=
      sum(j,zeta(j)*d(j)+0.5*eta(j)*sqr(d(j)))
      -sum(i,theta(i)*s(i)+0.5*lambda(i)*sqr(s(i)))
      -sum((i,j), c(i,j)*x(i,j));
excess_demand(j).. sum(i, x(i,j)) =g= d(j);
excess_supply(i).. sum(j, x(i,j)) =l= s(i);

model m /objective,excess_demand,excess_supply,price_demand,price_supply/;
solve m using nlp maximizing welfare;



感谢

关键词:gams AMS GAM Formulation Transportat

沙发
vistro 在职认证  发表于 2018-6-27 19:26:50
上述代码我运行了下 存在两个问题
1 索引使用双引号
1.png
2 Table的数据要对齐
2.png
3 Solver 选择CONOPT3
3.png
https://bbs.pinggu.org/?from^^uid=1356739

藤椅
vistro 在职认证  发表于 2018-6-27 19:31:09
不太会编辑帖子,这是可以运行的gms文件 Spatial equilibrium.zip (705 Bytes) 本附件包括:
  • Spatial equilibrium.gms

https://bbs.pinggu.org/?from^^uid=1356739

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

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2026-1-1 03:58