gusucode.com > 改进的遗传算法的课表编排功能matlab源码程序 > 改进的遗传算法的课表编排功能/改进的遗传算法的课表编排功能/排课/shijianxishu.m
function y=shijianxishu(x) a=[8:2:18;5:-1:0];%时间权值(8-10点:5,10-12:4,12-14:3,14-16:2,16-18:1) b=[5,5,4,4,2,2,1,1]; j=1; %星期 while j<=5 if (x-8*(j-1))==1 y=b(x-8*(j-1)); j=6; elseif (x-8*(j-1))==2 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==3 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==4 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==5 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==6 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==7 y=b(x-8*(j-1));j=6; elseif (x-8*(j-1))==8 y=b(x-8*(j-1));j=6; else j=j+1; end end