Set


Sets are lists of elements—such as industries, commodities or regions—which might be read from file or listed directly in the TAB file.

Read from File

Set REG # Regions # read elements from file GTAPSETS header H1 ;

Maximum size N clauses in set statements are now obsolete unless you are still using the obsolete F77L3 compiler.

Enumerated

Set IND # industries # (wool, car, food) ;

Set IND # industries # (ind1 - ind100) ;

Set IND # industries # (ind001 - ind100) ; ! fixedwidth numbering !

Members Unknown

Set COM # commodities # SIZE 10 ;

Set COM # commodities # SIZE NCOM ;

Unions and Intersections

Set DEMD_COMM # Demanded Commodities # = ENDW_COMM union TRAD_COMM ;

The statements

Set SET1 (e1, e2, e3, e4);

Set SET2 (e2, e6, e1);

SET3 = SET1 union SET2;

SET4 = SET1 intersect SET2 ;

SET5 = SET2 union SET1 ;

imply:

SET3 has elements (e1, e2, e3, e4, e6),

SET4 has elements (e1, e2), and

SET5 has elements (e2, e6, e1, e3, e4) -- same members but different order to SET3.

Intertemporal sets are not allowed in union or intersection statements.

Both UNION and + can be used to specify set union. The difference is that + specifies that the two sets must have no elements in common (ie, are disjoint).This is checked at run time. You should use +, unless you think the two sets MAY share elements.

Since Release 10.002 (April 2010) GEMPACK allows statements such as:

Set DEMANDERS = IND + LOCALDEM + Exports;

to define new sets in terms of existing sets. Previously the RHS of such statements could contain at most two sets. These longer set expressions may contain operators UNION, INTERSECT, +, - and \. Parentheses ( or ) are allowed but not other types of brackets [ ] or { }. Single elements may be placed in doublequotes.

Complements

Set NONMARCOM = COM - MARCOM ;

means that NONMARCOM consists of all COM except members of MARCOM.

Above requires that MARCOM has been declared as a subset of COM, and automatically declares NONMARCOM to be a subset of COM.

Since Release 10.002 (April 2010) GEMPACK you could also write:

Set NONMARCOM = COM \ MARCOM ;

which has the same effect, but in this case MARCOM is allowed to have elements not in COM.

Intertemporal sets are not allowed in set complement statements.

Conditional membership

Set SPCOM = (all,c,COM: TOTX(c) > TOTY(c)/5 ) ;

Above, SPCOM automatically becomes a subset of COM. The RHS condition is tested only once, even in multi-step computations.

Equal Sets

SET IND # Industries # = COM ;

Writing Sets

Write (set) COM to file OUTHAR header YY03;

Write (allsets) to file SETSHAR;

The second example must be the only write to the header array file SETSHAR.

Intertemporal Sets

If you want to write formulae like:

(all,t,FWDTIME) C1(t+1) = C1(t) + D(t) ;

the set TIME1 must be declared as intertemporal, for example:

Set (intertemporal) ALLTIME (p0 - p101) ;

Set (intertemporal) FWDTIME (p0 - p100) ;

Set (intertemporal) ENDTIME (p101);

Subset FWDTIME is subset of ALLTIME;

Subset ENDTIME is subset of ALLTIME;

To read the number of periods from a file:

Coefficient (integer) NINTERVAL;

! number of time grid intervals is NINTERVAL !

! number of time grid points is NINTERVAL+1 !

Read NINTERVAL from file header NINT;

Set (intertemporal) ALLTIME maximum size 101

(p[0] - p[NINTERVAL]) ;

Set (intertemporal) FWDTIME maximum size 100

(p[0] - p[NINTERVAL-1]) ;

Set (intertemporal) ENDTIME size 1 (p[NINTERVAL]) ;

SIZE is not allowed with intertemporal sets.

see also:

Ranked Sets New for GEMPACK 9.0

Product Sets and Projection Mappings

MAKE sets and mappings example

back to TABLO language contents



URL of this topic: www.copsmodels.com/webhelp/tabmate/hc_set.htm

Link to full GEMPACK Manual

Link to GEMPACK homepage