Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pyomo ValueError:PositiveReals不是有效的域_Python_Nonlinear Optimization_Pyomo_Valueerror_Mixed Integer Programming - Fatal编程技术网

Python Pyomo ValueError:PositiveReals不是有效的域

Python Pyomo ValueError:PositiveReals不是有效的域,python,nonlinear-optimization,pyomo,valueerror,mixed-integer-programming,Python,Nonlinear Optimization,Pyomo,Valueerror,Mixed Integer Programming,我试图用PyOMO解决一个约束混合整数非线性优化问题。具体地说,我试图找到齿轮直径和齿数,以便满足两个给定的传动比。关于如何使用Set()和Var()。我一直在阅读文档,但对于集合的实际含义还不是非常清楚!它是一个索引,我可以用来访问问题的类似分组部分吗?以下是我的代码:(Python 3.5) 此代码给出以下错误: WARNING: Element 4.5 already exists in set D_index; no action taken. File "/Library/Fram

我试图用PyOMO解决一个约束混合整数非线性优化问题。具体地说,我试图找到齿轮直径和齿数,以便满足两个给定的传动比。关于如何使用
Set()
Var()。我一直在阅读文档,但对于集合的实际含义还不是非常清楚!它是一个索引,我可以用来访问问题的类似分组部分吗?以下是我的代码:(Python 3.5)

此代码给出以下错误:

WARNING: Element 4.5 already exists in set D_index; no action taken.
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/PyomoModel.py", line 920, in _initialize_component
ERROR: Constructing component 'D' from data=None failed:
    declaration.construct(data)
    ValueError: PositiveReals is not a valid domain. Variable domains must be an instance of one of (<class 'pyomo.core.base.set_types.RealSet' at 0x1004bee98>, <class 'pyomo.core.base.set_types.IntegerSet' at 0x1004f2558>, <class 'pyomo.core.base.set_types.BooleanSet' at 0x1004f28f8>), or an object that declares a method for bounds (like a Pyomo Set). Examples: NonNegativeReals, Integers, Binary
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/var.py", line 573, in construct
    component=None)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/var.py", line 299, in __init__
    "Integers, Binary" % (domain, (RealSet, IntegerSet, BooleanSet)))
ValueError: PositiveReals is not a valid d
警告:集合D_索引中已存在元素4.5;没有采取行动。
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site packages/pyomo/core/base/pyomodel.py”,第920行,在“初始化”组件中
错误:从数据=无构造组件“D”失败:
声明.构造(数据)
ValueError:PositiveReals不是有效的域。变量域必须是(,)之一的实例,或声明边界方法的对象(如Pyomo集)。示例:非负整数、整数、二进制
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site packages/pyomo/core/base/var.py”,第573行,在构造中
组件=无)
文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site packages/pyomo/core/base/var.py”,第299行,在__
“整数,二进制”%(域,(实数集,整数集,布尔集)))
ValueError:PositiveReals不是有效的d

我还尝试使用
RangeSet()
并将关联的集合作为
Var()
的第一个参数传递,但这也没有任何作用!我知道我错过了一些非常明显的东西,但我已经盯着屏幕看了4个小时了,我正在寻求你的帮助!感谢将
内的
更改为
内=positiverelals
,等等

应为
中的
(或
)关键字分配从
pyomo.environ
导入的一组域对象。不应为它们分配字符串

WARNING: Element 4.5 already exists in set D_index; no action taken.
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/PyomoModel.py", line 920, in _initialize_component
ERROR: Constructing component 'D' from data=None failed:
    declaration.construct(data)
    ValueError: PositiveReals is not a valid domain. Variable domains must be an instance of one of (<class 'pyomo.core.base.set_types.RealSet' at 0x1004bee98>, <class 'pyomo.core.base.set_types.IntegerSet' at 0x1004f2558>, <class 'pyomo.core.base.set_types.BooleanSet' at 0x1004f28f8>), or an object that declares a method for bounds (like a Pyomo Set). Examples: NonNegativeReals, Integers, Binary
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/var.py", line 573, in construct
    component=None)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyomo/core/base/var.py", line 299, in __init__
    "Integers, Binary" % (domain, (RealSet, IntegerSet, BooleanSet)))
ValueError: PositiveReals is not a valid d