void SolverMRP::SolverMRPdata::solveSafetyStock(SolverMRP* solver) { OperatorDelete cleanup("sweeper", this); safety_stock_planning = true; if (getLogLevel()>0) logger << "Start safety stock replenishment pass " << solver->getConstraints() << endl; vector< list<Buffer*> > bufs(HasLevel::getNumberOfLevels() + 1); for (Buffer::iterator buf = Buffer::begin(); buf != Buffer::end(); ++buf) if (buf->getCluster() == cluster && ( buf->getMinimum() || buf->getMinimumCalendar() || buf->getType() == *BufferProcure::metadata ) ) bufs[(buf->getLevel()>=0) ? buf->getLevel() : 0].push_back(&*buf); for (vector< list<Buffer*> >::iterator b_list = bufs.begin(); b_list != bufs.end(); ++b_list) for (list<Buffer*>::iterator b = b_list->begin(); b != b_list->end(); ++b) { state->curBuffer = NULL; // A quantity of -1 is a flag for the buffer solver to solve safety stock. state->q_qty = -1.0; state->q_date = Date::infinitePast; state->a_cost = 0.0; state->a_penalty = 0.0; planningDemand = NULL; state->curDemand = NULL; state->motive = *b; state->curOwnerOpplan = NULL; // Call the buffer solver (*b)->solve(*solver, this); // Check for excess if ((*b)->getType() != *BufferProcure::metadata) (*b)->solve(cleanup, this); CommandManager::commit(); } if (getLogLevel()>0) logger << "Finished safety stock replenishment pass" << endl; safety_stock_planning = false; }
DECLARE_EXPORT Calendar::~Calendar() { // De-allocate all the dynamic memory used for the bucket objects while (firstBucket) { CalendarBucket* tmp = firstBucket; firstBucket = firstBucket->nextBucket; delete tmp; } // Remove all references from locations for (Location::iterator l = Location::begin(); l != Location::end(); ++l) { if (l->getAvailable() == this) l->setAvailable(NULL); } // Remove reference from buffers for (Buffer::iterator b = Buffer::begin(); b != Buffer::end(); ++b) { if (b->getMaximumCalendar() == this) b->setMaximumCalendar(NULL); if (b->getMinimumCalendar() == this) b->setMinimumCalendar(NULL); } // Remove references from resources for (Resource::iterator r = Resource::begin(); r != Resource::end(); ++r) { if (r->getMaximumCalendar() == this) r->setMaximumCalendar(NULL); } }