📄 structure.html
字号:
<html><title>Directory and File Structure of Avida</title><body bgcolor="#FFFFFF" text="#000000" link="#0000AA" alink="#0000FF" vlink="#000044"><h2 align=center>Directory and File Structure of Avida</h2><p>This document contains a guide to all of the files present in avida, andwhere they are located.<h3>Filenames</h3><p>Source code files in avida follow a standard naming convention.A file that ended in "<tt><font color="000088">.hh</font></tt>" is a calleda "header" file, while one that ends in"<tt><font color="000088">.cc</font></tt>" is a "code" file. Headerstend to contain class descriptions with only the declaration of theirmethods, while their corresponding code files contain the methoddefinitions. When one file needs to use a class defined in another, allthat it needs to do is reference the header file. Since the bulk of thesource code will be in the code file, this minimized cross-compilation.<p>When you compile a program in C++, it goes through a "compilation" phaseand then a "link" phase. The compilation phase takes each code (<tt>.cc</tt>)file and compiles it independently into an object (<tt>.o</tt>) file. In thelink phase, all of these compiled object files are linked together into asingle executable (such as "<tt>primitive</tt>").<p>Since the bodies of the methods are only in the code files, they only needto be compiled once into a single object file. If you place a functionbody in the header file it will get compiled again each time anotherclass includes that header. Since a header will often be included becauseonly one or two methods from a class are required, this can create real bloat -- a function will be compiled as long as its body is included, evenif the method is never directly called within the object file being created.<p>For example: The cOrganism object is declared in the file"<tt><font color="#000088">organism.hh"</font></tt>" and the fullydefined in "<tt><font color="#000088">organism.cc"</font></tt>". Whenthis file is compiled, it creates the object file"<tt><font color="#000088">organism.o</font></tt>". Both the cPopulationclass ("<tt><font color="#000088">population.cc</font></tt>") and thecTestCPU class ("<tt><font color="#000088">test_cpu.cc</font></tt>") usethe cOrganism object, but its methods are in"<tt><font color="#000088">organism.cc"</font></tt>", so they only need tobe compiled once, and are then linked in at the link stage.<p>Occasionally you want short functions to have their bodies directly in theheader file. When a function compiled in one object file is run from another,the linker basically points the caller to the location of that function.There are an extra few CPU cycles expended while it goes to find that functionand starts it up. A small function can be made "<tt>inline</tt>", whichmeans it will be placed, as a whole, right inside of the function that callsit. If the function is short enough, it only takes up as much space as thecall to it would have taken anyway, and hence does not increase the sizeof the executable.<p>This will probably start to make more sense when you are directly modifyingthe code.<h3>Directory: <tt><font color="#008844">current/</font></tt></h3>All of the files for the current version of avida reside in the directorylabeled "<font color="#008844"><tt>current/</tt></font>", which isautomatically created when you check avida out of the CVS. In addition tothe subdirectories "<tt><font color="#008844">doc/</font></tt>","<tt><font color="#008844">source/</font></tt>" and"<tt><font color="#008844">work/</font></tt>" (all described below),this directory contains several key information and automatic compilationfiles. The most important of these are described here.<p><table cellpadding=4><tr><td valign=top><tt><font color="#000088">configure</font></tt> <td>This is a script used to choose which portions of avida should be compiled and how. In particular, it allows the user to choose "<tt><font color="#000000">--enable-debug</font></tt>" for debugging options (which slow avida down substantially, but turn on checks to make sure nothing is going wrong) or "<tt><font color="#000000">--enable-viewer</font></tt>" for the ncurses viewer and "<tt><font color="#000000">--enable-qt-viewer</font></tt>" for the graphical viewer. Several other options can be listed by typing "<tt><font color="#000000">./configure --help</font></tt>" in this directory.<tr><td valign=top><tt><font color="#000088">Makefile</font></tt> <td>This file performs the compilation after the configure script is run. When you make changes to the source code, you can type "<tt>make</tt>" to process the Makefile without needing to re-configure.<tr><td valign=top><tt><font color="#000088">AUTHORS</font></tt> <td>This file contains information about the authorship of avida.<tr><td valign=top><tt><font color="#000088">COPYING</font></tt><br> <tt><font color="#000088">COPYING.gpl</font></tt> <td valign=top>These files contain copyright information.<tr><td valign=top><tt><font color="#000088">README</font></tt> <td>A general guide on how to get started once you put the avida files on your machine.<tr><td valign=top><tt><font color="#000088">README.cvs</font></tt> <td>How-to guide on setting up avida from the CVS<tr><td valign=top><tt><font color="#000088">INSTALL</font></tt> <td>How to install avida on your machine.<tr><td valign=top><tt><font color="#000088">NEWS</font></tt> <td>Ideally a list of all recent changes to avida. In practice, its not being kept as up-to-date as it should be.</table><h3>Directory: <tt><font color="#008844">current/work/</font></tt></h3><p>After you type "<tt>make install</tt>", this directory will contain all ofthe configuration files for avida (explained in more detail under in theirown documentation files). The key files and directorieshere are:<p><table cellpadding=4><tr><td valign=top><tt><font color="#000088">analyze.cfg</font></tt> <td>The default file used to write analysis scripts.<tr><td valign=top><tt><font color="#000088">environment.cfg</font></tt> <td>This file contains the default environment information.<tr><td valign=top><tt><font color="#000088">events.cfg</font></tt> <td>This file contains the default event list.<tr><td valign=top><tt><font color="#000088">genesis</font></tt> <td>This is the main configuration file that is used by default.<tr><td valign=top><tt><font color="#000088">inst_set.default</font></tt> <td>This is the main, heads-based instruction set that is used by default.<tr><td valign=top><tt><font color="#000088">organism.default</font></tt> <td>This file contains a short, default starting ancestor. Watch out because sometimes it can get stuck at a small length and not acquire any tasks.<tr><td valign=top><tt><font color="#000088">organism.heads.100</font></tt> <td>This is a longer (length 100), hand written ancestor. It is nearly identical to <tt><font color="#000088">organism.default</font></tt>, but contains a long sequence of the "<tt>nop-C</tt>" instruction to pad its length.<tr><td valign=top><tt><font color="#008844">genebank/</font></tt> <td>This directory is created when you run avida. If you save any individual genotypes during the course of a run, their files will be placed here by default.</table><h3>Directory: <tt><font color="#008844">current/source/</font></tt></h3>This is a large sub-directory structure that contains all of the sourcecode that makes up avida. Each sub-directory here will include its ownMakefile information. The only two important files directly in thisdirectory are:<p><table cellpadding=4><tr><td valign=top><tt><font color="#000088">LEVELS</font></tt> <td>This is a "levelization" map of most of the avida files. It is good programming technique to keep track of which files depend on each other, and to make sure there are no "circular dependencies". This file keeps track of all of the dependencies, placing each component on a level, where they only depend on files in lower levels. See the <a href="level_map.html">levelization map</a> for more information on this.<tr><td valign=top><tt><font color="#000088">defs.hh</font></tt> <td>This is a header file that contains all of the definitions required globally throughout the avida source.</table><h3>Directory: <tt><font color="#008844">current/source/main/</font></tt></h3>This sub-directory contains all of the core source code files for the software.For ease, I'm listing them in three groups of "more important components","less important components", and "utility components", each in alphabeticalorder. The syntax "<tt>name.??</tt>" indicates that I am referring to bothof the files, "<tt>name.hh</tt>" and "<tt>name.cc</tt>". The more importantfiles are:<p><table cellpadding=6><tr><td valign=top><tt><font color="#000088">analyze.??</font></tt> <td valign=top>These files define the class cAnalyze and associated helper classes, which work together to run the analyze mode in avida. All of the code to process the analyze.cfg file is located here.<tr><td valign=top><tt><font color="#000088">avida.??</font></tt> <td valign=top>These are the main files that manage an avida run. They process command line arguments, setup global classes, and hand control over to the driver class that will actually run the avida experiment.<tr><td valign=top><tt><font color="#000088">config.??</font></tt> <td valign=top>These files define the cConfig object that maintains the current configuration state of avida. This class is initialized by the genesis file, but can later be modified by the event list.<tr><td valign=top><tt><font color="#000088">environment.??</font></tt> <td valign=top>This file defines the cEnvironment object, which controls all of the environmental interactions in an avida run. It makes use of reactions, resources, and tasks.<tr><td valign=top><tt><font color="#000088">genebank.??</font></tt> <td valign=top>The cGenebank object, defined here, keeps track of genotype (and species) formation in the population. Every time a new organism is born, the genebank assigns it a genotype.<tr><td valign=top><tt><font color="#000088">genome.??</font></tt> <td valign=top>The cGenome object maintains of a sequence of objects of class cInstruction.<tr><td valign=top><tt><font color="#000088">genotype.??</font></tt> <td valign=top>The cGenotype object maintains statistics about those organisms that have the associated identical genome.<tr><td valign=top><tt><font color="#000088">inst.??</font></tt> <td valign=top>The cInstruction class is very simple, maintaining a single instruction in avida.<tr><td valign=top><tt><font color="#000088">inst_lib.??</font></tt> <td valign=top>The cInstLib class associates instructions with their corresponding functionality in the hardware, and keeps track of the full set of possible instructions available in the current run.<tr><td valign=top><tt><font color="#000088">mutations.??</font></tt> <td valign=top>These files contain the cMutationRates class which maintain the probability of occurrence for each type of mutation.<tr><td valign=top><tt><font color="#000088">organism.??</font></tt> <td valign=top>The cOrganism class represents a single organism, and contains the initial genome of that organism, its phenotypic information, its virtual hardware, etc.<tr><td valign=top><tt><font color="#000088">phenotype.??</font></tt> <td valign=top>The cPhenotype class maintains information about what a single organism has done over the course of its life.<tr><td valign=top><tt><font color="#000088">population.??</font></tt> <td valign=top>The cPopulation class manages the organisms that exist in an avida population. It maintains a collection of cPopulationCell objects (either as A grid, or independent cells for mass action) and contains the scheduler, genebank, event manager, etc.<tr><td valign=top><tt><font color="#000088">population_cell.??</font></tt> <td valign=top>A cPopulationCell is a single location in an avida population. It can contain an organism, and has its own mutation rates (but not yet its own environment.)<tr><td valign=top><tt><font color="#000088">stats.??</font></tt> <td valign=top>A cStatistics object maintains track of many different population-wide statistics.</table><p>Next, we have the less important files, which are basically various forms
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -