سينا پورخطايي منصف

‫سينا پورخطايي منصف‬
MATLAB
JAVA
C
MATLAB
GAMS
MINLP
GAMS
MIP
NLP
LP
MATLAB GAMS
GAMS
GDX
GAMS
EXCEL
GDXXRW
GAMS
GDX
[email protected]
http://rasti.iut.ac.ir
MATLAB
GDX
1
2
8 /2
GDX ‫ ايجاد فايل‬-‫گام اول‬
gdxxrw Excel_FileName/Excel_filePath.xlsx Input_Information
Excel_FileName
GAMS
GAMS
GAMS
C:\Users\UserName\Documents\GAMSdir\projdir
User
UserName
‘.xlsx’
Office
‘.xls’
Input_Information
$call
GAMS
GDXXRW
d
B1:D1
GDX
1 ‫شکل‬
$ call gdxxrw test1.xlsx
par=d
rng=A1:D3
rdim=1 cdim=1
A2:A3
8 /3
Input_Information
‘rng’
‘dset’
‘par’
‘cdim’
‘rdim’
d
2 ‫شکل‬
$ call
gdxxrw test1.xlsx
par=d
rng=A1:C6
rdim=2
:‫نکته‬
sheet
gdxxrw
rng=A1
sheet
‫ به منظور خوانايي بيشتر‬text ‫استفاده از فايل‬-
8 /4
gdxxrw test2.xlsx dset=i rng=sheet1!A1 rdim=1 par=data rng=sheet2!A1 rdim=1
text
$onecho > text_FileName.txt
Inpute_Information
$offecho
$call
gdxxrw
excel_FileName/excel_filePath.xlsx
text
text_fileName
@text_FileName.txt
$offecho $onecho
Input_Information
$onecho > text1.txt
dset=i
rng=sheet1!A1
rdim=1
par=data
rng=sheet2!A1
rdim=1
$offecho
$call gdxxrw test2.xlsx
@text1.txt
GAMS ‫ توسط‬GDX ‫ فراخواني فايل‬:‫گام دوم‬
GDX
$call GDXIN
$GDXIN
excel_FileName/excel_FilePath.gdx
GDX
C:\Users\UserName\Documents\GAMSdir\projdir
8 /5
GDX
GDX
C:\Users\UserName\Documents\GAMSdir\projdir
$call GDXIN C:\Users\UserName\Documents\GAMSdir\projdir \excel_FileName.gdx
‫ بارگذاري مجموعهها يا پارامترها‬-‫گام سوم‬
$LOAD
$LOAD SetName/ParameterName
GDX
$GDXIN
GDX ‫ ايجاد فايل‬-‫گام اول‬
GDX
Execute_unload “ GDX_FileName/GDX_FilePath.gdx ”
GDX
GDX
GDX
C:\Users\UserName\Documents\GAMSdir\projdir
‫ و نوشتن اطالعات در اکسل‬GDX ‫ فراخواني فايل‬-‫گام دوم‬
GDX
Execute ' gdxxrw.exe GDX_FilePath.gdx o=excel_FilePath.xlsx
OutPut_information '
8 /6
GDX
-
GDX
excel_FilePath
GDX_FilePath
GAMSdir GAMS
OutPut_Information
GAMS
‘var’
MATLAB GAMS
GAMS
“ D:\ data\ excel_data.xlsx ”
$onecho >data_text.txt
dset=i rng=i!A1 rdim=1
dset=j rng=j!A1 cdim=1
par=S rng=Supply!A1
rdim=1
par=D rng=Demand!A1
cdim=1
par=C rng=Cost!A1 rdim=1 cdim=1
$offecho
$CALL GDXXRW.EXE D:\data\excel_data.xlsx @data_text.txt
$GDXIN C:\Users\UserName\Documents\GAMSdir\projdir\excel_data.gdx
Sets
i
canning plants
j
markets ;
$LOAD i,j
Parameters
S(i) capacity of plant i in cases
D(j) demand at market j in cases
C(i,j) distance in thousands of miles
$LOAD S,D,C
$GDXIN
;
Scalar f freight in dollars per case per thousand miles /90/ ;
Parameter CC(i,j) transport cost in thousands of dollars per case ;
CC(i,j) = f * C(i,j) / 1000 ;
Variables
x(i,j) shipment quantities in cases
z
total transportation costs in thousands of dollars ;
Positive Variable x ;
8 /7
Equations
cost
supply(i)
demand(j)
define objective function
observe supply limit at plant i
satisfy demand at market j ;
cost ..
z =e= sum((i,j), CC(i,j)*x(i,j)) ;
supply(i) ..
sum(j, x(i,j)) =l= S(i) ;
demand(j) ..
sum(i, x(i,j)) =g= D(j) ;
Model transport /all/ ;
Solve transport using lp minimizing z ;
execute_unload "D:\data\outGDX.gdx"
execute 'gdxxrw.exe D:\data\outGDX.gdx o= D:\data\OutPut.xlsx
rng=z!A1 var=x.l rng=x!A1'
GAMS
xlswrite()
var=z.l
execute
xlsread()
xlsread()
xlsread ( ' filename ', ' sheet ', ' range ',…)
:FileName
-
:sheet
8 /8
sheet
:range
xlsread('D:\data\excel1.xlsx','sheet1','A1:C6')
xlswrite()
xlswrite ( ' filename ', A , ' sheet ', ' range ',…)
xlsread()
A
xlsread('D:\data\OutPut.xlsx',data,'sheet1','A1:C6')
xlswrite()