Resources

Getting Started Examples


/***************************************************************/
/*                                                             */
/*          S A S   S A M P L E   L I B R A R Y                */
/*                                                             */
/*    NAME: onetg01                                            */
/*   TITLE: Getting Started Examples                           */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: OPTNET, PRINT, SORT                                */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*     REF:                                                    */
/*    MISC: Examples from the Getting Started section of the   */
/*          OPTNET documentation.                              */
/*                                                             */
/***************************************************************/

/* Check OPTNET version (Overview section)                     */

/* Road Network Shortest Path                                  */

data LinkSetInRoadNC10am;
   input start_inter $1-20 end_inter $20-40 miles miles_per_hour;
   datalines;
614CapitalBlvd      Capital/WadeAve      0.6  25
614CapitalBlvd      Capital/US70W        0.6  25
614CapitalBlvd      Capital/US440W       3.0  45
Capital/WadeAve     WadeAve/RaleighExpy  3.0  40
Capital/US70W       US70W/US440W         3.2  60
US70W/US440W        US440W/RaleighExpy   2.7  60
Capital/US440W      US440W/RaleighExpy   6.7  60
US440W/RaleighExpy  RaleighExpy/US40W    3.0  60
WadeAve/RaleighExpy RaleighExpy/US40W    3.0  60
RaleighExpy/US40W   US40W/HarrisonAve    1.3  55
US40W/HarrisonAve   SASCampusDrive       0.5  25
;

data LinkSetInRoadNC10am;
   set LinkSetInRoadNC10am;
   time_to_travel = miles * 1/miles_per_hour * 60;
run;

proc optnet
   data_links   = LinkSetInRoadNC10am;
   data_links_var
      from      = start_inter
      to        = end_inter
      weight    = time_to_travel;
   shortpath
      out_paths = ShortPath
      source    = "614CapitalBlvd"
      sink      = "SASCampusDrive";
run;

proc print data=ShortPath(keep=order start_inter end_inter time_to_travel)
           noobs label;
   sum time_to_travel;
run;

data LinkSetInRoadNC5pm;
   input start_inter $1-20 end_inter $20-40 miles miles_per_hour;
   datalines;
614CapitalBlvd      Capital/WadeAve      0.6  25
614CapitalBlvd      Capital/US70W        0.6  25
614CapitalBlvd      Capital/US440W       3.0  45
Capital/WadeAve     WadeAve/RaleighExpy  3.0  25 /*high traffic*/
Capital/US70W       US70W/US440W         3.2  60
US70W/US440W        US440W/RaleighExpy   2.7  60
Capital/US440W      US440W/RaleighExpy   6.7  60
US440W/RaleighExpy  RaleighExpy/US40W    3.0  60
WadeAve/RaleighExpy RaleighExpy/US40W    3.0  60
RaleighExpy/US40W   US40W/HarrisonAve    1.3  55
US40W/HarrisonAve   SASCampusDrive       0.5  25
;

data LinkSetInRoadNC5pm;
   set LinkSetInRoadNC5pm;
   time_to_travel = miles * 1/miles_per_hour * 60;
run;

proc optnet
   data_links   = LinkSetInRoadNC5pm;
   data_links_var
      from      = start_inter
      to        = end_inter
      weight    = time_to_travel;
   shortpath
      out_paths = ShortPath
      source    = "SASCampusDrive"
      sink      = "614CapitalBlvd";
run;

proc print data=ShortPath(keep=order start_inter end_inter time_to_travel)
           noobs label;
   sum time_to_travel;
run;