Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions applications/finance/value_at_risk/Persik.metadata.json

This file was deleted.

255 changes: 109 additions & 146 deletions applications/finance/value_at_risk/value_at_risk.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"friendly_name": "Value At Risk",
"description": "Value At Risk",
"problem_domain_tags": [],
"vertical_tags": ["finance"],
"qmod_type": ["application"],
"level": ["advanced"]
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
qstruct OptionPricingState {
asset: qnum<7, False, 0>;
ind: qbit;
}

qfunc iqae_algorithm(k: int, oracle_operand: qperm (qbit[]), sp_operand: qfunc (qbit[]), x: qbit[]) {
sp_operand(x);
power (k) {
grover_operator(oracle_operand, sp_operand, x);
}
}

qperm iqae_oracle(const state: OptionPricingState) {
Z(state.ind);
qperm oracle(const est_reg: qbit[]) {
Z(est_reg[est_reg.len - 1]);
}

qfunc load_distribution(asset: qnum) {
Expand Down Expand Up @@ -148,19 +136,27 @@ qfunc load_distribution(asset: qnum) {
}

qperm payoff(const asset: qnum, ind: qbit) {
ind ^= asset < 34;
ind ^= asset < 32;
}

qfunc state_preparation(asset: qbit[], ind: qbit) {
load_distribution(asset);
payoff(asset, ind);
}

qfunc state_preparation(state: OptionPricingState) {
load_distribution(state.asset);
payoff(state.asset, state.ind);
qfunc space_transform(est_reg: qbit[]) {
state_preparation(est_reg[0:est_reg.len - 1], est_reg[est_reg.len - 1]);
}

qfunc main(k: int, output ind: qbit) {
state: OptionPricingState;
allocate(8, state);
iqae_algorithm(k, iqae_oracle, state_preparation, state);
asset: qnum<7>;
state -> {asset, ind};
drop(asset);
qfunc main(k: int, output indicator: qbit) {
est_reg: qbit[];
problem_vars: qbit[7];
allocate(problem_vars);
allocate(indicator);
within {
{problem_vars, indicator} -> est_reg;
} apply {
amplitude_amplification(k, oracle, space_transform, est_reg);
}
drop(problem_vars);
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
{
"constraints": {
"max_gate_count": {},
"max_width": 28,
"optimization_parameter": "no_opt"
},
"preferences": {
"custom_hardware_settings": {
"basis_gates": [
"sxdg",
"r",
"rz",
"u2",
"cx",
"cz",
"u",
"h",
"ry",
"sxdg",
"u1",
"p",
"cy",
"s",
"cx",
"rx",
"x",
"t",
"sdg",
"y",
"u1",
"u",
"x",
"id",
"rx",
"s",
"tdg",
"rz",
"ry",
"r",
"u2",
"z",
"sx",
"p",
"t",
"id"
"y"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"machine_precision": 8,
"machine_precision": 7,
"optimization_level": 1,
"output_format": ["qasm"],
"pretty_qasm": true,
"random_seed": 2641333644,
"random_seed": 3469868444,
"synthesize_all_separately": false,
"timeout_seconds": 300,
"transpilation_option": "auto optimize"
Expand Down
Loading