Optimization using genetic algorithm in matlab

In summary, the author is optimizing the thermal efficiency of a boiler using a genetic algorithm. They are having difficulty writing their fitness function, constraint equations, and uploading their initial population.
  • #1
amos.ngwoke
3
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
  • #2
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?)?
 
  • #3
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
 
  • #4
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?
 
  • #5
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.
 
  • #6
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
  • #7
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.
 
  • #8
The cost function is continuous, and i think convex. Use FMINNUNC, LSQNONLIN ! instead of slowwwwwwww genetic algorithm.
 
  • #9
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.
 

Related to Optimization using genetic algorithm in matlab

1. What is a genetic algorithm?

A genetic algorithm is a type of optimization technique inspired by the process of natural selection. It involves creating a population of potential solutions to a problem and using genetic operators such as mutation and crossover to produce new generations of solutions. The fittest individuals from each generation are selected and used to create even better solutions in the next generation.

2. How does a genetic algorithm work in Matlab?

In Matlab, a genetic algorithm is implemented by defining a fitness function that evaluates the performance of each potential solution. The algorithm then uses this function to evaluate and select the fittest individuals, and applies genetic operators to create new generations. The process continues until a satisfactory solution is found.

3. What types of problems can be solved using genetic algorithm in Matlab?

Genetic algorithms can be used to solve a wide range of optimization problems, including those with nonlinear, non-differentiable, and multi-modal objective functions. Some examples include optimization of engineering designs, scheduling problems, and machine learning tasks.

4. How does the performance of genetic algorithm compare to other optimization techniques?

The performance of genetic algorithm depends on the specific problem being solved and the quality of the implementation. In general, it is known to be effective for solving complex problems with large search spaces, but may not always find the best solution. It can also take longer to converge compared to other optimization techniques such as gradient descent.

5. Are there any drawbacks to using genetic algorithm in Matlab?

One potential drawback of using genetic algorithm in Matlab is that it requires careful parameter tuning for optimal performance. The choice of population size, genetic operators, and termination criteria can greatly affect the results. Additionally, genetic algorithm may not always guarantee the best solution, as it relies on randomness in the search process.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
930
  • Engineering and Comp Sci Homework Help
Replies
28
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
13K
  • Programming and Computer Science
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • General Engineering
Replies
2
Views
4K
Back
Top