Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. (4 points) Within your code's main portion, write some test code for both of your functions. For power set, verify that the function works

image text in transcribed
3. (4 points) Within your code's main portion, write some test code for both of your functions. For power set, verify that the function works correctly for arguments of several different lengths. Be sure to test with a list of length 0 too! For find optimal subset, test by using the set of experiments from the earlier table, with a payload capacity of 700. This should result in an optimal subset containing experiment IDs 1, 3, 5, 6, 8, 9, 10, 11, and 12, with a combined mass of 697 kg and value rating of 53. 4. (6 points) The brute force approach to solving our space launch problem has to consider all subsets of the set of experiments. Since we have only 12 experiments to consider, there are 212 4096 total subsets to analyze, which isn't bad at all for a computer. But what if we double the size of the set of experiments, to 24? Suddenly we're looking at 224 = 16,777,216 subsets! Not good. Within your code's main portion, create a new 2D list representing a set of 24 experiments. The ID numbers should range from 1 to 24, but the masses and value ratings can be randomly generated. To generate random numbers in Python, you can use the randint functon from the random module: from random import randint # Assign x a random integer between 1 and 100, inclusive x = randint(1, 100) Then time how long it takes for your find.optimal subset function to run on this set of 24 experiments. You can use Python's process time function, located in the time module: from time import process_time start_time = process_time() # Put code to time here end_time- process_time() # Elapsed time in seconds is (end_time start_time) As a reference point, the running time on my desktop (a stock Ryzen 9 5900X, Win10 Pro, Python 3.9.2 x64) is about 97-98 seconds. The exact execution time may vary quite a bit depending on your hardware and software 3. (4 points) Within your code's main portion, write some test code for both of your functions. For power set, verify that the function works correctly for arguments of several different lengths. Be sure to test with a list of length 0 too! For find optimal subset, test by using the set of experiments from the earlier table, with a payload capacity of 700. This should result in an optimal subset containing experiment IDs 1, 3, 5, 6, 8, 9, 10, 11, and 12, with a combined mass of 697 kg and value rating of 53. 4. (6 points) The brute force approach to solving our space launch problem has to consider all subsets of the set of experiments. Since we have only 12 experiments to consider, there are 212 4096 total subsets to analyze, which isn't bad at all for a computer. But what if we double the size of the set of experiments, to 24? Suddenly we're looking at 224 = 16,777,216 subsets! Not good. Within your code's main portion, create a new 2D list representing a set of 24 experiments. The ID numbers should range from 1 to 24, but the masses and value ratings can be randomly generated. To generate random numbers in Python, you can use the randint functon from the random module: from random import randint # Assign x a random integer between 1 and 100, inclusive x = randint(1, 100) Then time how long it takes for your find.optimal subset function to run on this set of 24 experiments. You can use Python's process time function, located in the time module: from time import process_time start_time = process_time() # Put code to time here end_time- process_time() # Elapsed time in seconds is (end_time start_time) As a reference point, the running time on my desktop (a stock Ryzen 9 5900X, Win10 Pro, Python 3.9.2 x64) is about 97-98 seconds. The exact execution time may vary quite a bit depending on your hardware and software

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

List and explain the two functions used in ANN.

Answered: 1 week ago