Skip to content

Commit b3dadad

Browse files
committed
update to new IQAE and add comments
1 parent faeeb86 commit b3dadad

File tree

5 files changed

+156
-195
lines changed

5 files changed

+156
-195
lines changed

applications/finance/value_at_risk/Persik.metadata.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

applications/finance/value_at_risk/value_at_risk.ipynb

Lines changed: 109 additions & 146 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"friendly_name": "Value At Risk",
3+
"description": "Value At Risk",
4+
"problem_domain_tags": [],
5+
"vertical_tags": ["finance"],
6+
"qmod_type": ["application"],
7+
"level": ["advanced"]
8+
}

applications/finance/value_at_risk/Persik.qmod renamed to applications/finance/value_at_risk/value_at_risk.qmod

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
qstruct OptionPricingState {
2-
asset: qnum<7, False, 0>;
3-
ind: qbit;
4-
}
5-
6-
qfunc iqae_algorithm(k: int, oracle_operand: qperm (qbit[]), sp_operand: qfunc (qbit[]), x: qbit[]) {
7-
sp_operand(x);
8-
power (k) {
9-
grover_operator(oracle_operand, sp_operand, x);
10-
}
11-
}
12-
13-
qperm iqae_oracle(const state: OptionPricingState) {
14-
Z(state.ind);
1+
qperm oracle(const est_reg: qbit[]) {
2+
Z(est_reg[est_reg.len - 1]);
153
}
164

175
qfunc load_distribution(asset: qnum) {
@@ -148,19 +136,27 @@ qfunc load_distribution(asset: qnum) {
148136
}
149137

150138
qperm payoff(const asset: qnum, ind: qbit) {
151-
ind ^= asset < 34;
139+
ind ^= asset < 32;
140+
}
141+
142+
qfunc state_preparation(asset: qbit[], ind: qbit) {
143+
load_distribution(asset);
144+
payoff(asset, ind);
152145
}
153146

154-
qfunc state_preparation(state: OptionPricingState) {
155-
load_distribution(state.asset);
156-
payoff(state.asset, state.ind);
147+
qfunc space_transform(est_reg: qbit[]) {
148+
state_preparation(est_reg[0:est_reg.len - 1], est_reg[est_reg.len - 1]);
157149
}
158150

159-
qfunc main(k: int, output ind: qbit) {
160-
state: OptionPricingState;
161-
allocate(8, state);
162-
iqae_algorithm(k, iqae_oracle, state_preparation, state);
163-
asset: qnum<7>;
164-
state -> {asset, ind};
165-
drop(asset);
151+
qfunc main(k: int, output indicator: qbit) {
152+
est_reg: qbit[];
153+
problem_vars: qbit[7];
154+
allocate(problem_vars);
155+
allocate(indicator);
156+
within {
157+
{problem_vars, indicator} -> est_reg;
158+
} apply {
159+
amplitude_amplification(k, oracle, space_transform, est_reg);
160+
}
161+
drop(problem_vars);
166162
}

applications/finance/value_at_risk/Persik.synthesis_options.json renamed to applications/finance/value_at_risk/value_at_risk.synthesis_options.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
{
22
"constraints": {
33
"max_gate_count": {},
4+
"max_width": 28,
45
"optimization_parameter": "no_opt"
56
},
67
"preferences": {
78
"custom_hardware_settings": {
89
"basis_gates": [
9-
"sxdg",
10+
"r",
11+
"rz",
12+
"u2",
13+
"cx",
1014
"cz",
15+
"u",
1116
"h",
17+
"ry",
18+
"sxdg",
19+
"u1",
20+
"p",
1221
"cy",
13-
"s",
14-
"cx",
15-
"rx",
16-
"x",
22+
"t",
1723
"sdg",
18-
"y",
19-
"u1",
20-
"u",
24+
"x",
25+
"id",
26+
"rx",
27+
"s",
2128
"tdg",
22-
"rz",
23-
"ry",
24-
"r",
25-
"u2",
2629
"z",
2730
"sx",
28-
"p",
29-
"t",
30-
"id"
31+
"y"
3132
],
3233
"is_symmetric_connectivity": true
3334
},
3435
"debug_mode": true,
35-
"machine_precision": 8,
36+
"machine_precision": 7,
3637
"optimization_level": 1,
3738
"output_format": ["qasm"],
3839
"pretty_qasm": true,
39-
"random_seed": 2641333644,
40+
"random_seed": 3469868444,
4041
"synthesize_all_separately": false,
4142
"timeout_seconds": 300,
4243
"transpilation_option": "auto optimize"

0 commit comments

Comments
 (0)