apply_profile

apply_profile(profile, argin, dim)

apply_profile() - Applies changes defined in a profile to a data structure.

CHGTABS = APPLY_PROFILE( PROFILE, CHGTABSI )
XGD     = APPLY_PROFILE( PROFILE, XGDI, DIM )
SD      = APPLY_PROFILE( PROFILE, SDI, DIM )
CTSETS  = APPLY_PROFILE( PROFILE, CTSETS, DIM ) (not yet implemented)

Applies a single profile of the given type to the given ARGIN. There are
4 different types of profiles, and each one affects differently the
input to produce the output. Profile input must contain the following
fields:

Inputs:
    PROFILE: a single-dimensional Profile struct with the following fields:
        .type       (string)
        .table      (string or scalar)
        .rows       (vector)
        .col        (scalar)
        .chgtype    (scalar)
        .values     (array) with at most 3 dimensions assumed to be
                      [ (1 or nt) by (1 or nj_max) or (1 or length(rows)) ]
        See IDX_PROFILE for details on the Profile struct.

    CHGTABI:    cell array of change tables to be modified
    XGDI:       xGenData struct to be modified
    STORAGEI:   StorageData struct to be modified
    CTSETSI:    array with ContingencyData (not yet implemented)

    DIM :   (scalar) indicates the total number of elements in the
            table or field being modified. Elements here refers to the
            3rd dimension, not time nor scenarios, but rather elements
            such as generators, number of different contingencies in
            master chgtab matrix (different labels), and storage units.
            DIM required to be able to expand, to a full DIM dimension,
            the data to be modified when it is summarized by a
            singleton dimension representing all the elements in that
            particular data set. It is ignored for type 'mpcData',
            mandatory for all other types.

Outputs:
    CHGTABS : cell array of modified change tables (nr x 7)
    XGD:      modified xGenData struct
    STORAGE:  modified StorageData struct
    CTSETS:   (not yet implemented)

Additional notes:

In general, field 'values' does not need to match dimensions of
dim = [nt nj_max n], where 'n' represents the subset of elements being
affected by the profile, i.e., the elements indicated by 'rows', but it
does need to be smaller or equal. Each dimension of 'values' is allowed
to be either the indicated above, or a singleton dimension, in which
case a singleton meaning that the profile "applies to all" elements in
that dimension, with the exception that the third dimension may be a
singleton also in the case affecting a single element (as opposed to all
elements in the third dimension).

type == 'mpcData'
    Generates/adds contingency-like tables to a cell array can be
    used to apply a change 'chgtype' to values in column 'col' of
    elements 'rows' on table 'table'. 'values' is a numeric array
    with up to 3 dimensions organized necessarily as in [nt nj_max
    n]. The third dimension indicates the subset of elements to
    which the profile is to be applied. Output CHGTABS is a (nt by
    nj) cell array of chgtab matrices (7 cols) with unspecified
    labels nor probabilities. CHGTABI must always be provided, even
    if it's a cell array with (nt x nj_max) empty entries. These
    dimensions are required in order to be able to expand changes
    correctly across time periods and scenarios. Dimensions of
    'values' are expanded if required (i.e., if inconsistent with nt,
    nj_max, or length of 'rows', resp.).

type == 'xGenData'
    Profile modifies the field of XGD struct indicated by the
    string 'table'. 'rows' indicates gens to modify, 'col' is
    ignored, and 'chgtype' the type of change using 'values'.
    Dimensions of 'values' are expanded if required (ie, if
    inconsistent with nt, nj_max, or length of 'rows', resp.).

type == 'StorageData'
    Profile modifies the field of STORAGE struct indicated by the
    string 'table'. 'rows' indicates storage units to modify (using
    storage-dedicated idx's as opposed to gen idx's), 'col' is ignored,
    and 'chgtype' the type of change using 'values'. Dimensions of
    'values' are expanded if required (ie, if inconsistent with nt,
    nj_max, or length of 'rows', resp.).

type == 'ContingencyData' (not yet implemented)
    Profile modifies the provided 'indicative' 3-dim array of
    binary variables: 1st dim spans the labels of contingencies,
    2nd dim spans time periods, and 3rd dim spans scenarios. Thus,
    'rows' indicates which labeled contingencies are to be modified
    by the profile, 'col' is ignored, and 'cghtype' the type of
    change using 'values'. Dimensions of 'values' expanded if
    required  (ie, if inconsistent with nt, nj_max, or length of
    'rows', resp.).