Probabilistic and stochastic algorithms have been used to solve
many hard optimization problems since they can provide solutions
to problems where often standard algorithms have failed. These
algorithms basically search through a space of potential solutions
using randomness as a major factor to make decisions. In this
research, the knapsack problem (optimization problem) is solved
using a genetic algorithm approach. Subsequently, comparisons
are made with a greedy method and a heuristic algorithm. The
knapsack problem is recognized to be NP-hard. Genetic algorithms
are among search procedures based on natural selection and natural
genetics. They randomly create an initial population of
individuals. Then, they use genetic operators to yield new
offspring. In this research, a genetic algorithm is used to
solve the 0/1 knapsack problem. Special consideration is given
to the penalty function where constant and self-adaptive penalty
functions are adopted.