资源

使用备用资源调度(clpe10)

/***************************************************************//*                                                             *//*S A S S A M P L E L I B R A R Y*//*                                                             *//*名称:clpe10*//*标题:使用备用资源调度(clpe10)*//*产品:或*//*系统:所有*//*关键字:或*//*程序:CLP、SQL、GANTT*//*数据:*//*                                                             *//*支持:更新:*//*参考:*//*MISC:CLP程序章节中的示例10*//*约束编程书*//*                                                             *//***************************************************************/数据项目;数组v{11}$8。j1-j3 m1-m3 o1-o4 dur;输入v{*};数据线;1    .    .    0    1    .    0    1    2    .    12    .    .    0    1    2    0    1    2    .    13    .    .    1    2    3    0    1    2    .    14    5    6    3    4    5    2    3    4    5    17    .    .    6    7    8    5    6    .    .    18    9    .    6    7    8    .    .    .    .    110   .    .    7    8    9    .    .    .    .    111。1 2。0    1    2    3    112   13   14   7    8    9    0    1    2    3    115   16   .    5    6    .    4    5    6    .    117   .    .    3    4    .    4    5    6    .    118   .    .    3    4    .    .    .    .    .    119。0    1    2    .    .    .    .    120   .    .    0    1    .    .    .    .    .    121   22   .    0    1    .    0    1    2    .    223   .    .    2    .    .    0    1    2    .    224   25   36   8    9    .    .    .    .    .    126   35   75   6    7    .    .    .    .    .    127   34   74   6    7    .    5    6    .    .    128   .    .    4    5    .    5    6    .    .    129   .    .    4    5    .    3    4    .    .    130   .    .    3    .    .    3    4    .    .    131   .    .    3    .    .    3    4    .    .    232。4 5。3    4    .    .    233   .    .    4    5    .    5    6    .    .    237   76   77   8    9    .    .    .    .    .    138   39   .    0    1    .    0    1    .    .    140   .    .    2    .    .    2。141   .    .    6    7    .    6    .    .    .    242   62   82   6    7    .    .    .    .    .    243   44   63   8    9    .    .    .    .    .    245   46   65   0    1    .    4    5    .    .    247   67   .    2    3    .    2    3    .    .    248   68   .    2    3    .    2    3    .    .    149   50   69   4    5    .    0    1    .    .    151   52   .    3    4    .    1    2    .    .    253   .    .    5    6    .    0    .    .    .    254   .    .    5    6    .    6    .    .    .    155   56   57   7    8    9    .    .    .    .    158 59 78 0 1 2 3 4。160 80之间。0    1    2    5    6    .    .    161   81   .    6    7    .    5    6    .    .    264   83   84   8    9    .    .    .    .    .    266   .    .    0    1    .    4    5    .    .    270   .    .    5    .    .    0 1。171   .    .    5    .    .    0    1    2    .    272   73   .    3    4    .    0    1    2    .    279   .    .    0    1    2    3    4    .    .    185   .    .    0    .    .    3    .    .    .    186   .    .    1    .    .    4    .    .    .    187   .    .    2    .    .    5    .    .    .    188   .    .    3    .    .    0    .    .    .    189   .    .    4    .    .    1    .    .    .    190   .    .    5    .    .    2。1;数据项目2;设置项目;数组v{11}$8。j1-j3 m1-m3 o1-o4 dur;保留j1-j3 s_start s_finish segmt_no后继;继任者=。;segmt_no=1;重命名j1=Jb1;重命名j2=Jb2;重命名j3=Jb3;do i=4到10;如果输入(v{i},最好)ne。然后做;偏移量=0;如果i>6,则执行;偏移=10;结束;s_start=偏移量+输入(v{i},最佳);s_完成=s_开始+0.45;如果输入(dur,best)eq 2,则执行;s_完成=s_开始+0.9;结束;产出;segmt_no=segmt_no+1;结束;结束;运行;proc格式;价值资源0=“马赫数0”1=“马赫数1”2=“马赫数2”3=“马赫数3”4=“马赫数4”5=“马赫数5”6=“马赫数6”7=“马赫数7”8=“马赫数8”9=“马赫数9”10=“操作0”11=“操作1”12=“操作2”13=“操作3”14=“操作4”15=“操作5”16=“操作6”17 = ' '18=“”19=“”;运行;图案1 c=黑色v=e r=10;proc-gantt数据=proj2;格式化s_start资源。;图表/增量=1个nojobnumnolegend使用格式maxdate=17图表宽度=90压缩跳过=3介于=4之间barht=1.5高度=4参考=10;id Jb1 Jb2 Jb3;运行;proc clp dom=[0,12]重新启动=500 dpr=6显示进度schedtime=schedtime_altres schedres=schedres_altres;schedule start=0 finish=12 actselect=dminls edgefinder;活性(J1-J20 J24-J30 J34-J40 J48-J50 J54-J60J68-J70 J74-J80 J85-J90)=(1)/*一天工作*/(J21-J23 J31-J33 J41-J47 J51-J53 J61-J67J71-J73 J81-J84)=(2);/*两天的工作*/资源(M0-M9)(OP0-OP6);要求/*机器要求*/(J85)=(M0)(J1 J20 J21 J22 J38 J39 J45 J46 J65 J66)=(M0,M1)(J19 J2 J58 J59 J60 J78 J79 J80)=(M0、M1、M2)(J86)=(M1)(J11)=(M1,M2)(J3)=(M1、M2、M3)(J23 J40 J87)=(M2)(J47 J48 J67 J68)=(M2、M3)(J30 J31 J88)=(M3)(J17 J18 J51 J52 J72 J73)=(M3、M4)(J4 J5 J6)=(M3、M4、M5)(J89)=(M4)(J28 J29 J32 J33 J49 J50 J69)=(M4、M5)(J70 J71 J90)=(M5)(J15 J16 J53 J54)=(M5,M6)(J26 J27 J34 J35 J41 J42 J61 J62 J74 J75 J81 J82)=(M6,M7)(J7 J8 J9)=(M6,M7,M8)(J10 J12 J13 J14 J55 J56 J57)=(M7,M8,M9)(J24 J25 J36 J37 J43 J44 J63 J64 J76 J77 J83 J84)=(M8,M9)/*操作员要求*/(J53 J88)=(OP0)(J38 J39 J49 J50 J69 J70)=(OP0,OP1)(J1 J2 J21 J22 J23 J3 J71 J72 J73)=(OP0,OP1,OP2)(J11 J12 J13 J14)=(OP0,OP1,OP2,OP3)(J89)=(OP1)(J51 J52)=(OP1,OP2)(J40 J90)=(OP2)(J47 J48 J67 J68)=(OP2,OP3)(J4 J5 J6)=(OP2,OP3,OP4,OP5)(J85)=(OP3)(J29 J30 J31 J32 J58 J59 J78 J79)=(OP3,OP4)(J86)=(OP4)(J45 J46 J65 J66)=(OP4,OP5)(J15 J16 J17)=(OP4、OP5、OP6)(J87)=(OP5)(J27 J28 J33 J34 J60 J61 J7 J74 J80 J81)=(OP5,OP6)(J41 J54)=(OP6);运行;数据sched_aa;label activity='JOB'operator='operator'machine='machine';设置schedres_altres;如果(索引(资源,“M”)),则执行;机器=资源;产出;结束;如果(索引(资源,“O”)),则执行;操作员=资源;产出;结束;运行;proc-sql;将台式机创建为选择不同的活动,资源作为机器来自schedres_altres其中(索引(资源,“M”));将表运算符创建为选择不同的活动,资源作为操作员来自schedres_altres其中(索引(资源,“O”));将表join1创建为选择machine.activity、machine.machine、,当operator.operator然后operator.operator时的情况else“N/A”结束为运算符从机器完全联接运算符在machine.activity上=操作员活动;将表schedaltres创建为选择时间*、机器、操作员从schedtime_altres as time full join join1on-time.activity=join1.activity;退出;/***************************************************************//*为图形输出定义实用程序宏*//***************************************************************//*%colorIdex创建资源-图案-颜色映射*//*%fnLegend使用脚注根据映射添加图例*//*%setPatterns根据映射执行模式语句*/%宏colorIdex(res_var=,proj=,palette=,out=);proc-sql;创建表格输出为(&O)从&proj;中选择distinct(&resvar);退出;数据输出;出发;删除名称tr颜色ct;格式颜色$10。;保留模式1;保留color_ct 1;名称tr=小写(strip(&res_var));如果name_tr eq'n/a'或name_tr eq'',则color='red';否则;color=扫描(&palette,color_ct);color_ct=color_ct+1;结束;产出;_模式=模式+1;运行;%修补colorIdex;/*宏%fnLegend使用脚注添加图例*//*标题*//*                                                                       *//*颜色条11文本。。。颜色条1n文本*//*颜色条m1文本。。。颜色条mn文本*/%宏fnLegend(tfact=1.75,h=10,xStart=5,rhs=100,nCol=,nRow=,title=“使用的资源”,map=,font=“Albany AMT”,var=_Resource_);%设rH=%sysevalf(/h/([nRow+2));/*行高*/%让cW=%sysevalf((&rhs-2*&xStart)/&nCol);/*列宽*/%let rowsH=%sysevalf(&rH*&nRow);/*所有图例行的高度*/%设barH=%sysevalf(&rH*0.35);/*图例高度(彩条)*/%让rTextH=%sysevalf(&barH*&tfact);/*图例行中的文字高度*/%让tiTextH=%sysevalf(&rTextH*1.2);/*标题行中文本的高度*/脚注;数据_全部_;调用执行('footnote1 f='||“&font”||'j=c h='||&tiTextH||'ct'||'“'||&标题||'“;');调用执行('footnote2 f='||“&font”||'h='||&rH||'ct“;');运行;数据_全部_;设置&map end=完成;保留计数0;idxRow=int(计数/&nCol);idxCol=计数-idxRow*&nCol;x=&xStart+idxCol*&cW;y=&rowsH-idxRow*&rH;_fnlStr_=条带(&var);如果_fnlStr_eq“”,则_fnl Str_='N/A';如果count eq为0,则调用execute('fotnote3 h='|&rowsH||'ct“”');如果小写(条带(颜色))等于“红色”,则调用execute(catx('','f=',“&font”,'h=',&barH,'ct','m=(',x,',',y,')pct','c=',颜色,'方框=1 bs=0 pct“”');其他的调用execute(catx('','f=',“&font”,'h=',&barH,'ct','m=(',x,',',y,')pct','c=',color,'bc=',颜色,'方框=1 bs=0 pct“”');调用执行(catx('','f=',“&font”,'h=',&rTextH,'ct','m=(+0.5,',y,')pct','c=黑色')||'“'||trim(_fnlStr_)||''”);计数=计数+1;如果完成,则调用execute(';');运行;%修正fnLegend;%宏集合模式(map);数据_全部_;集合↦cstr=小写(条带(颜色));如果cstr eq为“红色”,则调用执行('pattern'||strip(_pattern)||'v=e color='||cstr||'重复=1;');其他的调用执行('pattern'||strip(_pattern)||'v=s color='|cstr||'重复=1;');运行;%修补setPatterns;/***************************************************************//*结束宏定义*//***************************************************************//*按运算符添加模式*/%let _palette='黑-蓝-黄-橙-蓝-棕-绿';%colorIdex(res_var=operator,proj=sched_altres,palette=&_palette,输出=res_col_patn);proc-sql;将表schedgantt_altres创建为选择a.*、b.pattern来自schedaltres a、rescolpatn b其中a.operator=b.operator;退出;/*开始绘制甘特图*/title1 j=c h=6pct“操作员#BYVAL(操作员)时间表”;title2 j=c h=4pct“机器在棒材上方识别”;%setPatterns(res_col_patn);选项nobyline;/*禁止署名*/数据标签;_y=-1;_lvar=“机器”;_xvar=“开始”;_hlabel=1.5;_yoffset=-.3;_flabel=“Albany AMT”;运行;进程排序数据=sched_gant_altres;由操作员启动;运行;proc-gantt数据=sched_gantt_altres(其中=(运算符ne“N/A”))labdata=标签;操作员;图表/pcompress(压缩)诺霍布努姆诺列根s_start=开始s_finish=完成比例尺=12在=6之间高度=1.7跳过=2;id活性;运行;proc-sql;更新标签集_hlabel=2.5;退出;title1 j=c h=3pct“自动化任务时间表”;proc-gantt数据=sched_gantt_altres(其中=(运算符=“N/A”))labdata=标签;图表/压缩诺霍布努姆诺列根s_start=开始s_finish=完成比例=23介于=15之间高度=3跳过=3;id活性;运行;title1 j=c h=5pct“使用备用资源调度”;title2 j=c h=3pct“按机器调度”;%fnLegend(xStart=20,h=18,map=res_col_patn,title='需要操作员',nCol=4,nRow=2,var=运算符,rhs=110,tfact=1.5);/*添加段编号*/进程排序数据=sched_gant_altres;通过机器启动;运行;数据sched_gant_altres;设置sched_gant_altres;label machine=“机器”;保留sn“”;保留segmt_no 1;滴sn;如果sn-ne机器那么做;segmt_no=1;sn=机器;结束;否则segmt_no=segmt_no+1;运行;数据标签;_y=-1;_lvar=“活动”;_xvar=“开始”;_hlabel=1.3;_yoffset=-.2;运行;proc-gantt数据=sched_gant_altreslabdata=标签;图表/pcompress(压缩)跳过=2高度=1.5比例=13诺霍布努姆介于=13之间诺列根s_start=开始s_finish=完成;id机器;运行;goptions重置=全部;