如何为变量添加条件-GAMS [英] How to add a condition to a variable - GAMS

查看:302
本文介绍了如何为变量添加条件-GAMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我要构建的模型中,我有一个变量定义为:

Variables
    x(i,j)  number of motors produced in month i to be delivered in month j ;

在该变量中,j必须始终等于或大于i才有意义(您不能在本月产生任何东西要在上个月交付). 但是,我不知道如何正确地对此建模.我已经搜索过,但是找不到一个简单的解决方案.

有什么想法吗?

解决方案

为此,您应该使用域受限的变量",有关更多详细信息,请参见此处,它是GAMS的一项相当新的功能: 解决方案

You should use "variables with limited domains" for this, look here for more details, it is a rather new GAMS feature: https://www.gams.com/latest/docs/UG_ModelSolve.html#UG_ModelSolve_LimitedDomain

So, in your example, it would look like this:

Set limX(i,j) limiting domain of x;

limX(i,j) = ord(j) >= ord(i);

Model m /all, x(limX)/;
...

Edit: Corrected syntax of model statement.

这篇关于如何为变量添加条件-GAMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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