i am getting different results for different times of running the genetic algorithm

hi i'm working on a project in which i have to minimize the net annual cost( objective function). the variable range is in 500-5000. i am getting different results when i run it several times and also the results are weird. can anyone help me i have attached my objective function file and can anyone give me suggestions in choosing the parameters like mutation rate etc. thank you in advance

3 Comments

https://docs.google.com/document/d/1xHRkwEXGynsP6ElWm7TumkwVyVk-p5uCZs6uFTrXFaU/edit?usp=sharing
this is my function. sorry for not uploading my file for the first time
I am facing the same problem, I am using Multi objective particle swarm optimization for 2 objective functions.

Sign in to comment.

 Accepted Answer

I didn't see any attachments, so I cannot comment directly on your problem.
Are you sure you want to use the genetic algorithm to solve your problem? If your problem is smooth, Optimization Toolbox solvers such as fmincon are usually faster and more reliable. And if your problem is not smooth, then patternsearch is usually faster and easier to tune than ga.
But if you insist on using ga, I suggest you try the following:
  • Give a good initial range
  • Use a large population, 200 or even more if you have a lot of variables
  • Set a large StallGenLimit to try to keep the solver from stopping prematurely
Basically, ga is a random search algorithm, so if you want better answers, you have to let it search a bigger space and take more tries.
I suggest again you use a different algorithm, either fmincon or patternsearch. You can start either of those solvers at random points within your bounds by using
x0 = lb + rand(size(lb)).*(ub - lb);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

5 Comments

https://docs.google.com/document/d/1xHRkwEXGynsP6ElWm7TumkwVyVk-p5uCZs6uFTrXFaU/edit?usp=sharing
this is my function. sorry for not uploading my file for the first time
Hello, I am using pattern search to solve a non-smooth combined control and design problem with 22 decision variables. Why do I get different results each time I run a pattern search problem? Is there a way to make the results deterministic? Or pattern search always gives different results unless the problem is convex?
You would probably get more visibility for your question by creating a new question rather than adding to an existing question.
Pattern search is, by default, deterministic, meaning that unless you have changed some default options the algorthm does not give different results each time. To get reproducible results, do not specify options that can change results (such as MADS polling, parallel processing, or random poll order). If your results continue to vary, the reason lies elsewhere.
Alan Weiss
MATLAB mathematical toolbox documentation
Please suggest algorithm for 3 objectives optimization problem. Is it possible to use optimization toolbox for 3 objective functions?
You would probably get more visibility for your question by creating a new question rather than adding an irrelevant answer to an existing question.
In Global Optimization Toolbox there are gamultiobj and paretosearch. In plain Optimization Toolbox there is fgoalattain. See Multiobjective Optimization and Generate and Plot Pareto Front.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Asked:

on 17 Oct 2013

Commented:

on 2 Mar 2021

Community Treasure Hunt

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

Start Hunting!