Following the previous articles on interfaces (+) and (exact) solvers (+) for optimization in Python, in this article, I introduce some packages that provide an easy-to-use “interface” for artificially intelligent algorithms (AIAs) (e.g., heuristics, meta-heuristics, math-heuristics, learn-heuristics, hyper-heuristics, or sim-heuristics).
AIAs may not reach globally optimal solutions, which means that the user should always be aware of the reason for choosing them based on a use case and try to tune their parameters or increase their adaptiveness to the landscape of an optimization problem. However, contrary to the (exact) solvers introduced, they can obtain solutions in a reasonably shorter amount of time. Besides, AIAs may not derive feasible solutions based on the characteristics of an optimization model (and the programming expertise of the user). The significant advantage of using an AIA is that no matter the features of the optimization problem (e.g., LP, MIP, MILP, or MINLP), an AIA can be a general problem solver (GPS) and solve all of them.
Notably, this is not a complete survey of what is available, but I will try to complete it over time. Moreover, I implement either GA or PSO via the packages introduced, two of the most famous AIAs introduced in 1975 and 1995. Hence, the introduced packages should also support them. Finally, since the optimization model is presented here (+) and has constraints, I model them as penalties in the objective function.
1. GeneticAlgorithm for optimization in Python
- Supported algorithms: GA.
- Supporting multiple objectives: No.
Here, I provide a coding example using “geneticalgorithm” in Python:
2. PYSWARMS for optimization in Python
- Supported algorithms: PSO.
- Supporting multiple objectives: No
Here, I provide a coding example using “pyswarms” in Python:
Click the button below to download the complete pack of the above coding examples:
If this article is going to be used in research or other publishing methods, you can cite it as Tafakkori (2022) (in text) and refer to it as follows: Tafakkori, K. (2022). Artificially intelligent algorithms for optimization in Python. Supply Chain Data Analytics. url: https://www.supplychaindataanalytics.com/artificially-intelligent-algorithms-for-optimization-in-python/
Industrial engineer focusing on leveraging optimization methods and artificial intelligence technologies using multiple programming languages to empower a business to achieve its goals!