AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Gentic Algo GEPChromosome

The forum is to discuss topics from different artificial intelligence areas, like neural networks, genetic algorithms, machine learning, etc.

Gentic Algo GEPChromosome

Postby bilal_78699 » Mon Sep 01, 2014 5:53 am

Hello Everyone!

I'm using Aforge.net for genetic algorithm. It's a good library for .net. I have used binary chromosome and I know how to convert a binary chromosome value to normal values as it was written in Optimization functions. But i want to know that how can i convert/translate GEPChromosome values to normal/user value. I have to optimize 4 values. So can you please guide me that how can I take out four values from GEPChromosome? As I want to use GEPChromosme as it has more options than binary chromosome and is fit for my problem. Please help me!

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am

Re: Gentic Algo GEPChromosome

Postby andrew.kirillov » Mon Sep 01, 2014 8:51 am

Hello,

You need to use some fitness function to convert chromosome into something which is more human readable - those have the knowledge about what chromosome is aimed for (which task it solves). For binary chromosome you used 1D/2D optimization function. So for GP/GEP chromosomes you need to use appropriate fitness function as well.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2886
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Gentic Algo GEPChromosome

Postby bilal_78699 » Mon Sep 01, 2014 12:48 pm

Thanks for the reply, I have seen the fitness function related to GEPChromosome but i'm unable to understand it. Plus is there adaptive feasible mutation algorithm for binary chromosome available in aforge ?

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am

Re: Gentic Algo GEPChromosome

Postby andrew.kirillov » Mon Sep 01, 2014 1:19 pm

bilal_78699 wrote:Thanks for the reply, I have seen the fitness function related to GEPChromosome but i'm unable to understand it.

What is not clear? Which part you can not understand?

bilal_78699 wrote: Plus is there adaptive feasible mutation algorithm for binary chromosome available in aforge ?

"adaptive feasible mutation algorithm" ?? No, it it not there. Everything what is available is listed in documentation. There is no hidden stuff.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2886
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Gentic Algo GEPChromosome

Postby bilal_78699 » Mon Sep 01, 2014 2:09 pm

In symbolic regression fitness, this is the code which i'm unable to understand it:

public double Evaluate( IChromosome chromosome )
{
// get function in polish notation
string function = chromosome.ToString( );

// go through all the data
double error = 0.0;
for ( int i = 0, n = data.GetLength( 0 ); i < n; i++ )
{
// put next X value to variables list
variables[0] = data[i, 0];
// avoid evaluation errors
try
{
// evalue the function
double y = PolishExpression.Evaluate( function, variables );
// check for correct numeric value
if ( double.IsNaN( y ) )
return 0;
// get the difference between evaluated Y and real Y
// and sum error
error += Math.Abs( y - data[i, 1] );
}
catch
{
return 0;
}
}

// return optimization function value
return 100.0 / ( error + 1 );
}

I have objective function which takes 4 inputs and provides the fitness value. Now I have to take out 4 values from GEPChromosome and pass these 4 values to my function. How can I achieve this? Can you please help me in this?

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am

Re: Gentic Algo GEPChromosome

Postby andrew.kirillov » Mon Sep 01, 2014 2:15 pm

I would suggest starting from sample application. In samples' folder you will find a sample application for Symbolic Regression using GEP. It may shed some light on how it all works. Also long time ago I had an article on the GA topic.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2886
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Gentic Algo GEPChromosome

Postby bilal_78699 » Mon Sep 01, 2014 2:22 pm

Thank you very much for the help, yes i was reading your article and I have found that GEPChromosome is not applicable to my function. Only binary chromosome are applicable for my problem. But unfortunately binary chromosome in not searching in the space between range thats due to mutation algorithm used in aforge. Actually I was comparing my results with Matlab GA toolbox results. And the results are not closer.

I will let you know in case of any other confusion. Thanks for helping.

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am

Re: Gentic Algo GEPChromosome

Postby bilal_78699 » Tue Sep 02, 2014 6:15 am

Hello Andrew

I have a question I know you can help me in this. I have seen the documentation and code of double array chromosome, it looks that it will solve my problem. Can you please tell me that how can i specify in this type to generate numbers with in some range? Is it possible by using this type of chromosome.

I will be waiting for your reply.

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am

Re: Gentic Algo GEPChromosome

Postby andrew.kirillov » Tue Sep 02, 2014 7:00 am

Hello,

You need to specify random number generator when you create your chromosome. See this constructor.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 2886
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Gentic Algo GEPChromosome

Postby bilal_78699 » Tue Sep 02, 2014 7:49 am

Hello

Thanks, I have seen the full code of this chromosome type. These random number generators are used for mutation except for crossovergenerator which is used to initialize chromosomes. I have 4 variables whose range are [1 5],[0.001 0.011], [0.2 10], [0.002 0.01], I want these parameters to be optimized so I had created length 4 in double array chromosome or i can provide default values which i have no issue. My main concern is how can i translate the values in to these ranges. Did you get my point? If no I can explain you in detail.

Thanks,
Bilal
bilal_78699
 
Posts: 7
Joined: Mon Sep 01, 2014 5:47 am



Next

Return to Artificial Intelligence