MATLAB Answers

4 variables problem optimization with Genetic Algorithm

2 views (last 30 days)
I have a 4 variables nonlinear problem optimization that want to solve it with Genetic Algorithm, my lower bounds are [-100 -100 -3000 -3000] and upper bounds are
[100 100 700 700]. But every time I run the program it gives me the different results for variables and the variables don't converge. How can I fix this problem to get a specific result?

Accepted Answer

Alan Weiss
Alan Weiss on 11 May 2021
ga is a stochastic algorithm, and is expected to give different results on different runs. You can get reproducible behavior by setting the random seed. For example, run
rng default
before running ga.
A different question: is ga the right solver for you? See Choose a Solver.
Alan Weiss
MATLAB mathematical toolbox documentation
Ali Ghalavand
Ali Ghalavand on 14 May 2021
Thank you Alan,
I wrote GA code yesterday and I used rng function then I saw the variables converged and my problem was solved.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by