[Scilab-users] How to use Genetic Algorithms to optimize a function with multiple parameters?

eha eha at hs-furtwangen.de
Mon Feb 20 12:31:45 CET 2017


Dear Scilab community,

I am completely new to Scilab. Since I would like to get used to Genetic
Algorithms, I experimented a bit using the documentation's examples. Until
now, I am quite happy. My first steps went well, but I have got a question
regarding functions with multiple input parameters:

I experimented with optim_ga examples I could find in the documentation. All
of these examples had only one varying parameter, i.e. f(x). Now, I would
like optim_ga to find the minimum of e.g. Rosenbrock function or Ackley's
function, i.e. f(x,y). What do I have to do to find the minimum of such a
function with two (or more) parameters with optim_ga?

Even though I know that the following code does not work since it passes
only one parameter to function 'rosenbockC', it demonstrates my approach
(and surely why I fail, too).

clear;
clc;

// Rosenbock
function f=rosenbrockC(x1, x2)
    x = [x1 x2];
    f = 100.0 *(x(2)-x(1)^2)^2 + (1-x(1))^2;
endfunction

// Optimization parameters
PopSize     = 100;
Proba_cross = 0.7;
Proba_mut   = 0.1;
NbGen       = 10;
NbCouples   = 110;
Log         = %T;

ga_params = init_param();

// Parameters to control the initial population.
ga_params = add_param(ga_params,"dimension",2);

// Optimize
[pop_opt, fobj_pop_opt] = optim_ga(rosenbrockC, PopSize, NbGen, Proba_mut,
Proba_cross, Log, ga_params);

Thank you in advance for your help.
Hans



--
View this message in context: http://mailinglists.scilab.org/How-to-use-Genetic-Algorithms-to-optimize-a-function-with-multiple-parameters-tp4035535.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list