public WeightValue ALLOW_RUN_DOWN_TIME(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { FabAoEquipment eqp = target as FabAoEquipment; FabLot lot = entity as FabLot; var wf = WeightHelper.GetWeightFactor(eqp.Target.Preset, Constants.WF_ALLOW_RUN_DOWN_TIME); if (wf == null || wf.Factor == 0) { return(new WeightValue(0)); } decimal inflowHour = (decimal)wf.Criteria[0]; var idleTime = eqp.GetIdleRunTime(); decimal adjustHour = inflowHour - Convert.ToDecimal(idleTime.TotalHours); if (adjustHour < 0) { return(new WeightValue(0)); } var inflowQty = InFlowMaster.GetAllowRunDownWip(eqp, lot.CurrentProductID, lot.OrigProductVersion, lot.OwnerType, lot.CurrentStep as FabStep, adjustHour); float score = 0f; if (inflowQty > 0) { score = 1f; } string desc = string.Format("[inflow:{0}]", inflowQty); return(new WeightValue(score * factor.Factor, desc)); }
public WeightValue CU_DENSITY_3402(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } FabAoEquipment eqp = target as FabAoEquipment; FabLot lot = entity as FabLot; FabStep step = lot.CurrentFabStep; string targetStep = "3402"; int limitDensity = (int)factor.Criteria[0]; if (limitDensity == 0) { return(new WeightValue(0)); } float currDensity = eqp.AcidDensity == null ? 0 : eqp.AcidDensity.CurrentAcid; string desc = string.Format("[Density:{0}, Limit:{1}]", currDensity, limitDensity); float score = 0f; if (step.StepID == targetStep && currDensity < limitDensity) { score = 1f; } return(new WeightValue(score * factor.Factor, desc)); }
public SimEventHandle(ISimEntity sender, ISimEntity target, ISimEvent simEvent, UniqueDouble udt) { _sender = sender; _target = target; _simEvent = simEvent; _udt = udt; }
public ISimEventHandle Register(ISimEntity sender, ISimEntity target, ISimEvent simEvent, double t) { if (t < 0) { Console.WriteLine("Cannot register an event in the past!"); System.Diagnostics.StackTrace st = new StackTrace(true); Console.WriteLine(st.ToString()); Environment.Exit(-1); } SingletonLogger.Instance().DebugLog(typeof(Scheduler), "@ " + Scheduler.GetTime() + " Register src:" + sender + " dst:" + target + " ev:" + simEvent + " t:" + t); double deliveryTime = Scheduler.GetTime() + t; ISimEventHandle eventHandle = new SimEventHandle(sender, target, simEvent, new UniqueDouble(deliveryTime)); HashSet <ISimEventHandle> eventsFrom = Instance().GetEventsFrom(eventHandle.Sender); eventsFrom.Add(eventHandle); HashSet <ISimEventHandle> eventsTo = Instance().GetEventsTo(eventHandle.Target); eventsTo.Add(eventHandle); Instance()._ud2ehandle.Add(eventHandle.UDT, eventHandle); return(eventHandle); }
public void Entering(ISimEntity locale) { if (locale is IMatcher) { IMatcher m = (IMatcher)locale; m.recvOrderbookNotification(_ob, _evt); } }
public void Entering(ISimEntity locale) { if (locale is IOrderbookObserver) { IOrderbookObserver obs = (IOrderbookObserver)locale; obs.recvOrderbookNotification(_ob, _evt); } }
public WeightValue NEXT_STEP_RUN_PRIORITY(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } float criteria0 = WeightHelper.GetCriteria(factor, 0, 0.5f); FabAoEquipment eqp = target as FabAoEquipment; FabLot lot = entity as FabLot; FabStep nextStep = BopHelper.GetNextMandatoryStep(lot); float score = 0f; int workingCnt = 0; int adv = 0; if (nextStep != null && nextStep.IsMandatoryStep) { bool checkProductVersion = true; var workingEqps = nextStep.StdStep.GetWorkingEqpList(lot, checkProductVersion); //checkProductVersion = false if (workingEqps == null || workingEqps.Count == 0) { checkProductVersion = false; workingEqps = nextStep.StdStep.GetWorkingEqpList(lot, checkProductVersion); } workingCnt = workingEqps == null ? 0 : workingEqps.Count; if (workingCnt > 0) { score = checkProductVersion ? 1f : criteria0; } var hasDummy = workingEqps.Find(t => t.IsDummyWait) != null; if (hasDummy) { adv = 2; score *= adv; } } string nextStepID = nextStep != null ? nextStep.StepID : Constants.NULL_ID; string desc = string.Format("[Next:{0}, Working:{1}, Adv:{2}]", nextStepID, workingCnt, adv); return(new WeightValue(score * factor.Factor, desc)); }
private HashSet <ISimEventHandle> GetEventsTo(ISimEntity simEntity) { HashSet <ISimEventHandle> hSet; if (_to2set.Contains(simEntity)) { hSet = (HashSet <ISimEventHandle>)_to2set[simEntity]; } else { hSet = new HashSet <ISimEventHandle>(); _to2set.Add(simEntity, hSet); } return(hSet); }
public WeightValue OWNER_TYPE_PRIORITY(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } FabLot lot = entity as FabLot; float score = 0f; string desc = string.Empty; string ownerType = lot.OwnerType; if (factor.Criteria != null && factor.Criteria.Length > 0) { string[] types = (string[])factor.Criteria; if (types.Length > 0) { if (ownerType == types[0]) { score = 1f; } } if (types.Length > 1) { if (ownerType == types[1]) { score = 0.5f; } } if (types.Length > 2) { if (ownerType == types[2]) { score = 0f; } } } return(new WeightValue(score * factor.Factor, desc)); }
public abstract void Recv(ISimEntity src, ISimEvent simEvent);
public void Entering(ISimEntity locale) { }
protected ISimEventHandle Send(ISimEntity dst, ISimEvent simEvent, double t) { return(Scheduler.Instance().Register(this, dst, simEvent, t)); }
// receive a signal from the Simulation (via the Population) public override void Recv(ISimEntity src, ISimEvent simEvent) { if (Orderbook == null) { return; } if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "recv ISimEvent " + simEvent + " @ " + Scheduler.GetTime()); } // events received from the DES if (simEvent is ActionPrompt) { if (DecideToAct()) { if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "acts @ " + Scheduler.GetTime() + " I have " + _orders.Count + " orders open"); } EvaluateAllOpenOrders(); if (DecideToMakeOrder()) { if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + "makes order @ " + Scheduler.GetTime()); } if (!Orderbook.isNonDegenerate()) { SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " witnesses Orderbook blowup @ " + Scheduler.GetTime() + "\n" + Orderbook.ToStringLong()); } IOrder newOrder = null; if (DecideToSubmitBid()) { if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submits bid @ " + Scheduler.GetTime()); } // bid double price = GetBidPrice(); int volume = GetBidVolume(); if (volume > 0) { newOrder = Orderbook.addBid(price, volume, this); } else { if (LoggerDiags.Enabled) { SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " attempts unsuccessful zero sized bid @ " + Scheduler.GetTime()); } } } else { if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submits ask @ " + Scheduler.GetTime()); } // ask double price = GetAskPrice(); int volume = GetAskVolume(); if (volume > 0) { newOrder = Orderbook.addAsk(price, volume, this); } else { if (LoggerDiags.Enabled) { SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " attempts unsuccessful zero sized ask @ " + Scheduler.GetTime()); } } } if (newOrder != null) { // may be null if dual volume is 0 preventing creation of new orders AddToOpenOrderList(newOrder); if (LoggerDiags.Enabled) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " submitted " + newOrder + " @ " + Scheduler.GetTime()); } } else { throw new Exception("We got a problem"); } } } double timeToNextPrompt = GetTimeToNextActionPrompt(); if (timeToNextPrompt < 0.0) { // agent checks out of ecosystem by indicating a negative time if (LoggerDiags.Enabled) { SingletonLogger.Instance().WarningLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " leaves simulation by indicating negative prompt time @ " + Scheduler.GetTime()); } } else { this.Send(this, simEvent, timeToNextPrompt); } } }
public override void Recv(ISimEntity src, ISimEvent simEvent) { // no op // throw new Exception("Unexpected call to Simulation.Recv"); }
public WeightValue SMALL_LOT(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } FabAoEquipment eqp = target as FabAoEquipment; FabLot lot = entity as FabLot; int smallSize = (int)factor.Criteria[0]; if (smallSize == 0) { return(new WeightValue(0)); } int stepCount = (int)factor.Criteria[1]; if (stepCount == 0) { return(new WeightValue(0)); } var job = InFlowMaster.GetJobState(lot); if (job == null) { return(new WeightValue(0)); } int currentUnitQty = lot.UnitQty; string shopID = lot.CurrentShopID; string productID = lot.CurrentProductID; string productVer = lot.CurrentProductVersion; bool isLastPlan = ResHelper.IsLastPlan(eqp, lot); float score = 0f; if (isLastPlan) { score = 1f; } FabStep step = lot.CurrentFabStep; string stepType = step.StepType; int cnt = 0; int runQty = 0; int waitQty = 0; int total = 0; while (cnt < stepCount) { List <FabStep> preSteps = step.GetPrevSteps(productID); List <FabLot> runWips = job.GetPrevStepWipList(step, WipType.Run, productVer); List <FabLot> waitWips = job.GetPrevStepWipList(step, WipType.Wait, productVer); if (runWips.Count <= 0 && waitWips.Count <= 0) { cnt++; continue; } int prevRunQty = runWips.Sum(x => x.UnitQty); int preWaitQty = waitWips.Sum(x => x.UnitQty); runQty += prevRunQty; waitQty += preWaitQty; total += runQty + waitQty; foreach (FabStep prevStep in preSteps) { if (prevStep.StepType == "MAIN") { step = prevStep; } if (step == null) { continue; } } cnt++; } int compareQty = currentUnitQty + total; string desc = string.Format("[SmallSize:{0}, CompareQty:{1}, IsLast:{2}]", smallSize, compareQty, isLastPlan); if (compareQty > smallSize) { score = 1f; } return(new WeightValue(score * factor.Factor, desc)); }
public void Entering(ISimEntity locale) { Scheduler.Instance().Stop(); }
public override void Recv(ISimEntity src, ISimEvent simEvent) { // no op }