Solve global optimization problems.
Project description
How to use the package.
To use the package you need to provide four things to the PO methods
- Optimization function, which the is function that you are trying to optimize. Our method can cater to constraints as well by using static penalty. An example is given below.
- Number of dimensions of the problem
- Lower boundary
- Upper boundary
Note The boundaries can be scalars or arrays. The example below uses arrays because the boundaries are different for different variables, if they are same, use scalar values.
import numpy as np
import matplotlib.pyplot as plt
## optimization function.
def TCSD(x: np.ndarray):
x1 = x[0]
x2 = x[1]
x3 = x[2]
z = (x3 + 2) * x2 * (x1 * x1)
c = [
1 - ((x2 * x2 * x2 * x3)) / (71785 * x1 * x1 * x1 * x1),
((4 * x2 * x2 - (x1 * x2)) / (12566 * (x2 * x1 * x1 * x1 - (x1 ** 4))))
+ (1 / (5108 * x1 * x1))
- 1,
1 - ((140.45 * x1) / (x2 * x2 * x3)),
((x1 + x2) / 1.5) - 1,
]
cmaxes = [x if x > 0 else 0 for x in c]
c_np_array = np.array(cmaxes)
c_np_array = np.power(c_np_array, 2)
c_np_array = (10 ** 10) * c_np_array
sumofarray = np.sum(c_np_array)
return z + sumofarray
scores = [0 for x in range(RUNS)]
for i in range(RUNS):
# matlab's rng("shuffle") seeds with the system's default time, python's random.seed has that as default val
np.random.seed(1)
# implement political optimizer.
objectiveFunction = TCSD
dim = 3 # dimentions
lb = [0.05, 0.25, 2.00] # upper boundary
ub = [2.00, 1.30, 15.00] # lower boundary
(leaderScore, leaderPosition, convergenceCurve) = PO(lb, ub, dim, objectiveFunction)
print(leaderScore)
print(leaderPosition)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enhanced-political-optimizer-1.0.0.tar.gz.
File metadata
- Download URL: enhanced-political-optimizer-1.0.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14353d7b002c18e57756a9cb18e91ca9787207848fcd20921435906df7346d65
|
|
| MD5 |
67c8211fc199d54f3742358e5f502f76
|
|
| BLAKE2b-256 |
a26eac0972f7c28d0dc1404651a932741fdddb3e02a4252c791a504812cbc2c0
|
File details
Details for the file enhanced_political_optimizer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: enhanced_political_optimizer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59b915c2b135900895a5f1d8a8fbe8524969eb83e30fe17231fb54bdf1f1e5ef
|
|
| MD5 |
c70cd158eb4bdfb52911c9007534d878
|
|
| BLAKE2b-256 |
d9e9d419e329c04ac4d85807933cb629dfcdf2a8c23899939d8f472777745491
|