ec.app.majority
Class MajorityGA
- java.lang.Object
-
- ec.Problem
-
- ec.app.majority.MajorityGA
-
- All Implemented Interfaces:
- Prototype, Setup, SimpleProblemForm, java.io.Serializable, java.lang.Cloneable
public class MajorityGA extends Problem implements SimpleProblemForm
MajorityGA.java Implements a GA-style vector rule for the one-dimensional Majority-Ones cellular automaton problem. This code is in the spirit of Das, Crutchfield, Mitchel, and Hanson, "Evolving Globally Synchronized Cellular Automata", http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.55.7754&rep=rep1&type=pdf The primary difference is in the trials mechanism, in which we're using 25/25/50 rather than 50/50/0. If you run java ec.app.majority.MajorityGA, it'll test using the ABK rule instead (0.8342 using 10000 tests, 0.82528 if you use 100000 tests, 0.823961 if you use 1000000 tests)- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intCA_WIDTHstatic intNEIGHBORHOODstatic intNUM_TESTSstatic intNUM_TRIALSstatic intSTEPS
-
Constructor Summary
Constructors Constructor and Description MajorityGA()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static booleanall(int[] vals, int val)voiddescribe(EvolutionState state, Individual ind, int subpopulation, int threadnum, int log)Part of SimpleProblemForm.voidevaluate(EvolutionState state, Individual ind, int subpopulation, int threadnum)Evaluates the individual in ind, if necessary (perhaps not evaluating them if their evaluated flags are true), and sets their fitness appropriately.voidfinishEvaluating(EvolutionState state, int threadnum)Will be called by the Evaluator after prepareToEvaluate(...) is called and then a series of individuals are evaluated.voidgenerateTrials(EvolutionState state, int thread)static voidmain(java.lang.String[] args)voidprepareToEvaluate(EvolutionState state, int threadnum)May be called by the Evaluator prior to a series of individuals to evaluate, and then ended with a finishEvaluating(...).voidsetup(EvolutionState state, Parameter base)Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.-
Methods inherited from class ec.Problem
canEvaluate, clone, closeContacts, defaultBase, describe, initializeContacts, reinitializeContacts
-
-
-
-
Field Detail
-
NUM_TRIALS
public static final int NUM_TRIALS
- See Also:
- Constant Field Values
-
CA_WIDTH
public static final int CA_WIDTH
- See Also:
- Constant Field Values
-
NEIGHBORHOOD
public static final int NEIGHBORHOOD
- See Also:
- Constant Field Values
-
STEPS
public static final int STEPS
- See Also:
- Constant Field Values
-
NUM_TESTS
public static final int NUM_TESTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateTrials
public void generateTrials(EvolutionState state, int thread)
-
setup
public void setup(EvolutionState state, Parameter base)
Description copied from interface:PrototypeSets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
-
prepareToEvaluate
public void prepareToEvaluate(EvolutionState state, int threadnum)
Description copied from class:ProblemMay be called by the Evaluator prior to a series of individuals to evaluate, and then ended with a finishEvaluating(...). If this is the case then the Problem is free to delay modifying the individuals or their fitnesses until at finishEvaluating(...). If no prepareToEvaluate(...) is called prior to evaluation, the Problem must complete its modification of the individuals and their fitnesses as they are evaluated as stipulated in the relevant evaluate(...) documentation for SimpleProblemForm or GroupedProblemForm. The default method does nothing. Note that prepareToEvaluate() can be called *multiple times* prior to finishEvaluating() being called -- in this case, the subsequent calls may be ignored.- Overrides:
prepareToEvaluatein classProblem
-
finishEvaluating
public void finishEvaluating(EvolutionState state, int threadnum)
Description copied from class:ProblemWill be called by the Evaluator after prepareToEvaluate(...) is called and then a series of individuals are evaluated. However individuals may be evaluated without prepareToEvaluate or finishEvaluating being called at all. See the documentation for prepareToEvaluate for more information. The default method does nothing.- Overrides:
finishEvaluatingin classProblem
-
all
public static boolean all(int[] vals, int val)
-
evaluate
public void evaluate(EvolutionState state, Individual ind, int subpopulation, int threadnum)
Description copied from interface:SimpleProblemFormEvaluates the individual in ind, if necessary (perhaps not evaluating them if their evaluated flags are true), and sets their fitness appropriately.- Specified by:
evaluatein interfaceSimpleProblemForm
-
describe
public void describe(EvolutionState state, Individual ind, int subpopulation, int threadnum, int log)
Description copied from class:ProblemPart of SimpleProblemForm. Included here so you don't have to write the default version, which usually does nothing.- Specified by:
describein interfaceSimpleProblemForm- Overrides:
describein classProblem
-
main
public static void main(java.lang.String[] args)
-
-
DMelt 3.0 © DataMelt by jWork.ORG