ext2int

ext2int(bus, gen, branch, areas)

ext2int() - Converts external to internal indexing.

This function has two forms, (1) the old form that operates on
and returns individual matrices and (2) the new form that operates
on and returns an entire MATPOWER case struct.

1.  [I2E, BUS, GEN, BRANCH, AREAS] = EXT2INT(BUS, GEN, BRANCH, AREAS)
    [I2E, BUS, GEN, BRANCH] = EXT2INT(BUS, GEN, BRANCH)

If the first argument is a matrix, it simply converts from (possibly
non-consecutive) external bus numbers to consecutive internal bus
numbers which start at 1. Changes are made to BUS, GEN and BRANCH,
which are returned along with a vector of indices I2E that can be
passed to INT2EXT to perform the reverse conversion, where
EXTERNAL_BUS_NUMBER = I2E(INTERNAL_BUS_NUMBER).
AREAS is completely ignored and is only included here for backward
compatibility of the API.

Examples:
    [i2e, bus, gen, branch, areas] = ext2int(bus, gen, branch, areas);
    [i2e, bus, gen, branch] = ext2int(bus, gen, branch);

2.  MPC = EXT2INT(MPC)
    MPC = EXT2INT(MPC, MPOPT)

If the input is a single MATPOWER case struct, followed optionally
by a MATOWER options struct, then all isolated buses, off-line
generators and branches are removed along with any generators or
branches connected to isolated buses. Then the buses are renumbered
consecutively, beginning at 1. Any 'ext2int' callback routines registered
in the case are also invoked automatically. All of the related indexing
information and the original data matrices are stored in an 'order'
field in the struct to be used by INT2EXT to perform the reverse
conversions. If the case is already using internal numbering it is
returned unchanged.

Examples:
    mpc = ext2int(mpc);
    mpc = ext2int(mpc, mpopt);

The 'order' field of MPC used to store the indexing information
needed for subsequent internal to external conversion is structured
as:

    order
        state       'i' | 'e'
        ext | int
            bus
            branch
            gen
            gencost
            A
            N
        bus
            e2i
            i2e
            status
                on
                off
        gen
            e2i
            i2e
            status
                on
                off
        branch
            status
                on
                off

See also int2ext(), e2i_field(), e2i_data().