Search code examples
optimizationlinear-programmingamplglpk

How we can make thousands of set in ampl?


I am wondering if there is a way to define sets in ampl for the following problem?!

I wanna make a model with parameter X which is n dimensional. It is about information of each person in a household. such as age, job, ... now I have 1000 family and for each family I want to define a parameter which has information X for each person.For example if I have one family I can define:

set G,  default{1..p};
set F,  default{1..t}; #number of family
set K, within G cross F;
param X{K};

in the above example, X show the information of each person in the household.

How about if I have 1000 household? it does not make sense if I want to define 1000 sets with my hand!


Solution

  • You can index a set over another set; see Section 6.5 of the AMPL book.

    As a side note, I would recommend that you create separate parameters for each piece of information (age, job, ...) rather than including them all in a single parameter X.