Z3Py 代码中出现错误



以下脚本 http://rise4fun.com/Z3Py/Cbl 有什么问题?添加最后两行会给我以下错误'instancemethod' object is not #subscriptable

x,t,t1,t2,x_next=Reals ('x t t1 t2 x_next')
location,location_next=Bools('location location_next')
x=0
location=BoolVal(False)
k=20
for i in range(k):
 s=Solver()
 s.add(Or(And(x_next-x>=2*t,x_next-x<=3*t,x_next<=12,t>0,Not(location)),
         And(x_next-x>=-2*t,x_next-x<=-t,x_next>=0,t>0,location)),location_next==If(And(Not(location),x_next>=12),True,If(And(location,x_next<=0),False,location)))
print s.check()
print s.model()
m=s.model
#x=m[x_next]
#location=m[location_next]
m=s.model

m分配一个函数。 我相信你的意思是分配调用s.model的结果,所以包括括号进行调用:

m=s.model()

相关内容

最新更新