question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Normal order should reduce, not the other way around

See original GitHub issue

Environment

  • Qiskit Nature version: 98de3b06fbc8b03e4079fbf7e256169f0196facc
  • Python version: N/A
  • Operating system: N/A

What is happening?

Normal ordering should put an operator into a canonical form. This means that two equivalent operators should have the same normal order. So FermionicOp.to_normal_order should “reduce” the operator by merging terms with the same label. It currently does not do this.

Reducing an operator should refer to merging terms with the same label. This is a useful operation in itself. It should not perform normal ordering, which takes exponential time in general. Reducing should be efficient. Currently, reducing a FermionicOp normal orders it, which is incorrect behavior.

How can we reproduce the issue?

import random
from qiskit_nature.operators.second_quantization import FermionicOp

random.seed(123)
k = 50
n = 100

op = sum(
    (FermionicOp(''.join(random.choices('+-ENI', k=k)), display_format="dense") * random.random())
    for _ in range(n))
op.reduce()

What should happen?

This operation should complete in at most a few seconds, probably under one second. Instead, it takes a very long time (I have not witnessed it complete, so I don’t know how long).

Any suggestions?

FermionicOp.to_normal_order should normal order and reduce, and FermionicOp.reduce should only reduce (not normal order).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinsungcommented, Mar 18, 2022

Actually, simplified is a better name because the method returns a copy rather than modifying the operator in place. But we’d need to use simplify to be consistent with SparsePauliOp. But then the tense would be inconsistent with normal_ordered. Unfortunate…

1reaction
kevinsungcommented, Mar 8, 2022

Ok I’ll go ahead then. Just to be clear, the agreed changes are:

  1. Add simplify and deprecate reduce.
  2. Add normal_ordered and deprecate to_normal_order.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop-Loss Orders: One Way To Limit Losses and Reduce Risk
Stop-limit orders may not get executed whereas a stop-loss order will always be executed (assuming there are buyers and sellers for the security)....
Read more >
Eliminate order bias to improve your survey responses
To prevent bias in your survey, we'll walk through common ways to limit your influence on the respondent's subconscious. Let's start with a...
Read more >
Eight Ways To Reduce Waste - The Nature Conservancy
1. Use a reusable bottle/cup for beverages on-the-go · 2. Use reusable grocery bags, and not just for groceries · 3. Purchase wisely...
Read more >
Stop Trying to Delight Your Customers
The Idea in Brief​​ Reps should focus on reducing the effort customers must make. Doing so increases the likelihood that they will return...
Read more >
Reduce, Reuse, Recycle: Alternatives for Waste Management
This publication provides an overview of the reasons and ways to better manage garbage or other household waste by following the 'Three Rs':...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found