问题描述
我正在尝试使用GAMS为问题建模.我有2个问题:
I am trying to model a problem using GAMS. I have 2 questions:
1)如何初始化决策值P?它应该采用以下格式
1) How to initialize the decesion value P? it supose to be in the following form
P(I)/
i1 25
i2 33/
2)我正在尝试像
SINR(I)= e = hh(I)* P(I)/sqrsigma)+ sum(I,H(J,I)* P(I));
SINR(I) =e= hh(I)*P(I) / sqr(sigma)+sum(I,H(J,I)*P(I));
但是,我总是得到一个错误,即该设置已经是控制器或域问题.我该如何解决这个问题?
However, I got always an erro either the set is already controller or domain isssues. How can I solve this problem?
部分代码
我的用户数/i1,i2/
I number of users /i1,i2/
J个用户干扰/j1,j2/
J users to interfer with /j1,j2/
迭代次数/1/;
参数
CP(I) circuit power per user /
i1 10
i2 10 /
hh(I) channel quality / i1 48 i2 106 /
Sigma Noise /0.0057/
tol tolerence value /0.01/
minRate minimum rate /0.1/
maxiter max number of iterations /3/ ;
Table H(J,I) interference value
> i1 i2
>
> j1 0 18.8030
>
> j2 8.9555 0
;>
P(I)
F
lambda
SINR(I)
b(I)
a(I)
方程式Objectivefun,SINRFUN,lambdaFUN,RateFUN,afun,bfun, nonlconfun;
equations Objectivefun, SINRFUN, lambdaFUN, RateFUN, afun, bfun, nonlconfun;
SINRFUN(I).. SINR(I)= e = hh(I)* P(I)/ sqr(sigma)+ sum(I,H(J,I)* P(I));
SINRFUN(I).. SINR(I) =e= hh(I)*P(I) / sqr(sigma)+sum(I,H(J,I)*P(I));
先谢谢您.
推荐答案
语句
SINRFUN(I).. SINR(I) =e= hh(I)*P(I) / sqr(sigma)+sum(I,H(J,I)*P(I));
有一个问题,我们在i
上有一个隐式循环,然后在同一i
上的和内.这在数学上不是很好定义.因此,您可以执行以下操作:
has a problem we have an implicit loop over i
and then inside a sum over the same i
. This is mathematically not very well defined. So you could do something like:
alias(i,ii);
SINRFUN(I).. SINR(I) =e= hh(I)*P(I) / sqr(sigma)+sum(ii,H(J,ii)*P(ii));
您可以使用赋值语句初始化P(i)
:
You can initialize P(i)
with an assignment statement:
parameter initp(i) /i1 25, i2 33/;
p.L(i) = initp(i);
.L
表示我们为变量分配了级别值(其他可能性是诸如.lo
,.up
,.m
之类的内容:有关更多信息,请参见文档-阅读一些文档可能对任何情况).
The .L
means we assign to the level values of the variables (other possibilities are things like.lo
, .up
, .m
: see the documentation for more information -- reading some docs may be beneficial in any case).
这篇关于以set +公式的形式初始化GAMS中的决策变量会产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!