Today I added the Bag component (number 36 in the frame above), which you can think of as a parking lot. It works largely the same way as a ProcessComponent but it doesn’t store its entities in a FIFO queue internally. Rather, it defines a list of entities with one space for each possible entity up to the defined maxCapacity
of the component. An entity enters the component, gets assigned to the lowest empty index in the list, and begins working off its defined process time. When the process time ends the entity is moved over to an exit queue, which is another list of entities within the Bag component. The exit queue shows which entities are waiting to leave the Bag component, which is only relevant if the next downstream component is an exclusive one that is not currently open. I added a downstream Process component to the model in order to visually demonstrate this behavior.
The procedure for drawing the entities in the linked displayElement
is a bit different than for the queue or process components. The designer should specify more entityLocs
spaces than the capacity of the component. The first maxCapacity
spaces are used to display the entities while they are “parked”. Any additional spaces are used to display the entities waiting in the exit queue. The Bag component in today’s version of the example model has a capacity of twelve and an additional five spaces reserved to show the exit queue. If there are more entities in the internal exit queue than there are spaces left to display them then the extras do not get displayed. One trick to make this more visually interesting, if it’s appropriate to the real process being modeled, is to assign the entity locations up to the Bag’s capacity in a semi-random order. That way the entities look like they’re parking in a more naturalistic manner rather than obediently filling spaces in regimented order. The border modeling programs I worked with at Regal Decision Systems (BorderWizard, CanSim, and SimFronteras) all allowed for this, and the effect was particularly striking in situations where there were large numbers of vehicles in a parking area. The commercial parking area at Ambassador Bridge in Detroit used to fill up in a big way when many trucks needed to park so the drivers could attend to customs paperwork. (That process has since been largely obviated by automating the paperwork so it’s completed offsite before the vehicle makes the crossing.)
Having a Bag component feed directly into another component that’s exclusive should probably be rare, but the full behavior is included. I’m thinking of my time analyzing and collecting data at dozens of border crossings where vehicles and pedestrians were almost always able to leave a Process or Bag (parking lot, literally) and go someplace else. There was effectively a non-exclusive queue in front of most processes and parking lots. That said, one can easily imagine a tightly coupled manufacturing process when internal queues have been squeezed out by design or after rearrangement following a Lean analysis.
Here’s the code for the entire Bag component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
function BagComponent(processTime, processTimeSwitch, maxCapacity, routingTable) { if (typeof maxCapacity === "undefined") {maxCapacity = 1;} if (typeof routingTable === "undefined") {routingTable = [1.0];} //generally exclusive, should always be fed by a queue or at least "protected" by a status-based diversion component setOfComponents.push(this); this.componentID = getNewComponentID(); this.componentType = "Bag"; this.componentName = "Bag"; this.componentGroup = "Bag"; this.exclusive = true; this.routingMethod = 1; //1: one connection, 2: distribution, 3 routing this.previousComponentList = []; this.previousComponentCount = 0; this.nextComponentList = []; this.nextComponentCount = 0; this.nextComponentIDList = []; this.processTime = processTime; this.processTimeSwitch = processTimeSwitch; this.maxCapacity = maxCapacity; this.savedDestination = -1; this.previousComponentIndex = 0; this.nextComponentIndex = 0; this.entityQueue = []; for (var i=0; i<maxCapacity; i++) { this.entityQueue[i] = null; } this.exitQueue = []; this.routingTable = routingTable; this.openStatus = true; this.entryTime = ""; this.entryEntityID = ""; this.exitTime = ""; this.exitEntityID = ""; this.exitResidenceTime = ""; this.countInBag = 0; this.countInProcess = 0; this.activity = ""; this.endEntryDisplayTime = 0; this.endExitDisplayTime = 0; this.endAllDisplayTime = 0; this.displayDelay = 0; this.graphic = null; this.reset = function() { this.previousComponentIndex = this.previousComponentCount - 1; this.nextComponentIndex = this.nextComponentCount - 1; this.entityQueue = []; for (var i=0; i<maxCapacity; i++) { this.entityQueue[i] = null; } this.exitQueue = []; this.openStatus = true; this.savedDestination = -1; this.entryTime = ""; this.entryEntityID = ""; this.exitTime = ""; this.exitEntityID = ""; this.exitResidenceTime = ""; this.countInBag = 0; this.countInProcess = 0; this.activity = ""; this.endEntryDisplayTime = 0; this.endExitDisplayTime = 0; this.endAllDisplayTime = 0; }; this.assignPreviousComponent = function(prev) { //TODO-: implement code that makes this actually work this.previousComponentList.push(prev); this.previousComponentCount++; this.previousComponentIndex = this.previousComponentCount - 1; //TODO-: assign this automatically when upstream link and exclusive paths are required? }; this.assignNextComponent = function(next) { //BagComponent this.nextComponentList.push(next); this.nextComponentCount++; this.nextComponentIndex = this.nextComponentCount - 1; next.assignPreviousComponent(this); //TODO-: automatically assign upstream link if downstream component is exclusive? }; this.verifyLinks = function() { var i; var error = ""; if (this.nextComponentCount > 0) { for (i = 0; i < this.nextComponentCount; i++) { //> if (this.nextComponentList[i]) { //link exists if (typeof this.nextComponentList[i] === "object") { //link points to an object if ("componentType" in this.nextComponentList[i]) { //object contains member componentType if ((this.nextComponentList[i].componentType == "Arrivals") || (this.nextComponentList[i].componentType == "Entry")) { error += this.componentType + " comp. " + this.componentID + " next comp. list element " + i + " is not an allowed comp.\n"; } } else { //linked object does not contain member componentType error += this.componentType + " comp. " + this.componentID + " next comp. list item " + i + " does not have componentType\n"; } } else { //link points to something that is not an object error += this.componentType + " comp. " + this.componentID + " next comp. list item " + i + " is not an object\n"; } } else { //link that should exist does not error += this.componentType + " comp. " + this.componentID + " next comp. list item " + i + " does not exist\n"; } } } else { error += this.componentType + " comp. " + this.componentID + " has index of zero next components\n"; } if (this.previousComponentCount > 0) { for (i = 0; i < this.previousComponentCount; i++) { //> if (this.previousComponentList[i]) { //link exists if (typeof this.previousComponentList[i] === "object") { //link points to an object if ("componentType" in this.previousComponentList[i]) { //object contains member componentType if ((this.previousComponentList[i].componentType == "Arrivals") || (this.previousComponentList[i].componentType == "Exit")) { error += this.componentType + " comp. " + this.componentID + " previous comp. list element " + i + " is not an allowed comp.\n"; } } else { //linked object does not contain member componentType error += this.componentType + " comp. " + this.componentID + " previous comp. list item " + i + " does not have componentType\n"; } } else { //link points to something that is not an object error += this.componentType + " comp. " + this.componentID + " previous comp. list item " + i + " is not an object\n"; } } else { //link that should exist does not error += this.componentType + " comp. " + this.componentID + " previous comp. list item " + i + " does not exist\n"; } } } else { error += this.componentType + " comp. " + this.componentID + " has index of zero previous components\n"; } return error; }; this.getNextComponentIDs = function() { for (var i = 0; i < this.nextComponentCount; i++) { if (this.nextComponentList[i].getComponentType() != "Path") { this.nextComponentIDList[i] = this.nextComponentList[i].getComponentID(); } else { this.nextComponentIDList[i] = this.nextComponentList[i].passComponentID(); } } }; this.getComponentID = function() { return this.componentID; }; this.getComponentType = function() { //BagComponent return this.componentType; }; this.getComponentName = function() { return this.componentName; }; this.setComponentName = function(componentName) { this.componentName = componentName; }; this.getComponentGroup = function() { return this.componentGroup; }; this.setComponentGroup = function(componentGroup) { this.componentGroup = componentGroup; addToGroupStatsNameListWrapper(componentGroup); }; this.getExclusive = function() { return this.exclusive; }; this.setExclusive = function(exclusive) { this.exclusive = exclusive; }; this.getProcessTime = function() { return this.processTime; }; this.getProcessTimeSwitch = function() { return this.processTimeSwitch; }; this.setProcessTimeSwitch = function(processTimeSwitch) { this.processTimeSwitch = processTimeSwitch; }; this.getMaxCapacity = function() { return this.maxCapacity; }; this.setMaxCapacity = function(maxCapacity) { this.maxCapacity = maxCapacity; }; this.getOpenStatus = function() { return this.openStatus; }; this.setOpenStatus = function(openStatus) { this.openStatus = openStatus; }; this.getForwardAttemptTime = function() { if (this.exitQueue.length > 0) { return this.exitQueue[this.exitQueue.length - 1].getForwardAttemptTime(); } else { return Infinity; } }; this.getRoutingMethod = function() { return this.routingMethod; }; this.setRoutingMethod = function(routingMethod) { this.routingMethod = routingMethod; }; this.getEntryTime = function() { return this.entryTime; }; this.getEntryEntityID = function() { return this.entryEntityID; }; this.getExitTime = function() { return this.exitTime; }; this.getExitEntityID = function() { return this.exitEntityID; }; this.getExitResidenceTime = function() { return this.exitResidenceTime; }; this.getCountInBag = function() { return this.countInBag; }; this.getCountInProcess = function() { return this.countInProcess; }; this.getActivity = function() { return this.activity; }; this.getEndEntryDisplayTime = function() { return this.endEntryDisplayTime; }; this.getEndExitDisplayTime = function() { return this.endExitDisplayTime; }; this.getEndAllDisplayTime = function() { return this.endAllDisplayTime; }; this.dataGroup = new DisplayGroup1(); this.defineDataGroup = function(displayDelay, x, y, vw, bc, vc, lc) { this.displayDelay = displayDelay; this.dataGroup.define(this.componentID, this.componentType, x, y, vw, bc, vc, lc); }; this.dataGroup.addValue(this.entryEntityID, "Entry ID", "integer"); this.dataGroup.addValue(this.countInBag, "# In Bag", "numdec", "integer"); this.dataGroup.addValue(this.exitEntityID, "Exit ID", "integer"); this.dataGroup.addValue(this.exitResidenceTime, "Resdnce Tm", "numdec", 5); this.dataGroup.addValue(this.activity, "Activity", "text"); this.assignDisplayValues = function() { this.dataGroup.valueList[0].value = this.entryEntityID; this.dataGroup.valueList[1].value = this.countInBag; this.dataGroup.valueList[2].value = this.exitEntityID; this.dataGroup.valueList[3].value = this.exitResidenceTime; this.dataGroup.valueList[4].value = this.activity; if (this.exclusive) { if (this.openStatus) { this.dataGroup.setBorderColor("#00FF00"); } else { this.dataGroup.setBorderColor("#FF0000"); } } }; this.drawData = function() { //BagComponent this.assignDisplayValues(); this.dataGroup.drawBasic(); }; this.defineGraphic = function(graphic) { this.graphic = graphic; }; this.updateGraphic = function() { this.graphic.setTraverseValue(this.countInProcess); this.graphic.setCountValue(this.countInBag); //if (this.exclusive) { // if (this.openStatus) { // this.graphic.setBorderColor("#00FF00"); // } else { // this.graphic.setBorderColor("#FF0000"); // } //} }; this.isOpen = function() { //BagComponent if (this.exclusive) { if (this.currentCount() < this.maxCapacity) { this.openStatus = true; } else { this.openStatus = false; } for (var i = 0; i < this.previousComponentCount; i++) { if (this.previousComponentList[i].getComponentType() == "Path") { this.previousComponentList[i].setPreviousStatus(this.openStatus); //this may only be needed to determine open/closed status for display, count <=> capacity used when something is trying to enter } } } return this.openStatus; //if not exclusive should be set to true by default }; this.clearEntryDisplay = function() { //only clear display if a new one hasn't started a new timer if (globalSimClock >= this.endEntryDisplayTime) { this.entryTime = ""; this.entryEntityID = ""; } if (globalSimClock >= this.endAllDisplayTime) { this.activity = ""; } //displayProgressText("Bag entry "+this.componentID+" clears at time "+globalSimClock.toFixed(6)); }; this.clearExitDisplay = function() { //only clear display if a new one hasn't started a new timer if (globalSimClock >= this.endExitDisplayTime) { this.exitTime = ""; this.exitEntityID = ""; this.exitResidenceTime = ""; } if (globalSimClock >= this.endAllDisplayTime) { this.activity = ""; } //displayProgressText("Bag exit "+this.componentID+" clears at time "+globalSimClock.toFixed(6)); }; this.currentCount = function() { var count = 0; if (this.exclusive) { //start with entities already in component count = this.countInBag; //add entities in feeding paths for (var i = 0; i < this.previousComponentCount; i++) { if (this.previousComponentList[i].componentType == "Path") { //TODO- consider adding test for whether path is boundary component for associated exclusive group of components //do this using no-time/no-space control component to define boundary count += this.previousComponentList[i].currentCount(); } } } return count; }; this.pullFromPrevious = function() { //BagComponent var oldest = this.previousComponentList[0].getForwardAttemptTime(); var oldestIndex = 0; for (var i = 1; i < this.previousComponentCount; i++) { var age = this.previousComponentList[i].getForwardAttemptTime(); if (age < oldest) { oldestIndex = i; } } if (this.previousComponentList[oldestIndex].getComponentType() != "Path") { if (this.previousComponentList[oldestIndex].getComponentType() != "Entry") { //TODO: this should call forward entity in a way that ensures that previous component only sends entity to where it is requested and if one is available and if this is a legitimate destination this.previousComponentList[oldestIndex].forwardEntity(this.componentID); } } else { displayProgressText("Bag comp. " + this.componentID + " pulls from previous (" + oldestIndex + ") at time " + globalSimClock.toFixed(6)); this.previousComponentList[oldestIndex].pullFromPrevious(this.componentID); } }; this.nextOpen = function() { var startIndex = this.nextComponentIndex; var tempIndex = startIndex; do { tempIndex++; if (tempIndex >= this.nextComponentCount) { tempIndex = 0; } if (this.nextComponentList[tempIndex].isOpen()) { //open link found, update and return nextComponentIndex return tempIndex; } } while (tempIndex != startIndex); return -1; //no open links found, leave nextComponentIndex unchanged }; this.processComplete = function(entity) { //BagComponent this.countInProcess--; //TODO: ensure handled properly if process time is zero //prob. not applicable //figure out which entity just finished processing var tempID = entity.entityID; this.exitQueue.unshift(entity); this.entityQueue[entity.getLocalIndex()] = null; entity.setForwardAttemptTime(globalSimClock); displayProgressText("Bag comp. " + this.componentID + " entity: " + tempID + " processed at " + globalSimClock.toFixed(6)); this.forwardEntity(); //try to forward it }; //##default parameters## //this.forwardEntity = function(destIndex = -1) { //BagComponent //this.forwardEntity = function() { //BagComponent ///var routingTable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; this.forwardEntity = function(destIndex) { //BagComponent if (typeof destIndex === "undefined") {destIndex = -1;} var dest = -1; if (destIndex >= 0) { //pull request from a specific downstream component, must send entity there if (this.routingMethod == 1) { //single connection, nothing to do dest = 0; } else if (this.routingMethod == 2) { //distribution, send to any request dest = 0; while ((this.nextComponentIDList[dest] != destIndex) && (dest < this.nextComponentCount)) { //second test should not be needed, loop can't fail to return valid result dest++; } } else if (this.routingMethod == 3) { //model routing logic, TODO: don't forward if not desired destination dest = 0; while ((this.nextComponentIDList[dest] != destIndex) && (dest < this.nextComponentCount)) { //second test should not be needed, loop can't fail to return valid result dest++; } } dummy2 = 0; } else { if (this.routingMethod == 1) { //single connection if (this.nextComponentList[0].isOpen()) { dest = 0; } } else if (this.routingMethod == 2) { //distribution var nextIndex = this.nextOpen(); if (nextIndex >= 0) { dest = nextIndex; //this.nextComponentIndex = dest; } } else if (this.routingMethod == 3) { //model routing logic if (this.savedDestination >= 0) { dest = this.savedDestination; } else { dest = 0; var test = Math.random(); //need access to entity type but can't pop it off queue here var index = this.countInQueue - 1; if (index >= 0) { index = entityDiversionPercentIndex(this.entityQueue[index]); //get head item in queue and find out what type it is } else { index = 0; //nothing in queue, following code will work but nothing will be popped and processed below } while (test > this.routingTable[index][dest]) { dest++; } if (dest <= this.nextComponentCount) { if (!this.nextComponentList[dest].isOpen()) { dest = -1; } } else { alert("Bag comp. tried to assign destination with too high of an index") } if (dest >= 0) { this.savedDestination = dest; //ensure that once destination is determined for this entity that we don't keep changing it } } } else { //0 uninitialized or anything else alert("comp. " + this.componentID + " incorrect routing method: " + this.routingMethod); } } if (dest >= 0) { if (this.countInBag > this.countInProcess) { var entity = this.exitQueue.pop(); //TODO-: are we testing to ensure the next entity is really available if (entity) { //TODO-: since we've tested above this should not be necessary //calculate how long item was in process this.exitResidenceTime = globalSimClock - entity.getLocalEntryTime(); this.exitTime = globalSimClock; this.exitEntityID = entity.entityID; this.activity = "forward entity"; this.endExitDisplayTime = globalSimClock + this.displayDelay; this.endAllDisplayTime = this.endExitDisplayTime; advance(this.displayDelay, this, "clearExitDisplay"); displayProgressText("Bag comp. " + this.componentID + " forwards entity: " + this.exitEntityID + " at time " + globalSimClock.toFixed(6)); this.countInBag--; //should be open now if (this.exclusive) { displayProgressText("Bag comp. " + this.componentID + " calls pull from previous at time " + globalSimClock.toFixed(6)); if (!this.openStatus) { this.pullFromPrevious(); //TODO: call this with a modest (~1 sec) delay to account for reaction time? //may or may not successfully get an entity but should always be called } } this.isOpen(); //if (this.exclusive) { // for (var i=0; i<this.previousComponentCount; i++) { // if (this.previousComponentList[i].getComponentType() == "Path") { // this.previousComponentList[i].setPreviousStatus(this.openStatus); //this may only be needed to determine open/closed status for display, count <=> capacity used when something is trying to enter // } // } //} //this.nextComponentList[this.nextComponentIndex].receiveEntity(entity); this.nextComponentIndex = dest; this.savedDestination = -1; //clear old choice when entity successfully forwarded this.nextComponentList[dest].receiveEntity(entity); //record stats //TODO: test to ensure not going to another component in the same componentGroup //TODO: do the same thing for the ProcessComponent recordGroupStatsWrapper(this.componentGroup, entity.getComponentGroupEntryTime(), entity); } } } }; this.receiveEntity = function(entity) { //BagComponent //receive the entity entity.setLocalEntryTime(); //record time entity entered bag if (entity.getComponentGroup() != this.componentGroup) { entity.setComponentGroup(this.componentGroup); entity.setComponentGroupEntryTime(globalSimClock); recordGroupStatsSystemEntryWrapper(this.componentGroup,entity); } //figure out which parking space to use var i = 0; while (this.entityQueue[i] != null) { i++; } if (i < this.maxCapacity) { this.entityQueue[i] = entity; entity.setLocalIndex(i); } else { //this shouldn't happen alert("Bag comp. "+this.componentID+" over capacity at time "+this.globalSimClock.toFixed(6)); } entity.setForwardAttemptTime(Infinity); //TODO: figure out how to handle this entity.setPermission(false); //entity has reached end of related components group, permission no longer matters this.countInProcess++; this.countInBag++; //TODO: handle if process time is zero? this.isOpen(); //display what was done this.entryTime = globalSimClock; this.entryEntityID = entity.entityID; this.activity = "receive entity"; //set timer to clear the display after a bit this.endEntryDisplayTime = globalSimClock + this.displayDelay; this.endAllDisplayTime = this.endEntryDisplayTime; advance(this.displayDelay, this, "clearEntryDisplay"); //set timer for the process duration var pTime = this.processTime[entityProcessTimeIndex(entity,this.processTimeSwitch)]; advance(pTime, this, "processComplete",entity); displayProgressText("Bag comp. " + this.componentID + " receives entity: " + this.entryEntityID + " at time " + globalSimClock.toFixed(6)); }; this.activate = function(nextState, entity2) { if (nextState == "clearEntryDisplay") { this.clearEntryDisplay(); } else if (nextState == "clearExitDisplay") { this.clearExitDisplay(); } else if (nextState == "processComplete") { this.processComplete(entity2); } else { errorUndefinedAdvanceState(this.entityID, this.nextState); } }; //this.activate } //BagComponent |
I had to add the parameter processTimeSwitch
to allow different type indices to be used for determining the process time for each entity type. The process times are provided to the component as an array of values meant to apply to different types using the function entityProcessTimeIndex(entity,this.processTimeSwitch)
. In the primary Process components I wanted the types to be based on a combination of the entity’s residency and process speed. In the secondary group I specified the same time for all types so it didn’t matter what indices were used. I noticed the problem when I was looking at the report output for the “Parking Lot” group when there was no Process component in place after the Bag component. I had defined process times of 30, 50, and 80 units envisioning that they would apply to citizens, LPRs, and visitors, respectively, but the process times reported for those types varied in ways I didn’t expect. Then I remembered how the entityProcessTimeIndex
function worked and added a switch to it to allow different indices to be generated based on an entity’s properties. That index had to be added to the component definition for both the Bag and Process components.
Since JavaScript is so modular it should be possible to supply a custom function to the processTime
parameter that embodies any combination of indices and process time values. I’ll experiment with that tomorrow.
Here’s the updated code for drawing the display element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
this.drawEntities = function() { var i; var drawCount; var drawColor; //if (this.parent.getComponentType() == "Path") { if (this.isPath) { drawCount = this.parent.entityQueue.length; for (i=0; i<drawCount; i++) { var location = this.parent.entityQueue[i].getLocation(); drawNode(location.x,location.y,5,this.readyColor); drawNode(location.x,location.y,3,this.parent.entityQueue[i].getEntityColor()) } } else if (this.parent.getComponentType() == "Bag") { //new section drawCount = this.parent.maxCapacity; //should be < this.entityLocs.length drawColor = this.waitingColor; for (i=0; i<drawCount; i++) { if (this.parent.entityQueue[i] != null) { var xx = this.entityLocs[i].x; var yy = this.entityLocs[i].y; drawNode(this.x1+xx,this.y1+yy,5,drawColor); drawNode(this.x1+xx,this.y1+yy,3,this.parent.entityQueue[i].getEntityColor()); } } drawCount = this.entityLocs.length - this.parent.maxCapacity; if (this.parent.exitQueue.length < drawCount) { drawCount = this.parent.exitQueue.length; } drawColor = this.readyColor; for (i=0; i<drawCount; i++) { //locs for exit queue in order from maxCapacity var xx = this.entityLocs[this.parent.maxCapacity + i].x; var yy = this.entityLocs[this.parent.maxCapacity + i].y; drawNode(this.x1+xx,this.y1+yy,5,drawColor); //exit queue items in reverse order drawNode(this.x1+xx,this.y1+yy,3,this.parent.exitQueue[this.parent.exitQueue.length-1-i].getEntityColor()); } } else if (this.parent.getComponentType() != "Arrivals") { var qCount = this.countValue - this.traverseValue; if (this.countValue > this.locsCount) { drawCount = this.locsCount; } else { drawCount = this.countValue; } for (i=0; i<drawCount; i++) { if (i < qCount) { drawColor = this.readyColor; } else { drawColor = this.waitingColor; } var xx = this.entityLocs[i].x; var yy = this.entityLocs[i].y; drawNode(this.x1+xx,this.y1+yy,5,drawColor); drawNode(this.x1+xx,this.y1+yy,3,this.parent.entityQueue[i].getEntityColor()); } } }; |
I tested the Bag component with and without the subsequent Process component and everything worked as it should procedurally. I also assigned the Bag and Process components to a componentGroup
called “Parking Lot” and the reporting mechanism picked up the new group and reported it like a champ. However, I noticed that there were negative entity counts during some time intervals in the “Parking Lot” section of the report for each entity type. I traced this down to the erroneous assumption that exiting a Process or Bag component should always trigger recording an exit from a component group. This worked fine when the groups start with a Queue component and end with a Process component, but not so well when a group contained multiple Process and Bag components in series. I therefore have to add a test to see whether an entity is truly exiting a component group before triggering the exit reporting mechanism. That will be another part of tomorrow’s work.
Last but not least I’ll update the framework so it can be allowed to run until all entities have cleared the system, after a specified minimum running time. This is not always the desired behavior for analysis or reporting, so a switch setting will have to be included as well.