在GAMS中,变量和参数有什么区别? [英] In GAMS, what is the difference between variables and parameters?

查看:429
本文介绍了在GAMS中,变量和参数有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GAMS中,变量和参数有什么区别?

In GAMS, what is the difference between variables and parameters?

在哪种情况下,其中一种比另一种更好?

In which cases is one of them better to use than the other one?

推荐答案

简短说明

参数用于将数据引入模型. 该数据可用于方程式,并且不会受到优化的影响.在数学上,您可能会想到一个常数. (决定)变量在优化过程中是变量".优化完成后,报告最佳状态中变量的值.

Short explanation

Parameters are used for introducing data into the model. This data can be used in equations and will not be affected by the optimisation. Mathematically, you may think of a constant. (Decision) Variables are 'variable' during the optimisation. The value of a variable in the optimum is reported after the optimisation has finished.

模型是否应该确定数据值(例如产量,分配等):
是->变量
否->参数

Should the model decide on the value of the data (e.g. production quantity, allocation etc.):
Yes -> Variable
No -> Parameter

从GAMS网站获取运输问题示例,目标是尽量减少将货物从2家工厂运送到3个市场的成本.

Take the Tansport Problem Example from the GAMS website, where the objective is to minimize the cost of shipping goods from 2 plants to 3 markets.

由于知道了两个工厂之间的距离(我们无法更改或要决定什么,所以),此数据作为参数(在本例中为表格)输入到模型中

As the distance between the two plants is known (and nothing we could change or want to decide on), this data is entered into the model as a Parameter (in this case a table)

Table  d(i,j)  distance in thousands of miles
                  New-York       Chicago      Topeka
    Seattle          2.5           1.7          1.8
    San-Diego        2.5           1.8          1.4  ;

此外,在这种类型的模型中,货运成本是已知的.由于此数据(每千英里每箱的美元)是一维的,因此可以将其作为标量(也是参数)输入

Also, in this type of model, the freight costs are known. As this data (dollars per shipping case per thousand miles) is one dimensional, it can be entered as a scalar (which is also a Parameter)

Scalar f  freight in dollars per case per thousand miles  /90/ ; 

有了这些信息,您可以通过将运费乘以不同工厂之间的距离来计算运费.

With this information, you can calculate the shipping costs by multiplying the freight cost with the distance between the different plants.

Parameter
c(i,j)  transport cost in thousands of dollars per case ;
c(i,j) = f * d(i,j) / 1000 ;

如您所见,我们通过指定货运成本和罐头厂之间的距离的函数,为参数c(i,j)分配了一个值. 与模型类型(LP,MIP,NLP等)无关,只要不涉及决策变量,我们就可以在计算参数值时使用非线性函数.

As you can see, we assigned a value to the parameter c(i,j) by specifying a function of freight costs and distance between the canning plants. Independant on the model type (LP, MIP, NLP etc.), we can use non-linear functions when calculating parameter values as long as there are no decision variables involved.

现在模型可以决定的唯一事情是不同工厂(i)和市场(j)之间的运输量,在我们的模型中标记为x(i,j)

Now the only thing the model may decide on is the shipping quantity between the different plants (i) and markets (j), in our model labeled as x(i,j)

cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ;

我希望这个小例子能指出一个参数和一个决策变量(至少在GAMS中是这样).

I hope this little example points out what a parameter and a decision variable (at least in the context of GAMS) is.

知道参数值是在编译时计算的,而变量是在求解(或执行时间)期间计算的,这也可能很有趣.

It may also be interesting to know that Parameter values are computed at compile time, while variables will be computed during solve (or execution time).

这篇关于在GAMS中,变量和参数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