G
G
Gagatyn2017-05-09 20:01:07
Mathematics
Gagatyn, 2017-05-09 20:01:07

How to find the extremum of a non-linear function of two variables using a genetic algorithm?

Hello!
I can't write a program. I can’t systematize everything in my head, I need an algorithm for writing code. I'm probably wondering how to do this:

  1. Create a dynamic x and y array, size specified by the user, random 0 and 10 (required 0 to 10)
  2. apply x and y to your own function, sort function values, mutate, delete bad ones
  3. Output result

I really doubt the correctness of this algorithm, I need help. My function z = sqrt(3 * x * x - 5 * y * y)
There are code sketches, but they don't work. What to do? If there are links to a finished problem or analysis, I will be grateful (I just struggle with the solution for a long time).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Skusnov, 2017-05-10
@AlexSku

Genetic algorithm in MatLab.

A
Andrew, 2017-05-10
@OLS

In step 2 (one of the possible scenarios) - for an array of 10 elements:
2.1. apply x and y to your function
2.2. sort function values,
2.3. leave the 3 best ones (let's call them A, B, C)
2.4. create 3 new random mutations A', B', C'
2.5. create 3 more new ones by crossing AB, BC, AC
2.6. create 1 more new one completely by accident ("fresh blood")
In total, we got 10 elements again.
Repeat steps 2.* until the best value A of the previous run differs from the best value A of the current run by no more than 0.00001 (user-defined).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question