Resources

Altering Arc Data (int2)

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: INT2                                                */
/*   TITLE: Altering Arc Data (int2)                            */
/* PRODUCT: OR                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: OR                                                  */
/*   PROCS: INTPOINT                                            */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT:                             UPDATE:                 */
/*     REF:                                                     */
/*    MISC: Example 2 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 arc1;
   input _tail_ $ _head_ $ _cost_ _capac_ _lo_ _FLOW_ _FCOST_
         diagonal factory ;
datalines;
fact1_1  f1_apr_1   78.60 600 50 600.000   47160.00 19 1
f1_mar_1 f1_apr_1   15.00  50  .   0.000       0.00 19 1
f1_may_1 f1_apr_1   28.00  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 550.000   95975.00 25 1
f1_mar_2 f1_apr_2   20.00  40  .   0.000       0.00 25 1
f1_may_2 f1_apr_2   41.00  15  .  15.000     615.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 345.000   44125.49 19 1
f1_apr_1 f1_mar_1   28.00  20  .  20.000     560.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   32.00  30  .  30.000     960.00 25 1
f2_mar_2 f1_mar_2   20.00  25  .  25.000     500.00 25 .
fact1_1  f1_may_1   95.10 400 50  50.000    4755.01 19 1
f1_apr_1 f1_may_1   12.00  50  .  50.000     600.00 19 1
f2_may_1 f1_may_1   13.00  40  .   0.000       0.00 19 .
fact1_2  f1_may_2  133.30 350 40  40.000    5332.00 25 1
f1_apr_2 f1_may_2   18.00  40  .   0.000       0.00 25 1
f2_may_2 f1_may_2   43.00  25  .   0.000       0.00 25 .
f1_apr_1 f2_apr_1   11.00   .  .  30.000     330.00 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   25.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 680.000  133756.00 25 2
f2_mar_2 f2_apr_2   28.00  50  .   0.000       0.00 25 2
f2_may_2 f2_apr_2   54.00  15  .  15.000     810.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   17.00  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 645.000  117390.00 25 2
f2_apr_2 f2_mar_2   31.00  15  .   0.000       0.00 25 2
f1_may_1 f2_may_1   16.00   .  . 100.000    1600.00 19 .
fact2_1  f2_may_1  133.80 250 35  35.000    4683.00 19 2
f2_apr_1 f2_may_1   20.00  30  .  15.000     300.00 19 2
f1_may_2 f2_may_2   26.00   .  .   0.000       0.00 25 .
fact2_2  f2_may_2  201.40 550 35  35.000    7049.00 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  . 155.000  -50785.73 19 1
f1_apr_1 shop1_1  -300.00 250  . 250.000  -75000.00 19 1
f1_may_1 shop1_1  -285.00 250  .   0.000       0.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  . 245.000  -71050.02 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   .  .  25.000  -11875.50 25 1
f2_mar_2 shop1_2  -567.83 500  . 500.000 -283915.00 25 2
f2_apr_2 shop1_2  -542.19 500  . 375.000 -203321.25 25 2
f2_may_2 shop1_2  -461.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   .  . 535.000 -294078.80 25 1
f1_may_2 shop2_2  -460.00   .  .   0.000       0.00 25 1
f2_mar_2 shop2_2  -542.83 500  . 120.000  -65139.60 25 2
f2_apr_2 shop2_2  -559.19 500  . 320.000 -178940.80 25 2
f2_may_2 shop2_2  -489.06 500  .  20.000   -9781.20 25 2
;

data arc1a;
   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 arc1;
    merge arc1 arc1a;


title2 'Minimum Cost Flow problem- Altered Arc Data';
data arc2;
   set arc1;
   oldcost=_cost_;
   oldfc=_fcost_;
   oldflow=_flow_;
   if key_id='backorder'
      then _cost_=_cost_*1.2;
      else if _tail_='f2_may_2' then _cost_=_cost_-30;
   if key_id='production' & mth_made='May' then
      if diagonal=19 then _cost_=_cost_-5;
                     else _cost_=_cost_-20;
   run;


proc intpoint
   bytes=100000
   printlevel2=2
   nodedata=node0
   arcdata=arc2
   conout=arc3;
   run;

proc print data=arc3;
var _tail_ _head_ _capac_ _lo_ _supply_ _demand_ _name_
 _cost_ _flow_ _fcost_ oldcost oldflow oldfc
 diagonal factory key_id mth_made;
 /* to get this variable order */
     sum oldfc _fcost_;
run;