Optimization using genetic algorithm in matlab

Click For Summary

Discussion Overview

The discussion revolves around optimizing the thermal efficiency of a boiler using a genetic algorithm in MATLAB. Participants explore the formulation of a fitness function, constraint equations, and the creation of an initial population for the optimization process.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant shares a fitness function for calculating thermal efficiency based on various parameters such as steam quantity, enthalpy, fuel quantity, and gross calorific value.
  • Another participant questions the specific aspects of efficiency that need optimization and suggests considering factors like fuel type, boiler size, and temperature.
  • It is noted that pressure and temperature of the boiler and feed water, as well as mass flow rates, can be altered, but they are also necessary for calculating enthalpy.
  • A suggestion is made to either use a pre-written package for the genetic algorithm or to write a custom implementation, with a recommendation for a book that discusses initial populations and constraints.
  • A participant provides a code snippet for creating an initial population, emphasizing the importance of defining appropriate bounds for the optimization variables.
  • There is a suggestion that the cost function may be continuous and convex, proposing the use of FMINUNC or LSQNONLIN as alternatives to genetic algorithms.
  • Another participant argues that genetic algorithms can be efficient if implemented outside of MATLAB, sharing their experience with a custom version developed in Visual C++.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency of genetic algorithms compared to other optimization methods, and there is no consensus on the best approach to take for the optimization task. The discussion remains unresolved regarding the optimal method and the specifics of the fitness function and constraints.

Contextual Notes

Participants have not reached a consensus on the formulation of the fitness function or the constraints necessary for the optimization process. There are also varying opinions on the effectiveness of genetic algorithms versus other optimization techniques.

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   Reactions: 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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 28 ·
Replies
28
Views
6K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 2 ·
Replies
2
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
9K
  • · Replies 2 ·
Replies
2
Views
4K