Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Optimization using Genetic Algorithm

Subject: Optimization using Genetic Algorithm

From: Mansel Oliver

Date: 31 Mar, 2008 09:50:03

Message: 1 of 9

Does anybody know how to solve equations using Genetic
Algorithm...
 I have to solve a muiltiobjective maufacturing problem
usin GA...
  
  I've tried using the genetic algorith and search toolbox
version 1.01...but its of no avail...
  
   My objective equation is
    f(x) = 11445.34 + 0.1133a - 0.0183b - 0.07788c

where a,b and c are process parameters which are given by
bounds
200<a<650
.2<b<0.6
200<c<550

the probabiltiy of crossover is 0.85
                   mutation 0.03
                   

Regards

Mansel
+91-9894862570

Subject: Optimization using Genetic Algorithm

From: Dave Brackett

Date: 2 Apr, 2008 15:07:02

Message: 2 of 9

"Mansel Oliver" <mansel.oliver@gmail.com> wrote in message
<fsqc4b$hab$1@fred.mathworks.com>...
> Does anybody know how to solve equations using Genetic
> Algorithm...
> I have to solve a muiltiobjective maufacturing problem
> usin GA...
>
> I've tried using the genetic algorith and search
toolbox
> version 1.01...but its of no avail...
>
> My objective equation is
> f(x) = 11445.34 + 0.1133a - 0.0183b - 0.07788c
>
> where a,b and c are process parameters which are given by
> bounds
> 200<a<650
> .2<b<0.6
> 200<c<550
>
> the probabiltiy of crossover is 0.85
> mutation 0.03
>
>
> Regards
>
> Mansel
> +91-9894862570
>
>
>

what are your objectives? are you trying to minimise f?
what exactly is the trouble you are having?

have you tried looking at the help documentation for the
ga? type "help ga" in the command window.

Subject: Optimization using Genetic Algorithm

From: Mansel Oliver

Date: 4 Apr, 2008 06:54:02

Message: 3 of 9

"Dave Brackett" <davebrackett@hotmail.com> wrote in
message <ft07em$251$1@fred.mathworks.com>...
> "Mansel Oliver" <mansel.oliver@gmail.com> wrote in
message
> <fsqc4b$hab$1@fred.mathworks.com>...
> > Does anybody know how to solve equations using Genetic
> > Algorithm...
> > I have to solve a muiltiobjective maufacturing
problem
> > usin GA...
> >
> > I've tried using the genetic algorith and search
> toolbox
> > version 1.01...but its of no avail...
> >
> > My objective equation is
> > f(x) = 11445.34 + 0.1133a - 0.0183b - 0.07788c
> >
> > where a,b and c are process parameters which are given
by
> > bounds
> > 200<a<650
> > .2<b<0.6
> > 200<c<550
> >
> > the probabiltiy of crossover is 0.85
> > mutation 0.03
> >
> >
> > Regards
> >
> > Mansel
> > +91-9894862570
> >
> >
> >
>
> what are your objectives? are you trying to minimise f?
> what exactly is the trouble you are having?
>
> have you tried looking at the help documentation for the
> ga? type "help ga" in the command window.
My ibjective is to maximise f while the variables remain
within the bounds... i've tried using the help ..but it's
so much of a help as i'm pretty new to matlab...

Subject: Optimization using Genetic Algorithm

From: Mansel Oliver

Date: 4 Apr, 2008 16:02:02

Message: 4 of 9

"Mansel Oliver" <mansel.oliver@gmail.com> wrote in message
<ft4jaa$2lf$1@fred.mathworks.com>...
> "Dave Brackett" <davebrackett@hotmail.com> wrote in
> message <ft07em$251$1@fred.mathworks.com>...
> > "Mansel Oliver" <mansel.oliver@gmail.com> wrote in
> message
> > <fsqc4b$hab$1@fred.mathworks.com>...
> > > Does anybody know how to solve equations using
Genetic
> > > Algorithm...
> > > I have to solve a muiltiobjective maufacturing
> problem
> > > usin GA...
> > >
> > > I've tried using the genetic algorith and search
> > toolbox
> > > version 1.01...but its of no avail...
> > >
> > > My objective equation is
> > > f(x) = 11445.34 + 0.1133a - 0.0183b - 0.07788c
> > >
> > > where a,b and c are process parameters which are
given
> by
> > > bounds
> > > 200<a<650
> > > .2<b<0.6
> > > 200<c<550
> > >
> > > the probabiltiy of crossover is 0.85
> > > mutation 0.03
> > >
> > >
> > > Regards
> > >
> > > Mansel
> > > +91-9894862570
> > >
> > >
> > >
> >
> > what are your objectives? are you trying to minimise
f?
> > what exactly is the trouble you are having?
> >
> > have you tried looking at the help documentation for
the
> > ga? type "help ga" in the command window.
> My ibjective is to maximise f while the variables remain
> within the bounds... i've tried using the help ..but
it's
> so much of a help as i'm pretty new to matlab...
hey i got the other message typed in wrong....i'm new to
matlab so the help documentation wasn't so much of a help
as i expected....It would be really usefull if anyone
could give me the instructions....

