Skip to content

flag to run simulation in reverse #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Geremia
Copy link

@Geremia Geremia commented Apr 27, 2025

  • optional argument (bool "reverse") to simpleSimulation for running simulations backward
  • C++ and Python tests of this for cost and line aware simulations

Note: This requires C++20:

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-lgtest -std=c++20' -DBINDINGS=ON
$ make

Building the Python wheel:

$ export CXXFLAGS='-lgtest -std=c++20'
$ python3 -m build --wheel
$ pip install ./dist/mqt_syrec-1.2.1.dev20+g6763cee-cp312-cp312-linux_x86_64.whl

Test Python binding simple_simulation:

$ python -m pytest test/python/test_syrec.py

Fixes discussion #223 .

Geremia and others added 2 commits April 26, 2025 21:21
… simulations backward

 - C++ and Python tests of this for cost and line aware simulations

See discussion munich-quantum-toolkit#223 .

Note: This requires C++20:
    mkdir build
    cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-lgtest -std=c++20' -DBINDINGS=ON

Building the Python wheel:
    export CXXFLAGS='-lgtest -std=c++20'
    python3 -m build --wheel

Test Python binding simple_simulation:
    python -m pytest test/python/test_syrec.py
Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
This looks good overall, but it's not necessary to use C++20 features here. See the inline comment.

Comment on lines 72 to 74
for (const auto& g: std::ranges::reverse_view(circ)) {
coreGateSimulation(*g, output);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use ranges here and raise the minimum standard to C++20.
Just use circ.crbegin() and circ.crend() to do the reverse iteration.

@burgholzer burgholzer added feature New feature or request python Anything related to Python code c++ Anything related to C++ code labels Apr 27, 2025
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/simulation/simple_simulation.cpp 80.0% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Anything related to C++ code feature New feature or request python Anything related to Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants