本文整理汇总了Python中z3.Bool方法的典型用法代码示例。如果您正苦于以下问题:Python z3.Bool方法的具体用法?Python z3.Bool怎么用?Python z3.Bool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类z3
的用法示例。
在下文中一共展示了z3.Bool方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def __init__(
self,
ast: mlil_ast.MediumLevelILAst,
condition: Bool,
condition_il: MediumLevelILInstruction,
true: MediumLevelILAstNode,
false: MediumLevelILAstNode = None,
):
if condition is None:
raise NotImplementedError("condition should not be None")
self._condition = condition
super().__init__(ast)
self._type = "cond"
self._condition_il = condition_il
self._true = true
self._false = false
self._flatten_conditions()
示例2: _gen_variable
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def _gen_variable(self, qb_id):
""" After each gate generate a new unique variable name for each of the
qubits, using scheme: 'q[id]_[gatenum]', e.g. q1_0 -> q1_1 -> q1_2,
q2_0 -> q2_1
Args:
qb_id (int): index of qubit to generate new variable for
Returns:
BoolRef: z3 variable of qubit state
"""
varname = "q" + str(qb_id) + "_" + str(self.gatenum[qb_id])
var = Bool(varname)
self.gatenum[qb_id] += 1
self.variables[qb_id].append(var)
return var
示例3: create_z3_vars
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def create_z3_vars(self):
"""
Setup the variables required for Z3 optimization
"""
for gate in self.dag.gate_nodes():
t_var_name = 't_' + str(self.gate_id[gate])
d_var_name = 'd_' + str(self.gate_id[gate])
f_var_name = 'f_' + str(self.gate_id[gate])
self.gate_start_time[gate] = Real(t_var_name)
self.gate_duration[gate] = Real(d_var_name)
self.gate_fidelity[gate] = Real(f_var_name)
for gate in self.xtalk_overlap_set:
self.overlap_indicator[gate] = {}
self.overlap_amounts[gate] = {}
for g_1 in self.xtalk_overlap_set:
for g_2 in self.xtalk_overlap_set[g_1]:
if len(g_2.qargs) == 2 and g_1 in self.overlap_indicator[g_2]:
self.overlap_indicator[g_1][g_2] = self.overlap_indicator[g_2][g_1]
self.overlap_amounts[g_1][g_2] = self.overlap_amounts[g_2][g_1]
else:
# Indicator variable for overlap of g_1 and g_2
var_name1 = 'olp_ind_' + str(self.gate_id[g_1]) + '_' + str(self.gate_id[g_2])
self.overlap_indicator[g_1][g_2] = Bool(var_name1)
var_name2 = 'olp_amnt_' + str(self.gate_id[g_1]) + '_' + str(self.gate_id[g_2])
self.overlap_amounts[g_1][g_2] = Real(var_name2)
active_qubits_list = []
for gate in self.dag.gate_nodes():
for q in gate.qargs:
active_qubits_list.append(q.index)
for active_qubit in list(set(active_qubits_list)):
q_var_name = 'l_' + str(active_qubit)
self.qubit_lifetime[active_qubit] = Real(q_var_name)
meas_q = []
for node in self.dag.op_nodes():
if isinstance(node.op, Measure):
meas_q.append(node.qargs[0].index)
self.measured_qubits = list(set(self.input_measured_qubits).union(set(meas_q)))
self.measure_start = Real('meas_start')
示例4: __init__
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def __init__(self, name):
self.name = name
self.__z3__ = z3.Bool(self.name)
# TODO write test that these areq unique with pointer eq
# i.e StatVar('x') != StatVar('x')
# vs
# x = StatVar('x')
# assert x == x
示例5: condition
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def condition(self) -> Bool:
return self._condition
示例6: z3Node
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def z3Node(self):
return z3.Bool(self.name)
示例7: getBoolVar
# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import Bool [as 别名]
def getBoolVar(self, name):
return z3.Bool(name)