Skip to content

Commit d682c84

Browse files
committed
partialy updated electric_grid_opt
1 parent ce1e531 commit d682c84

File tree

3 files changed

+74
-73
lines changed

3 files changed

+74
-73
lines changed

applications/optimization/electric_grid_optimization/electric_grid_optimization.ipynb

Lines changed: 52 additions & 35 deletions
Large diffs are not rendered by default.

applications/optimization/electric_grid_optimization/electric_grid_optimization.qmod

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
qstruct QAOAVars {
2-
x_0,0: qbit;
3-
x_0,1: qbit;
4-
x_0,2: qbit;
5-
x_0,3: qbit;
6-
x_1,0: qbit;
7-
x_1,1: qbit;
8-
x_1,2: qbit;
9-
x_1,3: qbit;
10-
x_2,0: qbit;
11-
x_2,1: qbit;
12-
x_2,2: qbit;
13-
x_2,3: qbit;
14-
source_supply_rule_0_slack_var_0: qbit;
15-
source_supply_rule_0_slack_var_1: qbit;
16-
source_supply_rule_1_slack_var_0: qbit;
17-
source_supply_rule_1_slack_var_1: qbit;
18-
source_supply_rule_2_slack_var_0: qbit;
19-
source_supply_rule_2_slack_var_1: qbit;
2+
x: qbit[4][3];
3+
source_supply_rule_0_slack_var: qbit[2];
4+
source_supply_rule_1_slack_var: qbit[2];
5+
source_supply_rule_2_slack_var: qbit[2];
206
}
217

22-
23-
248
qfunc main(params: real[12], output v: QAOAVars) {
259
allocate(v.size, v);
2610
hadamard_transform(v);
2711
repeat (i: 6) {
28-
phase (-(((((((((((((((((((0.5 * v.x_0,0) + v.x_0,1) + v.x_0,2) + (2.1 * v.x_0,3)) + v.x_1,0) + (0.6 * v.x_1,1)) + (1.4 * v.x_1,2)) + v.x_1,3) + v.x_2,0) + (1.4 * v.x_2,1)) + (0.4 * v.x_2,2)) + (2.3 * v.x_2,3)) + (16 * ((((v.x_0,0 + v.x_1,0) + v.x_2,0) - 1) ** 2))) + (16 * ((((v.x_0,1 + v.x_1,1) + v.x_2,1) - 1) ** 2))) + (16 * ((((v.x_0,2 + v.x_1,2) + v.x_2,2) - 1) ** 2))) + (16 * ((((v.x_0,3 + v.x_1,3) + v.x_2,3) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_0_slack_var_0) + (0.5 * v.source_supply_rule_0_slack_var_1)) + (0.5 * v.x_0,0)) + (0.5 * v.x_0,1)) + (0.5 * v.x_0,2)) + (0.5 * v.x_0,3)) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_1_slack_var_0) + (0.5 * v.source_supply_rule_1_slack_var_1)) + (0.5 * v.x_1,0)) + (0.5 * v.x_1,1)) + (0.5 * v.x_1,2)) + (0.5 * v.x_1,3)) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_2_slack_var_0) + (0.5 * v.source_supply_rule_2_slack_var_1)) + (0.5 * v.x_2,0)) + (0.5 * v.x_2,1)) + (0.5 * v.x_2,2)) + (0.5 * v.x_2,3)) - 1) ** 2))), params[i]);
12+
phase (-(((((((((((((((((((0.5 * v.x[0][0]) + v.x[0][1]) + v.x[0][2]) + (2.1 * v.x[0][3])) + v.x[1][0]) + (0.6 * v.x[1][1])) + (1.4 * v.x[1][2])) + v.x[1][3]) + v.x[2][0]) + (1.4 * v.x[2][1])) + (0.4 * v.x[2][2])) + (2.3 * v.x[2][3])) + (16 * ((((v.x[0][0] + v.x[1][0]) + v.x[2][0]) - 1) ** 2))) + (16 * ((((v.x[0][1] + v.x[1][1]) + v.x[2][1]) - 1) ** 2))) + (16 * ((((v.x[0][2] + v.x[1][2]) + v.x[2][2]) - 1) ** 2))) + (16 * ((((v.x[0][3] + v.x[1][3]) + v.x[2][3]) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_0_slack_var[0]) + (0.5 * v.source_supply_rule_0_slack_var[1])) + (0.5 * v.x[0][0])) + (0.5 * v.x[0][1])) + (0.5 * v.x[0][2])) + (0.5 * v.x[0][3])) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_1_slack_var[0]) + (0.5 * v.source_supply_rule_1_slack_var[1])) + (0.5 * v.x[1][0])) + (0.5 * v.x[1][1])) + (0.5 * v.x[1][2])) + (0.5 * v.x[1][3])) - 1) ** 2))) + (64.0 * ((((((((0.5 * v.source_supply_rule_2_slack_var[0]) + (0.5 * v.source_supply_rule_2_slack_var[1])) + (0.5 * v.x[2][0])) + (0.5 * v.x[2][1])) + (0.5 * v.x[2][2])) + (0.5 * v.x[2][3])) - 1) ** 2))), params[i]);
2913
apply_to_all(lambda(q) {
3014
RX(params[6 + i], q);
3115
}, v);

applications/optimization/electric_grid_optimization/electric_grid_optimization.synthesis_options.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@
77
"machine_precision": 8,
88
"custom_hardware_settings": {
99
"basis_gates": [
10-
"p",
1110
"y",
11+
"u2",
12+
"rx",
1213
"ry",
13-
"u1",
14-
"u",
14+
"rz",
15+
"tdg",
16+
"cy",
1517
"t",
16-
"s",
17-
"x",
18+
"p",
19+
"cx",
20+
"sx",
1821
"id",
1922
"r",
20-
"rx",
21-
"tdg",
22-
"cz",
23-
"sx",
24-
"cy",
25-
"h",
26-
"u2",
27-
"z",
23+
"s",
2824
"sxdg",
29-
"cx",
30-
"rz",
31-
"sdg"
25+
"u",
26+
"x",
27+
"sdg",
28+
"u1",
29+
"z",
30+
"cz",
31+
"h"
3232
],
3333
"is_symmetric_connectivity": true
3434
},
@@ -38,6 +38,6 @@
3838
"pretty_qasm": true,
3939
"transpilation_option": "auto optimize",
4040
"timeout_seconds": 300,
41-
"random_seed": 4093170185
41+
"random_seed": 654633485
4242
}
4343
}

0 commit comments

Comments
 (0)