[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Help on automating optimization (genetic algorithms)



PureBytes Links

Trading Reference Links

Howard -

Absolutely great post.  I know that you had to skip some things to 
put together an overview (bias as a converge calc for example), but 
your summary and cautions to Gary seemed right on target to me.  We 
probably share some similar AI experience, but probably in different 
areas.  I've been down some deep "rat holes" with GA, back-prop 
neural nets, etc.

I was at a conference once sitting next to someone who had also done 
work in these areas related to investments, and the speaker was 
talking on genetic optimizers for portfolio composition.  This guy 
next to me sighed and said "It's like waving a drink in front of a 
recovering alcoholic".



--- In amibroker@xxxxxxxxxxxxxxx, "Howard Bandy" <howardbandy@xxxx> 
wrote:
> Hi Gary -
> 
>  
> 
> The procedure you describe is called "Evolutionary Operation" (and, 
as you
> describe it, is not related to genetic algorithms).  It works well 
when
> searching for optimal points among variables that do not have 
interactions.
> 
> 
>  
> 
> You can easily test to see if there are interactions.  Pick a 
trading system
> that has two (or more) variables, and run an optimization on them 
using two
> variables at a time.  Export the results to Excel.  Plot the 
objective
> function of your choice as a surface with the values for the two 
variables
> as the x and y axis.  In the two dimensional case, if the surface 
shows
> concentric circles (or close to circles) with the best solution 
somewhere
> inside the circles, then your method will work.  If two or more 
variables
> have interactions, you will see scattered non-contiguous areas, or 
banana
> shaped areas.  The method you suggest will not work in these cases.
> 
>  
> 
> An approach that is based on genetic algorithms is roughly as 
follows:
> 
> A.	Generate (through iteration or random selection) some number 
of
> points in your search space.  If your system is a moving average 
crossover,
> and has two variables - one for each moving average length, with 
limits of 1
> and 100 for both, then your search space is the "square" defined by 
MA1 from
> 1 to 100, and MA2 from 1 to 100.  The initial points are pairs 
(v1,v2) which
> represent values for the MA1 and MA2 variables.  In order to 
reasonably
> cover the space, you might want about 5 data points in each 
dimension.  So a
> two variable system will start with 25 points, a three variable 
system with
> 125 points, etc.  
> B.	Calculate the objective function at each point.
> C.	Go through a loop as follows until some stopping criterion 
(such as
> no significant improvement in objective function, or ten minutes of
> searching, or 100000 iterations, or whatever) is met:
> 
> 1.       Pick the best point(s) and remember the parameter values 
and
> objective function value.
> 
> 2.       Generate some new test points in the search space.  There 
are many
> methods for doing this.  The literature will describe them 
as "crossover",
> "mutation", "steepest descent", etc.  Using crossover, you might 
create the
> new points by taking the value for v1 from one good point and the 
value for
> v2 from another.  Using mutation, you might perturb one or more 
variables of
> a good point.  Using steepest descent, you might perturb every 
variable from
> a good point, then move in the direction of the best improvement.
> 
> 3.       Calculate the objective function at each point.
> 
>  
> 
> Note several things.
> 
> 1.	You must have complete confidence that your objective 
function ranks
> alternative results in the order you want them to be ranked.  You 
will not
> have an opportunity to evaluate intermediate results or alternative
> solutions.  See my earlier posts concerning objective functions for 
more
> details.
> 2.	You will not be able to cover all the possible data points in 
the
> search space, so it is possible that there are better solutions 
that have
> not been explored.  The literature discusses this as the problem of 
being
> "stuck" at a "local optimum" rather than finding the "global 
optimum".  In
> my opinion, it is not necessary to find "the best" solution.  It is 
only
> necessary to find "a sufficiently profitable" solution.
> 3.	If the surface formed by the objective function is not 
smooth, and
> you are using the crossover technique, the search routine will be 
trying to
> combine values from two or more good areas that are separated by 
bad areas,
> and will be confused.  Building a "smoothness" component into the 
objective
> function helps overcome this.
> 4.	You may or may not need to use AmiBroker's Optimize 
procedures.  You
> may be able to simply use a loop, calculating your own objective 
function,
> and storing intermediate results in an array or writing them out to 
a disk
> file periodically.  Or, you may want to use Optimize over a dummy 
variable
> in order to have AB calculate its standard objective functions.
> 5.	Genetic search procedures (and neural network search 
procedures)
> seem to encourage modelers (us people designing systems) to work 
with search
> spaces that have large dimensions.  Be Very Careful to avoid curve 
fitting.
> I Strongly Recommend that an Independent out-of-sample data set be 
reserved
> for testing before real trades are taken.
> 6.	Genetic and neural network searches, when applied to time 
series,
> often use three data sets.  The earliest is the "learning" set and 
is used
> to determine the best parameter values.  The next is the "testing" 
set and
> is used to determine when to stop the search.  The most recent is 
the
> "validation" set and is used Once (or a Very Few number of times) to
> determine whether the model will perform profitably out of sample.
> 
>  
> 
> Howard
> 
>  
> 
> -----Original Message-----
> From: Gary A. Serkhoshian [mailto:serkhoshian777@x...] 
> Sent: Wednesday, November 12, 2003 4:00 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Help on automating optimization (genetic 
algorithms)
> 
>  
> 
> Hi all,
> 
>  
> 
> I should preface this e-mail by saying that I'm not trying to 
create a Rube
> Goldberg as I can go through the process ourlined below manually.  
So, if
> what I'm suggesting requires a Rube Goldberg type solution let me 
know, and
> I'll let it go.
> 
>  
> 
> Essentially what I'm doing with optimizations over multiple 
variables is
> prioritizing variables on importance, and optimizing one variable 
at a time
> leaving the others static.  I just keep iterating through all the 
variables
> until things stabilize in terms of standard measures.  The cocktail 
party
> term is genetic algorithms, but between us it's necesary as 
optimizing over
> multiple variables (4+)  will either take too long or worse cause 
AmiBroker
> to crash due to memory issues.
> 
>  
> 
> Here's the punchline.  Can you all give some input on ways to 
program this
> in afl so as to automate the process outlined above rather than me 
manually
> iterating through as it is labor intensive.
> 
>  
> 
> Many thanks,
> 
> Gary
> 
>   _____  
> 
> Do you Yahoo!?
> Protect your identity with 
<http://antispam.yahoo.com/whatsnewfree>  Yahoo!
> Mail AddressGuard 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/>  Terms of Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/