Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Genetic Algorithm and working with discrete variables
Date: Wed, 22 Aug 2007 14:58:20 +0000 (UTC)
Organization: QinetiQ Ltd
Lines: 34
Message-ID: <fahiuc$hj7$1@fred.mathworks.com>
References: <fah9bs$lne$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187794700 18023 172.30.248.38 (22 Aug 2007 14:58:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 22 Aug 2007 14:58:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 503430
Xref: news.mathworks.com comp.soft-sys.matlab:424965



"Mohammad " <john.doe.nospam@mathworks.com> wrote in message
<fah9bs$lne$1@fred.mathworks.com>...
> hello
> How can I do in the GAtool (genetic algorithm toolbox) if 
> my variables are allowed to select from a set of special 
> discrete values? because it works with continuous ranges of 
> values. thanks. good luck

I've not done it; but suggest that you get the mutation
function to optimise over a bounded continuous range; (say
0.5 to 8.5). 

In this case, you would have 8 discrete variables. Round the
output of the mutation function - you get 1,2,3,4,5,6,7 or
8. Use the output to index into your discrete variable.

If you need to assign a continuous desirability function,
then do this:

x = [0.5 1 2 3 4 5 6 7 8 8.5];
y = [0 s1 s2 s3 s4 s5 s6 s7 s8 0]; 
% where sx is the score of 
% the corresponding discrete variable
pp = pchip(x,y); 
% don't use spline, or it'll 
% oscillate like mad

% then access the desirability 
% score using:
yi = ppval(xi);

Just a few ideas- hope it helps :)

Tom