ECJ-INTEREST-L Archives

February 2009

ECJ-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
Date:
Sun, 22 Feb 2009 16:17:05 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (28 lines)
Vlad Palnik wrote:

> 1 Has anyone found a solution which avoids
> building a unique class for every variable in
> a problem. Say you have over a thousand
> variables, is there a way to define a single
> class which returns different variables ???
> (I believe this is partly due to how java works)

I'm not sure what you mean by 'variable' here, but let's assume you mean
something like the 'X' in Symbolic Regression. The answer is: sure, of
course. Instead of an X.java and Y.java etc., just make a Variable.java
file. In this file, make a subclass of ERC.java.

You're responsible for creating at least the resetNode(), encode(), and
nodeEquals() methods, and probably will want to define the toString()
method too. Your ERC's value will be an integer from 0..N-1 where N is
the number of variables. You'd store that value as an instance
variable. Your toString() method etc. would likely print out not the
number but a pretty version of the variable (printing out 'X' instead of
1, 'Y' instead of 2, etc.).

Now we just have a global array, of size N, stored in your Problem
class. Each slot holds the current value of one of the variables. When
your method is evaluated, you just go to that slot and return its value.

Sean

ATOM RSS1 RSS2