# GA calculates wrong penalty

4 visualizaciones (últimos 30 días)
Tom Brenner el 26 de Mzo. de 2019
Comentada: Tom Brenner el 26 de Mzo. de 2019
I have a GA problem with the optimization file Lowest. I set the initial population using a set of parameters X:
optim.options.InitialPopulationMatrix = X;
I check the result:
Lowest(X,[5 15], 1)
or indeed
Lowest(optim.options.InitialPopulationMatrix,[5 15], 1)
both yield
ans = 0.16.
I now define and run the following:
fopt = @(x)Lowest(x,[5 15],1);
[x,fval]=ga(fopt,optim.nvars,optim.Aineq,optim.bineq,[],[],optim.lb,optim.ub,[],optim.intcon,optim.options);
With optim.options.Display = 'iter'; The first values the GA run generates for me are always much higher than 0.16.
Why??!?
Any help greatly appreciated.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Alan Weiss el 26 de Mzo. de 2019
To answer your second question first, if you set a problem structure as documented then you can call ga by
[x,fval] = ga(problem)
For your first question, you can see the description of the penalty function in Integer ga algorithm. What I was trying to say is that your initial point might be infeasible, and then the penalty function is higher than the fitness function.
For the documentation on passing extra parameters, see Passing Extra Parameters.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Tom Brenner el 26 de Mzo. de 2019
Yes, somehow some of the variables violated the upper or lower limits (not the intcon). That was not supposed to happen, but somehow wrong values made their way in.

Iniciar sesión para comentar.

### Más respuestas (2)

Alan Weiss el 26 de Mzo. de 2019
You are probably seeing the result of the integer-constrained solver. The fitness function is modified by a penalty term. It is possible that your initial population matrix is not integer-feasible.
Also, since you seem to like making a struct for your problem, why not go all the way and use a real problem structure?
Alan Weiss
MATLAB mathematical toolbox documentation
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Tom Brenner el 26 de Mzo. de 2019
Editada: Tom Brenner el 26 de Mzo. de 2019
Thank you for the reply, Alan. I am ashamed to admit I can make no head or tail of it. Integer-constrained solver = the constraint I set through optim.intcon? In my case, optim.intcon = 1, and the first parameter in optim.options.InitialPopulationMatrix is 44. The fitness function cannot operate with anything other than an integer for x(1).
What is the difference between a problem structure and the "struct" I used for my problem? Again, sorry, I could not make the difference from the documentation page you directed me to. I picked up the syntax I posted after searching for the recommended ways to pass extra variables to the fitness function used by GA.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Problem-Based Optimization Setup en Help Center y File Exchange.

R2018a

### Community Treasure Hunt

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

Start Hunting!

Translated by