# crispyn
CRIteria Significance determining in PYthoN - The Python 3 Library for determining criteria weights for MCDA methods.
This library provides 15 criteria weighting methods: 11 objective, 4 subjective and a Stochastic Multicriteria Acceptability Analysis Method (SMAA)
that does not require criteria weights.
## Installation
```
pip install crispyn
```
## Usage
`crispyn` is the Python 3 package that provides 15 weighting methods: 11 objective and 4 subjective, which can be used to determine criteria weights for
solving multi-criteria problems with Multi-Criteria Decision Analysis (MCDA) methods. The first step is providing the decision matrix `matrix` with alternatives'
performance values. The decision matrix is two-dimensional and contains m alternatives in rows and n criteria in columns. You also have to provide
criteria types `types`. Criteria types are equal to 1 for profit criteria and -1 for cost criteria. Then you have to calculate criteria weights
using the weighting method chosen from `crispyn.weighting_methods` submodule. Depending on the chosen objective method, you have to provide `matrix` or `matrix` and `types` as
weighting method arguments. In the case of subjective weighting methods, provided parameters are different, such as ordered criteria indexes and significance values assigned by the decision-maker to criteria. It is detailed in Usage in the documentation. Then, you can evaluate alternatives from the decision matrix using the VIKOR method
from `crispyn.mcda_methods` module. The VIKOR method returns a vector with preference values `pref` assigned to alternatives. To rank alternatives
according to VIKOR preference values, you have to sort them in ascending order because, in the VIKOR method, the best alternative has the lowest
preference value. The alternatives are ranked using the `rank_preferences` method provided in the `crispyn.additions` submodule. Parameter `reverse = False` means that alternatives
are sorted in ascending order. Here is an example of using the Entropy weighting method `entropy_weighting` for determining criteria weights and
the VIKOR method to calculate preference values:
```python
import numpy as np
from crispyn.mcda_methods import VIKOR
from crispyn import weighting_methods as mcda_weights
from crispyn import normalizations as norms
from crispyn.additions import rank_preferences
matrix = np.array([[256, 8, 41, 1.6, 1.77, 7347.16],
[256, 8, 32, 1.0, 1.8, 6919.99],
[256, 8, 53, 1.6, 1.9, 8400],
[256, 8, 41, 1.0, 1.75, 6808.9],
[512, 8, 35, 1.6, 1.7, 8479.99],
[256, 4, 35, 1.6, 1.7, 7499.99]])
types = np.array([1, 1, 1, 1, -1, -1])
weights = mcda_weights.entropy_weighting(matrix)
# Create the VIKOR method object
vikor = VIKOR(normalization_method=norms.minmax_normalization)
# Calculate alternatives preference function values with VIKOR method
pref = vikor(matrix, weights, types)
# Rank alternatives according to preference values
rank = rank_preferences(pref, reverse = False)
```
### Stochastic Multicriteria Acceptability Analysis Method (SMAA)
Additionally, the Crispyn library provides the Stochastic Multicriteria Acceptability Analysis Method (SMAA), which, combined
with the VIKOR method, is designed to solve decision problems when there is a lack of information about criteria preferences (unknown criteria
weights). This method is implemented in the class named `VIKOR_SMAA`. This method requires only the decision matrix, a matrix with
weight vectors and criteria types provided in one call. The number of weight vectors is equal to the number of iterations. First, the matrix with
weight vectors must be generated with `_generate_weights` method provided by the `VIKOR_SMAA` class. In this method, uniform distributed weights
are generated by Monte Carlo simulation. The results of the provided `VIKOR_SMAA` method are Rank acceptability index, Central weight vector, and
Rank scores.
### Rank acceptability index
The ranking is built based on generated weights. Next, counters for corresponding ranks in relation to the alternatives are increased.
After a given number of iterations, the rank acceptability indexes are obtained by dividing the counters by the number of iterations.
Rank acceptability index shows the share of different scores placing an alternative in a given rank.
### Central weight vector
The central weights are calculated similarly. In each iteration, the weight vector is added to its ‘summed weight vector’ when the
alternative gets the rank. Next, this vector is divided by the number of iterations to get the central weight vector. The central weight
vector describes the preferences of a typical decision-maker, supporting this alternative with the assumed preference model. It allows the
decision-maker to see what criteria preferences result in the best evaluation of given alternatives.
### Rank scores
Final ranking of alternatives provided by the ranking function, which adds to each alternative value of 1 each time it has better preference
values than each other.
Here is example of use of the `VIKOR_SMAA` method:
```python
from crispyn.mcda_methods import VIKOR_SMAA
# criteria number
n = matrix.shape[1]
# SMAA iterations number
iterations = 10000
# create the VIKOR_SMAA method object
vikor_smaa = VIKOR_SMAA()
# generate multiple weight vectors in matrix
weight_vectors = vikor_smaa._generate_weights(n, iterations)
# run the vikor_smaa method
rank_acceptability_index, central_weight_vector, rank_scores = vikor_smaa(matrix, weight_vectors, types)
```
## License
`crispyn` was created by Aleksandra Bączkiewicz. It is licensed under the terms of the MIT license.
## Documentation
Documentation of this library with instruction for installation and usage is
provided [here](https://crispyn.readthedocs.io/en/latest/)
Raw data
{
"_id": null,
"home_page": "https://github.com/energyinpython/crispyn",
"name": "crispyn",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.4",
"maintainer_email": "",
"keywords": "",
"author": "Aleksandra B\u0105czkiewicz",
"author_email": "aleksandra.baczkiewicz@phd.usz.edu.pl",
"download_url": "https://files.pythonhosted.org/packages/94/8a/2ea57cfe4f696c88f86985cfd764354f0f3ca4411e098cdea12517c9e27e/crispyn-0.0.6.tar.gz",
"platform": null,
"description": "# crispyn\r\nCRIteria Significance determining in PYthoN - The Python 3 Library for determining criteria weights for MCDA methods.\r\n\r\nThis library provides 15 criteria weighting methods: 11 objective, 4 subjective and a Stochastic Multicriteria Acceptability Analysis Method (SMAA) \r\nthat does not require criteria weights.\r\n\r\n## Installation\r\n\r\n```\r\npip install crispyn\r\n```\r\n\r\n## Usage\r\n\r\n`crispyn` is the Python 3 package that provides 15 weighting methods: 11 objective and 4 subjective, which can be used to determine criteria weights for \r\nsolving multi-criteria problems with Multi-Criteria Decision Analysis (MCDA) methods. The first step is providing the decision matrix `matrix` with alternatives' \r\nperformance values. The decision matrix is two-dimensional and contains m alternatives in rows and n criteria in columns. You also have to provide \r\ncriteria types `types`. Criteria types are equal to 1 for profit criteria and -1 for cost criteria. Then you have to calculate criteria weights \r\nusing the weighting method chosen from `crispyn.weighting_methods` submodule. Depending on the chosen objective method, you have to provide `matrix` or `matrix` and `types` as \r\nweighting method arguments. In the case of subjective weighting methods, provided parameters are different, such as ordered criteria indexes and significance values assigned by the decision-maker to criteria. It is detailed in Usage in the documentation. Then, you can evaluate alternatives from the decision matrix using the VIKOR method \r\nfrom `crispyn.mcda_methods` module. The VIKOR method returns a vector with preference values `pref` assigned to alternatives. To rank alternatives \r\naccording to VIKOR preference values, you have to sort them in ascending order because, in the VIKOR method, the best alternative has the lowest \r\npreference value. The alternatives are ranked using the `rank_preferences` method provided in the `crispyn.additions` submodule. Parameter `reverse = False` means that alternatives \r\nare sorted in ascending order. Here is an example of using the Entropy weighting method `entropy_weighting` for determining criteria weights and \r\nthe VIKOR method to calculate preference values:\r\n\r\n```python\r\nimport numpy as np\r\nfrom crispyn.mcda_methods import VIKOR\r\nfrom crispyn import weighting_methods as mcda_weights\r\nfrom crispyn import normalizations as norms\r\nfrom crispyn.additions import rank_preferences\r\n\r\nmatrix = np.array([[256, 8, 41, 1.6, 1.77, 7347.16],\r\n[256, 8, 32, 1.0, 1.8, 6919.99],\r\n[256, 8, 53, 1.6, 1.9, 8400],\r\n[256, 8, 41, 1.0, 1.75, 6808.9],\r\n[512, 8, 35, 1.6, 1.7, 8479.99],\r\n[256, 4, 35, 1.6, 1.7, 7499.99]])\r\n\r\ntypes = np.array([1, 1, 1, 1, -1, -1])\r\nweights = mcda_weights.entropy_weighting(matrix)\r\n\r\n# Create the VIKOR method object\r\nvikor = VIKOR(normalization_method=norms.minmax_normalization)\r\n# Calculate alternatives preference function values with VIKOR method\r\npref = vikor(matrix, weights, types)\r\n# Rank alternatives according to preference values\r\nrank = rank_preferences(pref, reverse = False)\r\n```\r\n\r\n### Stochastic Multicriteria Acceptability Analysis Method (SMAA)\r\n\r\nAdditionally, the Crispyn library provides the Stochastic Multicriteria Acceptability Analysis Method (SMAA), which, combined \r\nwith the VIKOR method, is designed to solve decision problems when there is a lack of information about criteria preferences (unknown criteria \r\nweights). This method is implemented in the class named `VIKOR_SMAA`. This method requires only the decision matrix, a matrix with \r\nweight vectors and criteria types provided in one call. The number of weight vectors is equal to the number of iterations. First, the matrix with\r\nweight vectors must be generated with `_generate_weights` method provided by the `VIKOR_SMAA` class. In this method, uniform distributed weights \r\nare generated by Monte Carlo simulation. The results of the provided `VIKOR_SMAA` method are Rank acceptability index, Central weight vector, and \r\nRank scores.\r\n\r\n### Rank acceptability index\r\n\r\nThe ranking is built based on generated weights. Next, counters for corresponding ranks in relation to the alternatives are increased. \r\nAfter a given number of iterations, the rank acceptability indexes are obtained by dividing the counters by the number of iterations. \r\nRank acceptability index shows the share of different scores placing an alternative in a given rank. \r\n\r\n### Central weight vector\r\n\r\nThe central weights are calculated similarly. In each iteration, the weight vector is added to its \u2018summed weight vector\u2019 when the \r\nalternative gets the rank. Next, this vector is divided by the number of iterations to get the central weight vector. The central weight \r\nvector describes the preferences of a typical decision-maker, supporting this alternative with the assumed preference model. It allows the \r\ndecision-maker to see what criteria preferences result in the best evaluation of given alternatives.\r\n\r\n### Rank scores\r\n\r\nFinal ranking of alternatives provided by the ranking function, which adds to each alternative value of 1 each time it has better preference \r\nvalues than each other.\r\n\r\nHere is example of use of the `VIKOR_SMAA` method:\r\n\r\n```python\r\nfrom crispyn.mcda_methods import VIKOR_SMAA\r\n\r\n# criteria number\r\nn = matrix.shape[1]\r\n# SMAA iterations number\r\niterations = 10000\r\n\r\n# create the VIKOR_SMAA method object\r\nvikor_smaa = VIKOR_SMAA()\r\n\r\n# generate multiple weight vectors in matrix\r\nweight_vectors = vikor_smaa._generate_weights(n, iterations)\r\n\r\n# run the vikor_smaa method\r\nrank_acceptability_index, central_weight_vector, rank_scores = vikor_smaa(matrix, weight_vectors, types)\r\n```\r\n\r\n## License\r\n\r\n`crispyn` was created by Aleksandra B\u0105czkiewicz. It is licensed under the terms of the MIT license.\r\n\r\n## Documentation\r\n\r\nDocumentation of this library with instruction for installation and usage is \r\nprovided [here](https://crispyn.readthedocs.io/en/latest/)\r\n",
"bugtrack_url": null,
"license": "",
"summary": "CRIteria Significance determining in PYthoN - The Python 3 Library for determining criteria weights for MCDA methods.",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/energyinpython/crispyn"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "98967182ae547d67a090021a26016ea8ada5537b26b28eaa731c5ba34b06ea47",
"md5": "b120346bc692723c9163be04912f942a",
"sha256": "9e9730807e7df03e9f7779df0a458f2b13c89b3a89a4b7c77f671c859652be33"
},
"downloads": -1,
"filename": "crispyn-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b120346bc692723c9163be04912f942a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.4",
"size": 16159,
"upload_time": "2023-09-13T14:41:57",
"upload_time_iso_8601": "2023-09-13T14:41:57.790894Z",
"url": "https://files.pythonhosted.org/packages/98/96/7182ae547d67a090021a26016ea8ada5537b26b28eaa731c5ba34b06ea47/crispyn-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "948a2ea57cfe4f696c88f86985cfd764354f0f3ca4411e098cdea12517c9e27e",
"md5": "5b80fbe0baf403eb88e215b9d8045328",
"sha256": "bff7761d5d25319f329a5062fc10473b879b1617514af1db5ec8f002fedb265a"
},
"downloads": -1,
"filename": "crispyn-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "5b80fbe0baf403eb88e215b9d8045328",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.4",
"size": 20947,
"upload_time": "2023-09-13T14:41:59",
"upload_time_iso_8601": "2023-09-13T14:41:59.724051Z",
"url": "https://files.pythonhosted.org/packages/94/8a/2ea57cfe4f696c88f86985cfd764354f0f3ca4411e098cdea12517c9e27e/crispyn-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-13 14:41:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "energyinpython",
"github_project": "crispyn",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "matplotlib",
"specs": [
[
"==",
"3.7.1"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.24.2"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"1.5.3"
]
]
},
{
"name": "scipy",
"specs": [
[
"==",
"1.11.2"
]
]
},
{
"name": "seaborn",
"specs": [
[
"==",
"0.12.2"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"65.5.0"
]
]
}
],
"lcname": "crispyn"
}