Skip to content

Commit d589b1b

Browse files
committed
Quantum Based Resiliency Planning
1 parent d10cd20 commit d589b1b

File tree

5 files changed

+1134
-0
lines changed

5 files changed

+1134
-0
lines changed

applications/telecom/resiliency_planning/resiliency_planning.ipynb

Lines changed: 1045 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"friendly_name": "Quantum-Based Resiliency Planning",
3+
"description": "Quantum-Based Resiliency Planning",
4+
"problem_domain_tags": ["chemistry"],
5+
"qmod_type": ["application"],
6+
"level": []
7+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
qfunc cost_layer(gamma: real, qba: qbit[]) {
2+
phase (((((((((((((((((0 + (0.025 * qba[0])) + (0.025 * qba[1])) + (0.025 * qba[2])) + (0.025 * qba[3])) + (0.025 * qba[4])) + (0.025 * qba[5])) + (0.05 * qba[6])) + (0.025 * qba[12])) + (0.025 * qba[13])) + (0.025 * qba[14])) + (0.025 * qba[15])) + (0.025 * qba[16])) + (0.025 * qba[17])) + (0.05 * qba[18])) + ((((0 + ((0.25 * qba[7]) * qba[19])) + ((0.25 * qba[8]) * qba[20])) + ((0.25 * qba[9]) * qba[21])) + ((0.25 * qba[11]) * qba[23]))) + ((0 + ((1 * qba[1]) * qba[14])) + ((1 * qba[2]) * qba[13]))) + (0.125 * (((((((((((0 + ((((1 - (2 * qba[7])) + qba[0]) + qba[1]) ** 2)) + ((((0 - (2 * qba[19])) + qba[12]) + qba[13]) ** 2)) + ((((0 - (2 * qba[8])) + qba[3]) + qba[5]) ** 2)) + ((((1 - (2 * qba[20])) + qba[15]) + qba[17]) ** 2)) + ((((((0 - (2 * qba[9])) + qba[0]) + qba[2]) + qba[3]) + qba[4]) ** 2)) + ((((((0 - (2 * qba[21])) + qba[12]) + qba[14]) + qba[15]) + qba[16]) ** 2)) + (((((1 - (2 * qba[10])) + qba[1]) + qba[2]) + qba[6]) ** 2)) + (((((1 - (2 * qba[22])) + qba[13]) + qba[14]) + qba[18]) ** 2)) + (((((0 - (2 * qba[11])) + qba[4]) + qba[5]) + qba[6]) ** 2)) + (((((0 - (2 * qba[23])) + qba[16]) + qba[17]) + qba[18]) ** 2)) + ((((0 + (1 - qba[10])) + (1 - qba[7])) + (1 - qba[22])) + (1 - qba[20])))), gamma);
3+
}
4+
5+
qfunc mixer_layer(beta: real, qba: qbit[]) {
6+
apply_to_all(lambda(q) {
7+
RX(1 * beta, q);
8+
}, qba);
9+
}
10+
11+
qfunc main(params: real[40], output z: qbit[24]) {
12+
allocate(z);
13+
hadamard_transform(z);
14+
repeat (i: 20) {
15+
cost_layer(params[2 * i], z);
16+
mixer_layer(params[(2 * i) + 1], z);
17+
}
18+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"constraints": {
3+
"max_gate_count": {},
4+
"optimization_parameter": "no_opt"
5+
},
6+
"preferences": {
7+
"custom_hardware_settings": {
8+
"basis_gates": [
9+
"u",
10+
"rz",
11+
"ry",
12+
"s",
13+
"u2",
14+
"tdg",
15+
"u1",
16+
"cy",
17+
"rx",
18+
"h",
19+
"id",
20+
"r",
21+
"x",
22+
"p",
23+
"cx",
24+
"y",
25+
"sxdg",
26+
"sx",
27+
"z",
28+
"t",
29+
"cz",
30+
"sdg"
31+
],
32+
"is_symmetric_connectivity": true
33+
},
34+
"debug_mode": true,
35+
"machine_precision": 8,
36+
"optimization_level": 1,
37+
"output_format": ["qasm"],
38+
"pretty_qasm": true,
39+
"random_seed": 1217435508,
40+
"synthesize_all_separately": false,
41+
"timeout_seconds": 300,
42+
"transpilation_option": "auto optimize"
43+
}
44+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from tests.utils_for_testbook import (
2+
validate_quantum_program_size,
3+
validate_quantum_model,
4+
wrap_testbook,
5+
)
6+
from testbook.client import TestbookNotebookClient
7+
8+
9+
@wrap_testbook("resiliency_planning", timeout_seconds=1801)
10+
def test_notebook(tb: TestbookNotebookClient) -> None:
11+
# test quantum programs
12+
validate_quantum_program_size(
13+
tb.ref_pydantic("qprog"),
14+
expected_width=24,
15+
expected_depth=1000, # Actual is 586
16+
expected_cx_count=None,
17+
)
18+
19+
# test notebook content
20+
pass # Todo

0 commit comments

Comments
 (0)