GAMS Solution for Ex5.
来源:互联网 发布:mac u盘安装 mac os x 编辑:程序博客网 时间:2024/05/06 01:08
* Here is try to create gdx file
* Please notice that, rdim and cdim only tell gdx how the data store in excel,
* not for the form in theory.
$onecho > in.txt
dset=i rng=a3 rdim=1
dset=j rng=b2 cdim=1
par=d rng=A2 rdim=1 cdim=1
par=p rng=A8 rdim=1
par=a rng=A13 rdim=1
par=c rng=A19 rdim=1
$offecho
$call gdxxrw.exe transportdata.xlsx @in.txt
* Here is to display xlsx
*
* From the Excel file transportdata.xlsx read the information for the sets of
* markets and plants as well as the distance table (given in thousands of
* kilometers) and save it in a .gdx file. Read the data from the .gdx file into
* GAMS and display it.
$gdxin transportdata.gdx
set i(*) plants ;
set j(*) markets ;
$load i j
display i,j ;
* In a new GAMS program, read the above values again using the created
* text file. Then multiply each of the distances by 1000 to convert them into
* thousands of meters. Save the new data in the transportdata.gdx file and
* write it in the Excel file transportdata.xlsx, Sheet2, starting from A1. Repeat
* the exercise by saving the data in a .gdx file called transportdata4 and
* writing the updated distance table in a new Excel file called transportdata4,
* but starting from cell F2.
parameter d(i,j) distance table ;
$load d
* close gdx
$gdxin
scalar pp multiplier to 1000 /1000/ ;
parameter xxx(i,j) distance after multiply by 1000 ;
xxx(i,j) = d(i,j) * pp ;
display xxx;
* execute_unload 'transportdata4.gdx',xxx ;
* execute 'gdxxrw.exe transportdata4.gdx par=x rng=tabelle2!A1' ;
* Implement and solve the transportation problem in GAMS by importing
* all the necessary information from the file transportdata.xlsx and writing
* the result in the file transportdata.xlsx, Sheet2, starting from A8.
* load gdx
$gdxin transportdata.gdx
parameter p(i) plants quantity ;
parameter a(j) market quantity ;
$load p a
display p,a ;
scalar c transport cost ;
$load c
display c;
* close gdx
$gdxin
parameter xc(i,j) cost table ;
xc(i,j) = d(i,j) * c / 1000;
variables
x(i,j) quantities table
z total cost;
positive variable x ;
equations
cost cost function
supply(i) supply st.
demand(j) demand st. ;
cost.. z =e= sum((i,j), xc(i,j) * x(i,j)) ;
supply(i).. sum(j,x(i,j)) =l= p(i) ;
demand(j).. sum(i,x(i,j)) =g= a(j) ;
model transport /all/ ;
solve transport using lp minimizing z ;
display z.l;
execute_unload 'transportdata.gdx',z ;
execute 'gdxxrw.exe transportdata.gdx var=z rng=tabelle1!B21' ;
- GAMS Solution for Ex5.
- ex5
- Solution Accelerator for Intranets
- Index for WC Solution
- Datameer for Hadoop Solution
- Solution for eclipse NoClassDefFoundError
- Codeforces887C-Solution for Cube
- GAMS Example
- ex5.py
- perfect solution for playing heroes3
- ExtMail Solution HOWTO for Linux
- Record for windows thread solution
- linux command solution for problems
- Capture Text solution for Qt
- codeforces C. Solution for Cube
- C#程序调用GAMS
- GAMS的使用
- notepad++ 编辑GAMS文件
- 一切都不晚!
- Google的翻译还真是体贴
- 地球物理学习
- http还原
- Oracle 客户端连接服务器端常见问题排除方法
- GAMS Solution for Ex5.
- ubuntu 下的webqq精彩使用
- 微软在嵌入式领域又大展拳脚
- 乱码问题解决。
- gzip算法实现
- decode和encode
- 删除E:/music/*.mp3, 使用的是先copy到E:/,然后在逐个覆盖,重命名等的方式。
- gzip算法源代码
- mondrian 中MDX函数解析 执行入口