A Streamlit app that uses a genetic algorithm to solve linear equations of the form:
a·x + b·y + c·z + ... = Target
Given a set of coefficients and a target value, the algorithm evolves a population of candidate solutions over generations - selecting, combining, and mutating them - until it finds integer values that satisfy the equation.
[Add your Streamlit Cloud URL here once deployed]
- Custom equations - enter any number of coefficients
- Adjustable parameters - population size, mutation rate, max generations
- Elitism - the best candidate found is always carried into the next generation, so progress is never lost
- Live convergence chart - tracks both best and average population fitness over time
- Real-time feedback - progress bar and per-generation status updates
- Initial population - random integer candidates are generated
- Fitness function - measures how far each candidate's result is from the target (lower is better, 0 = solved)
- Elitism - the best candidate from the current generation is preserved into the next
- Selection - the top-performing candidates are kept as parents
- Crossover - parent values are combined to produce new candidates
- Mutation - occasional random tweaks are introduced to maintain diversity and avoid getting stuck
The process repeats until either a candidate reaches zero error (an exact solution) or the maximum number of generations is reached, at which point the closest solution found is shown.
Clone the repository:
git clone https://github.com/salamlakhan7/Genetics-Algorithm-Solver.git
cd Genetics-Algorithm-SolverInstall dependencies:
pip install -r requirements.txtRun the app:
streamlit run GA_app.py- Candidate values are currently sampled from a fixed integer range, so very large or negative-only solutions may not be reachable without adjusting the code
- Designed for linear equations; not currently built for quadratic or non-linear targets
Built by Abdul Salam as a personal project exploring genetic algorithms with Python and Streamlit.