Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Genetic Mutations

Status
Not open for further replies.

Dr_Doggy

Well-Known Member
I am working on a theory so i can calculate the amount of nutrients in my compost based on the input materials.. in my app there are inputs that i can adjust the input materials, and with them the app derives the amount of elements going in to it and outputs the difference of ( nutes provided - nuets requd ).

attached is an AI to adjust the amount of input material and calcs fitness where 0 is the target like this:

internal decimal checkFitness(string p1, string p2, string p3, string p4, string p5, string p6)
{
decimal s1 = decimal.Parse(p1) - TargetN; if (s1 < 0) { s1 *= -1; }
decimal s2 = decimal.Parse(p2) - TargetP; if (s2 < 0) { s2 *= -1; }
decimal s3 = decimal.Parse(p3) - TargetK; if (s3 < 0) { s3 *= -1; }
decimal s4 = decimal.Parse(p4) - TargetC; if (s4 < 0) { s4 *= -1; }
decimal s5 = decimal.Parse(p5) - TargetM; if (s5 < 0) { s5 *= -1; }
decimal s6 = decimal.Parse(p6) - TargetS; if (s6 < 0) { s6 *= -1; }
return( s1 + s2 + s3 + s4 + s5 + s6);
}


Here is how im mutating my offspring right now:

offspring = new offspringItem(nuteList.Count);
int index = 0;
foreach (nuteObject o in nuteList)
{
decimal rnd22 = 0;
decimal rnd23 = 0;
int rnd1 = random.Next(0, offspringList.Count/2); // select random offspring at top of list
rnd22 = random.Next(-200, +200); // get random
rnd22 /= 100; // convert random to 2 decimal places
rnd23 = offspringList[rnd1].arr4[index] + rnd22; // add random to random selections (i thought multiply would be better but it wasnt)
if (rnd23 > 99) { rnd23 = 99; } // keep within program scope
if (rnd23 <= 0) { rnd23 = 0.02M; } // keep within program scope
NumericList[index].Value = rnd23; // setup in app
offspring.import(index, rnd23); // save new child parameters
index++;
}


however the GA stops finding better solutions at a fitness of about 7-10 , maybe there is a suggestion to generate healthier offspring??
 
Status
Not open for further replies.

Latest threads

Back
Top