Resources

Adding Side Constraints (int3)

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: INT3                                                */
/*   TITLE: Adding Side Constraints (int3)                      */
/* PRODUCT: OR                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: OR                                                  */
/*   PROCS: INTPOINT                                            */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT:                             UPDATE:                 */
/*     REF:                                                     */
/*    MISC: Example 3 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
;


title2 'Adding Side Constraints';
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 arc3;
   input _tail_ $ _head_ $ _capac_ _lo_ _cost_ diagonal factory
         key_id $10. mth_made $ _name_&$17. ;
datalines;
fact1_1  f1_apr_1 600 50   78.60 19 1 production April prod f1 19 apl
f1_mar_1 f1_apr_1  50  .   15.00 19 1 storage    March .
f1_may_1 f1_apr_1  20  .   33.60 19 1 backorder  May   back f1 19 may
f2_apr_1 f1_apr_1  40  .   11.00 19 . f2_to_1    April .
fact1_2  f1_apr_2 550 50  174.50 25 1 production April prod f1 25 apl
f1_mar_2 f1_apr_2  40  .   20.00 25 1 storage    March .
f1_may_2 f1_apr_2  15  .   49.20 25 1 backorder  May   back f1 25 may
f2_apr_2 f1_apr_2  25  .   21.00 25 . f2_to_1    April .
fact1_1  f1_mar_1 500 50  127.90 19 1 production March prod f1 19 mar
f1_apr_1 f1_mar_1  20  .   33.60 19 1 backorder  April back f1 19 apl
f2_mar_1 f1_mar_1  40  .   10.00 19 . f2_to_1    March .
fact1_2  f1_mar_2 400 40  217.90 25 1 production March prod f1 25 mar
f1_apr_2 f1_mar_2  30  .   38.40 25 1 backorder  April back f1 25 apl
f2_mar_2 f1_mar_2  25  .   20.00 25 . f2_to_1    March .
fact1_1  f1_may_1 400 50   90.10 19 1 production May   .
f1_apr_1 f1_may_1  50  .   12.00 19 1 storage    April .
f2_may_1 f1_may_1  40  .   13.00 19 . f2_to_1    May   .
fact1_2  f1_may_2 350 40  113.30 25 1 production May   .
f1_apr_2 f1_may_2  40  .   18.00 25 1 storage    April .
f2_may_2 f1_may_2  25  .   13.00 25 . f2_to_1    May   .
f1_apr_1 f2_apr_1   .  .   11.00 19 . f1_to_2    April .
fact2_1  f2_apr_1 480 35   62.40 19 2 production April prod f2 19 apl
f2_mar_1 f2_apr_1  30  .   18.00 19 2 storage    March .
f2_may_1 f2_apr_1  15  .   30.00 19 2 backorder  May   back f2 19 may
f1_apr_2 f2_apr_2   .  .   23.00 25 . f1_to_2    April .
fact2_2  f2_apr_2 680 35  196.70 25 2 production April prod f2 25 apl
f2_mar_2 f2_apr_2  50  .   28.00 25 2 storage    March .
f2_may_2 f2_apr_2  15  .   64.80 25 2 backorder  May   back f2 25 may
f1_mar_1 f2_mar_1   .  .   11.00 19 . f1_to_2    March .
fact2_1  f2_mar_1 450 35   88.00 19 2 production March prod f2 19 mar
f2_apr_1 f2_mar_1  15  .   20.40 19 2 backorder  April back f2 19 apl
f1_mar_2 f2_mar_2   .  .   23.00 25 . f1_to_2    March .
fact2_2  f2_mar_2 650 35  182.00 25 2 production March prod f2 25 mar
f2_apr_2 f2_mar_2  15  .   37.20 25 2 backorder  April back f2 25 apl
f1_may_1 f2_may_1   .  .   16.00 19 . f1_to_2    May   .
fact2_1  f2_may_1 250 35  128.80 19 2 production May   .
f2_apr_1 f2_may_1  30  .   20.00 19 2 storage    April .
f1_may_2 f2_may_2   .  .   26.00 25 . f1_to_2    May   .
fact2_2  f2_may_2 550 35  181.40 25 2 production May   .
f2_apr_2 f2_may_2  50  .   38.00 25 2 storage    April .
f1_mar_1 shop1_1  250  . -327.65 19 1 sales      March .
f1_apr_1 shop1_1  250  . -300.00 19 1 sales      April .
f1_may_1 shop1_1  250  . -285.00 19 1 sales      May   .
f2_mar_1 shop1_1  250  . -297.40 19 2 sales      March .
f2_apr_1 shop1_1  250  . -290.00 19 2 sales      April .
f2_may_1 shop1_1  250  . -292.00 19 2 sales      May   .
f1_mar_2 shop1_2    .  . -559.76 25 1 sales      March .
f1_apr_2 shop1_2    .  . -524.28 25 1 sales      April .
f1_may_2 shop1_2    .  . -475.02 25 1 sales      May   .
f2_mar_2 shop1_2  500  . -567.83 25 2 sales      March .
f2_apr_2 shop1_2  500  . -542.19 25 2 sales      April .
f2_may_2 shop1_2  500  . -491.56 25 2 sales      May   .
f1_mar_1 shop2_1  250  . -362.74 19 1 sales      March .
f1_apr_1 shop2_1  250  . -300.00 19 1 sales      April .
f1_may_1 shop2_1  250  . -245.00 19 1 sales      May   .
f2_mar_1 shop2_1  250  . -272.70 19 2 sales      March .
f2_apr_1 shop2_1  250  . -312.00 19 2 sales      April .
f2_may_1 shop2_1  250  . -299.00 19 2 sales      May   .
f1_mar_2 shop2_2    .  . -623.89 25 1 sales      March .
f1_apr_2 shop2_2    .  . -549.68 25 1 sales      April .
f1_may_2 shop2_2    .  . -460.00 25 1 sales      May   .
f2_mar_2 shop2_2  500  . -542.83 25 2 sales      March .
f2_apr_2 shop2_2  500  . -559.19 25 2 sales      April .
f2_may_2 shop2_2  500  . -519.06 25 2 sales      May   .
;


proc intpoint
   bytes=1000000
   printlevel2=2
   nodedata=node0 arcdata=arc3
   condata=con3 sparsecondata rhsobs='CHIP/BO LIMIT'
   conout=arc4;
   id diagonal factory key_id mth_made;
   run;

proc print data=arc4;
   var _tail_ _head_ _cost_ _capac_ _lo_ _flow_ _fcost_;
       /* to get this variable order */
   sum _fcost_;
   run;