Using Constraints/More Alteration to Arc Data (int4)

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: INT4                                                */
/*   TITLE: Using Constraints/More Alteration to Arc Data (int4)*/
/* PRODUCT: OR                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: OR                                                  */
/*   PROCS: INTPOINT                                            */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT:                             UPDATE:                 */
/*     REF:                                                     */
/*    MISC: Example 4 from INTPOINT chapter                     */
/****************************************************************/

data node0;
   input _node_ $ _supdem_ ;
   datalines;
fact1_1   1000
fact2_1    850
fact1_2   1000
fact2_2   1500
shop1_1   -900
shop2_1   -900
shop1_2   -900
shop2_2  -1450
;

data con3;
   input _column_ &$14. _row_ &$15. _coef_ ;
   datalines;
prod f1 19 mar  FACT1 MAR GIZMO  3
prod f1 25 mar  FACT1 MAR GIZMO  4
CHIP/BO LIMIT   FACT1 MAR GIZMO  2600
prod f2 19 mar  FACT2 MAR GIZMO  3
prod f2 25 mar  FACT2 MAR GIZMO  4
CHIP/BO LIMIT   FACT2 MAR GIZMO  3750
prod f1 19 apl  FACT1 APL GIZMO  3
prod f1 25 apl  FACT1 APL GIZMO  4
CHIP/BO LIMIT   FACT1 APL GIZMO  2600
prod f2 19 apl  FACT2 APL GIZMO  3
prod f2 25 apl  FACT2 APL GIZMO  4
CHIP/BO LIMIT   FACT2 APL GIZMO  3750
back f1 19 apl  TOTAL BACKORDER  1
back f1 25 apl  TOTAL BACKORDER  1
back f2 19 apl  TOTAL BACKORDER  1
back f2 25 apl  TOTAL BACKORDER  1
back f1 19 may  TOTAL BACKORDER  1
back f1 25 may  TOTAL BACKORDER  1
back f2 19 may  TOTAL BACKORDER  1
back f2 25 may  TOTAL BACKORDER  1
CHIP/BO LIMIT   TOTAL BACKORDER  50
;
data arc4;
   input _tail_ $ _head_ $ _cost_ _capac_ _lo_ _flow_
         _fcost_ diagonal factory;
