help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Sets of arbitrary length sets in MathProg


From: Andrew Makhorin
Subject: Re: [Help-glpk] Sets of arbitrary length sets in MathProg
Date: Wed, 22 Feb 2012 11:55:22 +0300

> However, I'm still having a hard time figuring out how to do certain 
> things.  I've looked (and grepped) in the examples and I don't see 
> anything similar to what I need.  Now that I have my WORKER_CLIQUE set I 
> need to declare some binary variables for each set in WORKER_CLIQUE.  
> I'd like to be able to say something like:
> 
> var Y_clique{clique in WORKER_CLIQUE, v in 1..number_of_shifts} binary;
> 
> However, this results in in the "WORKER_CLIQUE must be subscripted".  
> The card function doesn't seem to help either in getting the number of 
> cliques defined in WORKER_CLIQUE.  Is a forall more appropriate in these 
> circumstances?

In your case WORKER_CLIQUE is a family of sets, not a plain set, so you
need to specify which its member is used as the index set:

var Y_clique{v in 1..number_of_shifts, clique in WORKER_CLIQUE[v]}
binary;

> 
> In addition to the Y_clique vars being defined I also need to create 
> additional constraints for each WORKER_CLIQUE.  (I'm creating these 
> binary indicator vars and constraints to  represent logical 
> conditions[1].)  Again, the missing piece for me is how to iterate over 
> the sets in the set so I can do something like:
> 
> s.t. clique_constraints{clique in WORKER_CLIQUE, shift in 
> 1..number_of_shifts}:
>       (sum{worker in clique}  ....... ) -  (M*Y_clique[clique, shift]) 
> <= 0; # notice how I need to loop over the workers

The same. It should be:

s.t. clique_constraints{shift in 1..number_of_shifts}:
      (sum{worker in WORKER_CLIQUE[shift]}  ....... ) ...

Please note that a dummy index (e.g. worker) can take its values only on
elements of a plain set.

> 
> s.t. constrain_indicator_vars{clique in WORKER_CLIQUE}:
>       sum{shift in 1..number_of_shifts} Y[clique, shift] <= 1;
> 
> Sorry, for all of this pseudo mathprog code. :(  By and large I've found 
> MathProg intuitive and easy to use I'm just having a hard time 
> representing this part of the problem.





reply via email to

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