Mapping


A mapping from set A to set B identifies for each element in A, a corresponding element in B. For example, each of 100 industries could be part of one broad sector. A mapping (from industries to broad sectors) would describe this relation. Mappings are complicated but very useful: so read the GEMPACK manuals carefully !

Set COM (wool, wheat, trade, banking, hotels) ;

Set AGGCOM (agriculture, services) ;

Mapping COMTOAGGCOM from COM to AGGCOM ;

Read COMTOAGGCOM from file SETS header MTRD;

By default above read expects to find an integer header.

Read (by_elements) (all,c,TRAD) COMTOAGGCOM(c)

from file SETS header MTRD;

Above partial read expects to find a string header.

Formula COMTOAGGCOM(wool) = agriculture ;

Formula COMTOAGGCOM(wheat) = 1; ! ie, to agriculture !

Formula (all,c,COM) COMTOAGGCOM(c) = INTVEC(c);

Above, INTVEC must be an integer vector.

Coefficient (all,aggc,AGGCOM) AGGDHOUS(aggc) ;

Coefficient (all,c,COM) DHOUS(c) ;

Formula (all,aggc,AGGCOM)

AGGDHOUS(aggc) = SUM(c,COM: COMTOAGGCOM(c) EQ aggc, DHOUS(c) );

Variable (all,c,COM) xhous(c) ;

Variable (all,aggc,AGGCOM) agg_xhous(aggc) ;

Equation E_agg_xhous (all,aggc,AGGCOM)

sum(c,COM: COMTOAGGCOM(c) EQ aggc, DVHOUS(c)) * agg_xhous(aggc) =

sum(c,COM: COMTOAGGCOM(c) EQ aggc, DHOUS(c) * xhous(c) );

Above equation could be more stylishly written:!

Equation E_agg_xhous (all,aggc,AGGCOM)

sum{c,COM: COMTOAGGCOM(c) EQ aggc, DVHOUS(c)

*[agg_xhous(aggc)-xhous(c)]}=0;

Below FORMULA (BY_ELEMENTS) is used to make the mapping of a subset follow a mapping of parent set.

Set MAR (trade,hotels);

Subset MAR is subset of COM;

Set AGGMAR (services);

Subset AGGMAR is subset of AGGCOM;

Mapping MAR2AGGMAR from MAR to AGGMAR ;

Formula (by_elements) (All,m,MAR) MAR2AGGMAR(m) = COM2AGGCOM(m) ;

Mapping (ONTO) COM2AGGCOM from COM to AGGCOM ;

The qualifier (ONTO) causes GEMPACK to check that every element of AGGCOM is mapped to by at least one element of COM -- by default this is NOT done.

Write COM2AGGCOM to file SETS header MCOM; ! store as integers !

To store the mapping as a vector of strings, use:

Write (by_elements) COM2AGGCOM to file SETS header MCOM;

In the above examples, no longname was specified, so GEMPACK will make one up which conforms to the conventions required by ViewHAR.

Set mappings are not allowed on the LHS of a formula or of an update, or in the declaration of coefficients or variables, or in reads, writes or displays.

see also Example: Mapping skill shares from broad to detailed sectors

see also Product Sets and Projection Mappings

see also MAKE sets and mappings example

back to TABLO language contents



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

Link to full GEMPACK Manual

Link to GEMPACK homepage