Skip to content

PID tuner, uses Genetic Agorithm to minimize ISE

Notifications You must be signed in to change notification settings

barthap/GA_PID_Tuner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GA PID Tuner

Genetic algorithm that optimizes PID values to minimize ISE. It can use either Matlab/Simulink or built-in Python model for simulating plant.

Screen 1 Screen 2 Screen 3

Used dependencies

  • Python 3.6+
  • NumPy
  • SciPy
  • Control
  • Matlotlib
  • MATLAB Engine for Python
  • TKInter

Installation and startup

  1. Install Python 3.6+
  2. Clone this repo
  3. Install dependencies:
pip install numpy scipy matplotlib control
  1. Go into the repo directory and run main.py
cd GA_PID_Tuner && python main.py
(Optional) MATLAB Engine for Python installation

Described here: https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html

Project structure

Opis większości plików i katalogów w projekcie:

  • genetic - Genetic Algorithm reletated files
    • algorithms - Crossover, mutation and selection implementations
  • matlab - Matlab and simulink files
    • simulate.m - [function] Simulates model with Simuling
    • simulate2.m - [function] Sumulates model WITHOUT Simulink
    • circuit.slx - Simulink model (Note: watch out the Simulation Parameters)
    • run.m - for testing purposes
  • sim - model simulation and fitness calculation
    • AbstractSimModel.py - base class
    • PythonSimulatedModel.py - simulation in Python using Control lib
    • MatlabModel.py - starts Matlab and runs simulate2.m
    • MatlabSimulinkModel.py - Starts Matlab and runs simulate.m + Simulink
  • tests - unit tests
  • main.py - run this file to start
  • config.py - default config
  • application.py - UI Interface

Enabling Matlab

By default, a Python built-in model is used for calculating fitness, but there is also Matlab support. To switch model to matlab, do the following:

  1. Make sure that you have Matlab Engine for Python installed
  2. Check the matlab directory to see how scripts are made
  3. Open application.py
  4. Add the beginning, add the proper import:
from sim.MatlabModel import MatlabModel
# Or, if you want to use Simulink:
from sim.MatlabSimulinkModel import MatlabSimulinkModel
  1. In line 289, change PythonSimulatedModel(cfg) to either MatlabModel(cfg) or MatlabSimulinkModel(cfg)
self.simulation = Simulation(cfg,
                            PythonSimulatedModel(cfg),
                            GeneticAlgorithmImpl(cfg))

About

PID tuner, uses Genetic Agorithm to minimize ISE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published