Skip to main content

A Python library implementing the Carousel Greedy Algorithm.

Project description

Py Carousel Greedy Logo

Py Carousel Greedy

A modular and user-friendly Python implementation of the Carousel Greedy algorithm.

py-carouselgreedy is the first open-source Python library designed specifically for the Carousel Greedy algorithm, a flexible metaheuristic for solving a wide variety of combinatorial optimization problems. The library was developed with a focus on ease of use, modularity, and integration into experimental pipelines.

📄 Introduced in the Conference Paper:
Carousel Greedy: From Drone Photogrammetry to Social Network Analysis, A Systematic Survey and the First Open-Source Python Library
Raffaele Dragone, Carmine Cerrone, Bruce L. Golden
Presented at ODS 2025


✨ Features

  • Easy to use: define only a feasibility function and a greedy function.
  • Modular and lightweight: no external dependencies.
  • Adaptable to any discrete optimization problem (e.g. vertex cover, knapsack, influence maximization).
  • Includes ready-to-use examples for common problems.
  • Fully documented and tested.

🚀 Installation

Install from PyPI:

pip install py_carouselgreedy

🔧 Usage Example

from py_carouselgreedy import carousel_greedy

def my_feasibility(cg_instance, solution):
    # Return True if solution is feasible
    return ...

def my_greedy(cg_instance, solution, candidate):
    # Return a score for the candidate
    return ...

cg = carousel_greedy(
    candidate_elements=[...],
    test_feasibility=my_feasibility,
    greedy_function=my_greedy
)

best_solution = cg.minimize(alpha=10, beta=0.2)

📂 Examples

You can find full working examples in the examples/ folder:

  • minimum_vertex_cover.py
  • minimum_label_spanning_tree.py

Each example shows how to define a problem-specific greedy function and feasibility check using NetworkX or standard Python structures.


📖 Algorithm Overview

The Carousel Greedy algorithm is composed of four phases:

  1. Greedy Construction – builds an initial solution.
  2. Removal Phase – removes a portion of it (based on β).
  3. Iterative Phase – removes and adds elements (based on α).
  4. Completion Phase – restores feasibility if necessary.

Users only need to define two functions:

  • greedy_function(cg_instance, solution, candidate)
  • test_feasibility(cg_instance, solution)

🧑‍🔬 Citation

If you use this library in your research, please cite:

@inproceedings{dragone2025carousel,
  title={Carousel Greedy: From Drone Photogrammetry to Social Network Analysis, A Systematic Survey and the First Open-Source Python Library},
  author={Dragone, Raffaele and Cerrone, Carmine and Golden, Bruce L.},
  booktitle={Optimization and Decision Science (ODS)},
  year={2025}
}

📬 Contact & Contributions

Pull requests are welcome. For major changes, please open an issue first.

Questions? Suggestions? Reach out to:

  • raffaele.dragone@edu.unige.it

📄 License

This project is licensed under the BSD 3-Clause License.
See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_carouselgreedy-0.0.5.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_carouselgreedy-0.0.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file py_carouselgreedy-0.0.5.tar.gz.

File metadata

  • Download URL: py_carouselgreedy-0.0.5.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for py_carouselgreedy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 b6948f8d21c8497f5189795e1f1865f4a258568353cee49be6bf5a5f0e12ec77
MD5 aac156206fe89727265740d7b9c5f135
BLAKE2b-256 9fdc94d94f2d75c72e2b801b767d307ca07225aacbada4cd82957c788e850c42

See more details on using hashes here.

File details

Details for the file py_carouselgreedy-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for py_carouselgreedy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7a319da49e94a1a802472e7f0f21f9122627188a724049060bb21e801030e35c
MD5 aee2521fe7b104211bc86cb257acb501
BLAKE2b-256 a63600cf5b06706c16f4fe14ea6cd78d1cbfab3b34b188138b8716a0e55dd39e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page