
The source code using neural network methods to solve the N-Queen problem as well as a data preparation file are given below. They are both written in C and C++ and are designed for any environment, preferably UNIX.
The program wasn't flexible with regard to opening the ranum files.
The next step is optional, but is recommended
as it helps when analyzing the data. The output method of the program should
be changed so that it only outputs 4 numbers: Alpha, Znaut, Feasibility
and Average iterations, where alpha and znaut represent the input arguments
and Feasibility represents the chance of finding a solution to the N-queen
problem from that starting point. The average number of iterations is the
average number of calculations required to get that solution. Example output
of the program from a single job is:
Lastly, to change the size of the chessboard
the line:
When all of the above is running, Clustor can be introduced to help speed up the process of getting through all the jobs. A file called clustor.nodes must be created to tell clustor which computers (nodes) to use and where to find them (ie. through telnet). This allows clustor to login to each machine and run the jobs on them. The file should also have the login name and possibly the password for each node. If you want to run the program in background mode, then the password needs to entered.
This picture shows the first screen in Clustor. To prepare a plan for clustor click on the preparator button. The wizard appears to help you make a plan. For this application you should first enter the parameters alpha and znaut.
Enter the name and label, click on range next to floating point, as the variables for alpha are from 0.05 to 1.00. Set the values for alpha by clicking on set value.
This is repeated for parameter znaut.
Skip the next few windows until the User Command window appears.
The command line shown should include the exact directory locations of dataprep and queen otherwise clustor will not be able to find these files. $jobname is a number representing which job is being completed. The file output.$jobname contains the results for that job. For example, if job 035 is being executed, the results will be placed in "output.035".
Skip the rest of the windows to complete the plan file.
Save this file and move to the generator phase. This phase compiles the plan to create a run file for the dispatcher to execute.
The generator window will open, stating that 361 jobs have been created. If everything is correct, move to the dispatch phase.
From here Clustor executes the jobs on the specified nodes in the clustor.nodes file.
While running, a status window gives the estimated finishing time, how many nodes are available and whether or not jobs were successful.
When all jobs are complete the output files are copied back to the root machine.
|
|
|