Python pyomo GDP名称错误:名称';逻辑约束&x27;没有定义

Python pyomo GDP名称错误:名称';逻辑约束&x27;没有定义,python,nameerror,pyomo,Python,Nameerror,Pyomo,当我在官方文档中实现以下示例时 from pyomo.gdp import * from pyomo.environ import * m = ConcreteModel() m.s = RangeSet(4) m.ds = RangeSet(2) m.d = Disjunct(m.s) m.djn = Disjunction(m.ds) m.djn[1] = [m.d[1], m.d[2]] m.djn[2] = [m.d[3], m.d[4]] m.x = Var(bounds=(-2,

当我在官方文档中实现以下示例时

from pyomo.gdp import *
from pyomo.environ import *

m = ConcreteModel()
m.s = RangeSet(4)
m.ds = RangeSet(2)
m.d = Disjunct(m.s)
m.djn = Disjunction(m.ds)
m.djn[1] = [m.d[1], m.d[2]]
m.djn[2] = [m.d[3], m.d[4]]
m.x = Var(bounds=(-2, 10))
m.d[1].c = Constraint(expr=m.x >= 2)
m.d[2].c = Constraint(expr=m.x >= 3)
m.d[3].c = Constraint(expr=m.x <= 8)
m.d[4].c = Constraint(expr=m.x == 2.5)
m.o = Objective(expr=m.x)

# Create Boolean variables associated with the disjuncts.
m.Y = BooleanVar(m.s)
for idx in m.Y:
    m.Y[idx].associate_binary_var(m.d[idx].indicator_var)

# Add the logical proposition
m.p = LogicalConstraint(expr=m.Y[1].implies(m.Y[4]))

TransformationFactory('core.logical_to_linear').apply_to(m)
TransformationFactory('gdp.bigm').apply_to(m)
是不是我没有导入相关模块

NameError: name 'BooleanVar' is not defined

NameError: name 'LogicalConstraint' is not defined