Why does ga change the 'Vectorized'-option to 'on' by itself?

1 view (last 30 days)
My ga optimizer problem always produces an error after some generations. The error is caused by calling my fitness function vectorized, even though I set the 'Vectorized'-option to 'off' before.
When I set a breakpoint directly before in 'galincon', I can see that the 'Vectorized'-option is set to 'on'. 'galincon' is called from 'gaminlpengine' (no code), which is called from 'gaminlp' (no code), which is called from 'ga'. If I set a breakpoint in 'ga', the 'Vectorized'-option is still set to 'off'.
It's no big problem, I could easily change my fitness function code to work vectorized. But it should not happen that way, should it? Why is that option changed automatically?
  1 Comment
Stephen23
Stephen23 on 14 Sep 2016
Jochen Schuettler's "Answer" moved here:
As an additional problem: I'd know a very good way to improve crossover, but I must not change it to 'custom' with integer problems. Why? Is there a workaround?

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 14 Sep 2016
I am still not sure why you ran into this problem, but the development team tells me that it is not a bug that causes the internal state of the solver to change to Vectorized, this is something that the integer ga algorithm does. However, your fitness function is not supposed to see this, there is a wrapper for compatibility with non-vectorized fitness functions. So I am really not sure what is happening.
As to your second question or comment, you are free to change your crossover function by using your own version of integer ga in the following way. Set your population type to 'custom', and make your own creation, mutation, and crossover functions in a way that keeps your problem pure integer. Sorry, but if you want to use the built-in MILP solver, you have to use the built-in limitations of that solver.
If you still believe that you have uncovered a bug in the solver, please contact technical support--I am not equipped to diagnose a full-fledged detailed problem.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  4 Comments
Jochen Schuettler
Jochen Schuettler on 14 Sep 2016
...and, having read all of your answer once again: If I could write an integer ga solver, I'd earn my money at The Mathworks, probably. So, no crossover tweaking.
Alan Weiss
Alan Weiss on 14 Sep 2016
Thanks for your good-humored comments. I am glad that there was no bug in our software that caused you trouble. We try very hard to make reliable software, and take it very seriously when someone uncovers a bug.
One final comment. The intlinprog MILP solver sometimes can be adapted to help solve nonlinear integer problems. See this example of a quadratic problem. Maybe you can adapt that idea to your problem.
Good luck, and thanks again for reporting back.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (1)

Alan Weiss
Alan Weiss on 13 Sep 2016
This sounds to me like a bug. Thanks for the thorough report. Can you please tell us what version of MATLAB you are using? And can you give reproduction steps? It sounds as if you are solving a mixed-integer problem. I have never seen this bug, and I have solved a good number of such problems, so this might be hard for us to find without reproduction steps.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Comments
Jochen Schuettler
Jochen Schuettler on 14 Sep 2016
Hello Alan, it's R2014a. Can I send my code to you somehow? Else this is the call for ga:
Kostenfkt = @(x)Kosten_ga2(x,Gewichte,Kosten,SollZahlBereitschaften_gesamt,Klim,Olim_mat,K,K2,nicht_oefter,Oeffnungstage);
options = gaoptimset;
options = gaoptimset(options,'Generations', inf);
options = gaoptimset(options,'TimeLimit', 3600);
options = gaoptimset(options,'StallGenLimit', inf);
options = gaoptimset(options,'Display', 'off');
options = gaoptimset(options,'PlotFcns', { @gaplotbestf });
options = gaoptimset(options,'PlotInterval', 100);
options = gaoptimset(options,'UseParallel', true);
options = gaoptimset(options,'Vectorized', 'off');
[x,fval,exitflag,output,population,score] = ga(Kostenfkt,2*Olim,[],[],[],[],ones(2*Olim,1),ul,[],1:2*Olim,options);
It's a nonlinear all-integer optimization problem. It doesn't converge well, I have to tweak the Recombination function. Till now I just let it run very long, so it hits good solutions more or less by chance.
Best regards, Jochen
Jochen Schuettler
Jochen Schuettler on 14 Sep 2016
Additionally, changing 'UseParallel' to false changes nothing regarding the bug.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!