Strategic sub-setting

Top  Previous  Next

When using full data sets in debugging or development, we usually narrowing focus to a few items and use subsets to facilitate this in an exercise I call strategic subsetting.

Consider modification of tranlrg.gms renaming overall sets plants and markets and introducing subsets plant and market (transtrt.gms).  All tables, parameters, variables and equations are defined with supersets but model and calculations are defined in a subset.

 

SETS  PLANTs PLANT LOCATIONS /NEWYORK , CHICAGO , LOSANGLS , BALTIMORE , WASHINGTON

                                 PHILADEL , LASVEGAS,  RENO    , SEATTLE   , BOISE/

      MARKETs   DEMAND MARKETS  /MIAMI,   HOUSTON, MINEPLIS, PORTLAND,BOSTON/

set plant (plants) a possibly reduced set of plants

                /newyork,chicago,losangls/

    market (MARKETs)   a possible reduced set of DEMAND MARKETS

                /MIAMI,   HOUSTON/; 

* plant (plants)=yes ;market(markets)=yes;

PARAMETERS   SUPPLY (PLANTs)  QUANTITY AVAILABLE AT EACH PLANT

     /NEWYORK   100, CHICAGO    75, LOSANGLS   90,

      BALTIMORE  80, WASHINGTON 70, PHILADEL   60,

      LASVEGAS   40, RENO       20, SEATTLE    55, BOISE      10/

DEMAND (MARKETs)   QUANTITY REQUIRED BY DEMAND MARKET

        /MIAMI 100, HOUSTON    90,  MINEPLIS  120, PORTLAND   90, BOSTON    180/;

TABLE DISTANCE (PLANTs, MARKETs) DISTANCE FROM EACH PLANT TO EACH MARKET

                    MIAMI   HOUSTON   MINEPLIS   PORTLAND  BOSTON

        NEWYORK      1300     1800       1100       3600     150

        CHICAGO      2200     1300        700       2900     800

        LOSANGLS     3700     2400       2500       1100    3800

        BALTIMORE    1100     1600       1200       3700     350

        RENO         3400     2200       2200        900    3400

        SEATTLE      3700     2500       1900        250    3500

        BOISE        3500     2200       1700        450    3300      ;

PARAMETER COST(PLANTs,MARKETs)    CALCULATED COST OF MOVING GOODS;

          COST (PLANT,MARKET) = 50 + 1 * DISTANCE (PLANT,MARKET);

POSITIVE VARIABLES    SHIPMENTS(PLANTs,MARKETs) AMOUNT SHIPPED OVER A ROUTE;

VARIABLES TCOST                 TOTAL COST OF SHIPPING OVER ALL ROUTES;

EQUATIONS TCOSTEQ               TOTAL COST ACCOUNTING EQUATION

          SUPPLYEQ(PLANTs)       LIMIT ON SUPPLY AVAILABLE AT A PLANT

          DEMANDEQ(MARKETs)      MINIMUM REQUIREMENT AT A DEMAND MARKET;

TCOSTEQ.. TCOST =E=SUM((PLANT,MARKET),

                         SHIPMENTS(PLANT,MARKET)*COST (PLANT,MARKET));

SUPPLYEQ (PLANT).. SUM(MARKET,SHIPMENTS(PLANT,MARKET))=L=SUPPLY(PLANT);

DEMANDEQ (MARKET)..SUM(PLANT,SHIPMENTS(PLANT,MARKET))=G=DEMAND(MARKET);

MODEL TRANSPORT /ALL/;

SOLVE TRANSPORT USING LP MINIMIZING TCOST;

 

In turn altering the lines defining the plant and market subsets as follows would alter problem from the restricted problem back to the full model.

 

set plant(plants) a possibly reduced set of plants

*                /newyork,chicago,losangls/

 market(MARKETs) a possibly reduced set of MARKETS

*                /MIAMI,   HOUSTON/

;

 plant (plants)=yes ;market(markets)=yes;

 

Furthermore, since the plant and market sets are now calculated items this could be done anywhere.  Thus, if one were employing code isolation one could further narrow the things being examined using strategic sub setting.

Strategic sub setting has proven to be an effective way of maintaining a small data set with little effort.  All one really does is pick elements from the full set that are representative for model development and debugging.