MATLAB Optimization using genetic algorithm in matlab

AI Thread Summary
The discussion focuses on optimizing the thermal efficiency of a boiler using a genetic algorithm in MATLAB for a B.Eng project. The user is struggling with writing the fitness function, constraint equations, and uploading the initial population based on their case study data. Key parameters for optimization include pressure, temperature, and mass flow rates, which affect enthalpy calculations in the efficiency equation. Recommendations include using a pre-written package or creating a custom solution, along with guidance on generating the initial population with defined bounds. The conversation highlights the importance of selecting appropriate bounds for effective optimization and suggests alternative optimization methods like FMINUNC for potentially faster results.
amos.ngwoke
Messages
3
Reaction score
0
For my B.Eng project, I'm optimizing the thermal efficiency of a boiler using genetic algorithm in MATLAB. I'm finding it very tough to write my fitness function, constraint equations and upload my initial population which is a set of data from my case study plant.
for boiler thermal efficiency,
η = Q(hf - hg)/ (q * GCV)

here's my fitness function

function E = thermal_eff(x)
% thermal_efficiency(x) calculates thermal efficiency of a steam boiler
%
% E = thermal_efficiency(x) calculates the thermal efficiency of the steam boiler
%
% x(1) = Q = Quantity of steam generated per hour in kg/hr
% x(2) = hg = Enthalpy of saturated steam in kCal/kg of steam
% x(3) = hf = Enthalpy of feed water in kCal/kg of water
% x(4) = q = Quantity of fuel used per hour (q) in kg/hr
% x(5) = GCV = Gross calorific value of the fuel (GCV) in kCal/kg of fuel
%
% thermal efficiency of a steam boiler
E = (x(1)*(x(2)- x(3))) / (x(4) * x(5));


I don't know how accurate I am, and I'm finding it difficult to write the constraint equations and upload my initial population

Please assist me in any way you can
Thanks
 
Physics news on Phys.org
Lets start from the beginning. You need to optimize the effciency in what sense? What are the things you can actually change (type of fuel?, size of the boiler?, temperature of the boiler?)?
 
pressure and temperature of boiler and feed water, mass flow rate of fuel and steam. all these can be altered. but the pressure and temperature are used to calculate the enthalpy which appears in the equation i wrote above
 
amos.ngwoke said:
pressure and temperature of boiler and feed water, mass flow rate of fuel and steam. all these can be altered. but the pressure and temperature are used to calculate the enthalpy which appears in the equation i wrote above

So you need to make your fitness function take as input these parameters use them to calculate the terms in the equation, from which you will get thermal efficiency.

Do you plan to use a pre-written package for the evolution engine, or do you intend to write your own?
 
Yes.
i haven't seen any detailed work close to it, from which i can pull some "pre-written package", so I'm making efforts to writing my own.
 
amos.ngwoke said:
Yes.
i haven't seen any detailed work close to it, from which i can pull some "pre-written package", so I'm making efforts to writing my own.

If you're going to do it yourself, I recommend getting a good book, such as books.google.com/books?isbn=3540606769

You will find there discussions about initial populations and handling constraints. If you have particular questions, you can post them in this thread.
 
  • Like
Likes 1 person
To create the initial population you need first of all make a function like this:

function Chrom = createRealPopulation(Nind, Bounds);
Range = rep((Bounds(2,:)-Bounds(1,:)),[Nind 1]);
Lower = rep(Bounds(1,:), [Nind 1]);
Chrom = rand(Nind,Nvar) .* Range + Lower;

The Bounds array is defined by you corresponding to the number of variables. Each variable gets an upper and a lower bound. During the optimization the algorithm will search between these bounds. It is essential to choose appropriate values for lower and upper bound, because the optimum search depends on it.
E.g. see an example of it.
NVAR = 5;
NIND= 20;
SUBPOP = 4;
% lower and upper bound, identical for all n variables
Bounds = [-5.12; 5.12];
Bounds = Bounds(1:2,ones(NVAR, 1));

Chrom = createRealPopulation(SUBPOP*NIND, Bounds);

Hopefully I moved your work a bit forward.
 
The cost function is continuous, and i think convex. Use FMINNUNC, LSQNONLIN ! instead of slowwwwwwww genetic algorithm.
 
The Genetic Algorithm isn't slow if you don't run it under MATLAB. I developped the algorithm in Visual C++. The running time is very quick. Otherwise my version (the MATLAB open source version only) is rather old, gets from 1994. Since I have an own new version in which I corrected the faults and extended with new features.
 
Back
Top