如何为集合中的每个元素设置上下限? [英] How to set upper and lower bounds for each element in a set?

查看:163
本文介绍了如何为集合中的每个元素设置上下限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建GAMS模型来解决一个简单的最大化问题.我有一个包含3个元素(1,2,3)的集合J和一个包含所有元素的变量x(J).

I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements.

我想知道GAMS中是否有一种方法可以为集合中的每个元素设置下限0和3的上限,而不必分别设置每个元素的边界并且不对下限使用正变量

I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound.

我尝试使用x.lo = e = 0和x.up = e = 3,但是这些都不起作用.我猜我没有使用正确的语法,但是在我的生命中似乎无法在官方文档中找到任何专门针对集合的内容.

I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not using the correct syntax but for the life of me cannot seem to find anything on the official documentation about it specifically for sets.

这样做的正确方法是什么?

What is the correct way of doing this?

推荐答案

尝试

x.lo(J)=0;
x.up(J)=3;

另请参见此处: https://www.gams.com/26/docs/UG_Variables.html#UG_Variables_AssigningValuesToVariableAttributes

这篇关于如何为集合中的每个元素设置上下限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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