datalines;
fact1_1  f1_apr_1   78.60 600 50 533.333   41920.00 19 1
f1_mar_1 f1_apr_1   15.00  50  .   0.000       0.00 19 1
f1_may_1 f1_apr_1   33.60  20  .   0.000       0.00 19 1
f2_apr_1 f1_apr_1   11.00  40  .   0.000       0.00 19 .
fact1_2  f1_apr_2  174.50 550 50 250.000   43625.00 25 1
f1_mar_2 f1_apr_2   20.00  40  .   0.000       0.00 25 1
f1_may_2 f1_apr_2   49.20  15  .   0.000       0.00 25 1
f2_apr_2 f1_apr_2   21.00  25  .   0.000       0.00 25 .
fact1_1  f1_mar_1  127.90 500 50 333.333   42633.33 19 1
f1_apr_1 f1_mar_1   33.60  20  .  20.000     672.00 19 1
f2_mar_1 f1_mar_1   10.00  40  .  40.000     400.00 19 .
fact1_2  f1_mar_2  217.90 400 40 400.000   87160.00 25 1
f1_apr_2 f1_mar_2   38.40  30  .  30.000    1152.00 25 1
f2_mar_2 f1_mar_2   20.00  25  .  25.000     500.00 25 .
fact1_1  f1_may_1   90.10 400 50 128.333   11562.83 19 1
f1_apr_1 f1_may_1   12.00  50  .   0.000       0.00 19 1
f2_may_1 f1_may_1   13.00  40  .   0.000       0.00 19 .
fact1_2  f1_may_2  113.30 350 40 350.000   39655.00 25 1
f1_apr_2 f1_may_2   18.00  40  .   0.000       0.00 25 1
f2_may_2 f1_may_2   13.00  25  .   0.000       0.00 25 .
f1_apr_1 f2_apr_1   11.00   .  .  13.333     146.67 19 .
fact2_1  f2_apr_1   62.40 480 35 480.000   29952.00 19 2
f2_mar_1 f2_apr_1   18.00  30  .   0.000       0.00 19 2
f2_may_1 f2_apr_1   30.00  15  .   0.000       0.00 19 2
f1_apr_2 f2_apr_2   23.00   .  .   0.000       0.00 25 .
fact2_2  f2_apr_2  196.70 680 35 577.500  113594.25 25 2
f2_mar_2 f2_apr_2   28.00  50  .   0.000       0.00 25 2
f2_may_2 f2_apr_2   64.80  15  .   0.000       0.00 25 2
f1_mar_1 f2_mar_1   11.00   .  .   0.000       0.00 19 .
fact2_1  f2_mar_1   88.00 450 35 290.000   25520.00 19 2
f2_apr_1 f2_mar_1   20.40  15  .   0.000       0.00 19 2
f1_mar_2 f2_mar_2   23.00   .  .   0.000       0.00 25 .
fact2_2  f2_mar_2  182.00 650 35 650.000  118300.00 25 2
f2_apr_2 f2_mar_2   37.20  15  .   0.000       0.00 25 2
f1_may_1 f2_may_1   16.00   .  . 115.000    1840.00 19 .
fact2_1  f2_may_1  128.80 250 35  35.000    4508.00 19 2
f2_apr_1 f2_may_1   20.00  30  .   0.000       0.00 19 2
f1_may_2 f2_may_2   26.00   .  . 350.000    9100.00 25 .
fact2_2  f2_may_2  181.40 550 35 122.500   22221.50 25 2
f2_apr_2 f2_may_2   38.00  50  .   0.000       0.00 25 2
f1_mar_1 shop1_1  -327.65 250  . 143.333  -46963.17 19 1
f1_apr_1 shop1_1  -300.00 250  . 250.000  -75000.00 19 1
f1_may_1 shop1_1  -285.00 250  .  13.333   -3800.00 19 1
f2_mar_1 shop1_1  -297.40 250  . 250.000  -74350.00 19 2
f2_apr_1 shop1_1  -290.00 250  . 243.333  -70566.67 19 2
f2_may_1 shop1_1  -292.00 250  .   0.000       0.00 19 2
f1_mar_2 shop1_2  -559.76   .  .   0.000       0.00 25 1
f1_apr_2 shop1_2  -524.28   .  .   0.000       0.00 25 1
f1_may_2 shop1_2  -475.02   .  .   0.000       0.00 25 1
f2_mar_2 shop1_2  -567.83 500  . 500.000 -283915.00 25 2
f2_apr_2 shop1_2  -542.19 500  . 400.000 -216876.00 25 2
f2_may_2 shop1_2  -491.56 500  .   0.000       0.00 25 2
f1_mar_1 shop2_1  -362.74 250  . 250.000  -90685.00 19 1
f1_apr_1 shop2_1  -300.00 250  . 250.000  -75000.00 19 1
f1_may_1 shop2_1  -245.00 250  .   0.000       0.00 19 1
f2_mar_1 shop2_1  -272.70 250  .   0.000       0.00 19 2
f2_apr_1 shop2_1  -312.00 250  . 250.000  -78000.00 19 2
f2_may_1 shop2_1  -299.00 250  . 150.000  -44850.00 19 2
f1_mar_2 shop2_2  -623.89   .  . 455.000 -283869.95 25 1
f1_apr_2 shop2_2  -549.68   .  . 220.000 -120929.60 25 1
f1_may_2 shop2_2  -460.00   .  .   0.000       0.00 25 1
f2_mar_2 shop2_2  -542.83 500  . 125.000  -67853.75 25 2
f2_apr_2 shop2_2  -559.19 500  . 177.500  -99256.23 25 2
f2_may_2 shop2_2  -519.06 500  . 472.500 -245255.85 25 2
;

data arc4a;
   input key_id $10. mth_made $ _name_&$17.;
datalines;
production April  prod f1 19 apl
storage    March  .
backorder  May    back f1 19 may
f2_to_1    April  .
production April  prod f1 25 apl
storage    March  .
backorder  May    back f1 25 may
f2_to_1    April  .
production March  prod f1 19 mar
backorder  April  back f1 19 apl
f2_to_1    March  .
production March  prod f1 25 mar
backorder  April  back f1 25 apl
f2_to_1    March  .
production May    .
storage    April  .
f2_to_1    May    .
production May    .
storage    April  .
f2_to_1    May    .
f1_to_2    April  .
production April  prod f2 19 apl
storage    March  .
backorder  May    back f2 19 may
f1_to_2    April  .
production April  prod f2 25 apl
storage    March  .
backorder  May    back f2 25 may
f1_to_2    March  .
production March  prod f2 19 mar
backorder  April  back f2 19 apl
f1_to_2    March  .
production March  prod f2 25 mar
backorder  April  back f2 25 apl
f1_to_2    May    .
production May    .
storage    April  .
f1_to_2    May    .
production May    .
storage    April  .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
sales      March  .
sales      April  .
sales      May    .
;

data arc4;
    merge arc4 arc4a;


title2 'Using Constraints and Altering arc data';
data new_arc4;
   set arc4;
   oldcost=_cost_;
   oldflow=_flow_;
   oldfc=_fcost_;
   if _tail_='f1_may_2' & (_head_='shop1_2' | _head_='shop2_2')
      then _cost_=_cost_-40;
   run;


proc intpoint
bytes=1000000
printlevel2=2
arcdata=new_arc4 nodedata=node0
condata=con3 sparsecondata rhsobs='CHIP/BO LIMIT'
conout=arc5;
run;

title2 'Using Constraints and Altering arc data';
proc print data=arc5;
   var _tail_ _head_ _cost_ _capac_ _lo_
       _supply_ _demand_ _name_ _flow_ _fcost_ oldflow oldfc;
          /* to get this variable order */
   sum oldfc _fcost_;
run;