def update_qmi(self, prefix, next_prefix, problem): num1 = qmasm.symbol_to_number(prefix + self.sym1, prefix, next_prefix) num2 = qmasm.symbol_to_number(prefix + self.sym2, prefix, next_prefix) if num1 == num2: self.error_in_line("A chain cannot connect a spin to itself") elif num1 > num2: num1, num2 = num2, num1 problem.chains[(num1, num2)] = None # Value is a don't-care.
def update_qmi(self, prefix, next_prefix, problem): num1 = qmasm.symbol_to_number(prefix + self.sym1, prefix, next_prefix) num2 = qmasm.symbol_to_number(prefix + self.sym2, prefix, next_prefix) if num1 == num2: self.error_in_line("A coupler cannot connect a spin to itself") elif num1 > num2: num1, num2 = num2, num1 problem.strengths[(num1, num2)] += self.strength
def update_qmi(self, prefix, next_prefix, problem): num1 = qmasm.symbol_to_number(prefix + self.sym1, prefix, next_prefix) num2 = qmasm.symbol_to_number(prefix + self.sym2, prefix, next_prefix) if num1 == num2: self.error_in_line("An anti-chain cannot connect a spin to itself") elif num1 > num2: num1, num2 = num2, num1 problem.antichains.add((num1, num2))
def update_qmi(self, prefix, next_prefix, problem): num1 = qmasm.symbol_to_number(prefix + self.sym1, prefix, next_prefix) num2 = qmasm.symbol_to_number(prefix + self.sym2, prefix, next_prefix) if num1 == num2: self.error_in_line("An anti-chain cannot connect a spin to itself") elif num1 > num2: num1, num2 = num2, num1 problem.antichains.add((num1, num2)) sym1 = qmasm.apply_prefix(prefix + self.sym1, None, next_prefix) sym2 = qmasm.apply_prefix(prefix + self.sym2, None, next_prefix) problem.pending_asserts.append((sym1, "/=", sym2))
def pin_qubits(self, pin_str, chain_str): "Use a helper qubit to help pin values to true or false." for q_user, b in self.pinned: q_helper = qmasm.symbol_to_number(new_internal_sym()) q1, q2 = q_helper, q_user if q1 > q2: q1, q2 = q2, q1 if b: self.weights[q_helper] -= pin_str else: self.weights[q_helper] += pin_str self.strengths[(q1, q2)] += -chain_str
def pin_qubits(self, pin_str, chain_str): "Use a helper qubit to help pin values to true or false." for q_user, b in self.pinned: q_helper = qmasm.symbol_to_number(new_internal_sym()) q1, q2 = q_helper, q_user if q1 > q2: q1, q2 = q2, q1 if q_helper not in self.weights: self.weights[q_helper] = 0 if b: self.weights[q_helper] -= pin_str else: self.weights[q_helper] += pin_str self.strengths[(q1, q2)] += -chain_str self.antichains.add((q1, q2)) self.pin_chains.add((q_helper, q_user))
def pin_qubits(self, pin_str, chain_str): "Use a helper qubit to help pin values to true or false." for q_user, b in self.pinned: q_user_sym = qmasm.sym_map.to_symbols(q_user) q_pin_sym = '$' + q_user_sym.pop() #TODO: A proper solution should create aliases for q_helper # if there are aliases for q_user q_helper = qmasm.symbol_to_number(q_pin_sym) q1, q2 = q_helper, q_user if q1 > q2: q1, q2 = q2, q1 if b: self.weights[q_helper] -= pin_str else: self.weights[q_helper] += pin_str self.strengths[(q1, q2)] += -chain_str
def update_qmi(self, prefix, next_prefix, problem): num = qmasm.symbol_to_number(prefix + self.sym, prefix, next_prefix) problem.weights[num] += self.weight
def update_qmi(self, prefix, next_prefix, problem): num = qmasm.symbol_to_number(prefix + self.sym, prefix, next_prefix) problem.pinned.append((num, self.goal))
def update_qmi(self, prefix, next_prefix, problem): num = qmasm.symbol_to_number(prefix + self.sym, prefix, next_prefix) problem.pinned.append((num, self.goal)) sym = qmasm.apply_prefix(prefix + self.sym, None, next_prefix) problem.pending_asserts.append((sym, "=", str(int(self.goal))))