« Return to Thread: [AMPL 2631] Arbitrary Cartesian Products

[AMPL 2643] Re: Arbitrary Cartesian Products

by Guilherme Freitas :: Rate this Message:

Reply to Author | View in Thread


Ok, I think I have cornered the problem (even though I don't know if
there is a solution). I have created some files (all posted in the
end):

- 'test1.mod': exposes part of the problem
- 'test2.mod': exposes another part of the problem
- 'test.dat': a simple data file
- 'test.run': a commands file to show all the problems

Just run 'test.run' and you should see the problem. But I also found
another thread in this mailing list that argues that what I want to do
is impossible in AMPL:

http://groups.google.com/group/ampl/browse_thread/thread/32d801bcd702bff4/5952ab6a36672f41?lnk=gst&q=cartesian#5952ab6a36672f41

I usually look at the history of the list before asking, and I really
thought I had searched this list before asking. Anyway. Is there any
hope that a feature to solve this problem will be implemented in the
future? Why AMPL does not do it? Is it particularly difficult to
implement? Bob Fourer mentioned that there may be workarounds in
special cases; is there a workaround for my case?

Best,

Guilherme

---begin test1.mod---
set Parties ordered;   # Set of political parties
param L = card(Parties);   # Number of parties
param n {Parties} integer > 0;   # number of legislators in each party

set C {s in 1..L} =    # auxiliary set
  if s == 1
    then 1..n[first(Parties)]
  else C[s-1] cross 1..n[member(s, Parties)];

set D = C[L];   # auxiliary set

---end test1.mod---

---begin test2.mod---
set Parties ordered;   # Set of political parties
param L = card(Parties);   # Number of parties
param n {Parties} integer > 0;   # number of legislators in each party

set C {s in 1..L} =    # auxiliary set
  if s == 1
    then 1..n[first(Parties)]
  else 1..n[member(1, Parties)] cross 1..n[member(s, Parties)];

set D = C[L];   # auxiliary set

---end test2.mod---

---begin test.dat---
set Parties = Republican, Democrat;

param n :=
Republican 2
Democrat 3 ;

---end test.dat---

---begin test.run---
model test1.mod;
data test.dat;

print "Displaying D: should be {1, 2} x {1, 2, 3}";
display D;

print "Building D by hand to check if commands make sense. Name it
E.";
set E = 1..n[first(Parties)] cross 1..n[member(2, Parties)];
display E;

print "Cheating the recursion that defines 'C' and exposing the
problem:";
reset;
model test2.mod;

---end test.run---

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: [AMPL 2631] Arbitrary Cartesian Products