How to Add Custom Function to GPdotNET


Several people have asked me how to quick add custom function in Function Set of GPdotNET. From the User perspective it is impossible, but if you open GPdotNET with Visual Studio 2010 and make some very few changes you can achieve this.

Suppose you need to add Function with the name: Substract5, which substract 5 numbers. Write short details about our function:

Name: Substract5
            Aritry: 5
Description: Substract 5 numbers.

So here is step by step instruction how to add new function in GPdotNET.

1.Open GPdotNET source code project with Visual Studio 2010. You can download the latest source from www.gpdotnet.codplex.com

2. Open FunctionSet.XML from GPdotNET project, like picture below:

image

3. Now that we finish definition in XML file, we need implement function in sourcecode.

4. Open GPFUnctionSte.cs from gpLib project. Add case statement in Evaluate Method. Case statement must contains the number the same as we defined in XML ID tag. So here is implementation.

image

5. That’s all. Compile and run application. In function set tab our new method will appear.

About Bahrudin Hrnjica

PhD in Mechanical Engineering, Microsoft MVP for .NET. Likes .NET, Math, Mechanical Engineering, Evolutionary Algorithms, Blogging.

Posted on 02/06/2011, in .NET, C#, GPdotNET and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s