Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:22:21+00:00 2026-06-09T09:22:21+00:00

The following code terminates after 8 iterations (while it should iterate 14 times) why?

  • 0

The following code terminates after 8 iterations (while it should iterate 14 times) why?

The code encodes a linear hybrid automata, it should run for the designated number of iterations but doesn’t.

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]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:22:22+00:00Added an answer on June 9, 2026 at 9:22 am

    The program stops because the set of assertions is unsatisfiable after iteration 8, and in your loop you have the statements:

    if s.check()==unsat:
        break
    

    In the first iteration you add the assertion:

    10*x_next <= 200 - t2 - 0
    

    In the last iteration, you add:

    10*x_next >= t2 - Q(40,3) + 10*Q(56,3),
    t2 - Q(40,3) > 0
    

    where, the command Q(a, b) is used to create the rational number a/b.
    That is, t1 is 40/3 and x is 56/3 at iteration 8.
    The three assertions above are unsatisfiable. The first two imply that t2 <= 40/3, and the last t2 > 40/3.

    BTW, the following statement seems to be incorrect. That is, I do not believe it reflects your intention. Note that, this is orthogonal problem.

    if  [location=='off' and x_next<19] :
    

    The expression x_next<19 does not evaluate to True or False. It creates the Z3 (symbolic) expression x_next < 19. I believe, you want to evaluate whether this expression is true in a model m. If that is the case, you should write:

    if  location=='off' and is_true(m.evaluate(x_next<19)) :
    

    The command m.evaluate(t) evaluates the expression t in the model m. The result is a Z3 expression. The function is_true(t) returns True if t is the Z3 expression true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After submitting our application several times, we continue to receive the following response: Thank
The following code throws an exception terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call>
I am using the following code, but even after I call it, my app
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();
Following code: <%= render 'shared/error_messages', f.object %> where f.object is instance of a class
Following code gets executed whenever I want to persist any entity. Things seems to
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is
Following code is generated by a for loop. <form action=saveresponse.php method=POST name=mainForm> <input class=cbox_yes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.