Metadata-Version: 2.4
Name: c2q-framework
Version: 0.1.1
Summary: C2|Q: Classical-to-Quantum software development framework
Author: C2Q Team
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [2024] [C2|Q> TEAM]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/C2-Q/C2Q
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohappyeyeballs==2.6.1
Requires-Dist: aiohttp==3.12.13
Requires-Dist: aiosignal==1.3.2
Requires-Dist: amazon-braket-default-simulator==1.27.0
Requires-Dist: amazon-braket-schemas==1.29.0
Requires-Dist: amazon-braket-sdk==1.97.0
Requires-Dist: annotated-types==0.7.0
Requires-Dist: antlr4-python3-runtime==4.9.2
Requires-Dist: anyio==4.4.0
Requires-Dist: appnope==0.1.4; sys_platform == "darwin"
Requires-Dist: argon2-cffi==23.1.0
Requires-Dist: argon2-cffi-bindings==21.2.0
Requires-Dist: arrow==1.3.0
Requires-Dist: asttokens==2.4.1
Requires-Dist: async-lru==2.0.4
Requires-Dist: attrs==23.2.0
Requires-Dist: azure-core==1.35.0
Requires-Dist: azure-identity==1.24.0
Requires-Dist: azure-quantum==3.2.0
Requires-Dist: azure-storage-blob==12.20.0
Requires-Dist: Babel==2.15.0
Requires-Dist: backoff==2.2.1
Requires-Dist: backports.entry-points-selectable==1.3.0
Requires-Dist: beautifulsoup4==4.12.3
Requires-Dist: bleach==6.1.0
Requires-Dist: boltons==25.0.0
Requires-Dist: boto3==1.38.43
Requires-Dist: botocore==1.38.43
Requires-Dist: certifi==2024.6.2
Requires-Dist: cffi==1.16.0
Requires-Dist: cftime==1.6.4.post1
Requires-Dist: charset-normalizer==3.3.2
Requires-Dist: click==8.1.7
Requires-Dist: cloudpickle==2.2.1
Requires-Dist: comm==0.2.2
Requires-Dist: contourpy==1.2.1
Requires-Dist: cryptography==42.0.8
Requires-Dist: cycler==0.12.1
Requires-Dist: dask==2024.6.2
Requires-Dist: datasets==2.21.0
Requires-Dist: debugpy==1.8.1
Requires-Dist: decorator==5.1.1
Requires-Dist: defusedxml==0.7.1
Requires-Dist: Deprecated==1.2.18
Requires-Dist: dill==0.3.8
Requires-Dist: django-qrcode==0.3
Requires-Dist: dlx==1.0.4
Requires-Dist: docplex==2.27.239
Requires-Dist: executing==2.0.1
Requires-Dist: extract-emails==5.3.4
Requires-Dist: fastdtw==0.3.4
Requires-Dist: fastjsonschema==2.20.0
Requires-Dist: filelock==3.18.0
Requires-Dist: fonttools==4.53.0
Requires-Dist: fpdf==1.7.2
Requires-Dist: fqdn==1.5.1
Requires-Dist: frozenlist==1.7.0
Requires-Dist: fsspec==2024.6.1
Requires-Dist: funcy==2.0
Requires-Dist: gensim==4.3.3
Requires-Dist: graphviz==0.21
Requires-Dist: h11==0.14.0
Requires-Dist: h5py==3.11.0
Requires-Dist: hf-xet==1.1.5
Requires-Dist: httpcore==1.0.5
Requires-Dist: httpx==0.27.0
Requires-Dist: huggingface-hub==0.33.0
Requires-Dist: ibm-cloud-sdk-core==3.20.1
Requires-Dist: ibm-platform-services==0.54.0
Requires-Dist: idna==3.7
Requires-Dist: importlib_metadata==8.7.0
Requires-Dist: inflection==0.5.1
Requires-Dist: iniconfig==2.1.0
Requires-Dist: ipykernel==6.29.4
Requires-Dist: ipython==8.25.0
Requires-Dist: ipywidgets==8.1.3
Requires-Dist: isodate==0.7.2
Requires-Dist: isoduration==20.11.0
Requires-Dist: jedi==0.19.1
Requires-Dist: Jinja2==3.1.4
Requires-Dist: jmespath==1.0.1
Requires-Dist: joblib==1.4.2
Requires-Dist: json5==0.9.25
Requires-Dist: jsonpointer==3.0.0
Requires-Dist: jsonschema==4.22.0
Requires-Dist: jsonschema-specifications==2023.12.1
Requires-Dist: jupyter==1.0.0
Requires-Dist: jupyter-console==6.6.3
Requires-Dist: jupyter-events==0.10.0
Requires-Dist: jupyter-lsp==2.2.5
Requires-Dist: jupyter_client==8.6.2
Requires-Dist: jupyter_core==5.7.2
Requires-Dist: jupyter_server==2.14.1
Requires-Dist: jupyter_server_terminals==0.5.3
Requires-Dist: jupyterlab==4.2.2
Requires-Dist: jupyterlab_pygments==0.3.0
Requires-Dist: jupyterlab_server==2.27.2
Requires-Dist: jupyterlab_widgets==3.0.11
Requires-Dist: kiwisolver==1.4.5
Requires-Dist: lark==1.2.2
Requires-Dist: lda==3.0.2
Requires-Dist: locket==1.0.0
Requires-Dist: loguru==0.5.3
Requires-Dist: Markdown==3.8.2
Requires-Dist: MarkupSafe==2.1.5
Requires-Dist: matplotlib==3.9.0
Requires-Dist: matplotlib-inline==0.1.7
Requires-Dist: mistune==3.0.2
Requires-Dist: more-itertools==10.3.0
Requires-Dist: mpmath==1.3.0
Requires-Dist: msal==1.32.3
Requires-Dist: msal-extensions==1.3.1
Requires-Dist: msrest==0.7.1
Requires-Dist: multidict==6.5.1
Requires-Dist: multiprocess==0.70.16
Requires-Dist: mypy_extensions==1.1.0
Requires-Dist: nbclient==0.10.0
Requires-Dist: nbconvert==7.16.4
Requires-Dist: nbformat==5.10.4
Requires-Dist: nest-asyncio==1.6.0
Requires-Dist: netCDF4==1.7.2
Requires-Dist: networkx==3.3
Requires-Dist: nltk==3.9.1
Requires-Dist: notebook==7.2.1
Requires-Dist: notebook_shim==0.2.4
Requires-Dist: numexpr==2.10.1
Requires-Dist: numpy==1.26.4
Requires-Dist: oauthlib==3.3.1
Requires-Dist: openpulse==1.0.1
Requires-Dist: openqasm3==1.0.1
Requires-Dist: opt_einsum==3.4.0
Requires-Dist: oqpy==0.3.7
Requires-Dist: ordered-set==4.1.0
Requires-Dist: overrides==7.7.0
Requires-Dist: packaging==24.1
Requires-Dist: pandas==2.2.2
Requires-Dist: pandocfilters==1.5.1
Requires-Dist: parso==0.8.4
Requires-Dist: partd==1.4.2
Requires-Dist: pbr==6.0.0
Requires-Dist: pexpect==4.9.0
Requires-Dist: pillow==10.3.0
Requires-Dist: platformdirs==4.2.2
Requires-Dist: pluggy==1.6.0
Requires-Dist: ply==3.11
Requires-Dist: portalocker==3.2.0
Requires-Dist: prometheus_client==0.20.0
Requires-Dist: prompt_toolkit==3.0.47
Requires-Dist: propcache==0.3.2
Requires-Dist: psutil==6.0.0
Requires-Dist: ptyprocess==0.7.0
Requires-Dist: pure-eval==0.2.2
Requires-Dist: pyarrow==20.0.0
Requires-Dist: pycparser==2.22
Requires-Dist: pydantic==2.7.4
Requires-Dist: pydantic_core==2.18.4
Requires-Dist: pydot==2.0.0
Requires-Dist: Pygments==2.18.0
Requires-Dist: PyJWT==2.8.0
Requires-Dist: PyLaTeX==1.4.2
Requires-Dist: pylatexenc==2.10
Requires-Dist: pyLDAvis==3.4.1
Requires-Dist: pyobjc-core==10.3.1; sys_platform == "darwin"
Requires-Dist: pyobjc-framework-Cocoa==10.3.1; sys_platform == "darwin"
Requires-Dist: pyparsing==3.1.2
Requires-Dist: pyqir==0.10.9
Requires-Dist: pyspnego==0.11.0
Requires-Dist: pytest==8.4.1
Requires-Dist: python-dateutil==2.9.0.post0
Requires-Dist: python-dotenv==1.1.1
Requires-Dist: python-json-logger==2.0.7
Requires-Dist: python-markdown-math==0.9
Requires-Dist: python-sat==1.8.dev13
Requires-Dist: pytket==2.6.0
Requires-Dist: pytket-qir==0.21.1
Requires-Dist: pytket-qiskit==0.64.0
Requires-Dist: pytket-quantinuum==0.45.0
Requires-Dist: pytz==2024.1
Requires-Dist: PyYAML==6.0.1
Requires-Dist: pyzmq==26.0.3
Requires-Dist: qiskit==1.4.3
Requires-Dist: qiskit-aer==0.16.0
Requires-Dist: qiskit-algorithms==0.3.0
Requires-Dist: qiskit-braket-provider==0.5.0
Requires-Dist: qiskit-ibm-runtime==0.34.0
Requires-Dist: qiskit-ionq==0.5.12
Requires-Dist: qrcode==8.0
Requires-Dist: qtconsole==5.5.2
Requires-Dist: QtPy==2.4.1
Requires-Dist: Quandl==3.7.0
Requires-Dist: qwasm==1.0.1
Requires-Dist: referencing==0.35.1
Requires-Dist: regex==2024.11.6
Requires-Dist: requests==2.32.2
Requires-Dist: requests-oauthlib==2.0.0
Requires-Dist: requests_ntlm==1.3.0
Requires-Dist: retworkx==0.15.1
Requires-Dist: rfc3339-validator==0.1.4
Requires-Dist: rfc3986-validator==0.1.1
Requires-Dist: rpds-py==0.18.1
Requires-Dist: rustworkx==0.15.1
Requires-Dist: s3transfer==0.13.0
Requires-Dist: safetensors==0.5.3
Requires-Dist: scikit-learn==1.5.1
Requires-Dist: scipy==1.13.1
Requires-Dist: seaborn==0.13.2
Requires-Dist: Send2Trash==1.8.3
Requires-Dist: setuptools==70.1.0
Requires-Dist: six==1.16.0
Requires-Dist: smart-open==7.0.5
Requires-Dist: sniffio==1.3.1
Requires-Dist: soupsieve==2.5
Requires-Dist: stack-data==0.6.3
Requires-Dist: stevedore==5.2.0
Requires-Dist: symengine==0.11.0
Requires-Dist: sympy==1.14.0
Requires-Dist: terminado==0.18.1
Requires-Dist: threadpoolctl==3.5.0
Requires-Dist: tinycss2==1.3.0
Requires-Dist: tokenizers==0.19.1
Requires-Dist: toolz==1.0.0
Requires-Dist: torch==2.4.1
Requires-Dist: tornado==6.4.1
Requires-Dist: tqdm==4.67.0
Requires-Dist: traitlets==5.14.3
Requires-Dist: transformers==4.44.2
Requires-Dist: types-python-dateutil==2.9.0.20240316
Requires-Dist: types-requests==2.32.4.20250611
Requires-Dist: typing_extensions==4.12.2
Requires-Dist: tzdata==2024.1
Requires-Dist: uri-template==1.3.0
Requires-Dist: urllib3==2.2.2
Requires-Dist: wcwidth==0.2.13
Requires-Dist: webcolors==24.6.0
Requires-Dist: webencodings==0.5.1
Requires-Dist: websocket-client==1.8.0
Requires-Dist: websockets==15.0.1
Requires-Dist: widgetsnbextension==4.0.11
Requires-Dist: wrapt==1.17.0
Requires-Dist: xarray==2025.6.1
Requires-Dist: xxhash==3.5.0
Requires-Dist: yarl==1.20.1
Requires-Dist: zipp==3.23.0
Dynamic: license-file

