Exemplo n.º 1
0
        public EnSquad SaveExistMbr(EnSquad Value)
        {
            EnSquad Result = ThisModule.Dac.Sqd.MbrDAC.SaveExist(Value);

            ThisModule.SendDataChanged();

            return(Result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 某班级所有待安排的课
        /// </summary>
        public IList <EnLsnAct> GetFailLsnActs(EnSquad squad)
        {
            IList <EnLsnAct> Result = new List <EnLsnAct>();

            ExIList.Append <EnLsnAct>(SqdScheduleList[squad].FailLsnActs, Result);

            return(Result);
        }
Exemplo n.º 3
0
        public void RemoveMember(EnSquadGroup grp, EnSquad mbr)
        {
            //移除班级与班级组关系后,此班级通过此组获得的课务安排会被删除
            ThisModule.Lsn.SquadRelationIsRelease(grp, mbr);

            ThisModule.Dac.Sqd.ReleaseRelation(grp, mbr);

            ThisModule.SendDataChanged();
        }
Exemplo n.º 4
0
        public void AddMember(EnSquadGroup grp, EnSquad mbr)
        {
            //增加班级与班级组关系后,此班级组的课务安排会自动应用到此班级
            ThisModule.Lsn.SquadRelationIsCreate(grp, mbr);

            ThisModule.Dac.Sqd.CreateRelation(grp, mbr);

            ThisModule.SendDataChanged();
        }
Exemplo n.º 5
0
            public SqdSchedule(EnSolution Sln, EnSquad Squad)
            {
                this.squad = Squad;

                matrix = new DtMatrix <ScheduleNode>(Sln);
                foreach (VcTime time in matrix.eachTime())
                {
                    matrix[time] = new ScheduleNode();
                }
            }
Exemplo n.º 6
0
        public void DeleteMbr(EnSquad mbr)
        {
            //删除班级后,此班级的课务安排会被删除
            ThisModule.Lsn.SquadIsDelete(mbr);

            ThisModule.Dac.Rule.DeleteRuleOfEty(mbr);
            ThisModule.Dac.Sqd.DeleteMbr(mbr);

            ThisModule.SendDataChanged();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 放弃某班级课表的编辑
        /// </summary>
        public void Cancel(EnSquad squad)
        {
            SqdSchedule sch = SqdScheduleList[squad];

            CollectAct(sch);
            PutActToMatrix(sch);
            sch.Modified = false;

            UpdateModified();
            AfterScheduleChanged(squad);
        }
Exemplo n.º 8
0
        /// <summary>
        ///  获得当前虚拟态的课表(未保存的内存中的课表)
        /// </summary>
        public DtMatrix <EnLsnAct> GetSqdMatrix(EnSquad squad)
        {
            DtMatrix <EnLsnAct> Result = new DtMatrix <EnLsnAct>(DataRule.Solution);
            SqdSchedule         sch    = SqdScheduleList[squad];

            foreach (VcTime time in Result.eachTime())
            {
                Result[time] = sch.Matrix[time].LsnAct;
            }

            return(Result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 保存某班级课表
        /// </summary>
        public void Save(EnSquad squad)
        {
            SqdSchedule      sch  = SqdScheduleList[squad];
            IList <EnLsnAct> Acts = HardeningAct(sch);

            DataRule.Lsn.SaveLsnActs(Acts);
            sch.Modified = false;
            UpdateModified();
            if (this.ModifiedChange != null)
            {
                this.ModifiedChange();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///  获得当前虚拟态的课表某节的规则列表与冲突
        /// </summary>
        public IList <VcActEtyRelation> GetSqdClash(EnSquad squad, VcTime time)
        {
            List <VcActEtyRelation> Result = new List <VcActEtyRelation>();

            if (!this.TimeIsEnabled(time))
            {
                return(Result);
            }

            //获得VcLsnAct
            EnLsnAct act = SqdScheduleList[squad].Matrix[time].LsnAct;

            if (act == null)
            {
                return(Result);
            }

            //添加授课教师
            if (act.ClsLesson.Teacher != null)
            {
                Result.Add(new VcActEtyRelation(act.ClsLesson.Teacher, eActEtyRelation.teach));

                //整理出冲突课程
                foreach (SqdSchedule sch in SqdScheduleList.Values)
                {
                    if (sch.Matrix[time].LsnAct != null &&
                        sch.Matrix[time].LsnAct.ClsLesson.Squad != squad &&
                        sch.Matrix[time].LsnAct.ClsLesson.Teacher == act.ClsLesson.Teacher)
                    {
                        Result.Add(new VcActEtyRelation(sch.Matrix[time].LsnAct.ClsLesson,
                                                        eActEtyRelation.clash, eRule.crisscross));
                    }
                }
            }

            //添加Lsn/ClsLsn的Rule
            Result.Add(new VcActEtyRelation(act.ClsLesson.Lesson, eActEtyRelation.rule,
                                            DataRule.Rule.GetRuleOfTime(act.ClsLesson.Lesson, time)));

            Result.Add(new VcActEtyRelation(act.ClsLesson, eActEtyRelation.rule,
                                            DataRule.Rule.GetRuleOfTime(act.ClsLesson, time)));

            //迭代Act的元素,添加Rule
            foreach (BaseEntity ety in this.eachClsLsnComponent(act.ClsLesson))
            {
                Result.Add(new VcActEtyRelation(ety, eActEtyRelation.rule,
                                                DataRule.Rule.GetRuleOfTime(ety, time)));
            }

            return(Result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 课表拖放后
        /// </summary>
        public void Move(EnSquad squad, EnLsnAct sAct, VcTime tTime)
        {
            SqdSchedule sch = SqdScheduleList[squad];

            //获得来源的act的时间sTime
            VcTime sTime = new VcTime();

            if (!sch.FailLsnActs.Contains(sAct))
            {
                foreach (VcTime tt in sch.Matrix.eachTime())
                {
                    if (sch.Matrix[tt].LsnAct == sAct)
                    {
                        tt.CopyFieldTo(sTime);
                        break;
                    }
                }
            }


            if (sTime == tTime)   //原地拖
            {
                return;
            }
            else if (sTime.HasValue && !tTime.HasValue)  //从课表拖到FailLsnActs
            {
                EnLsnAct ta = sch.Matrix[sTime].LsnAct;
                sch.FailLsnActs.Add(ta);
                sch.Matrix[sTime].LsnAct = null;
            }
            else if (!sTime.HasValue && tTime.HasValue)    //从FailLsnActs拖到课表
            {
                if (sch.Matrix[tTime].LsnAct != null)
                {
                    return;
                }

                sch.Matrix[tTime].LsnAct = sAct;
                sch.FailLsnActs.Remove(sAct);
            }
            else if (sTime.HasValue && tTime.HasValue)    //课表拖到课表
            {
                EnLsnAct ta = sch.Matrix[sTime].LsnAct;
                sch.Matrix[sTime].LsnAct = sch.Matrix[tTime].LsnAct;
                sch.Matrix[tTime].LsnAct = ta;
            }

            sch.Modified  = true;
            this.Modified = true;
            this.AfterScheduleChanged(squad);
        }
Exemplo n.º 12
0
        public void SquadRelationIsCreate(EnSquadGroup grp, EnSquad mbr)
        {
            //增加班级与班级组关系后,此班级组的课务安排会自动应用到此班级
            IList <EnLesson> Lsns = GetLessons(grp);

            foreach (EnLesson lsn in Lsns)
            {
                EnClsLesson clsLsn = new EnClsLesson();
                clsLsn.Lesson     = lsn;
                clsLsn.SharedTime = lsn.SharedTime;
                clsLsn.Squad      = mbr;
                SaveClsLsnTree(clsLsn);
            }
        }
Exemplo n.º 13
0
        public void SquadIsDelete(EnSquad squad)
        {
            IList <EnClsLesson> ClsLsns = new List <EnClsLesson>();

            foreach (EnClsLesson clsLsn in eachClsLesson())
            {
                if (clsLsn.Squad.Id == squad.Id)
                {
                    ClsLsns.Add(clsLsn);
                }
            }

            foreach (EnClsLesson clsLsn in ClsLsns)
            {
                this.RemoveClsLsn(clsLsn);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///  获得当前虚拟态的课表规则
        /// </summary>
        public DtMatrix <eRule> GetSqdRule(EnSquad squad)
        {
            DtMatrix <eRule> Result
                = new DtMatrix <eRule>(DataRule.Solution);
            SqdSchedule sch = SqdScheduleList[squad];

            foreach (VcTime time in Result.eachTime())
            {
                if (sch.Matrix[time].LsnAct == null)
                {
                    Result[time] = eRule.common;
                }
                else
                {
                    Result[time] = sch.Matrix[time].Rule;
                }
            }
            return(Result);
        }
Exemplo n.º 15
0
        public void SquadRelationIsRelease(EnSquadGroup grp, EnSquad mbr)
        {
            //移除班级与班级组关系后,此班级通过此组获得的课务安排会被删除
            IList <EnClsLesson> ClsLsns = new List <EnClsLesson>();

            foreach (EnClsLesson clsLsn in eachClsLesson())
            {
                if (clsLsn.Lesson.SquadGroup.Id == grp.Id &&
                    clsLsn.Squad.Id == mbr.Id)
                {
                    ClsLsns.Add(clsLsn);
                }
            }

            foreach (EnClsLesson clsLsn in ClsLsns)
            {
                this.RemoveClsLsn(clsLsn);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 一个班级的课表改变后,entity允许为null(自动排课时)
        /// </summary>
        private void AfterScheduleChanged(EnSquad squad)
        {
            SetSqdScheduleListRule();  //生成班级课表的规则,应用clsLsn的规则并标记出教师授课冲突
            SetFailActs();             //生成全校要处理的任务
            if (this.FailActChange != null)
            {
                this.FailActChange(this.FailActs);
            }

            this.SendScheduleUpdate(eScheduleUpdateKind.RefreshAct);
            this.SendScheduleUpdate(eScheduleUpdateKind.RefreshRule);
            //旧的实现很高效
            //foreach (EnSquad ss in ActSquadList)
            //    if (squad == null || ss == squad)
            //        this.SendScheduleUpdate(ss, eScheduleUpdateKind.RefreshAct);
            //    else
            //        this.SendScheduleUpdate(ss, eScheduleUpdateKind.RefreshRule);

            ////一个指定班级课表改变后只更新相关的教师课表
            //if (squad == null)
            //{
            //    foreach (EnTeacher ts in ActTeacherList)
            //        this.SendScheduleUpdate(ts, eScheduleUpdateKind.RefreshAct);
            //}
            //else
            //{
            //    SqdSchedule sch = SqdScheduleList[squad];
            //    foreach (EnTeacher ts in ActTeacherList)
            //        if (sch.Teaches.Contains(ts))
            //            this.SendScheduleUpdate(ts, eScheduleUpdateKind.RefreshAct);
            //}

            if (this.ModifiedChange != null)
            {
                this.ModifiedChange();
            }
        }
Exemplo n.º 17
0
 public PrtMatrixSqd(EnSquad sqd)
 {
     squad = sqd;
 }
Exemplo n.º 18
0
 public bool MbrNameExist(EnSquad mbr, string Name)
 {
     return(ThisModule.Dac.Sqd.MbrDAC.NameExist(mbr, Name));
 }
Exemplo n.º 19
0
        /// <summary>
        /// 仅负责把空课安排到合适的位置,不会动已排的课
        /// </summary>
        private Boolean Automatic(EnSquad squad)
        {
            if (SqdScheduleList[squad].FailLsnActs.Count == 0)
            {
                return(false);
            }

            //策略:
            //第一步:整理FailLsnActs到有序(同VcClsLesson相邻,为提高速度)
            //对每一VcLsnAct:计算优势值(靠评价函数),安排到优势值最大的Time

            SqdSchedule sch = SqdScheduleList[squad];

            sch.Modified = true;
            IList <EnLsnAct> OrderFailLsnActs = GetOrderFailLsnActs(sch.FailLsnActs);
            Int32            DaySum           = 0;

            foreach (Boolean bl in DataRule.Solution.ActiveWeekArr)
            {
                if (bl)
                {
                    DaySum++;
                }
            }

            EnClsLesson        frontClsLsn  = null;
            DtMatrix <Boolean> TchConcretes = null;
            DtMatrix <eRule>   ClsLsnRules  = null;

            Int32[] CourseCnt     = new Int32[7];
            Int32   CourseAverage = 0;

            foreach (EnLsnAct act in OrderFailLsnActs)
            {
                if (frontClsLsn == null || frontClsLsn != act.ClsLesson)
                {
                    frontClsLsn  = act.ClsLesson;
                    TchConcretes = new DtMatrix <bool>(DataRule.Solution);
                    ClsLsnRules  = this.ClsLsnRuleList[act.ClsLesson];

                    if (act.ClsLesson.Teacher != null)
                    {
                        foreach (VcTime time in sch.Matrix.eachTime())
                        {
                            if (sch.Matrix[time].LsnAct == null)
                            {
                                foreach (SqdSchedule sqdSch in SqdScheduleList.Values)
                                {
                                    if (sqdSch.Matrix[time].LsnAct != null &&
                                        sqdSch.Matrix[time].LsnAct.ClsLesson.Teacher == act.ClsLesson.Teacher)
                                    {
                                        TchConcretes[time] = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    //foreach (Int32 cnt in CourseCnt)
                    //    cnt = 0;
                    for (Int32 i = 0; i <= 6; i++)
                    {
                        CourseCnt[i] = 0;
                    }
                    Int32 CourseSum = 0;
                    foreach (VcTime time in sch.Matrix.eachTime())
                    {
                        if (sch.Matrix[time].LsnAct != null &&
                            sch.Matrix[time].LsnAct.ClsLesson.Lesson.Course == act.ClsLesson.Lesson.Course)
                        {
                            CourseCnt[(Int32)time.Week]++;
                            CourseSum++;
                        }
                    }
                    foreach (EnLsnAct failAct in sch.FailLsnActs)
                    {
                        if (failAct.ClsLesson.Lesson.Course == act.ClsLesson.Lesson.Course)
                        {
                            CourseSum++;
                        }
                    }
                    if (DaySum == 0)
                    {
                        CourseAverage = 0;
                    }
                    else
                    {
                        CourseAverage = (CourseSum + DaySum - 1) / DaySum;
                    }
                }

                //TchConcretes true教师冲突
                //ClsLsnRules 规则
                //CourseCnt 此课每天已经上的节数(数组)
                //CourseSum 此课每周总课时
                //CourseAverage 每天平均上课节数

                DtMatrix <Int32> Advantages = new DtMatrix <Int32>(DataRule.Solution);
                foreach (VcTime time in sch.Matrix.eachTime())
                {
                    if (sch.Matrix[time].LsnAct != null)
                    {
                        Advantages[time] = Int32.MinValue;
                    }
                    else
                    {
                        Advantages[time] = TchConcretes[time] ? -2 : (Int32)ClsLsnRules[time];
                        if (CourseCnt[(Int32)time.Week] >= CourseAverage)
                        {
                            if (Advantages[time] > -1)
                            {
                                Advantages[time] = -1;   //这一天上课比较多
                            }
                        }
                    }
                }

                Int32 MaxAdvantage      = Int32.MinValue;
                VcTime MaxAdvantageTime = new VcTime();
                foreach (VcTime time in Advantages.eachTime())
                {
                    if (MaxAdvantage < Advantages[time])
                    {
                        MaxAdvantage = Advantages[time];
                        time.CopyFieldTo(MaxAdvantageTime);
                    }
                }

                if (MaxAdvantage == Int32.MinValue)
                {
                    return(true); //没地方排了
                }
                if (MaxAdvantage >= -1)
                {
                    CourseCnt[(Int32)MaxAdvantageTime.Week]++;
                    sch.Matrix[MaxAdvantageTime].LsnAct = act;
                    sch.FailLsnActs.Remove(act);
                }
            }

            foreach (VcTime time in sch.Matrix.eachTime())
            {
                if (sch.FailLsnActs.Count > 0 && sch.Matrix[time].LsnAct == null)
                {
                    sch.Matrix[time].LsnAct = sch.FailLsnActs[sch.FailLsnActs.Count - 1];
                    sch.FailLsnActs.RemoveAt(sch.FailLsnActs.Count - 1);
                }
            }

            return(true);
        }
Exemplo n.º 20
0
 public EnSquad SaveNewMbr(EnSquad Value)
 {
     return(ThisModule.Dac.Sqd.MbrDAC.SaveNew(Value));
 }
Exemplo n.º 21
0
 //花指定的时间(ms)优化课表
 private void magic(EnSquad squad, bool LockIsEnabled, Int32 time)
 {
 }
Exemplo n.º 22
0
 public IList <EnSquadGroup> GetGroups(EnSquad mbr)
 {
     return(ThisModule.Dac.Sqd.GetGroups(mbr));
 }
Exemplo n.º 23
0
        /// <summary>
        /// 获取交换时优势
        /// </summary>
        public DtMatrix <eRule> GetActChangeRule(EnSquad squad,
                                                 EnLsnAct sAct, VcTime sTime)
        {
            Debug.Assert(sAct != null, "为简化程序逻辑,空课不可拖。");

            //这个方法是本程序中最复杂的逻辑
            //步骤:
            //一、获得所有位置当前优势
            //二、获得sAct当前优势
            //三、获得所有位置的Act移动到sTime的优势值
            //四、获得sAct移动到所有位置的优势值
            //五、比较当前优势和移动后的优势,获得交换的价值

            SqdSchedule NowSch = SqdScheduleList[squad];

            //一、获得所有位置当前优势
            DtMatrix <eRule> NowRules = this.GetSqdRule(squad);

            //二、获得sAct当前优势
            eRule sActNowRule;

            if (NowRules.TestTime(sTime))
            {
                sActNowRule = NowRules[sTime];
            }
            else
            {
                sActNowRule = eRule.common;  //未排
            }
            //三、获得所有位置的Act移动到sTime的优势值
            DtMatrix <eRule> FutureRules = new DtMatrix <eRule>(DataRule.Solution);

            if (FutureRules.TestTime(sTime))
            {
                IList <EnTeacher> sTimeTchs = new List <EnTeacher>();
                foreach (SqdSchedule sch in this.SqdScheduleList.Values)
                {
                    if (sch != NowSch && sch.Matrix[sTime].LsnAct != null)
                    {
                        EnLsnAct act = sch.Matrix[sTime].LsnAct;
                        if (act.ClsLesson.Teacher != null &&
                            !sTimeTchs.Contains(act.ClsLesson.Teacher))
                        {
                            sTimeTchs.Add(act.ClsLesson.Teacher);
                        }
                    }
                }

                foreach (VcTime time in FutureRules.eachTime())
                {
                    if (NowSch.Matrix[time].LsnAct != null)
                    {
                        EnLsnAct act = NowSch.Matrix[time].LsnAct;
                        if (act.ClsLesson.Teacher != null &&
                            sTimeTchs.Contains(act.ClsLesson.Teacher))
                        {
                            FutureRules[time] = eRule.crisscross;  //此课程移到sTime后导致教师冲突
                        }
                        else
                        {
                            FutureRules[time] = ClsLsnRuleList[act.ClsLesson][sTime]; //移到sTime后的优势
                        }
                    }
                }
            }
            else
            {
                //所有Act移动到未排,则优势一定是eRule.common
                foreach (VcTime time in FutureRules.eachTime())
                {
                    FutureRules[time] = eRule.common;
                }
            }

            //四、获得sAct移动到所有位置的优势值
            DtMatrix <eRule> sActFutureRules = new DtMatrix <eRule>(DataRule.Solution);

            DtMatrix <eRule> TmpRules = ClsLsnRuleList[sAct.ClsLesson];

            foreach (VcTime time in TmpRules.eachTime())
            {
                sActFutureRules[time] = TmpRules[time];
            }

            //检测课程冲突
            if (sAct.ClsLesson.Teacher != null)
            {
                EnTeacher NowTch = sAct.ClsLesson.Teacher;
                DtMatrix <IList <EnLsnAct> > sTchLsns = this.GetTchMatrix(NowTch);
                foreach (VcTime time in sTchLsns.eachTime())
                {
                    if (sTchLsns[time] != null && sTchLsns[time].Count > 0)
                    {
                        foreach (EnLsnAct act in sTchLsns[time])
                        {
                            if (act != NowSch.Matrix[time].LsnAct && //当前课表的,会被移走
                                act.ClsLesson.Teacher == NowTch)
                            {
                                sActFutureRules[time] = eRule.crisscross;  //sAct移到time后将导致冲突
                                break;
                            }
                        }
                    }
                }
            }

            //五、比较当前优势和移动后的优势,获得交换的价值矩阵
            DtMatrix <eRule> Result = new DtMatrix <eRule>(DataRule.Solution);

            //NowRules、sActNowRule、FutureRules、sActFutureRules
            //所有位置当前优势\拖动源当前优势\所有位置在拖动源的优势\拖动源拖到所有位置的优势

            foreach (VcTime time in Result.eachTime())
            {
                if (NowSch.Matrix[time].LsnAct != null &&
                    NowSch.Matrix[time].LsnAct.ClsLesson == sAct.ClsLesson)
                {
                    Result[time] = eRule.crisscross; //同样的课移动没意义的
                    continue;
                }

                Result[time] = ComparerActChangeRule(NowRules[time], sActNowRule,
                                                     FutureRules[time], sActFutureRules[time]);
            }

            return(Result);
        }