help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Subset


From: Andrew Makhorin
Subject: Re: [Help-glpk] Subset
Date: Mon, 17 Oct 2011 18:02:55 +0400

> I'm having problems with creating a subset.
> 
> What I want to be able to do is this:
> sum for s in S', forall S' where S' is a subset of Sc such that the
> size of S' = mc[c]
> 
> set S; /* The set of servers */
> set C; /* The set of Cluster */
> set Sc {c in C}; /* The set of servers in cluster c */
> param mc {c in C}, integer, > 0;
> 
> Is there a way to do this with GMPL?

If you need to enumerate all subsets of a given n-element set, you may
try the following:

set N := 1..n;
/* n-element set */

set U := 0..2^n-1;
/* "set" of all subsets of N numbered from 0 to 2^n-1 */

param e{i in U, j in N}, binary, := (i div 2^(j-1)) mod 2;
/* e[i,j] is 1 iff i-th subset of N includes element j */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]