text stringlengths 81 112k |
|---|
Returns a list of text lines representing the block's contents.
Args:
width: The width of the output text. Must be at least as large as
the block's minimum width.
height: The height of the output text. Must be at least as large as
the block's minimum heig... |
Returns the block at (x, y) so it can be edited.
def mutable_block(self, x: int, y: int) -> Block:
"""Returns the block at (x, y) so it can be edited."""
if x < 0 or y < 0:
raise IndexError('x < 0 or y < 0')
return self._blocks[(x, y)] |
Sets a minimum width for blocks in the column with coordinate x.
def set_col_min_width(self, x: int, min_width: int):
"""Sets a minimum width for blocks in the column with coordinate x."""
if x < 0:
raise IndexError('x < 0')
self._min_widths[x] = min_width |
Sets a minimum height for blocks in the row with coordinate y.
def set_row_min_height(self, y: int, min_height: int):
"""Sets a minimum height for blocks in the row with coordinate y."""
if y < 0:
raise IndexError('y < 0')
self._min_heights[y] = min_height |
Outputs text containing the diagram.
Args:
block_span_x: The width of the diagram in blocks. Set to None to
default to using the smallest width that would include all
accessed blocks and columns with a specified minimum width.
block_span_y: The height of ... |
Demonstrates Quantum Fourier transform.
def main():
"""Demonstrates Quantum Fourier transform.
"""
# Create circuit
qft_circuit = generate_2x2_grid_qft_circuit()
print('Circuit:')
print(qft_circuit)
# Simulate and collect final_state
simulator = cirq.Simulator()
result = simulator.s... |
Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_string.map_qubits(qubit_map)
def map_qubits(self: TSelf_PauliStringGateOperation,
qubit_map: Dict[raw_types.Qid, raw_types.Qid]
) -> TSelf_PauliSt... |
Sets a commit status indicator on github.
If not running from a pull request (i.e. repository is None), then this
just prints to stderr.
Args:
state: The state of the status indicator.
Must be 'error', 'failure', 'pending', or 'success'.
description: A s... |
Get the files changed on one git branch vs another.
Returns:
List[str]: File paths of changed files, relative to the git repo
root.
def get_changed_files(self) -> List[str]:
"""Get the files changed on one git branch vs another.
Returns:
List[str]: File... |
Creates a Duration from datetime.timedelta if necessary
def create(cls, duration: Union['Duration', timedelta]) -> 'Duration':
"""Creates a Duration from datetime.timedelta if necessary"""
if isinstance(duration, cls):
return duration
elif isinstance(duration, timedelta):
... |
Returns the handle of a RawArray created from the given numpy array.
Args:
arr: A numpy ndarray.
Returns:
The handle (int) of the array.
Raises:
ValueError: if arr is not a ndarray or of an unsupported dtype. If
the array is of an unsupported type, us... |
Frees the memory for the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
def _free_array(self, handle: int):
"""Frees the memory for the array with the given handle.
Arg... |
Returns the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
Returns:
The numpy ndarray with the handle given from _create_array.
def _get_array(self, handle: int) -> n... |
Write QASM output to a file specified by path.
def save(self, path: Union[str, bytes, int]) -> None:
"""Write QASM output to a file specified by path."""
with open(path, 'w') as f:
def write(s: str) -> None:
f.write(s)
self._write_qasm(write) |
Splits moments so that they contain either only acquaintance gates
or only permutation gates. Orders resulting moments so that the first one
is of the same type as the previous one.
Args:
circuit: The acquaintance strategy to rectify.
acquaint_first: Whether to make acquaintance moment firs... |
Replace every moment containing acquaintance gates (after
rectification) with a generalized swap network, with the partition
given by the acquaintance gates in that moment (and singletons for the
free qubits). Accounts for reversing effect of swap networks.
Args:
circuit: The acquaintance strat... |
Check if a gate is a native ion gate.
Args:
gate: Input gate.
Returns:
True if the gate is native to the ion, false otherwise.
def is_native_ion_gate(gate: ops.Gate) -> bool:
"""Check if a gate is a native ion gate.
Args:
gate: Input gate.
Returns:
True if the ga... |
Convert a single (one- or two-qubit) operation
into ion trap native gates
Args:
op: gate operation to be converted
Returns:
the desired operation implemented with ion trap gates
def convert_one(self, op: ops.Operation) -> ops.OP_TREE:
"""Convert a single (one- ... |
Returns an orthogonal matrix that diagonalizes the given matrix.
Args:
matrix: A real symmetric matrix to diagonalize.
rtol: float = 1e-5,
atol: float = 1e-8
Returns:
An orthogonal matrix P such that P.T @ matrix @ P is diagonal.
Raises:
ValueError: Matrix isn't re... |
Splits range(length) into approximate equivalence classes.
Args:
length: The length of the range to split.
comparator: Determines if two indices have approximately equal items.
Returns:
A list of (inclusive_start, exclusive_end) range endpoints. Each
corresponds to a run of app... |
Returns an orthogonal matrix that diagonalizes both given matrices.
The given matrices must commute.
Guarantees that the sorted diagonal matrix is not permuted by the
diagonalization (except for nearly-equal values).
Args:
symmetric_matrix: A real symmetric matrix.
diagonal_matrix: A r... |
Finds orthogonal matrices that diagonalize both mat1 and mat2.
Requires mat1 and mat2 to be real.
Requires mat1.T @ mat2 to be symmetric.
Requires mat1 @ mat2.T to be symmetric.
Args:
mat1: One of the real matrices.
mat2: The other real matrix.
rtol: Relative numeric error thre... |
Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.
Args:
mat: A unitary matrix.
rtol: Relative numeric error threshold.
atol: Absolute numeric error threshold.
check_preconditions: If set, verifies that the input is a unitary matrix
(to the given tolera... |
r"""Returns a AsymmetricDepolarizingChannel with given parameter.
This channel evolves a density matrix via
$$
\rho \rightarrow (1 - p_x - p_y - p_z) \rho
+ p_x X \rho X + p_y Y \rho Y + p_z Z \rho Z
$$
Args:
p_x: The probability that a Pauli X and no other gat... |
r"""
Returns a PhaseFlipChannel that flips a qubit's phase with probability p
if p is None, return a guaranteed phase flip in the form of a Z operation.
This channel evolves a density matrix via:
$$
\rho \rightarrow M_0 \rho M_0^\dagger + M_1 \rho M_1^\dagger
$$
With:
... |
r"""
Construct a BitFlipChannel that flips a qubit state
with probability of a flip given by p. If p is None, return
a guaranteed flip in the form of an X operation.
This channel evolves a density matrix via
$$
\rho \rightarrow M_0 \rho M_0^\dagger + M_1 \rho M_1^\dagger
$$
... |
Finds operations by time and qubit.
Args:
time: Operations must end after this time to be returned.
duration: Operations must start by time+duration to be
returned.
qubits: If specified, only operations touching one of the included
qubits will... |
Finds operations happening at the same time as the given operation.
Args:
scheduled_operation: The operation specifying the time to query.
Returns:
Scheduled operations that overlap with the given operation.
def operations_happening_at_same_time_as(
self, scheduled_ope... |
Adds a scheduled operation to the schedule.
Args:
scheduled_operation: The operation to add.
Raises:
ValueError:
The operation collided with something already in the schedule.
def include(self, scheduled_operation: ScheduledOperation):
"""Adds a schedul... |
Omits a scheduled operation from the schedule, if present.
Args:
scheduled_operation: The operation to try to remove.
Returns:
True if the operation was present and is now removed, False if it
was already not present.
def exclude(self, scheduled_operation: Schedule... |
Convert the schedule to a circuit.
This discards most timing information from the schedule, but does place
operations that are scheduled at the same time in the same Moment.
def to_circuit(self) -> Circuit:
"""Convert the schedule to a circuit.
This discards most timing information fr... |
Acquaints each of the qubits with another set specified by an
acquaintance gate.
Args:
qubits: The list of qubits of which half are individually acquainted
with another list of qubits.
layers: The layers to put gates into.
acquaintance_gate: The acquaintance gate that acquai... |
Acquaints and shifts a pair of lists of qubits. The first part is
acquainted with every qubit individually in the second part, and vice
versa. Operations are grouped into several layers:
* prior_interstitial: The first layer of acquaintance gates.
* prior: The combination of acquaintance gates a... |
Compiles the QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to produce a pdf of.
filepath: Where to output the pdf.
pdf_kwargs: The arguments to pass to generate_pdf.
qcircuit_kwargs: The arguments to pass to
circuit_to_latex_using_qcircuit... |
Breaks down a 2x2 unitary into more useful ZYZ angle parameters.
Args:
mat: The 2x2 unitary matrix to break down.
Returns:
A tuple containing the amount to phase around Z, then rotate around Y,
then phase around Z (all in radians).
def deconstruct_single_qubit_matrix_into_angles(
... |
Combines similar items into groups.
Args:
items: The list of items to group.
comparer: Determines if two items are similar.
Returns:
A list of groups of items.
def _group_similar(items: List[T],
comparer: Callable[[T, T], bool]) -> List[List[T]]:
"""Combines similar items into ... |
An eigendecomposition that ensures eigenvectors are perpendicular.
numpy.linalg.eig doesn't guarantee that eigenvectors from the same
eigenspace will be perpendicular. This method uses Gram-Schmidt to recover
a perpendicular set. It further checks that all eigenvectors are
perpendicular and raises an A... |
Applies a function to the eigenvalues of a matrix.
Given M = sum_k a_k |v_k><v_k|, returns f(M) = sum_k f(a_k) |v_k><v_k|.
Args:
matrix: The matrix to modify with the function.
func: The function to apply to the eigenvalues of the matrix.
rtol: Relative threshold used when separating e... |
Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.
Requires the matrix to be the kronecker product of two 2x2 unitaries.
Requires the matrix to have a non-zero determinant.
Giving an incorrect matrix will cause garbage output.
Args:
matrix: The 4x4 unitary matrix to factor.
... |
Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.
Mag is the magic basis matrix:
1 0 0 i
0 i 1 0
0 i -1 0 (times sqrt(0.5) to normalize)
1 0 0 -i
Args:
mat: A real 4x4 orthogonal matrix.
rtol: Per-matrix-entry relative toleran... |
Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.
Args:
x: The strength of the XX interaction.
y: The strength of the YY interaction.
z: The strength of the ZZ interaction.
Returns:
The canonicalized decomposition, with vector coefficients (x2, y2, z2)
... |
Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.
Args:
mat: The 4x4 unitary matrix to decompose.
rtol: Per-matrix-entry relative tolerance on equality.
atol: Per-matrix-entry absolute tolerance on equality.
Returns:
A `cirq.KakDecomposition` canonicalize... |
Updates a mapping (in place) from qubits to logical indices according to
a set of permutation gates. Any gates other than permutation gates are
ignored.
Args:
mapping: The mapping to update.
operations: The operations to update according to.
def update_mapping(mapping: Dict[ops.Qid, Logica... |
Updates a mapping (in place) from qubits to logical indices.
Args:
mapping: The mapping to update.
keys: The qubits acted on by the gate.
def update_mapping(self, mapping: Dict[ops.Qid, LogicalIndex],
keys: Sequence[ops.Qid]
) -> None:
... |
Adds text to the given location.
Args:
x: The column in which to write the text.
y: The row in which to write the text.
text: The text to write at location (x, y).
transposed_text: Optional text to write instead, if the text
diagram is transposed.... |
Determines if a line or printed text is at the given location.
def content_present(self, x: int, y: int) -> bool:
"""Determines if a line or printed text is at the given location."""
# Text?
if (x, y) in self.entries:
return True
# Vertical line?
if any(v.x == x an... |
Adds a vertical or horizontal line from (x1, y1) to (x2, y2).
Horizontal line is selected on equality in the second coordinate and
vertical line is selected on equality in the first coordinate.
Raises:
ValueError: If line is neither horizontal nor vertical.
def grid_line(self, x1:... |
Adds a line from (x, y1) to (x, y2).
def vertical_line(self,
x: Union[int, float],
y1: Union[int, float],
y2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x, y1) to (x, y2... |
Adds a line from (x1, y) to (x2, y).
def horizontal_line(self,
y: Union[int, float],
x1: Union[int, float],
x2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x1, ... |
Returns the same diagram, but mirrored across its diagonal.
def transpose(self) -> 'TextDiagramDrawer':
"""Returns the same diagram, but mirrored across its diagonal."""
out = TextDiagramDrawer()
out.entries = {(y, x): _DiagramText(v.transposed_text, v.text)
for (x, y), v... |
Determines how many entry columns are in the diagram.
def width(self) -> int:
"""Determines how many entry columns are in the diagram."""
max_x = -1.0
for x, _ in self.entries.keys():
max_x = max(max_x, x)
for v in self.vertical_lines:
max_x = max(max_x, v.x)
... |
Determines how many entry rows are in the diagram.
def height(self) -> int:
"""Determines how many entry rows are in the diagram."""
max_y = -1.0
for _, y in self.entries.keys():
max_y = max(max_y, y)
for h in self.horizontal_lines:
max_y = max(max_y, h.y)
... |
Change the padding after the given column.
def force_horizontal_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given column."""
self.horizontal_padding[index] = padding |
Change the padding after the given row.
def force_vertical_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given row."""
self.vertical_padding[index] = padding |
Helper method to transformer either row or column coordinates.
def _transform_coordinates(
self,
func: Callable[[Union[int, float], Union[int, float]],
Tuple[Union[int, float], Union[int, float]]]
) -> None:
"""Helper method to transformer either row or co... |
Insert a number of columns after the given column.
def insert_empty_columns(self, x: int, amount: int = 1) -> None:
"""Insert a number of columns after the given column."""
def transform_columns(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[... |
Insert a number of rows after the given row.
def insert_empty_rows(self, y: int, amount: int = 1) -> None:
"""Insert a number of rows after the given row."""
def transform_rows(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union... |
Outputs text containing the diagram.
def render(self,
horizontal_spacing: int = 1,
vertical_spacing: int = 1,
crossing_char: str = None,
use_unicode_characters: bool = True) -> str:
"""Outputs text containing the diagram."""
block_diagram = B... |
Checks if the tensor's elements are all near zero.
Args:
a: Tensor of elements that could all be near zero.
atol: Absolute tolerance.
def all_near_zero(a: Union[float, complex, Iterable[float], np.ndarray],
*,
atol: float = 1e-8) -> bool:
"""Checks if the te... |
Checks if the tensor's elements are all near multiples of the period.
Args:
a: Tensor of elements that could all be near multiples of the period.
period: The period, e.g. 2 pi when working in radians.
atol: Absolute tolerance.
def all_near_zero_mod(a: Union[float, complex, Iterable[float],... |
Fetches two branches including their common ancestor.
Limits the depth of the fetch to avoid unnecessary work. Scales up the
depth exponentially and tries again when the initial guess is not deep
enough.
Args:
remote: The location of the remote repository, in a format that the
git ... |
Uses content from github to create a dir for testing and comparisons.
Args:
destination_directory: The location to fetch the contents into.
repository: The github repository that the commit lives under.
pull_request_number: The id of the pull request to clone. If None, then
the ... |
Uses local files to create a directory for testing and comparisons.
Args:
destination_directory: The directory where the copied files should go.
verbose: When set, more progress output is produced.
Returns:
Commit ids corresponding to content to test/compare.
def fetch_local_files(des... |
Returns a compute function and feed_dict for a `cirq.Circuit`'s output.
`result.compute()` will return a `tensorflow.Tensor` with
`tensorflow.placeholder` objects to be filled in by `result.feed_dict`, at
which point it will evaluate to the output state vector of the circuit.
You can apply further ope... |
Transforms a circuit into a series of GroupMatrix+CZ layers.
Args:
circuit: The circuit to transform.
grouping: How the circuit's qubits are combined into groups.
Returns:
A list of layers. Each layer has a matrix to apply to each group of
qubits, and a list of CZs to apply to ... |
Equivalent to `tensor[index, ...]`.
This is a workaround for XLA requiring constant tensor indices. It works
by producing a node representing hardcoded instructions like the following:
if index == 0: return tensor[0]
if index == 1: return tensor[1]
if index == 2: return tensor[2]
.... |
Equivalent to `[t[index, ...] for t in tensors]`.
See `_deref` for more details.
def _multi_deref(tensors: List[tf.Tensor], index: tf.Tensor) -> List[tf.Tensor]:
"""Equivalent to `[t[index, ...] for t in tensors]`.
See `_deref` for more details.
"""
assert tensors
assert tensors[0].shape[0] >... |
Samples from the given Circuit or Schedule.
Args:
program: The circuit or schedule to simulate.
param_resolver: Parameters to run with the program.
repetitions: The number of repetitions to simulate.
Returns:
TrialResult for a run.
def run(
... |
Samples from the given Circuit or Schedule.
In contrast to run, this allows for sweeping over different parameter
values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
repetitions: The number of repetitions t... |
Returns a single MeasurementGate applied to all the given qubits.
The qubits are measured in the computational basis.
Args:
*qubits: The qubits that the measurement gate should measure.
key: The string key of the measurement. If this is None, it defaults
to a comma-separated list o... |
Returns a list of operations individually measuring the given qubits.
The qubits are measured in the computational basis.
Args:
*qubits: The qubits to measure.
key_func: Determines the key of the measurements of each qubit. Takes
the qubit and returns the key for that qubit. Defaul... |
Returns a gate with the matrix e^{-i X rads / 2}.
def Rx(rads: Union[float, sympy.Basic]) -> XPowGate:
"""Returns a gate with the matrix e^{-i X rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return XPowGate(exponent=rads / pi, global_shift=-0.5) |
Returns a gate with the matrix e^{-i Y rads / 2}.
def Ry(rads: Union[float, sympy.Basic]) -> YPowGate:
"""Returns a gate with the matrix e^{-i Y rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return YPowGate(exponent=rads / pi, global_shift=-0.5) |
Returns a gate with the matrix e^{-i Z rads / 2}.
def Rz(rads: Union[float, sympy.Basic]) -> ZPowGate:
"""Returns a gate with the matrix e^{-i Z rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return ZPowGate(exponent=rads / pi, global_shift=-0.5) |
See base class.
def _decompose_(self, qubits):
"""See base class."""
a, b = qubits
yield CNOT(a, b)
yield CNOT(b, a) ** self._exponent
yield CNOT(a, b) |
Checks if this gate can be applied to the given qubits.
By default checks if input is of type Qid and qubit count.
Child classes can override.
Args:
qubits: The collection of qubits to potentially apply the gate to.
Throws:
ValueError: The gate can't be applied... |
Returns an application of this gate to the given qubits.
Args:
*qubits: The collection of qubits to potentially apply the gate to.
def on(self, *qubits: Qid) -> 'gate_operation.GateOperation':
"""Returns an application of this gate to the given qubits.
Args:
*qubits: T... |
Returns a controlled version of this gate.
Args:
control_qubits: Optional qubits to control the gate by.
def controlled_by(self, *control_qubits: Qid) -> 'Gate':
"""Returns a controlled version of this gate.
Args:
control_qubits: Optional qubits to control the gate by.... |
Returns the same operation, but with different qubits.
Args:
func: The function to use to turn each current qubit into a desired
new qubit.
Returns:
The receiving operation but with qubits transformed by the given
function.
def transform_qubits(... |
Returns a controlled version of this operation.
Args:
control_qubits: Qubits to control the operation by. Required.
def controlled_by(self, *control_qubits: Qid) -> 'Operation':
"""Returns a controlled version of this operation.
Args:
control_qubits: Qubits to control ... |
The value of the display, derived from the full wavefunction.
Args:
state: The wavefunction.
qubit_map: A dictionary from qubit to qubit index in the
ordering used to define the wavefunction.
def value_derived_from_wavefunction(self,
... |
Evaluates the status check and returns a pass/fail with message.
Args:
env: Describes a prepared python 3 environment in which to run.
verbose: When set, more progress output is produced.
Returns:
A tuple containing a pass/fail boolean and then a details message.
d... |
Evaluates this check.
Args:
env: The prepared python environment to run the check in.
verbose: When set, more progress output is produced.
previous_failures: Checks that have already run and failed.
Returns:
A CheckResult instance.
def run(self,
... |
Evaluates this check in python 3 or 2.7, and reports to github.
If the prepared environments are not linked to a github repository,
with a known access token, reporting to github is skipped.
Args:
env: A prepared python 3 environment.
env_py2: A prepared python 2.7 envi... |
Convert a Sweepable to a list of ParamResolvers.
def to_resolvers(sweepable: Sweepable) -> List[ParamResolver]:
"""Convert a Sweepable to a list of ParamResolvers."""
if isinstance(sweepable, ParamResolver):
return [sweepable]
elif isinstance(sweepable, Sweep):
return list(sweepable)
el... |
Returns whether the object is parameterized with any Symbols.
A value is parameterized when it has an `_is_parameterized_` method and
that method returns a truthy value, or if the value is an instance of
sympy.Basic.
Returns:
True if the gate has any unresolved Symbols
and False otherw... |
Resolves symbol parameters in the effect using the param resolver.
This function will use the `_resolve_parameters_` magic method
of `val` to resolve any Symbols with concrete values from the given
parameter resolver.
Args:
val: The object to resolve (e.g. the gate, operation, etc)
par... |
Returns a QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to represent in latex.
qubit_order: Determines the order of qubit wires in the diagram.
Returns:
Latex code for the diagram.
def circuit_to_latex_using_qcircuit(
circuit: circuits.Circuit,
... |
Computes the kronecker product of a sequence of matrices.
A *args version of lambda args: functools.reduce(np.kron, args).
Args:
*matrices: The matrices and controls to combine with the kronecker
product.
Returns:
The resulting matrix.
def kron(*matrices: np.ndarray) -> np.nd... |
Computes the kronecker product of a sequence of matrices and controls.
Use linalg.CONTROL_TAG to represent controls. Any entry of the output
matrix corresponding to a situation where the control is not satisfied will
be overwritten by identity matrix elements.
The control logic works by imbuing NaN wi... |
Computes the dot/matrix product of a sequence of values.
A *args version of np.linalg.multi_dot.
Args:
*values: The values to combine with the dot/matrix product.
Returns:
The resulting value or matrix.
def dot(*values: Union[float, complex, np.ndarray]
) -> Union[float, complex,... |
Concatenates blocks into a block diagonal matrix.
Args:
*blocks: Square matrices to place along the diagonal of the result.
Returns:
A block diagonal matrix with the given blocks along its diagonal.
Raises:
ValueError: A block isn't square.
def block_diag(*blocks: np.ndarray) -> ... |
Finds the first index of a target item within a list of lists.
Args:
seqs: The list of lists to search.
target: The item to find.
Raises:
ValueError: Item is not present.
def index_2d(seqs: List[List[Any]], target: Any) -> Tuple[int, int]:
"""Finds the first index of a target item... |
Issues new linear sequence search.
Each call to this method starts new search.
Args:
trace_func: Optional callable which will be called for each simulated
annealing step with arguments: solution candidate (list of linear
sequences on the chip), current temperature (fl... |
Cost function that sums squares of lengths of sequences.
Args:
state: Search state, not mutated.
Returns:
Cost which is minus the normalized quadratic sum of each linear
sequence section in the state. This promotes single, long linear
sequence solutions and conv... |
Move function which repeats _force_edge_active_move a few times.
Args:
state: Search state, not mutated.
Returns:
New search state which consists of incremental changes of the
original state.
def _force_edges_active_move(self, state: _STATE) -> _STATE:
"""Move fu... |
Move which forces a random edge to appear on some sequence.
This move chooses random edge from the edges which do not belong to any
sequence and modifies state in such a way, that this chosen edge
appears on some sequence of the search state.
Args:
state: Search state, not mu... |
Move which forces given edge to appear on some sequence.
Args:
seqs: List of linear sequences covering chip.
edge: Edge to be activated.
sample_bool: Callable returning random bool.
Returns:
New list of linear sequences with given edge on some of the
s... |
Creates initial solution based on the chip description.
Initial solution is constructed in a greedy way.
Returns:
Valid search state.
def _create_initial_solution(self) -> _STATE:
"""Creates initial solution based on the chip description.
Initial solution is constructed in ... |
Gives unique representative of the edge.
Two edges are equivalent if they form an edge between the same nodes.
This method returns representative of this edge which can be compared
using equality operator later.
Args:
edge: Edge to normalize.
Returns:
Norma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.