Robert, Paul, thanks for the answers.
As I cannot automate this in the AMPL code, I will just write a little
program that generates the AMPL code for each program. In a sense, it
is a shame, because AMPL code is *very* readable, and I saw no need to
write a pretty interface for it to let my co-authors run their
numerical experiments; they could just create their data files. Now if
I have to write a program (a Python script) to generate AMPL code,
they will have interact with this script somehow, and then I will need
to worry about the interface.
Anyway, thanks for the answers.
Best,
Guilherme
On Jul 12, 1:52 am, Guilherme Freitas <
guilhe...@...> wrote:
> 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/32d801bcd702...
>
> 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-~----------~----~----~----~------~----~------~--~---