AForge Genetic algorithms for solving expression - c#

For example my expression is 2*x+y^2.
I have to use genetic algorithms to solve it with getting output closest to 0.
I was trying to define a population but I don't know how to start.
Population size is 20 for now, BinaryChromosome is 32, but what fitness function should be like? Is there a built in fitness solving my problem or I have to create new class for my own? Where to start? Thanks for the help in advance!

Related

Have an 'Unidentified' Class in Accord.Net SVM

I'm using the MultiClassSupportVectorMachine class to do some classification. Specifically, my data has 24 dimensions, with the values being grouped pretty close together. I will be identifying around 10 or so classes in this data.
I'm looking to identify when an inputted value is really far off from the groups. Something along the lines of having a class 0 which would be unidentified and then having classes 1 to 10 only being outputted when the SVM has a high degree of confidence it is in the group.
In essence I am looking to go from the top to the bottom of this image:
this image showing SVM classification
Is something like this possible in accord.net?
Thanks!
I answered my own question!
This can be accomplished by using the Probability function to get an estimate of how accurate the guess is from the SupportVectorMachine class, and then using that as a threshold to reject guesses with a low probability.

Quickly solve math functions with large values (for graph)

I'm looking for a way to quickly get the results for a mathematical equation. Take "0.5 * sin(x) + 3" for example. The Google calculator can easily give me an exact result for HUGE values, but my C# application will stutter when drawing a graph in high value ranges or even give me an overflow. How do I solve this?
Thanks in advance!

Searching intersection point of two splines in graph

I am stuck at this point. I am trying to find where two lines in graph intersects. I have 10 points for each spline, but they intersects between this points.
I am using c# graph. (System.Windows.Forms.DataVisualization.Charting.Chart chart2;)
Do you have an idea how to solve this?
Here is this situation. Points are measured manually so there is minimum posibility that it will intersetcs on this given points.
Refine the splines to the degree of precision you need and then intersect (straight) line pairs, as Matthew suggested. This can be done quite efficient if you chose the right data structure to store the line segments, so that it supports fast range queries (kd-tree perhaps?).
Doing it analytically is going to be really hard, I guess.
I found the solution, I used least squares theory and polynomial function to represent equation of curve and after that solve the equation. If anybody needs solution just write me.

Smoothing function for PRM output

I've implemented a Probabilistic roadmap method function, which works and executes correctly. The only problem is that the output of the prm is not smooth for example, if a hand needs to rotate from 30 to 100 degrees, the steps might be 30,55,42,66,99,100, i wat to be able to smoothen the transition betwen the 30 and 100 degree. I know that the problem is related tp smoothing of a signal yet i dont know what type of smoothing might be able to do the job. No sophisticated method is needed. My implementation is in c#, if possible i wish to let such job be done by a library. Is there any such library? which i can give it an array of integers and likewise produce an array of smoothed values.
I think what you need is a simple curve fitting algorithm. A quick google search will give you lots of example code. And if you want to have a strictly increasing curve, you need to sort the values before you do the curve fitting.
If you are just interested in reaching the target, you can drop the values in between and do a linear interpolation from start to end or something similar.

How can I represent math variables in c#?

I need to represent these mathematical equations in code and to solve them:
2x = 3y
3y = 4z
2x + 3y + 4z = 1
Please advise.
(I suspect this is homework, so I will give you some clues as to how to proceed...)
Think about how you would solve these equations on paper.
The same steps can be written into your software. Each equation has a variable and a coefficient, so you will most likely want to represent the coefficient with a variable in your program, and "solve" the equations using the same techniques you would by hand.
Perhaps this answer in SO is what you are after?
Here is a complete, documented/tutorial C# program to solve sets of linear equations: http://www.codeproject.com/KB/cs/LinearEquationsSystemSoln.aspx
By the way, C# isn't really the language for this. MATLAB or Python/scipy would have built-in solvers. See things like this: http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.solve.html
This sound like a simple case a linear algebra. Throw the equations into an M x N matrix where M is the number of coefficients + 1 and N is the number of equations.

Categories