|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
[AMPL 2813] How to generalize the problem?Hello all, I would appreciate your help in following problem. There are 3 subsets (A1, A2, A3) of set B. set B = {1..10}; set A1 within B; set A2 within B; set A3 within B; param onlyA1 = card(A1 diff ((A1 inter A2) diff (A1 inter A2 inter A3)) diff (A1 inter A3)); param onlyA2 = card(A2 diff ((A1 inter A2) diff (A1 inter A2 inter A3)) diff (A2 inter A3)); param onlyA3 = card(A3 diff ((A1 inter A3) diff (A1 inter A2 inter A3)) diff (A2 inter A3)); param onlyA1andA2 = card ((A1 inter A2) diff (A1 inter A2 inter A3)); param onlyA1andA3 = card ((A1 inter A3) diff (A1 inter A2 inter A3)); param onlyA2andA3 = card ((A2 inter A3) diff (A1 inter A2 inter A3)); param Rest = card(B)-onlyA1 - onlyA2 - onlyA3 - onlyA1andA2 - onlyA1andA3 - onlyA2andA3-card(A1 inter A2 inter A3); The same has to be done in general form. The number of subsets is n, the number of members of set B is N. I have to generate n subsets of the set B={1..N} and bring all formulas above in one - two general formulas. I would be happy to hearing from you... Regards, Phil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@... To unsubscribe from this group, send email to ampl+unsubscribe@... For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
[AMPL 2814] Re: How to generalize the problem?You might proceed with something like this: param N integer > 0; param n integer > 0; set B = 1..N; set A {1..n} within B; param Rest = card (B diff union {i in 1..n} A[i]); The need for the "onlyA1" and "onlyA1andA2" types of parameters is not clear, but you ought to be able to generate what you need using iterated union (as shown above) and iterated intersection. The only thing that would be harder is to generate for *every* subset of 1..n the number of members of B that are in all and only the corresponding A sets. But see question 4.4 at www.ampl.com/FAQ. Bob Fourer 4er@... > -----Original Message----- > From: ampl@... [mailto:ampl@...] > On Behalf Of Philipp [philipp.junghanns@...] > Sent: Sunday, September 13, 2009 4:15 PM > To: AMPL Modeling Language > Subject: [AMPL 2813] How to generalize the problem? > > > Hello all, > > I would appreciate your help in following problem. > > There are 3 subsets (A1, A2, A3) of set B. > > set B = {1..10}; > set A1 within B; > set A2 within B; > set A3 within B; > param onlyA1 = card(A1 diff ((A1 inter A2) diff (A1 inter A2 inter > A3)) diff (A1 inter A3)); > param onlyA2 = card(A2 diff ((A1 inter A2) diff (A1 inter A2 inter > A3)) diff (A2 inter A3)); > param onlyA3 = card(A3 diff ((A1 inter A3) diff (A1 inter A2 inter > A3)) diff (A2 inter A3)); > param onlyA1andA2 = card ((A1 inter A2) diff (A1 inter A2 inter A3)); > param onlyA1andA3 = card ((A1 inter A3) diff (A1 inter A2 inter A3)); > param onlyA2andA3 = card ((A2 inter A3) diff (A1 inter A2 inter A3)); > param Rest = card(B)-onlyA1 - onlyA2 - onlyA3 - onlyA1andA2 - > onlyA1andA3 - onlyA2andA3-card(A1 inter A2 inter A3); > > The same has to be done in general form. The number of subsets is n, > the number of members of set B is N. > I have to generate n subsets of the set B={1..N} and bring all > formulas above in one - two general formulas. > > I would be happy to hearing from you... > > Regards, > > Phil > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@... To unsubscribe from this group, send email to ampl+unsubscribe@... For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |