Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

optimisation using the ga function

Status
Not open for further replies.

duality

Electrical
Oct 18, 2005
1
Hi,

I'm trying to use the 'ga' function to optimise a model and am having some difficulties in using the tool. Specifically, I've got the following questions:

1. How do I set the parameter ranges for ga optimisation? For example, I want the moving average length tested to be between 5 and 200 hundred data points.

2. How do I make sure that parameter takes only integer values?

3. How do I include external data into the ga optimisation objective function? The examples I looked through in the help files uses functions in the form y = f(x), which do not make explicit use of external data. For example, the objective function I'm looking for can look like x = objfunc(data, p1, p2), where data is not necessarily a single vector and p1 and p2 are the parameters to be determined by the ga. (Note that I'm unable to use the objective function in this manner using the ga ... the ga function assumes that data is also a parameter)

4. If the objective function has more than one output, e.g. [x,y]=objfunc(z), how to set the optimisation for only one of them, e.g. x?

Below is an example that I hope will make things clearer for what I'm trying to achieve:

load data.mat

[p fval] = ga(@model1, 3);

[r,s] = model1(data, p1, p2, p3)

Thanks a bunch,

E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor