Effacer les filtres
Effacer les filtres

Hybrid Scheme in the Genetic Algorithm.

1 vue (au cours des 30 derniers jours)
Ba Ba Black Sheep!
Ba Ba Black Sheep! le 5 Jan 2017
Why doesn't neither of the following codes compile?
function genetic()
FitnessFcn = @dejong2fcn;
numberOfVariables = 2;
options = optimoptions(@ga,'PlotFcns',{@gaplotbestf,@gaplotstopping});
rng('default');
ga(FitnessFcn,numberOfVariables,[],[],[],[],[],[],[],options);
end
.
function hybrid()
fminuncOptions = optimoptions('Display','iter','Algorithm','quasi-newton');
options = optimoptions('HybridFcn',{@fminunc, fminuncOptions});
options = optimoptions(options,@ga,'PlotFcns',{@gaplotbestf,@gaplotstopping});
ga(@dejong2fcn,numberOfVariables,[],[],[],[],[],[],[],options);
end
I have written that code just like the following documentation.
Then, what is the issue?

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Jan 2017
First one:
Undefined function or variable 'dejong2fcn'.
Second one: you have not properly passed the solver names in.
fminuncOptions = optimoptions(@fminunc,'Display','iter','Algorithm','quasi-newton');
options = optimoptions(@ga,'HybridFcn',{@fminunc, fminuncOptions});
options = optimoptions(options,'PlotFcns',{@gaplotbestf,@gaplotstopping});

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by