Resources

Network Flow and Delay

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: IMNLPEX2                                            */
/*   TITLE: Network Flow and Delay                              */
/* PRODUCT: IML                                                 */
/*  SYSTEM: ALL                                                 */
/*    KEYS:                                                     */
/*   PROCS: IML                                                 */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: saswmh                      UPDATE: frwick 5/2015   */
/*     REF: Technical Report Examples                           */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/

proc iml;
start MAXFLOW(x);
   f = x[3] + x[4];
   return(f);
finish MAXFLOW;

/* constraints: lower and upper traffic limits; */
/* what flows into an intersection must flow out */
con = {  0.  0.  0.  0.  0.   .   . ,
        10. 30. 10. 30. 10.   .   . ,
         0.  1. -1.  0. -1.  0.  0. ,
         1.  0.  1. -1.  0.  0.  0. ,
         1.  1.  0. -1. -1.  0.  0. };

x = j(1,5, 1.);
optn = {1 2};
ods select ParameterEstimates#2;
CALL NLPCG(xres,rc,"MAXFLOW",x,optn,con);

title 'Minimize Total Delay in Network';
proc iml;
start MINDEL(x);
   t12 = 5. + .1 * x[1] / (1. - x[1] / 10.);
   t13 = x[2] / (1. - x[2] / 30.);
   t32 = 1. + x[3] / (1. - x[3] / 10.);
   t24 = x[4] / (1. - x[4] / 30.);
   t34 = 5. + .1 * x[5] / (1. - x[5] / 10.);
   f = t12*x[1] + t13*x[2] + t32*x[3] + t24*x[4] + t34*x[5];
   return(f);
finish MINDEL;

con = {  0.  0.  0.  0.  0.   .   . ,
        10. 30. 10. 30. 10.   .   . ,
         0.  1. -1.  0. -1.  0.  0. ,
         1.  0.  1. -1.  0.  0.  0. ,
         0.  0.  0.  1.  1.  0.  5. };

x = j(1,5, 1.);
optn = {0 3};
call nlpnrr(xres,rc,"MINDEL",x,optn,con);