i want to optimise(with genetic algorithm) a error function derived from 7 variables to obtain values of those variables. please tell me how to use ga on that function?

i have integrated 7 variables in the error function. in other terms, derived that function from them. function does't contain variables itself but made up of them. so how can i use genetic algorithm (optimisation) in this kind of situation.

Answers (1)

While I would not recommend using ga for this problem, the setup for ga or any other optimization solver is the same:
  1. Write your objective function (fitness function) as a function that takes one vector variable x = (x(1),...,x(k)) of control variables that you want to set, and outputs the objective function value. Suppose that your function is called objfun.
  2. Pass the objective function to your solver as a function handle @objfun.
For examples, see the Getting Started examples in Global Optimization Toolbox or in Optimization Toolbox documentation.
It sounds as if you are trying to minimize a discrepancy between a function and data (curve fitting), using x as parameters to optimize. If so, see Nonlinear Data Fitting.
Alan Weiss
MATLAB mathematical toolbox documentation

Categories

Asked:

on 5 Apr 2016

Answered:

on 5 Apr 2016

Community Treasure Hunt

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

Start Hunting!