Azzera filtri
Azzera filtri

Hybrid Scheme in the Genetic Algorithm.

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 5 Gen 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});

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by