/// <summary> /// 通常のProcessは、delayを考慮するだけの、FIFO /// </summary> /// <param name="events"></param> /// <param name="work"></param> public virtual void AddAndAdjustExitTiming(JitStage.WorkEventQueue events, JitWork work) { if (work.Next?.Process != null) { events.Enqueue(work.ExitTime, EventTypes.Out, work); // 退場予約 } }
/// <summary> /// Execute in-commands /// </summary> /// <param name="work">target work</param> /// <param name="time">simulation time</param> public void ExecInCommands(JitWork work, DateTime time) { foreach (var ci in InCommands) { ci.Exec(work, time); } }
/// <summary> /// change exit schedule depends on priorities of each child processes /// 工程毎優先順に従って、OUTするスケジュールに変更する /// </summary> /// <param name="events"></param> /// <param name="work"></param> public override void AddAndAdjustExitTiming(JitStage.WorkEventQueue events, JitWork work) { if (work.Next?.Process != null) { var sortList = events.FindAll(work.Current.ToChangeProcess(this), EventTypes.Out).ToList(); var tarDT = work.ExitTime; if (sortList.Count > 0) { tarDT = MathUtil.Max(sortList.Min(a => a.Value.DT), work.ExitTime); // 退場時刻は、既存のものに合わせる events.Remove(sortList); } var nn = new LinkedListNode <JitStage.WorkEventQueue.Item>(new JitStage.WorkEventQueue.Item { DT = tarDT, Type = EventTypes.Out, Work = work, }); sortList.Add(nn); sortList.Sort(new QueueItemComparer { ProcPriorities = procPriority, // Larger number is priority }.Comparer); foreach (var node in sortList) { events.Enqueue(tarDT, EventTypes.Out, node.Value.Work); // 退場予約 並び替えて、再登録 } } }
/// <summary> /// check out-constraint /// </summary> /// <param name="time"></param> /// <returns>true=cannot in yet</returns> /// <remarks> /// stop follow constraint checks if return false this constraint /// ※どれかの制約にあたったら、以降の制約は実行しない。 /// </remarks> public bool CheckConstraints(JitWork work, DateTime time, out CoBase hitConstraint) { hitConstraint = null; foreach (var co in Constraints) { bool ret = co.Check(work, time); if (ret) { hitConstraint = co; return(true); } } return(false); }
public override void Exec(JitWork work, DateTime now) { if (work.Is(TargetWorkClass)) { int nextLinkNo = DbUtil.ToInt(work.ChildVriables.GetValueOrNull(NextLinkVarName.Value.ToString())?.Value, def: -1); if (nextLinkNo >= 0) { var tarProc = GetCheckTargetProcess(work)?.Process; var nexts = work.Current.SubsetCache.GetProcessLinkPathes(tarProc); var pathkey = nexts[nextLinkNo]; work.Next = work.FindStage().FindSubsetProcess(work.Current, pathkey, false); } } }
/// <summary> /// in-command execute /// </summary> /// <param name="work">target work</param> /// <param name="now">simulation time</param> public override void Exec(JitWork work, DateTime now) { var kanbans = from kanban in work.Kanbans where kanban.Is(TargetKanbanClass) where kanban.PullTo.Equals(work.Current) select kanban; foreach (var kanban in kanbans.ToArray()) { work.Kanbans.Remove(kanban); kanban.Work = null; work.FindStage().SendKanban(now + Delay, kanban); } }
/// <summary> /// check maximum cost constraint to let the work wait at previous process /// MAXコストの制約を調べる /// </summary> /// <param name="work"></param> /// <param name="now"></param> /// <returns>true=waiting</returns> public override bool Check(JitWork work, DateTime now) { var stage = work.FindStage(); var wirs = stage.GetWorksInReserve(work.Next, this); var costs = from w in wirs //tarloc let cost = w.ChildVriables.GetValueOrNull("Cost") where cost != null let varval = cost[ReferenceVarName] select Convert.ToDouble((varval?.Value as JitVariable)?.Value); double totalcost = costs.Sum(); return(totalcost >= Value); }
/// <summary> /// work LIFO logic such as a stack /// </summary> /// <param name="buf"></param> /// <returns></returns> public static JitWork LIFOSelector(IEnumerable <WorkEntery> buf) { var max = DateTime.MinValue; JitWork ret = null; foreach (var wt in buf) { if (wt.Enter > max) { max = wt.Enter; ret = wt.Work; } } return(ret); }
/// <summary> /// work FIFO exit logic /// </summary> /// <param name="buf"></param> /// <returns></returns> public static JitWork FIFOSelector(IEnumerable <WorkEntery> buf) { var min = DateTime.MaxValue; JitWork ret = null; foreach (var wt in buf) { if (wt.Enter < min) { min = wt.Enter; ret = wt.Work; } } return(ret); }
/// <summary> /// in-command execute /// </summary> /// <param name="work">target work</param> /// <param name="now">simulation time</param> public override void Exec(JitWork work, DateTime now) { var childworkNames = from cw in work.ChildWorks where cw.Value.Is(TargetWorkClass) select cw.Key; foreach (string childWorkName in childworkNames.ToArray()) { var childWork = work.ChildWorks[childWorkName]; childWork.Next = work.Current.FindSubsetProcess(DestProcessKey, true); //work.Current.Subset.FindChildProcess(DestProcessKey); childWork.Current = work.Current.ToEmptyProcess(); // 子Workであった事を Process = null とする。 work.ChildWorks.Remove(childWorkName); // Remove work from child works. 子ワークから外す work.FindStage().Events.Enqueue(now + Delay, EventTypes.Out, childWork); // Reserve destination of push move. 次工程にPUSH予約 } }
/// <summary> /// exit a work from this process /// </summary> /// <param name="work"></param> /// <param name="now"></param> public virtual void Exit(JitWork work) { var stage = work.FindStage(); stage.RemoveWorkFromSubsetProcess(work.Current, work); var currentcios = work.Current?.Process?.Cios; if (currentcios != null) { foreach (var cio in currentcios) { stage.RemoveWorkInReserve(work.Current, cio, work); // Remove work from JitStage._cioWorkCache } } }
/// <summary> /// confirm condition and pick work from PullFrom process /// </summary> /// <param name="parentWork">parent work that is requested to exit from PullFrom process 前工程から退出したい 「親」ワーク</param> /// <param name="now">simulation time</param> /// <returns>true=cannot move work / false=moved</returns> public override bool Check(JitWork parentWork, DateTime now) { if (parentWork.ChildWorks.ContainsKey(ChildWorkKey)) { return(false); // already moved. すでにワークが付いているので制約なし(完了) } var procPullFrom = parentWork.Next.FindSubsetProcess(PullFromProcessKey); if (procPullFrom.Process.ExitCollectedWork(parentWork.Current, now) is JitWork sideWork) // work at PullFrom process 横工程のワーク { parentWork.ChildWorks[ChildWorkKey] = sideWork; return(false); } return(true); }
/// <summary> /// Put a work into this process /// </summary> /// <param name="work"></param> public virtual void Enter(JitWork work, DateTime now) { var stage = work.FindStage(); stage.SaveWorkToSubsetProcess(work.Next, work, now); // Add work to JitStage._worksInProcess work.Previous = work.Current; work.Current = work.Next; var nextProcs = stage.GetProcessLinkPathes(work.Current); if (nextProcs != null && nextProcs.Count > 0) { work.Next = nextProcs[0].NextLocation; } else { work.Next = null; } work.EnterTime = now; CheckAndAttachKanban(work.Current, now); // かんばんが有れば、NextProcessをかんばんで更新する }
/// <summary> /// check span constraint /// </summary> /// <param name="work"></param> /// <param name="now"></param> /// <returns>true=waiting / false=Can Enter</returns> public override bool Check(JitWork work, DateTime now) { return((now - work.FindStage().GetLastInTime(work.Next, this)) < Span); }
/// <summary> /// set exit time /// </summary> /// <param name="work">target work</param> /// <param name="now">simulation time</param> public override void Exec(JitWork work, DateTime now) { work.ExitTime = work.EnterTime + Delay; }
/// <summary> /// owner process /// </summary> /// <param name="work"></param> /// <returns></returns> /// <remarks> /// Check(...)実行時に、work.NextProcessは nullにならない /// </remarks> protected override JitLocation GetCheckTargetProcess(JitWork work) { return(work.Next); }
/// <summary> /// Execute in-command /// </summary> /// <param name="work">target work</param> /// <param name="now">simulation time</param> public abstract void Exec(JitWork work, DateTime now);
/// <summary> /// check the target work can NOT enter to next process /// 制約中かどうかを調べる /// </summary> /// <param name="work"></param> /// <param name="now"></param> /// <returns>true=cannot enter to next process / false=can</returns> public abstract bool Check(JitWork work, DateTime now);