Subject: Optimization using Genetic Algorithm

From: OkinawaDolphin

Date: 7 Apr, 2008 09:08:03

Message: 5 of 9

You can represent the genome of an individual as a vector
Individual = [a b c].
 
The fitness function is minimized and not maximized by ga
(). Therefore, you should implement your fitness function
like this:

function Result = Fitness(Individual)

% Check inequality constraints
if (Individual(1) > 200) && (Individual(1) < 650) ...
&& (Individual(2) > 0.2) && (Individual(2) < 0.6) ...
&& (Individual(3) > 200) && (Individual(3) < 550)

 % Fitness value of a parameter combination that fulfills
 % the constraints.

 Result = -Individual ...
        * (11445.34 + [0.1133 -0.0183 -0.07788]';

else

 % Fitness function of a parameter combination that
 % violates the constraints. It seems that the objective
 % function can't get negative or zero, so zeros is a
 % suitable upper bound for the fitness function.
 Result = 0;

end;

end


You set the options of your GA in the following way:

PopulationSize = 100; % or any other number

NumberOfCrossOverIndividuals = 0.85 * PopulationSize;

NumberOfMutationIndividuals = 0.03 * PopulationSize;

NumberOfEliteIndividuals = PopulationSize ...
                         - NumberOfCrossOverIndividuals ...
                         - NumberOfMutationIndividuals;

Options = gaoptimset('CrossOverFraction', ...
                     0.85, ...
                     'EliteCount', ...
                     NumberOfEliteIndividuals, ...
                     'PopulationSize', ...
                     PopulationSize);


You run your GA in the following way:

[OptimaIndividual OptimalFitness] = ga(@Fitness, ...
                                       3, ...
                                       [], ...
                                       [], ...
                                       [], ...
                                       [], ...
                                       [], ...
                                       [], ...
                                       [], ...
                                       Options);


Note that cross over produces only one offspring individual
for each set of parents. Mutation is not applied to
offspring, but to individuals of the current generation. If
you want to apply mutation to children generated by
crossover, you have to implement your own cross over
function.

I hope this helps you getting started.

Subject: Optimization using Genetic Algorithm

From: OkinawaDolphin

Date: 7 Apr, 2008 12:58:02

Message: 6 of 9

There is a mistake in the fitness function. Here is the
corrected version:

function Result = Fitness(Individual)

% Check inequality constraints
if (Individual(1) > 200) && (Individual(1) < 650) ...
&& (Individual(2) > 0.2) && (Individual(2) < 0.6) ...
&& (Individual(3) > 200) && (Individual(3) < 550)

 % Fitness value of a parameter combination that fulfills
 % the constraints.

 Result = -(11445.34 + ...
            Individual * [0.1133 -0.0183 -0.07788]');

else

 % Fitness function of a parameter combination that
 % violates the constraints. It seems that the objective
 % function can't get negative or zero, so zeros is a
 % suitable upper bound for the fitness function.
 Result = 0;

end;

end

Subject: Optimization using Genetic Algorithm

From: abhishek Kumar

Date: 4 Oct, 2008 21:10:17

Message: 7 of 9

yaaar...plz any1...
i need to minimize the error rate of a face detection function that i made in matlab..
all i need to do is reduce the error rate
plz ne1 tell me or help me to reduce the error rate...
will really appreciate it...
its really urgent!!!

Subject: Optimization using Genetic Algorithm

From: abhishek Kumar

Date: 4 Oct, 2008 21:37:01

Message: 8 of 9

hey hi...
plz help me out....
i need 2 minimize error rate in face detection...
i have a function that returns the error rate..
with 4 arguments...
nw i specify that function name in the fitness function column in "gatool"..
it runs also...
but it doesnt give me optimized value instead says optimization terminated due to stall time limit exceeded.
plz help me out to optimize this error rate....
can u tell me wat parameters 2 adjust and how?

Subject: Optimization using Genetic Algorithm

From: Dave Yap

Date: 14 Oct, 2009 06:47:02

Message: 9 of 9

Dear OkinawaDolphin,

Good day to you. I've tried your suggested code on setting the upperbound and lowerbound values for a, b and c. However, when i run ga, it still gives me a value between 0 and 1. Hope to get some solutions from u.

Thanks.

"OkinawaDolphin " <OkinawaDolphin@Hotmail.com> wrote in message <ftd5oq$lje$1@fred.mathworks.com>...
> There is a mistake in the fitness function. Here is the
> corrected version:
>
> function Result = Fitness(Individual)
>
> % Check inequality constraints
> if (Individual(1) > 200) && (Individual(1) < 650) ...
> && (Individual(2) > 0.2) && (Individual(2) < 0.6) ...
> && (Individual(3) > 200) && (Individual(3) < 550)
>
> % Fitness value of a parameter combination that fulfills
> % the constraints.
>
> Result = -(11445.34 + ...
> Individual * [0.1133 -0.0183 -0.07788]');
>
> else
>
> % Fitness function of a parameter combination that
> % violates the constraints. It seems that the objective
> % function can't get negative or zero, so zeros is a
> % suitable upper bound for the fitness function.
> Result = 0;
>
> end;
>
> end
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us