次のコードは、8回の反復後に終了します(14回反復する必要があります)。なぜですか?
コードは線形ハイブリッドオートマトンをエンコードします。指定された反復回数で実行する必要がありますが、実行しません。
from z3 import *
x,t,t1,t2,x_next=Reals ('x t t1 t2 x_next')
location=[None]
location='off'
x=20
t1=0
s=Solver()
#set_option(precision=10)
k=14
for i in range(k):
print location
if location=='off':
s.add((10*x_next)>=(3*t1)-(3*t2)+(10*x),(10*x_next)<=(10*x)-(t2-t1),x_next>=18,(t2-t1)>0)
elif location=='on':
s.add(10*x_next>=(t2-t1)+(10*x),(5*x_next)<=(5*x)+(t2-t1),x_next<=22,(t2-t1)>0)
if [location=='off' and x_next<19] :
location='on'
elif [location=='on' and x_next>21]:
location='off'
if s.check()==unsat:
break
m=s.model()
#print s.check()
print i
print location
print s.model()
print "value of x_next"
print m[x_next].as_decimal(10)
x=m[x_next]
t1=m[t2]