首页 > 解决方案 > GAMS中集合的变量定义问题

问题描述

我的问题是方程 1 中使用的变量“ds”的定义。方程 1 对每一行运行。并且每一行都有ns(ns是一个参数)步数。应为每行中的每个步骤定义变量“ds”。定义集合 l 和 nsl。参数 'linen' 显示网络中的行号。保持每行的步数相等,即 ns=250。定义变量 ds(l,nsl)。现在方程中这个变量的使用非常重要。我为行号 'linen' 编写了 ds(fdata(i,j,'linen'),nsl)) ,为步骤号编写了 nsl 。求和运行在 nsl 上。错误 121:eq1 中的 ds(fdata(i,j,'linen'),nsl)) 中的“设置预期”。

在这种情况下,任何人都可以帮助我定义变量“ds”吗?如果您需要更多信息,请告诉我。

Set
i 'Gas network buses' / 1*7 /
slack(i) 'Source bus' / 1, 3 /
t 'Time period' / t1*t1 /
mn 'Set to access fdata from excel sheet' /Cjj,Fgmin,Fgmax, linen/
l 'number of Gas lines' /1*6/
nsl 'steps' /1*250/ ;


Alias (i,j);

$call gdxxrw MultiEnergySystemData.xlsx par=fdata rng=ModifiedNGSystem!A21:F27 cDim=1 rDim=2

*=== Now import data from GDX
Parameter fdata(i,j, mn);
$gdxin MultiEnergySystemData.gdx
$load fdata
$gdxin
display data

Parameter ns /250/;


$ontext
fdata is like this
i j Cjj Fgmin Fgmax linen
1 2 50.6 0 3000 1
2 3 50.1 0 1000 2
3 4 45.3 0 10   3
2 5 45.3 0 2500 4
5 6 43.1 0 1200 5
6 7 37.5 0 600  6

$offtext

Parameter cx(i,j), cxv(i,j);
cx(i,j)$(fdata(i,j,'Cjj'))= 1;



Variables ds(l,nsl), fg(i,j);


Equation eq1;

eq1(i,j)$cx(i,j)..
fg(i,j) =e= fdata(i,j,'Fgmin') + sum(nsl,(1/ns)*(fdata(i,j,'Fgmax')-fdata(i,j,'Fgmin'))*ds(fdata(i,j,'linen'),nsl));

标签: gams-math

解决方案


推荐阅读