Since D is actually a collection of sets indexed over C, it's necessary to
specify the indexing of f (and x) as {k in C, D[k]}. Then f and x will have
3 subscripts and the constraint will look like this:
set A := 1..2;
set B := 1..2;
set C := 1..2;
set D{C} within A cross B default A cross B;
param rhs {C};
param f{k in C, D[k]} default 1;
var x {k in C, D[k]} >= 0;
subject to constr {k in C}:
sum {(i,j) in D[k]} f[k,i,j]*x[k,i,j] <= rhs[k];
Bob Fourer
4...@ampl.com
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.
param nSols integer default 0;
param maxSols integer > 0;
set A;
set B;
set Pos {1..nSols} within {A,B};
var x {A,B} binary;
subject to Exclude {k in 1..nSols}:
sum {(i,j) in Pos[k]} (1-x[i,j]) +
sum {(i,j) in {A,B} diff Pos[k]} x[i,j] >= 1;
along with your objective and constraints and any other sets and parameters
you need to describe them. Then the loop can have the form
repeat {
solve;
# <test & examine the solution>
let nSols := nSols + 1;
let Pos[nSols] := {i in A, j in B: x[i,j] > .5};
} until nSols = maxSols;
Similarly to Paul's loop, the number Exclude constraints -- and in this
case, also the number of Pos sets -- increases by one each time nSols is
stepped, which happens each time a new solution is found. To specify each
Exclude constraint properly it suffices to assign the new Pos set to contain
the indices of all the 0-1 variables that were 1 in the latest solution.
Bob Fourer
4...@ampl.com
It only appears this way because the knapsacks are numbered. The meaning of "param capacity := 1 6 2 4;" in this case is that capacity[1] is 6 and capacity[2] is 4.
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Prof. Dr. Michael Krätzschmar [kraetz...@mathematik.fh-flensburg.de]
Sent: Sunday, February 27, 2011 3:07 AM
To: am...@googlegroups.com
Subject: Re: [AMPL 4387] Re: parameter def on dependent set