znum 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- znum-0.1.0/.github/workflows/ci.yml +23 -0
- znum-0.1.0/.github/workflows/publish.yml +37 -0
- znum-0.1.0/.gitignore +34 -0
- znum-0.1.0/PKG-INFO +107 -0
- znum-0.1.0/README.md +78 -0
- znum-0.1.0/pyproject.toml +61 -0
- znum-0.1.0/requirements.txt +4 -0
- znum-0.1.0/tests/__init__.py +1 -0
- znum-0.1.0/tests/test_arithmetic.py +1139 -0
- znum-0.1.0/tests/test_comparison.py +759 -0
- znum-0.1.0/tests/test_mcdm.py +724 -0
- znum-0.1.0/znum/__init__.py +46 -0
- znum-0.1.0/znum/core.py +152 -0
- znum-0.1.0/znum/dist.py +183 -0
- znum-0.1.0/znum/exceptions.py +27 -0
- znum-0.1.0/znum/math_ops.py +203 -0
- znum-0.1.0/znum/promethee.py +114 -0
- znum-0.1.0/znum/sort.py +119 -0
- znum-0.1.0/znum/topsis.py +84 -0
- znum-0.1.0/znum/utils.py +80 -0
- znum-0.1.0/znum/valid.py +71 -0
- znum-0.1.0/znum/vikor.py +97 -0
- znum-0.1.0/znum/ztype.py +42 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: pip install -e ".[dev]"
|
|
22
|
+
- name: Run tests
|
|
23
|
+
run: pytest -v
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- name: Install dependencies
|
|
16
|
+
run: |
|
|
17
|
+
pip install -e ".[dev]"
|
|
18
|
+
- name: Run tests
|
|
19
|
+
run: pytest
|
|
20
|
+
|
|
21
|
+
publish:
|
|
22
|
+
needs: test
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
environment: pypi
|
|
25
|
+
permissions:
|
|
26
|
+
id-token: write # Required for trusted publishing
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.12"
|
|
32
|
+
- name: Install build tools
|
|
33
|
+
run: pip install build
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: python -m build
|
|
36
|
+
- name: Publish to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
znum-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Byte-compiled files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
ENV/
|
|
16
|
+
|
|
17
|
+
# IDE
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
*.swp
|
|
21
|
+
*.swo
|
|
22
|
+
|
|
23
|
+
# OS
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
|
|
27
|
+
# Testing
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
.coverage
|
|
30
|
+
htmlcov/
|
|
31
|
+
|
|
32
|
+
# Temporary files
|
|
33
|
+
temp/
|
|
34
|
+
*.xlsx
|
znum-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: znum
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Z-number data type for fuzzy arithmetic and multi-criteria decision making (TOPSIS, VIKOR, PROMETHEE)
|
|
5
|
+
Project-URL: Homepage, https://github.com/maganuriyev/znum
|
|
6
|
+
Project-URL: Repository, https://github.com/maganuriyev/znum
|
|
7
|
+
Project-URL: Issues, https://github.com/maganuriyev/znum/issues
|
|
8
|
+
Author-email: Maga Nuriyev <maganuriyev@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: fuzzy-arithmetic,fuzzy-number,mcdm,multi-criteria-decision-making,optimization,promethee,topsis,vikor,z-number
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: numpy>=1.24.0
|
|
25
|
+
Requires-Dist: scipy>=1.10.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# Znum
|
|
31
|
+
|
|
32
|
+
A Python library for Z-number arithmetic and multi-criteria decision making (MCDM).
|
|
33
|
+
|
|
34
|
+
A Z-number is a fuzzy number with two components:
|
|
35
|
+
- **A**: The main fuzzy set values (restriction on values)
|
|
36
|
+
- **B**: The confidence/belief values (reliability of A)
|
|
37
|
+
|
|
38
|
+
Znum supports full mathematical operations (addition, subtraction, multiplication, division, power), comparison operators, and includes implementations of TOPSIS, VIKOR, and PROMETHEE optimization methods.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install znum
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from znum import Znum
|
|
50
|
+
|
|
51
|
+
# Create Z-numbers
|
|
52
|
+
z1 = Znum([1, 2, 3, 4], [0.1, 0.2, 0.3, 0.4])
|
|
53
|
+
z2 = Znum([2, 4, 8, 10], [0.5, 0.6, 0.7, 0.8])
|
|
54
|
+
|
|
55
|
+
# Arithmetic operations
|
|
56
|
+
z3 = z1 + z2
|
|
57
|
+
z4 = z1 * z2
|
|
58
|
+
z5 = z1 - z2
|
|
59
|
+
z6 = z1 / z2
|
|
60
|
+
|
|
61
|
+
# Comparison
|
|
62
|
+
print(z1 > z2) # False
|
|
63
|
+
print(z1 < z2) # True
|
|
64
|
+
|
|
65
|
+
# Power
|
|
66
|
+
z7 = z1 ** 2
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## MCDM Methods
|
|
70
|
+
|
|
71
|
+
### TOPSIS
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from znum import Znum, Topsis, Beast
|
|
75
|
+
|
|
76
|
+
# Create weights, alternatives, and criteria types
|
|
77
|
+
weights = [Znum([0.2, 0.3, 0.4, 0.5], [0.1, 0.2, 0.3, 0.4])]
|
|
78
|
+
alternatives = [[Znum([7, 8, 9, 10], [0.6, 0.7, 0.8, 0.9])]]
|
|
79
|
+
criteria_types = [Beast.CriteriaType.BENEFIT]
|
|
80
|
+
|
|
81
|
+
table = [weights, *alternatives, criteria_types]
|
|
82
|
+
result = Topsis.solver_main(table)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### PROMETHEE
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from znum import Znum, Promethee, Beast
|
|
89
|
+
|
|
90
|
+
table = [weights, *alternatives, criteria_types]
|
|
91
|
+
promethee = Promethee(table)
|
|
92
|
+
sorted_alternatives = promethee.solve()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Install dependencies
|
|
99
|
+
pip install -e ".[dev]"
|
|
100
|
+
|
|
101
|
+
# Run tests
|
|
102
|
+
pytest
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|
znum-0.1.0/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Znum
|
|
2
|
+
|
|
3
|
+
A Python library for Z-number arithmetic and multi-criteria decision making (MCDM).
|
|
4
|
+
|
|
5
|
+
A Z-number is a fuzzy number with two components:
|
|
6
|
+
- **A**: The main fuzzy set values (restriction on values)
|
|
7
|
+
- **B**: The confidence/belief values (reliability of A)
|
|
8
|
+
|
|
9
|
+
Znum supports full mathematical operations (addition, subtraction, multiplication, division, power), comparison operators, and includes implementations of TOPSIS, VIKOR, and PROMETHEE optimization methods.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install znum
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from znum import Znum
|
|
21
|
+
|
|
22
|
+
# Create Z-numbers
|
|
23
|
+
z1 = Znum([1, 2, 3, 4], [0.1, 0.2, 0.3, 0.4])
|
|
24
|
+
z2 = Znum([2, 4, 8, 10], [0.5, 0.6, 0.7, 0.8])
|
|
25
|
+
|
|
26
|
+
# Arithmetic operations
|
|
27
|
+
z3 = z1 + z2
|
|
28
|
+
z4 = z1 * z2
|
|
29
|
+
z5 = z1 - z2
|
|
30
|
+
z6 = z1 / z2
|
|
31
|
+
|
|
32
|
+
# Comparison
|
|
33
|
+
print(z1 > z2) # False
|
|
34
|
+
print(z1 < z2) # True
|
|
35
|
+
|
|
36
|
+
# Power
|
|
37
|
+
z7 = z1 ** 2
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## MCDM Methods
|
|
41
|
+
|
|
42
|
+
### TOPSIS
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from znum import Znum, Topsis, Beast
|
|
46
|
+
|
|
47
|
+
# Create weights, alternatives, and criteria types
|
|
48
|
+
weights = [Znum([0.2, 0.3, 0.4, 0.5], [0.1, 0.2, 0.3, 0.4])]
|
|
49
|
+
alternatives = [[Znum([7, 8, 9, 10], [0.6, 0.7, 0.8, 0.9])]]
|
|
50
|
+
criteria_types = [Beast.CriteriaType.BENEFIT]
|
|
51
|
+
|
|
52
|
+
table = [weights, *alternatives, criteria_types]
|
|
53
|
+
result = Topsis.solver_main(table)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### PROMETHEE
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from znum import Znum, Promethee, Beast
|
|
60
|
+
|
|
61
|
+
table = [weights, *alternatives, criteria_types]
|
|
62
|
+
promethee = Promethee(table)
|
|
63
|
+
sorted_alternatives = promethee.solve()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Install dependencies
|
|
70
|
+
pip install -e ".[dev]"
|
|
71
|
+
|
|
72
|
+
# Run tests
|
|
73
|
+
pytest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "znum"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Z-number data type for fuzzy arithmetic and multi-criteria decision making (TOPSIS, VIKOR, PROMETHEE)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Maga Nuriyev", email = "maganuriyev@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"z-number",
|
|
17
|
+
"fuzzy-number",
|
|
18
|
+
"fuzzy-arithmetic",
|
|
19
|
+
"mcdm",
|
|
20
|
+
"multi-criteria-decision-making",
|
|
21
|
+
"topsis",
|
|
22
|
+
"vikor",
|
|
23
|
+
"promethee",
|
|
24
|
+
"optimization",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Science/Research",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
38
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
39
|
+
]
|
|
40
|
+
dependencies = [
|
|
41
|
+
"numpy>=1.24.0",
|
|
42
|
+
"scipy>=1.10.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
dev = [
|
|
47
|
+
"pytest>=7.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/maganuriyev/znum"
|
|
52
|
+
Repository = "https://github.com/maganuriyev/znum"
|
|
53
|
+
Issues = "https://github.com/maganuriyev/znum/issues"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.wheel]
|
|
56
|
+
packages = ["znum"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
testpaths = ["tests"]
|
|
60
|
+
python_files = ["test_*.py"]
|
|
61
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# znum test suite
|