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.