Types of Set

A set is a collection of unique elements. In AIMMS, a set is finite. When you declare a set in AIMMS, it is one of the following:

  • Root set

  • Calendar

  • Subset

  • Relation

Root Set

A collection of explicit names is called a root set.

For instance, the set s_Weathertypes = { Rainy, Cloudy, Sunny } is a root set.

1Set s_WeatherTypes {
2    Index: i_WeatherType;
3    Parameter: ep_WeatherType;
4    Definition: data { Rainy, Cloudy, Sunny };
5}

The elements of this set are Rainy, Cloudy, and Sunny. Note that the elements of a root set do not need to be specified in the model, they can be read in when the model is running; for instance from a database.

Calendar

A collection of dates is called a calendar.

A calendar is also a root set.

For instance the calendar cal_ThisWeek is declared as:

1Calendar cal_ThisWeek {
2    Index: i_dayThisWeek;
3    Parameter: ep_dayThisWeek;
4    Unit: day;
5    BeginDate: "2020-02-17";
6    EndDate: "2020-02-23";
7    TimeslotFormat: "%c%y-%m-%d";
8}

With this declaration, the calendar cal_ThisWeek contains the elements 2020-02-17, 2020-02-18, 2020-02-19, 2020-02-20, 2020-02-21, 2020-02-22, and 2020-02-23.

Note that the BeginDate, EndDate, and TimeslotFormat need not be explicit strings, but string parameters can be used as well.

Subset

A collection of elements, which are also elements of a root set (or calendar), is called a subset.

For instance, the set s_DryWeatherTypes is a subset of s_WeatherTypes and declared as follows:

1Set s_DryWeatherTypes {
2    SubsetOf: s_WeatherTypes;
3    Index: i_DryWeatherType;
4    Parameter: ep_DryWeatherType;
5    Definition: data { Cloudy, Sunny };
6}

A subset is not a root set. But like root sets, the data for a subset need not be specified in the model, but can be read in at runtime.

Relation

A collection of tuples, in which each component is an element of another set, is called a relation.

Observations can be modeled as a relation, for instance as follows:

 1Set s_ThisWeeksWeather {
 2    SubsetOf: (cal_ThisWeek,s_WeatherTypes);
 3    Definition: {
 4        data
 5        { ( 2020-02-17, Cloudy ), ( 2020-02-18, Sunny  ),
 6            ( 2020-02-19, Cloudy ), ( 2020-02-20, Sunny  ),
 7            ( 2020-02-21, Rainy  ), ( 2020-02-22, Rainy  ),
 8            ( 2020-02-23, Rainy  ) }
 9    }
10}

In this example, ( 2020-02-17, Cloudy ) is a tuple. Also 2020-02-17 is a component in a tuple, and it is an element of the set cal_ThisWeek.

Simple Sets vs. Relations

A root set, a calendar and a subset are all simple sets. A relation is not a simple set. For a simple set, you can declare: zero, one, or more indices; and zero, one, or more element parameters.

Compound Sets

A set that is both a relation and a simple set, is called a compound set. Compound sets are no longer supported. See Overview: Deprecation of Compound Sets.