Transitive Closure: Bug Tracking Circular Dependencies (netsle06)
/******************************************************************************/
/* */
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: netsle06 */
/* TITLE: Transitive Closure: Bug Tracking Circular Dependencies (netsle06) */
/* PRODUCT: OR */
/* SYSTEM: ALL */
/* KEYS: OR */
/* PROCS: OPTMODEL, PRINT, SQL */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: Example 6 from the network solver documentation. */
/* */
/******************************************************************************/
data DefectLinks;
input defectId $ linkedDefect $ linkType $ when datetime16.;
format when datetime16.;
datalines;
D0096978 S0711218 DUPTO 20OCT10:00:00:00
S0152674 S0153280 DUPTO 30MAY02:00:00:00
S0153280 S0153307 DUPTO 30MAY02:00:00:00
S0153307 S0152674 DUPTO 30MAY02:00:00:00
S0162973 S0162978 DUPTO 29NOV10:16:13:16
S0162978 S0165405 DUPTO 29NOV10:16:13:16
S0325026 S0575748 DUPTO 01JUN10:00:00:00
S0347945 S0346582 DUPTO 03MAR06:00:00:00
S0350596 S0346582 DUPTO 21MAR06:00:00:00
S0539744 S0643230 DUPTO 10MAY10:00:00:00
S0575748 S0643230 DUPTO 15JUN10:00:00:00
S0629984 S0643230 DUPTO 01JUN10:00:00:00
;
proc optmodel;
set<str,str> LINKS;
read data DefectLinks into LINKS=[defectId linkedDefect];
set<num,num,str> CYCLES;
set<str,str> CLOSURE;
solve with NETWORK /
loglevel = moderate
graph_direction = directed
links = (include=LINKS)
cycle = (mode=first_cycle)
out = (cycles=CYCLES)
;
put CYCLES;
create data Cycles from [cycle order node]=CYCLES;
solve with NETWORK /
loglevel = moderate
graph_direction = directed
links = (include=LINKS)
transitive_closure
out = (closure=CLOSURE)
;
put CLOSURE;
create data TransClosure from [defectId linkedDefect]=CLOSURE;
quit;
proc sql;
create table Chains as
select defectId, linkedDefect from TransClosure
except
select defectId, linkedDefect from DefectLinks;
quit;
proc print data=Cycles noobs label;
run;
proc print data=Chains noobs label;
run;