This repository contains a Python implementation of solving the binary knapsack problem using the Archimedes Optimization Algorithm (AOA). The AOA is a metaheuristic algorithm inspired by Archimedes’ Principle, which simulates the buoyant force exerted on an object immersed in a fluid. This principle is adapted to solve optimization problems.
The binary knapsack problem is a classic optimization problem where a knapsack has a limited weight capacity, and a set of items with associated weights and values must be selected to maximize the total value without exceeding the knapsack's capacity. The Archimedes Optimization Algorithm is employed to tackle this problem.
For more information on the Archimedes Optimization Algorithm and its application to the knapsack problem, refer to the article.
To use this knapsack problem solver, you can follow these steps:
- Install the necessary libraries (Numpy, Matplotlib).
- Use the
knapsack.py
module to define the problem's initial conditions, such as the number, mass, and value of the objects, as well as the capacity of the knapsack. - Generate random solutions and calculate the cost function using the functions provided in the
knapsack.py
module. - Utilize the Archimedes Optimization Algorithm functions defined in
AOA.py
. - Customize the conditions required for the problem in the
main.py
file.
knapsack.py
: Defines the initial conditions of the knapsack problem and includes functions for generating random solutions and calculating the cost function for each solution.AOA.py
: Contains functions related to the Archimedes Optimization Algorithm.main.py
: Defines conditions required for the problem and utilizes the defined functions to solve the knapsack problem.
The following libraries are used in this program:
- Numpy: For numerical operations and array manipulations.
- Matplotlib: For generating plots and visualizations.
- Archimedes Optimization Algorithm: An article describing the Archimedes Optimization Algorithm and its application.