Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following problem: Set Cover Input: A set I = { i 1 , i 2 , . . . , in } of
Consider the following problem:
Set Cover
Input: A set I i i in of items and a set S s s sm of subsets of I.
Output: All minimumsize set covers of I, ie all smallestpossible size subsets S of S such that the union of all sets in S is equal to I.
Write and document a Python program that uses a recursive backtracking algorithm to print all minimumsize set covers for a given itemset I and itemsubset set S where the files specifying I and S are input as commandline arguments. This algorithm will consider the set of candidate solutions consisting of all possible subsets of S An example itemsubset set file isettxt is as follows:
:
:
:
:
Each such file of m itemsubsets of a set of n items consists of n lines, where the first line contains the integers n and m respectively, and the remaining lines contain the itemsubsets, one per line, where each itemsubset is specified by the number of the itemsubset and its elements in ascending order. You may assume that all input files are formatted correctly. Examples of several program runs relative to the itemsubset set files isettxt isettxt isettxt isettxt isettxt isettxt isettxt and isettxt are given in script file out.script.min. It is these results that your program should be able to replicate. To aid understanding how this program should work, you have also been provided with an expanded version of this script file which shows the program's progress through the search tree of candidate solutions.
Hints
You may find it convenient to determine the optimal solution cost and to print optimal solutions in two separate recursive procedures see sample Java code for solving the Vertex Cover described in Lecture #
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started