ksrdp


Nameksrdp JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryProtecting graphs under multiple simultaneous attacks: a heuristic approach
upload_time2024-03-15 11:42:37
maintainer
docs_urlNone
author
requires_python>=3.8
licenseCopyright © 2024 <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords roman domination vns
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # General
This repo contains the implementation, instances and results of the paper 'Protecting graphs under multiple simultaneous attacks: a heuristic approach' by Marko Djukanovic, Stefan Kapunac, Aleksandar Kartelj and Dragan Matic.

Original implementation is in C++ and can be compiled using the ```Makefile```.
We also created Python bindings using the Pybind11 library.
For a quickstart see this [Colab notebook](https://colab.research.google.com/drive/1G_bv9X7vuZu3GsIH1XRfqo79YoIRl-Vn?usp=sharing).

# Installation
```pip install ksrdp```

# Minimal working example
```python
import ksrdp

def test_greedy(in_file_path: str, num_attacks: int) -> None:
    neighbors = ksrdp.read_instance(in_file_path)
    solution, value = ksrdp.greedy_uncovered(neighbors, num_attacks)
    print(f'greedy solution: {solution}, value: {value}')

def test_vns(in_file_path: str, num_attacks: int, vns_params: dict) -> None:
    neighbors = ksrdp.read_instance(in_file_path)
    solution, fitness, iter, end_time, best_found_time = ksrdp.vns(
        neighbors,
        vns_params['comb_take_all_bound'],
        vns_params['comb_intense_max'],
        vns_params['comb_lightweight_max'],
        num_attacks,
        vns_params['time_limit'],
        vns_params['iter_limit'],
        vns_params['k_min'],
        vns_params['k_max'],
        vns_params['move_prob'],
        vns_params['tries'],
        vns_params['num_alternatives_cutoff'],
        # verbose=True,
    )
    print(f'vns solution: {solution}, fitness: {fitness}, iter: {iter}, end_time: {end_time}, best_found_time: {best_found_time}')

def main():
    # help(ksrdp)
    in_file_path = '../instances/random/10_1.txt'
    num_attacks = 2
    test_greedy(in_file_path, num_attacks)
    vns_params = {
        'comb_take_all_bound': 100_000,
        'comb_intense_max': 10_000_000,
        'comb_lightweight_max': 10_000,
        'time_limit': 60,
        'iter_limit': 5000,
        'k_min': 1,
        'k_max': 10,
        'move_prob': 0.5,
        'tries': 10,
        'num_alternatives_cutoff': 100,
    }
    test_vns(in_file_path, num_attacks, vns_params)

if __name__ == '__main__':
    main()
```

# License
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ksrdp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "Roman domination,VNS",
    "author": "",
    "author_email": "Stefan Kapunac <stefankapunac@gmail.com>, Aleksandar Kartelj <aleksandar.kartelj@gmail.com>, Marko Djukanovic <marko.djukanovic@pmf.unibl.org>, Dragan Matic <dragan.matic@pmg.unibl.org>",
    "download_url": "https://files.pythonhosted.org/packages/f4/a4/efe7ad81ca2f4d5d62bbbc21b2def5737daf11718140c4e30e71bc62ef9c/ksrdp-0.0.2.tar.gz",
    "platform": null,
    "description": "# General\nThis repo contains the implementation, instances and results of the paper 'Protecting graphs under multiple simultaneous attacks: a heuristic approach' by Marko Djukanovic, Stefan Kapunac, Aleksandar Kartelj and Dragan Matic.\n\nOriginal implementation is in C++ and can be compiled using the ```Makefile```.\nWe also created Python bindings using the Pybind11 library.\nFor a quickstart see this [Colab notebook](https://colab.research.google.com/drive/1G_bv9X7vuZu3GsIH1XRfqo79YoIRl-Vn?usp=sharing).\n\n# Installation\n```pip install ksrdp```\n\n# Minimal working example\n```python\nimport ksrdp\n\ndef test_greedy(in_file_path: str, num_attacks: int) -> None:\n    neighbors = ksrdp.read_instance(in_file_path)\n    solution, value = ksrdp.greedy_uncovered(neighbors, num_attacks)\n    print(f'greedy solution: {solution}, value: {value}')\n\ndef test_vns(in_file_path: str, num_attacks: int, vns_params: dict) -> None:\n    neighbors = ksrdp.read_instance(in_file_path)\n    solution, fitness, iter, end_time, best_found_time = ksrdp.vns(\n        neighbors,\n        vns_params['comb_take_all_bound'],\n        vns_params['comb_intense_max'],\n        vns_params['comb_lightweight_max'],\n        num_attacks,\n        vns_params['time_limit'],\n        vns_params['iter_limit'],\n        vns_params['k_min'],\n        vns_params['k_max'],\n        vns_params['move_prob'],\n        vns_params['tries'],\n        vns_params['num_alternatives_cutoff'],\n        # verbose=True,\n    )\n    print(f'vns solution: {solution}, fitness: {fitness}, iter: {iter}, end_time: {end_time}, best_found_time: {best_found_time}')\n\ndef main():\n    # help(ksrdp)\n    in_file_path = '../instances/random/10_1.txt'\n    num_attacks = 2\n    test_greedy(in_file_path, num_attacks)\n    vns_params = {\n        'comb_take_all_bound': 100_000,\n        'comb_intense_max': 10_000_000,\n        'comb_lightweight_max': 10_000,\n        'time_limit': 60,\n        'iter_limit': 5000,\n        'k_min': 1,\n        'k_max': 10,\n        'move_prob': 0.5,\n        'tries': 10,\n        'num_alternatives_cutoff': 100,\n    }\n    test_vns(in_file_path, num_attacks, vns_params)\n\nif __name__ == '__main__':\n    main()\n```\n\n# License\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n",
    "bugtrack_url": null,
    "license": "Copyright \u00a9 2024 <copyright holders>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Protecting graphs under multiple simultaneous attacks: a heuristic approach",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/StefanKapunac/ksrdp"
    },
    "split_keywords": [
        "roman domination",
        "vns"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b695345d84183665c07eaebd294f66c4e13c5ff87c615d4465e518b078fcfc8e",
                "md5": "efee2f15f5038716e394873b0a08ae8c",
                "sha256": "1ea01da0a6e6487edebfe36b1898057e66c6f420ed68a284fd33e8493ace7102"
            },
            "downloads": -1,
            "filename": "ksrdp-0.0.2-cp38-cp38-manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "efee2f15f5038716e394873b0a08ae8c",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 119897,
            "upload_time": "2024-03-15T11:42:35",
            "upload_time_iso_8601": "2024-03-15T11:42:35.675794Z",
            "url": "https://files.pythonhosted.org/packages/b6/95/345d84183665c07eaebd294f66c4e13c5ff87c615d4465e518b078fcfc8e/ksrdp-0.0.2-cp38-cp38-manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4a4efe7ad81ca2f4d5d62bbbc21b2def5737daf11718140c4e30e71bc62ef9c",
                "md5": "6f6013d985c51c8caea9545905bfbdd3",
                "sha256": "b86bf31e696114f7f0baf5160984cd4805170901792f612f548d3bb07a17c360"
            },
            "downloads": -1,
            "filename": "ksrdp-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6f6013d985c51c8caea9545905bfbdd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9575,
            "upload_time": "2024-03-15T11:42:37",
            "upload_time_iso_8601": "2024-03-15T11:42:37.454969Z",
            "url": "https://files.pythonhosted.org/packages/f4/a4/efe7ad81ca2f4d5d62bbbc21b2def5737daf11718140c4e30e71bc62ef9c/ksrdp-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-15 11:42:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "StefanKapunac",
    "github_project": "ksrdp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ksrdp"
}
        
Elapsed time: 0.23468s