keras-quadopt


Namekeras-quadopt JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttp://github.com/ulf1/keras-quadopt
SummarySolving quadratic optimization problems with Keras.
upload_time2023-07-10 15:44:33
maintainer
docs_urlNone
authorUlf Hamster
requires_python>=3.7
licenseApache License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/keras-quadopt.svg)](https://badge.fury.io/py/keras-quadopt)
[![PyPi downloads](https://img.shields.io/pypi/dm/keras-quadopt)](https://img.shields.io/pypi/dm/keras-quadopt)
[![DOI](https://zenodo.org/badge/477837694.svg)](https://zenodo.org/badge/latestdoi/477837694)

# keras-quadopt: Solving Constrained Quadratic Optimization Problems with Reverse Automatic Differentation (Keras/TF2)
Solving quadratic optimization problems with resource constraints and upper boundaries using TF2/Keras.

## Usage

```py
import tensorflow as tf
import keras_quadopt as kqp
import time

# goodness scores
good = tf.constant([.51, .53, .55, .57])

# similarity matrices
simi_1 = tf.constant([
    [1, .9, .8, .7],
    [.9, 1, .6, .5],
    [.8, .6, 1, .4],
    [.7, .5, .4, 1],
])

simi_2 = tf.constant([
    [1, .7, .8, .3],
    [.7, 1, .4, .2],
    [.8, .4, 1, .6],
    [.3, .2, .6, 1],
])

# preference parameters
lam = 0.4
beta_1 = 0.25
beta_2 = 0.75

# compute weights
simi = kqp.aggregate_matrices(simi_1, beta_1, simi_2, beta_2)

start = time.time()
wbest, fbest = kqp.get_weights(good, simi, lam)
print(f"elapsed: {time.time() - start}")
```




## Appendix

### Installation
The `keras-quadopt` [git repo](http://github.com/ulf1/keras-quadopt) is available as [PyPi package](https://pypi.org/project/keras-quadopt)

```sh
pip install keras-quadopt
pip install git+ssh://git@github.com/ulf1/keras-quadopt.git
```

### Install a virtual environment

```sh
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt --no-cache-dir
pip install -r requirements-dev.txt --no-cache-dir
```

(If your git repo is stored in a folder with whitespaces, then don't use the subfolder `.venv`. Use an absolute path without whitespaces.)

### Python commands

* Check syntax: `flake8 --ignore=F401 --exclude=$(grep -v '^#' .gitignore | xargs | sed -e 's/ /,/g')`
* Run Unit Tests: `PYTHONPATH=. pytest`

Publish

```sh
python setup.py sdist 
twine upload -r pypi dist/*
```

### Clean up 

```sh
find . -type f -name "*.pyc" | xargs rm
find . -type d -name "__pycache__" | xargs rm -r
rm -r .pytest_cache
rm -r .venv
```


### Support
Please [open an issue](https://github.com/ulf1/keras-quadopt/issues/new) for support.


### Contributing
Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/ulf1/keras-quadopt/compare/).

### Acknowledgements
The "Evidence" project was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) - [433249742](https://gepris.dfg.de/gepris/projekt/433249742) (GU 798/27-1; GE 1119/11-1).

### Maintenance
- till 31.Aug.2023 (v0.1.0) the code repository was maintained within the DFG project [433249742](https://gepris.dfg.de/gepris/projekt/433249742)
- since 01.Sep.2023 (v0.2.0) the code repository is maintained by Ulf Hamster.



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/ulf1/keras-quadopt",
    "name": "keras-quadopt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ulf Hamster",
    "author_email": "554c46@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/17/7322cbd5feac64a05af556131769bac01ef10a563e60d099ee12ee052e33/keras-quadopt-0.2.0.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/keras-quadopt.svg)](https://badge.fury.io/py/keras-quadopt)\n[![PyPi downloads](https://img.shields.io/pypi/dm/keras-quadopt)](https://img.shields.io/pypi/dm/keras-quadopt)\n[![DOI](https://zenodo.org/badge/477837694.svg)](https://zenodo.org/badge/latestdoi/477837694)\n\n# keras-quadopt: Solving Constrained Quadratic Optimization Problems with Reverse Automatic Differentation (Keras/TF2)\nSolving quadratic optimization problems with resource constraints and upper boundaries using TF2/Keras.\n\n## Usage\n\n```py\nimport tensorflow as tf\nimport keras_quadopt as kqp\nimport time\n\n# goodness scores\ngood = tf.constant([.51, .53, .55, .57])\n\n# similarity matrices\nsimi_1 = tf.constant([\n    [1, .9, .8, .7],\n    [.9, 1, .6, .5],\n    [.8, .6, 1, .4],\n    [.7, .5, .4, 1],\n])\n\nsimi_2 = tf.constant([\n    [1, .7, .8, .3],\n    [.7, 1, .4, .2],\n    [.8, .4, 1, .6],\n    [.3, .2, .6, 1],\n])\n\n# preference parameters\nlam = 0.4\nbeta_1 = 0.25\nbeta_2 = 0.75\n\n# compute weights\nsimi = kqp.aggregate_matrices(simi_1, beta_1, simi_2, beta_2)\n\nstart = time.time()\nwbest, fbest = kqp.get_weights(good, simi, lam)\nprint(f\"elapsed: {time.time() - start}\")\n```\n\n\n\n\n## Appendix\n\n### Installation\nThe `keras-quadopt` [git repo](http://github.com/ulf1/keras-quadopt) is available as [PyPi package](https://pypi.org/project/keras-quadopt)\n\n```sh\npip install keras-quadopt\npip install git+ssh://git@github.com/ulf1/keras-quadopt.git\n```\n\n### Install a virtual environment\n\n```sh\npython3 -m venv .venv\nsource .venv/bin/activate\npip install --upgrade pip\npip install -r requirements.txt --no-cache-dir\npip install -r requirements-dev.txt --no-cache-dir\n```\n\n(If your git repo is stored in a folder with whitespaces, then don't use the subfolder `.venv`. Use an absolute path without whitespaces.)\n\n### Python commands\n\n* Check syntax: `flake8 --ignore=F401 --exclude=$(grep -v '^#' .gitignore | xargs | sed -e 's/ /,/g')`\n* Run Unit Tests: `PYTHONPATH=. pytest`\n\nPublish\n\n```sh\npython setup.py sdist \ntwine upload -r pypi dist/*\n```\n\n### Clean up \n\n```sh\nfind . -type f -name \"*.pyc\" | xargs rm\nfind . -type d -name \"__pycache__\" | xargs rm -r\nrm -r .pytest_cache\nrm -r .venv\n```\n\n\n### Support\nPlease [open an issue](https://github.com/ulf1/keras-quadopt/issues/new) for support.\n\n\n### Contributing\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/ulf1/keras-quadopt/compare/).\n\n### Acknowledgements\nThe \"Evidence\" project was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) - [433249742](https://gepris.dfg.de/gepris/projekt/433249742) (GU 798/27-1; GE 1119/11-1).\n\n### Maintenance\n- till 31.Aug.2023 (v0.1.0) the code repository was maintained within the DFG project [433249742](https://gepris.dfg.de/gepris/projekt/433249742)\n- since 01.Sep.2023 (v0.2.0) the code repository is maintained by Ulf Hamster.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Solving quadratic optimization problems with Keras.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "http://github.com/ulf1/keras-quadopt"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6177322cbd5feac64a05af556131769bac01ef10a563e60d099ee12ee052e33",
                "md5": "dce4977a4487cfdb57b0dfbd6971786f",
                "sha256": "b19950ba144ba73a8c146e8ab36ceeab901033c2e50ef7752fef5637c328f885"
            },
            "downloads": -1,
            "filename": "keras-quadopt-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dce4977a4487cfdb57b0dfbd6971786f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8556,
            "upload_time": "2023-07-10T15:44:33",
            "upload_time_iso_8601": "2023-07-10T15:44:33.974229Z",
            "url": "https://files.pythonhosted.org/packages/c6/17/7322cbd5feac64a05af556131769bac01ef10a563e60d099ee12ee052e33/keras-quadopt-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-10 15:44:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ulf1",
    "github_project": "keras-quadopt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "keras-quadopt"
}
        
Elapsed time: 2.16849s