1

For someone with zero experience, this can be very confusing.

How do I define the Set Packing problem as seen in the wikipedia article as a MathProg program, to be later ran in the GLPK tool?

Intution alone would lead me into something like this:

var x

maximize SetPacking :
 sum {s in Subsets} x
s.t.         ??              //x is an integer 0 or 1
s.t.         ??              //amount of x <=1
end;

But its logic is obviously wrong and I can't even finish it.

1 Answer 1

0

You can formulate the set packing problem in AMPL (and MathProg which is based on a subset of AMPL) as follows:

set U; # universe
set S; # subsets
set Members{S}; # members of subsets

# every set is either in the set packing or not
var x{S} binary;

# maximize the total number of subsets
maximize NumSets: sum{s in S} x[s];

# selected sets have to be pairwise disjoint
s.t. Disjoint{e in U}: sum{s in S: e in Members[s]} x[s] <= 1;

Note that you have to introduce indexed set Members with each element Members[s]representing members of subset s. This is the only difference from the algebraic formulation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.