code/inC/caga.c File Reference

The main()-containing file that calculates the fitness for an entire population of 2D CA, 9-neighborhood rulesets, where the fitness of each member is based on how many CAs of a given size can be correctly classified, as in majority classification. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "cellularAutomata.h"

Go to the source code of this file.

Functions

double * simulate (int **pop, int popSize, int caSize, int nStates, int nIters)
 Goes through the entire population, calculating the fitness of each member.
void usage ()
 Indicates how to use the program properly.
int ** getRules (char *file, int popSize)
 Gets the entire population of rules from the given file.
void freedom (int **rules, int popSize, double *fits)
 Free a lot of dynamically allocated memory used by this program.
void outputFitnesses (double *fits, int popSize)
 Outputs all of the fitnesses to the output file.
int verboseMain (char **argv)
 Identical to the main() function, except that verbosity is used.
int main (int argc, char **argv)

Variables

char outFile [256]
 The file to which the fitnesses are written.

Detailed Description

The main()-containing file that calculates the fitness for an entire population of 2D CA, 9-neighborhood rulesets, where the fitness of each member is based on how many CAs of a given size can be correctly classified, as in majority classification.

Author:
Ben Edwards <bedwards@cs.unm.edu>
Tyler Rush <me@tylerlogic.com>
Date:
Thursday April 1, 2010
Version:
1.0.0

Definition in file caga.c.


Function Documentation

void freedom ( int **  rules,
int  popSize,
double *  fits 
)

Free a lot of dynamically allocated memory used by this program.

Definition at line 170 of file caga.c.

int ** getRules ( char *  file,
int  popSize 
)

Gets the entire population of rules from the given file.

Parameters:
file The text file containing the entire population.
popSize The size of the population of rules, used for knowing when to stop extracting the memeber.
Returns:
The list of rules, and remember that the rules are a list of ints, so hence a matrix is returned.

Definition at line 190 of file caga.c.

int main ( int  argc,
char **  argv 
)

Definition at line 37 of file caga.c.

void outputFitnesses ( double *  fits,
int  popSize 
)

Outputs all of the fitnesses to the output file.

Parameters:
fits The list of fitnesses.
The size of the population, in order to know when to stop traversing the array of fitnesses.

Definition at line 150 of file caga.c.

double * simulate ( int **  pop,
int  popSize,
int  caSize,
int  nStates,
int  nIters 
)

Goes through the entire population, calculating the fitness of each member.

Parameters:
pop The set of rules that make up the population.
popSize The number of members in the population.
caSize The dimension of the square CA.
nStates The number of states that should be evaluated in order to determine the fitness of each member.
nIters The number of iterations that each evaluated CA should go through. Also can be thought of as the maximum number of iterations that a rule has to successfully classify the CA.
Returns:
An array of the fitnesses for each member. Each value in the array is the corresponding fitness of the member at the same index in the population.

Definition at line 235 of file caga.c.

void usage (  ) 

Indicates how to use the program properly.

Explains how to use this program.

Definition at line 286 of file caga.c.

int verboseMain ( char **  argv  ) 

Identical to the main() function, except that verbosity is used.

Parameters:
argv The parameters passed to the program.
Returns:
An integer indicating the state of the program.

Definition at line 96 of file caga.c.


Variable Documentation

char outFile[256]

The file to which the fitnesses are written.

Definition at line 34 of file caga.c.


Generated on Mon Apr 12 21:34:48 2010 for CS523: Complex Adaptive Systems, Spring 2010, Assignment 2 by  doxygen 1.6.1