Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON Programming Language 1. randomly generatea LGP individual withno more than[max_prog_length] instructions(4marks); 2. remove structurally ineffective instructions of the LGP program(4 marks); 3. print

IN PYTHON Programming Language

1. randomly generatea LGP individual withno more than[max_prog_length] instructions(4marks);

2. remove structurally ineffective instructions of the LGP program(4 marks);

3. print the original and structural-intron-free LGP programs(2marks)

GIVE BELOW is the main.py file where the answer is to be coded.

*************************************************************************************************

# Assignment 5 - LGP program generation and structural intron removal

def main():

# setting parameters max_prog_length = 6 # 6 instructions in total is the upper limit n_calculation_reg = 3 # {r0, r1, r2} and r0 is designated as the output register n_input_reg = 2 # {r3, r4} are the input registers n_operators = 4 # {+, -, *, /} are the operators n_constant = 5 # {1, 2, 3, 4, 5} are the constants constant_rate = 0.4 # An operand can be a constant with a 40% chance, however, both operands cannot be constants at the same time

##### 1. randomly generate a LGP program with no more than [max_prog_length] instructions # Hint: an instruction can be represented by a list of 4 elements, # i.e., its return register, operator, first and second operands # a LGP program is thus a list of instructions program = []

# student code begins

# student code ends

##### 2. print the LGP program as a list of instructions # An instruction should be printed as, for instance r3 = r1 + r0 or r2 = r0 * 5 print("The randomly generated LGP program is:")

# student code begins

# student code ends

##### 3. remove a program's structural intron program_intron_free = program.copy() effective_registers = ['r0'] effective_instruction_indices = []

# student code begins

# student code ends

##### 4. print the effective registers and the structual-intron free LGP program print("The effective registers are:") print(effective_registers) print("The LGP program withou any structual intron is:") # student code begins

# student code ends

# end of main

main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions