Math 230 project 3 genetic algorithm crossover using MIPs
Biological processes are often used as a basis for computer science algorithms. In computer science a "Genetic Algorithm" is a group of algorithms used to search large spaces to optimize a problem. There are a wide variety of variations in the implementations, all of which depend on the problem you're trying to solve. For this assignment, you will implement a very small element of a Genetic Algorithm, recombination. Recombination is the process of constructing new chromosomes from specific segments of two selected parent chromosomes.
The most common type of recombination involves making two new chromosomes from the sequences of two selected parents. This is done by choosing a point in the two parent sequences, copying each gene up to the point, then swapping all the remaining genes. For instance, if the chosen point splits the parents in half, then the first half of Parent A is joined to the latter half of Parent B, while the first half of Parent B is joined to the latter half of Parent A. This creates two new offspring with the varying features of both parents.
In this assignment you will prompt the user to input from the keyboard two strings of characters, each of length 16, and an integer value representing the cross-over point (ranging from 0 thru 15). You will write code that performs the cross-over operation and then subsequently writes the output to the terminal. Use of at least 2 functions is required.
A number of system services, mainly for input and output, are available for use by your MIPS program. They are described in the table found under the syscalls tab of the MARS help page. MIPS register contents are not affected by a system call, except for result registers as specified in the help page.
How to use SYSCALL system services:
- Load the service number in register $v0.
- Load argument values, if any, in $a0, $a1, $a2, or $f12 as specified.
- Issue the SYSCALL instruction.
- Retrieve return values, if any, from result registers as specified.
Example: display the value stored in $t0 on the console
li $v0, 1 # ser integer
add $a0, $t0, $zero # load desired value into argument register $a0 syscall
Sample run of code:
Enter your first string with no spaces (16 total): aaaabbbbccccdddd
Enter your second string with no spaces (16 total): 0000111100001111 Enter an integer between 0 & 15 (to be later used as an upper limit for splitting the arrays): 6
You entered the following:
Creating newly evolved candidates from your specified inputs...
Child One and Child Two are shown below:
aaaabbb100001111 0000111bccccdddvice 1 is printd
-- program is finished running --<>.data
#pre-made prompt messages
Prompt_encDec: .asciiz "type `e' to encrypt or `d' to decrypt: "
INBUFFER: .byte 0x11:100 #filling memory with this to make it easy to see
OUTBUFFER: .byte 0x22:100 #filling memory with this to make it easy to see
#prompt user to input 'e' or 'd' li $v0,4 la $a0,Prompt_encDec syscall
#read encrypt or decrypt choice li $v0,12 #set syscall to read char syscall
#jump to encrypt if 'e' or 'E' entered beq $v0,101,ENCRYPT #lowercase e
- prompts and accepts the user input for 16 chars (2 pts)
- writes input strings to memory (2 pts)
- writes output strings to console (2 pts)
- correctly does crossover (6 pts)
- sufficient comments (2 pts)
- effective use of functions/modularization (3 pts)
Proj 3: Evolutionary Algorithm Teaser
Programs that don't assemble/compile will receive a grade of 0.
points given for above:
- input prompt: x/2
- writes to memory: x/2
- writes output to console: x/2
- implements crossover successfully: x/6
- comments adequately : x/2
- uses modularization: x/3