コード例 #1
0
 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.
コード例 #2
0
 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
コード例 #3
0
ファイル: parse.py プロジェクト: losalamos/qasm
 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
コード例 #4
0
 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))
コード例 #5
0
 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))
コード例 #6
0
ファイル: parse.py プロジェクト: losalamos/qasm
 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))
コード例 #7
0
ファイル: problem.py プロジェクト: mikewlange/qmasm
 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
コード例 #8
0
ファイル: problem.py プロジェクト: losalamos/qasm
 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))
コード例 #9
0
ファイル: problem.py プロジェクト: joseppinilla/qmasm
 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
コード例 #10
0
 def update_qmi(self, prefix, next_prefix, problem):
     num = qmasm.symbol_to_number(prefix + self.sym, prefix, next_prefix)
     problem.weights[num] += self.weight
コード例 #11
0
 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))
コード例 #12
0
 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))))
コード例 #13
0
ファイル: parse.py プロジェクト: losalamos/qasm
 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))))
コード例 #14
0
ファイル: parse.py プロジェクト: losalamos/qasm
 def update_qmi(self, prefix, next_prefix, problem):
     num = qmasm.symbol_to_number(prefix + self.sym, prefix, next_prefix)
     problem.weights[num] += self.weight