📄 petrol.html
字号:
<html> <head><title>Petrol</title></head><BODY BGCOLOR="#000000" TEXT="#DDDDDD" link="#FF0000" vlink="#AA0000"><h1>Petrol</h1><h3>Code</h3><a href="petrol.tar.gz">petrol.tar.gz</a><p><h3>Quick Start Guide</h3>The file that contains the <code>fitness()</code> function is<code>fitness.c</code>. You are passed a pointer to<code>Individual</code> structure (<code>petrol.h</code>) that has thefollowing fields: <p><pre> int *chrom; int chromLen; double fitness;</pre><p>The <code>chrom</code> field is the encoded individual of thepopulation of a length defined by <code>chromLen</code>.<p>Once the fitness function has been implemented both<code>petrol</code> and <code>petrolslave</code> need to be remade.In order to do this though, you need to make sure your shellenvironment has both <code>PVM_ROOT</code> and <code>PVM_ARCH</code>defined. Here is an example <code>.cshrc</code> fragment that showshow to set them:<p><pre>if ( -d ~/pvm3 ) then setenv PVM_ROOT ~/pvm3endifset pvm = ( )if ( $?PVM_ROOT ) then if ( -x $PVM_ROOT/lib/pvmgetarch ) then setenv PVM_ARCH `$PVM_ROOT/lib/pvmgetarch` set pvm = ( $PVM_ROOT/lib/$PVM_ARCH $PVM_ROOT/bin/$PVM_ARCH ) endifendif...set path = ( ~/bin $pvm /bin /usr/bin /usr/local/bin /usr/X11R6/bin )...</pre><p>In order for this to work you need to create a <code>pvm3</code>directory in your home directory with symbolic links from thatdirectory to the installed PVM location:<p><pre>cdmkdir pvm3cd pvm3ln -s ~pvm/lib .ln -s ~pvm/include .ln -s ~pvm/man .mkdir bin</pre><p>Another thing to add to your <code>.cshrc</code> could be thefollowing environment setting to allow you to read the PVMman-pages:<p><pre>setenv MANPATH /usr/man:/usr/local/man:/usr/X11R6/man:$PVM_ROOT/man</pre><p>At this point you should test your <code>.cshrc</code> by restartingyour current shell and execute <code>echo $PVM_ROOT $PVM_ARCH$path</code>.<p>Back in the <code>petrol</code> directory, you need todo a <code>make install</code>. This will build all the objects for<code>petrol</code> and <code>petrolslave</code> (all suffixed with<code>$PVM_ARCH.o</code>), link, and install them into<code>~/pvm3/bin/$PVM_ARCH</code>. For each architecture, you need tobuild binaries on those machines (i.e., on the DEC stations, buildpetrol, on the Linux boxes, build petrol, etc.).<p>Once all the binaries have been built, PVM needs to be started and thehost machines need to be added to the virtual machine. There are twoways to add hosts. The first is to start PVM and enter the hosts byusing the <code>add</code> command:<p><pre>% pvmpvm> add dws0071 successful HOST DTID dws007 80000pvm> conf2 hosts, 1 data format HOST DTID ARCH SPEED batman 40000 LINUX 1000 dws007 80000 PMAX 1000pvm></pre><p>The other way is to create a file with each line containing a name ofa host and start PVM with the name of the file as the command lineargument.<p>Finally, execute <code>petrol</code> from your shell (notin <code>pvm</code>). This will start a <code>petrolslave</code> on eachof the hosts in your virtual machine and start a run of how every manygenerations specified.<p>IMPORTANT NOTE: If for some reason you stop <code>petrol</code> in themiddle of a run, you need to cleanup the <code>petrolslave</code>processes by hand. To do this, in the <code>pvm</code> console, do a<code>ps -a</code> and <code>kill</code> each of the<code>DTID</code> numbers listed. Or, if you <code>halt</code> themachine, it will kill them for you.<p><h3>Petrol Options</h3><pre>petrol [-b int] [-c float] [-g int] [-l int] [-m float] [-n] [-o string] [-p int] [-s int] [-v]-b PVM block size (default 10)-c Probability of crossover (default 0.66)-g Number of generations (default 500)-l Chromosome length (default 100)-m Probability of mutation (default 0.001)-n Minimize (default FALSE)-o Output to a file (default stdout)-p Population size (default 100)-s Random seed (default current time)-v Print extra information (verbose)</pre><p><h3>Code Structure</h3><h4><code>petrol.h</code></h4>The <code>Population</code> and <code>Individual</code> structures aredefined in this file, along with all the functions and theirparameters.<p><h4><code>petrol.c</code></h4>This file contains the startup code and command line processing. Theimportant part is in <code>main()</code> where<code>PopulationRun()</code> is called.<p><h4><code>population.c</code></h4>All the <code>Population</code> functions are here.<code>PopulationRun()</code> is the main loop of <code>petrol</code>.<code>PopulationGeneration()</code> is where the selection andcrossover takes place.<p><h4><code>report.c</code></h4>If any output needs to be changed, this is the file to modify.<code>ReportInitial()</code> is called before the first generation,<code>ReportGeneration()</code> is called after every new generation,and <code>ReportDone()</code> is called after all the generations havebeen created. These three functions are called from<code>PopulationRun()</code> in <code>population.c</code>.<p><h4><code>petrolslave.c</code> and <code>pvmfitness.c</code></h4>Both of these files perform the communication via PVM.<code>PVMFitness()</code> spawns off the <code>petrolslave</code>processes, sends the <code>Individual</code> structures, and fills inthe resulting fitness values. All <code>petrolslave</code> does isrespond to work requests and runs <code>fitness()</code> on the remotemachines.<p><h4><code>utils.h</code> and <code>utils.c</code></h4>These contain various utility functions used throughout<code>petrol</code>.<p><h3>References</h3>A good website to check out is the <ahref="http://www.epm.ornl.gov/pvm/pvm_home.html">Parallel VirtualMachine (PVM)</a>.<hr><address><STRONG><a href="http://www.cs.unr.edu/~eblood">EricBlood</a></STRONG><BR><A HREF="mailto:eblood@cs.unr.edu">eblood@cs.unr.edu</A><BR></address><!-- hhmts start -->Last modified: Thu Sep 26 14:40:08 1996<!-- hhmts end --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -