Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Data Fields
Statistics Class Reference

Statistics. More...

Public Member Functions

def __init__
 
def __deepcopy__
 
def __del__
 
def __repr__
 
def __len__
 
def __getitem__
 
def keys
 
def get_key_value
 
def __getattr__
 

Data Fields

 stats
 
 ctx
 

Detailed Description

Statistics.

Statistics for `Solver.check()`.

Definition at line 6235 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  stats,
  ctx 
)

Definition at line 6238 of file z3py.py.

6239  def __init__(self, stats, ctx):
6240  self.stats = stats
6241  self.ctx = ctx
6242  Z3_stats_inc_ref(self.ctx.ref(), self.stats)
void Z3_API Z3_stats_inc_ref(Z3_context c, Z3_stats s)
Increment the reference counter of the given statistics object.
def __init__
Definition: z3py.py:6238
def __del__ (   self)

Definition at line 6246 of file z3py.py.

6247  def __del__(self):
6248  if self.ctx.ref() is not None:
6249  Z3_stats_dec_ref(self.ctx.ref(), self.stats)
void Z3_API Z3_stats_dec_ref(Z3_context c, Z3_stats s)
Decrement the reference counter of the given statistics object.

Member Function Documentation

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 6243 of file z3py.py.

6244  def __deepcopy__(self, memo={}):
6245  return Statistics(self.stats, self.ctx)
def __deepcopy__
Definition: z3py.py:6243
Statistics.
Definition: z3py.py:6235
def __getattr__ (   self,
  name 
)
Access the value of statistical using attributes.

Remark: to access a counter containing blank spaces (e.g., 'nlsat propagations'),
we should use '_' (e.g., 'nlsat_propagations').

>>> x = Int('x')
>>> s = Then('simplify', 'nlsat').solver()
>>> s.add(x > 0)
>>> s.check()
sat
>>> st = s.statistics()
>>> st.nlsat_propagations
2
>>> st.nlsat_stages
2

Definition at line 6338 of file z3py.py.

6339  def __getattr__(self, name):
6340  """Access the value of statistical using attributes.
6341 
6342  Remark: to access a counter containing blank spaces (e.g., 'nlsat propagations'),
6343  we should use '_' (e.g., 'nlsat_propagations').
6344 
6345  >>> x = Int('x')
6346  >>> s = Then('simplify', 'nlsat').solver()
6347  >>> s.add(x > 0)
6348  >>> s.check()
6349  sat
6350  >>> st = s.statistics()
6351  >>> st.nlsat_propagations
6352  2
6353  >>> st.nlsat_stages
6354  2
6355  """
6356  key = name.replace('_', ' ')
6357  try:
6358  return self.get_key_value(key)
6359  except Z3Exception:
6360  raise AttributeError
def __getattr__
Definition: z3py.py:6338
def get_key_value
Definition: z3py.py:6318
def __getitem__ (   self,
  idx 
)
Return the value of statistical counter at position `idx`. The result is a pair (key, value).

>>> x = Int('x')
>>> s = Then('simplify', 'nlsat').solver()
>>> s.add(x > 0)
>>> s.check()
sat
>>> st = s.statistics()
>>> len(st)
6
>>> st[0]
('nlsat propagations', 2)
>>> st[1]
('nlsat stages', 2)

Definition at line 6282 of file z3py.py.

6283  def __getitem__(self, idx):
6284  """Return the value of statistical counter at position `idx`. The result is a pair (key, value).
6285 
6286  >>> x = Int('x')
6287  >>> s = Then('simplify', 'nlsat').solver()
6288  >>> s.add(x > 0)
6289  >>> s.check()
6290  sat
6291  >>> st = s.statistics()
6292  >>> len(st)
6293  6
6294  >>> st[0]
6295  ('nlsat propagations', 2)
6296  >>> st[1]
6297  ('nlsat stages', 2)
6298  """
6299  if idx >= len(self):
6300  raise IndexError
6301  if Z3_stats_is_uint(self.ctx.ref(), self.stats, idx):
6302  val = int(Z3_stats_get_uint_value(self.ctx.ref(), self.stats, idx))
6303  else:
6304  val = Z3_stats_get_double_value(self.ctx.ref(), self.stats, idx)
6305  return (Z3_stats_get_key(self.ctx.ref(), self.stats, idx), val)
bool Z3_API Z3_stats_is_uint(Z3_context c, Z3_stats s, unsigned idx)
Return true if the given statistical data is a unsigned integer.
Z3_string Z3_API Z3_stats_get_key(Z3_context c, Z3_stats s, unsigned idx)
Return the key (a string) for a particular statistical data.
def __getitem__
Definition: z3py.py:6282
unsigned Z3_API Z3_stats_get_uint_value(Z3_context c, Z3_stats s, unsigned idx)
Return the unsigned value of the given statistical data.
double Z3_API Z3_stats_get_double_value(Z3_context c, Z3_stats s, unsigned idx)
Return the double value of the given statistical data.
def __len__ (   self)
Return the number of statistical counters.

>>> x = Int('x')
>>> s = Then('simplify', 'nlsat').solver()
>>> s.add(x > 0)
>>> s.check()
sat
>>> st = s.statistics()
>>> len(st)
6

Definition at line 6268 of file z3py.py.

6269  def __len__(self):
6270  """Return the number of statistical counters.
6271 
6272  >>> x = Int('x')
6273  >>> s = Then('simplify', 'nlsat').solver()
6274  >>> s.add(x > 0)
6275  >>> s.check()
6276  sat
6277  >>> st = s.statistics()
6278  >>> len(st)
6279  6
6280  """
6281  return int(Z3_stats_size(self.ctx.ref(), self.stats))
unsigned Z3_API Z3_stats_size(Z3_context c, Z3_stats s)
Return the number of statistical data in s.
def __repr__ (   self)

Definition at line 6250 of file z3py.py.

6251  def __repr__(self):
6252  if in_html_mode():
6253  out = io.StringIO()
6254  even = True
6255  out.write(u('<table border="1" cellpadding="2" cellspacing="0">'))
6256  for k, v in self:
6257  if even:
6258  out.write(u('<tr style="background-color:#CFCFCF">'))
6259  even = False
6260  else:
6261  out.write(u('<tr>'))
6262  even = True
6263  out.write(u('<td>%s</td><td>%s</td></tr>' % (k, v)))
6264  out.write(u('</table>'))
6265  return out.getvalue()
6266  else:
6267  return Z3_stats_to_string(self.ctx.ref(), self.stats)
def __repr__
Definition: z3py.py:6250
Z3_string Z3_API Z3_stats_to_string(Z3_context c, Z3_stats s)
Convert a statistics into a string.
def get_key_value (   self,
  key 
)
Return the value of a particular statistical counter.

>>> x = Int('x')
>>> s = Then('simplify', 'nlsat').solver()
>>> s.add(x > 0)
>>> s.check()
sat
>>> st = s.statistics()
>>> st.get_key_value('nlsat propagations')
2

Definition at line 6318 of file z3py.py.

Referenced by Statistics.__getattr__().

6319  def get_key_value(self, key):
6320  """Return the value of a particular statistical counter.
6321 
6322  >>> x = Int('x')
6323  >>> s = Then('simplify', 'nlsat').solver()
6324  >>> s.add(x > 0)
6325  >>> s.check()
6326  sat
6327  >>> st = s.statistics()
6328  >>> st.get_key_value('nlsat propagations')
6329  2
6330  """
6331  for idx in range(len(self)):
6332  if key == Z3_stats_get_key(self.ctx.ref(), self.stats, idx):
6333  if Z3_stats_is_uint(self.ctx.ref(), self.stats, idx):
6334  return int(Z3_stats_get_uint_value(self.ctx.ref(), self.stats, idx))
6335  else:
6336  return Z3_stats_get_double_value(self.ctx.ref(), self.stats, idx)
6337  raise Z3Exception("unknown key")
bool Z3_API Z3_stats_is_uint(Z3_context c, Z3_stats s, unsigned idx)
Return true if the given statistical data is a unsigned integer.
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_string Z3_API Z3_stats_get_key(Z3_context c, Z3_stats s, unsigned idx)
Return the key (a string) for a particular statistical data.
unsigned Z3_API Z3_stats_get_uint_value(Z3_context c, Z3_stats s, unsigned idx)
Return the unsigned value of the given statistical data.
def get_key_value
Definition: z3py.py:6318
double Z3_API Z3_stats_get_double_value(Z3_context c, Z3_stats s, unsigned idx)
Return the double value of the given statistical data.
def keys (   self)
Return the list of statistical counters.

>>> x = Int('x')
>>> s = Then('simplify', 'nlsat').solver()
>>> s.add(x > 0)
>>> s.check()
sat
>>> st = s.statistics()

Definition at line 6306 of file z3py.py.

6307  def keys(self):
6308  """Return the list of statistical counters.
6309 
6310  >>> x = Int('x')
6311  >>> s = Then('simplify', 'nlsat').solver()
6312  >>> s.add(x > 0)
6313  >>> s.check()
6314  sat
6315  >>> st = s.statistics()
6316  """
6317  return [Z3_stats_get_key(self.ctx.ref(), self.stats, idx) for idx in range(len(self))]
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_string Z3_API Z3_stats_get_key(Z3_context c, Z3_stats s, unsigned idx)
Return the key (a string) for a particular statistical data.

Field Documentation

ctx

Definition at line 6240 of file z3py.py.

Referenced by Solver.__copy__(), Statistics.__deepcopy__(), Solver.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), ApplyResult.as_expr(), Solver.assert_and_track(), Optimize.assert_and_track(), Solver.assert_exprs(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), Solver.assertions(), Optimize.assertions(), Solver.consequences(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_ground_sat_answer(), Fixedpoint.get_rule_names_along_trace(), Fixedpoint.get_rules(), Fixedpoint.get_rules_along_trace(), Solver.model(), Optimize.model(), Solver.non_units(), Optimize.objectives(), Solver.param_descrs(), Fixedpoint.param_descrs(), Optimize.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Solver.proof(), Fixedpoint.query(), Solver.set(), Fixedpoint.set(), Optimize.set(), Tactic.solver(), Solver.statistics(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Solver.trail(), Solver.units(), Solver.unsat_core(), Optimize.unsat_core(), and Fixedpoint.update_rule().

stats

Definition at line 6239 of file z3py.py.

Referenced by Statistics.__deepcopy__(), Statistics.__del__(), Statistics.__getitem__(), Statistics.__len__(), Statistics.__repr__(), Statistics.get_key_value(), and Statistics.keys().