how can i make ga to reproduce specific result?

2 visualizaciones (últimos 30 días)
Odette
Odette el 17 de Mzo. de 2024
Comentada: John D'Errico el 17 de Mzo. de 2024
i know rng(default) reproduce the same result but i want to reproduce specific result after running for 4/5 times . is there any way to do this.please help

Respuesta aceptada

John D'Errico
John D'Errico el 17 de Mzo. de 2024
Editada: John D'Errico el 17 de Mzo. de 2024
No. You cannot enforce that GA will find any specific result. It appears you understand that GA may find different local solutions to a problem when called multiple times. But you cannot force GA to target any one of them, or that it will keep on finding different solutions when multiple local solutions exist.
At best all you can do is to use constraints to try to target some region, perhaps bound constraints. But I would postulate that if you already know the solution you want to see, then why bother using an optimization in the first place?
So I think you are hoping that if you call the code often enough, can you insure that eventually, it will find some solution that you think to be a good one, and not get stuck in another solution. The answer to that is no. One good thing is that GA, as a variety of a global solver, tries not to get stuck in a local, but suboptimal solution. But that is all you can ask for from the code.
Perhaps a similar question would be to ask you to roll a single, 6 sided die. After 5 rolls of the die, or 10, or 50, or any fixed number, can you absolutely insure that at least one of those rolls will be a 6? The answer should be clear to you: Of course not! More samples can increase the probability of finding an event that you like, but that is all you can do, and no more.
  4 comentarios
Sam Chak
Sam Chak el 17 de Mzo. de 2024
Editada: Sam Chak el 17 de Mzo. de 2024
I'm curious to know what it signifies to you if you can consistently reproduce the same solution in subsequent runs without initializing the default rng. Understanding your objectives will assist in providing suitable guidance. Regardless of whether it is considered practical or impractical, from a coder's perspective, there are numerous techniques to achieve remarkable outcomes. However, we will need to analyze the optimization problem before advising you on how to obtain the desired practical solution.
John D'Errico
John D'Errico el 17 de Mzo. de 2024
Again, you can't insure that subsequent runs of a tool will produce any desired result (well, if the random seed is not set to be the same.) GA tries to increase the probability that it gets to the globally optimal solution. But there is no certainty.
As I said, since GA uses a random starting set, it may produce different results after each call. And that means it is equivalent to my example of rolling a die, or flipping a coin. Flip a coin n times in a row, and it may come up tails every time, even though you might hope for it to come up heads at least once. Yes, the probability is good that you will suceed, but that is all you can make: a statement about probability.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by