# C2|Q>: Classical-to-Quantum Software Development Framework

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![Status: Research Prototype](https://img.shields.io/badge/status-research--prototype-orange)]()

---

## Overview

**C2|Q>** is a modular quantum software development framework that automates the full pipeline from classical problem specifications to quantum circuit generation and execution.

This repository accompanies the article:

> **"C2|Q>: A Robust Framework for Bridging Classical and Quantum Software Development"**
> Accepted at *ACM Transactions on Software Engineering and Methodology (TOSEM)* (in press).
> Preprint available on arXiv: https://arxiv.org/abs/2510.02854
---

## Table of Contents
- [Features](#features)
- [Architecture](#architecture)
- [Modular Reuse](#modular-reuse)
- [Getting Started](#getting-started)
- [PyPI Usage](#pypi-usage)
- [Programming Interface](#programming-interface)
- [Running Tests](#running-tests)
- [Reproducibility](#reproducibility)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

## Features
- Submit **standard Python code** describing a problem.
- Automatically **parse**, the problem into **Quantum-Compatible Formats (QCFs)**.
- **Select suitable quantum algorithms** (e.g., QAOA, VQE, Grover).
- **Recommend appropriate quantum devices** across platforms (e.g., IBM, IonQ, Rigetti).
- **Transpile and execute** on hardware or simulators.

---

## Architecture

![Framework Overview](./src/assets/workflow_editted-1.png)

Refer to [`src/assets/workflow_editted-1.png`](src/assets/classiq_flow.pdf) for detailed component diagrams and workflow explanations.

---
## Modular Reuse

For modular reuse, individual components of **C2|Q>** can be accessed independently:

- **Encoder Module**
  - Parser (`parser.py`)
  - QCF translation logic embedded within problem functions (in the `problems/` directory)
  - Circuit generator (`generator.py`)
  - Transpilation layer built on existing SDK interfaces

- **Deployment Module**
  - Hardware recommender (`recommender_engine.py`)
  - Execution interfaces provided by external quantum vendors

- **Decoder Module**
  - Result interpretation logic embedded within each problem-specific function (in the `problems/` directory)
## Getting Started

### Prerequisites
- Python 3.10+
- Git

### Quickstart
```bash
git clone https://github.com/C2-Q/C2Q.git
cd C2Q
pip install -r requirements-lock.txt
pip install -e .
```

## PyPI Usage

Install from PyPI:
```bash
python -m pip install c2q-framework
```

Check the installed CLI:
```bash
c2q-json -h
```

Minimal JSON smoke case:
```json
{
  "family": "ADD",
  "instance": {
    "operands": [1, 1],
    "bits": 2
  }
}
```

Run it:
```bash
c2q-json --input min_add.json
```

## Programming Interface

Use JSON DSL helpers from Python:
```python
from src.json_engine import load_input, normalise_task

task = load_input("min_add.json")
family, instance, params, goal = normalise_task(task)
print(family, instance)
```

Use parser API for Python-code classification:
```python
from src.parser.parser import Parser

# Requires downloaded model files (saved_models_2025_12)
parser = Parser(model_path="src/parser/saved_models_2025_12")
family, data = parser.parse("def add(a,b):\n    return a+b\n\nprint(add(1,2))")
print(family, type(data).__name__)
```

Parser model note:
- The parser model is not stored in GitHub/PyPI due to size.
- Download it from Google Drive and set `C2Q_MODEL_PATH` when needed.

### Running Tests
Test tiers are separated for contributor usability:
- `unit` (default): fast tests, no model required.
- `model`: parser model required.
- `paper`: long-running paper-scale tests.

Default fast tier:
```bash
PYTHONPATH=. pytest
```

Model tier (opt-in):
```bash
C2Q_MODEL_PATH=src/parser/saved_models_2025_12 PYTHONPATH=. pytest -m model -p no:warnings
# or use helper target:
make verify-model
```

One-command diagnostics before testing/reproduction:
```bash
make doctor
```

## Reproducibility

Use the reproducibility pipeline to run key experiments and export final artifacts.

Quick smoke run (small scale, around 4 reports):
```bash
make reproduce-smoke
```

Full paper run (up to 434 reports, time-consuming, roughly 10 hours):
```bash
make reproduce-paper
```

What this pipeline does:
- Creates/updates a local virtual environment and installs dependencies.
- Runs implementation-level validation (`src/validation/implementation_validation.py`).
- Runs algorithmic/structural validation (`src/validation/diversity_validation.py`).
- Generates report artifacts via `src/tests/tests_reports.py`.
- Exports metadata and artifact index under `artifacts/reproduce/{smoke|paper}`.

Input policy:
- Primary CSV: `src/parser/python_programs.csv`
- Backup CSV: `src/parser/data.csv`
- JSON inputs are kept under `src/c2q-dataset/inputs/json/`
- Dataset archive uploaded to Zenodo: [C2Q data record](https://zenodo.org/records/18780001)

Model requirement:
- The parser model is not committed to GitHub because of file size.
- Download the model from Google Drive: [saved_models_2025_12](https://drive.google.com/file/d/11xkJgioQkVdCGykGSLjJD1CcXu76RAIB/view?usp=drive_link)
- Place it at `src/parser/saved_models_2025_12/` (default path), or pass:
  - `MODEL_PATH=/path/to/saved_models_2025_12` for `make reproduce-*`
  - `C2Q_MODEL_PATH=/path/to/saved_models_2025_12` for direct `pytest` / script runs
- Expected model files: `config.json`, `tokenizer_config.json`, and one weight file (`model.safetensors` or `pytorch_model.bin`).
- Integrity checks: `tools/model_checksums.json` stores SHA256 checksums for the distributed model files.
- Collaboration helpers:
  - `make model-check` verifies model files exist and are complete.
  - `make model-download` downloads model archive from Google Drive via `gdown` and installs it (`pip install gdown` if missing).
  - `make doctor` checks Python/LaTeX/model/checksum readiness in one command.
  - Manual mode: `python tools/setup_model.py --archive /path/to/model_archive.zip`

Quick verification commands:
```bash
PYTHONPATH=. pytest
C2Q_MODEL_PATH=src/parser/saved_models_2025_12 PYTHONPATH=. pytest -m model -p no:warnings
MODEL_PATH=src/parser/saved_models_2025_12 make reproduce-smoke
```

---
## Using JSON DSL Input

In addition to Python code snippets, **C2|Q>** supports a lightweight **JSON-based Domain-Specific Language (DSL)** that allows developers to describe quantum problem instances without writing any quantum code.

### 📄 Example Format

Each JSON file must contain two fields:

- `"problem_type"`: the problem class (e.g., `"maxcut"`, `"add"`, `"factor"`)
- `"data"`: problem-specific parameters

Example — MaxCut on a 4-node graph:

```json
{
  "problem_type": "maxcut",
  "data": {
    "nodes": 4,
    "edges": [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2]]
  }
}
```

Supported problem types:
- `maxcut`
- `mis` (Maximum Independent Set)
- `tsp`
- `clique`
- `kcolor`
- `vc` (Minimum Vertex Cover)
- `factor` (Integer Factorization)
- `add` (Integer Addition)
- `mul` (Integer Multiplication)
- `sub` (Integer Subtraction)

Sample files are available in: `src/c2q-dataset/inputs/json/`

---

### 🚀 Running JSON Inputs via CLI

To execute a JSON-defined problem instance using the full C2|Q> workflow, run:

```bash
python -m src.json_engine --input src/c2q-dataset/inputs/json/mis/mis_04.json
```

This command:
- Parses and validates the input
- Classifies the problem and extracts relevant data
- Generates a quantum circuit using the correct algorithm
- Selects the best-fit backend (simulator or hardware)
- Transpiles, executes, and generates reports

---

### 📁 Output

A detailed PDF report will be saved in:

```
./MIS_report.pdf
```

Each report includes:
- Problem summary and visualization
- Quantum circuit diagram
- Device recommendation and parameters
- Execution results (e.g., bitstring outcomes, optimal solution)
- Runtime, fidelity, and cost breakdown

---

## Contributing
We welcome contributions from researchers, developers, and practitioners interested in quantum software engineering.

### Development Workflow
1. **Fork** the repository on GitHub.
2. **Clone** your fork and install dependencies:
   ```bash
   git clone https://github.com/YOUR_USERNAME/C2Q.git
   cd C2Q
   python -m venv venv
   source venv/bin/activate  # On Windows use venv\Scripts\activate
   pip install -r requirements-lock.txt
   make doctor
   make verify
   ```
3. **Create** a feature branch:
   ```bash
   git checkout -b feature/my-feature
   ```
4. **Commit** your changes:
   ```bash
   git add .
   git commit -m "Add explanation / fix bug / implement feature"
   ```
5. **Push** and open a pull request:
   ```bash
   git push origin feature/my-feature
   ```

### Guidelines
- Follow PEP8 coding conventions.
- Document public functions and modules clearly.
- Keep commits focused and descriptive.
- Be respectful in discussions and code reviews.

---

## License
This project is licensed under the [Apache 2.0 License](LICENSE).

## Contact
For research collaboration or substantial contributions, contact the maintainer:

📧 boshuai.ye@oulu.fi

📧 Teemu.Pihkakoski@oulu.fi

📧 arif.khan@oulu.fi (Project Principal Investigator (PI))

📧 matti.silveri@oulu.fi (Project Principal Investigator (PI))
