DECLARE_EXPORT SetupMatrix::~SetupMatrix() { // Destroy the rules. // Note that the rule destructor updates the firstRule field. while (firstRule) delete firstRule; // Remove all references to this setup matrix from resources for (Resource::iterator m = Resource::begin(); m != Resource::end(); ++m) if (m->getSetupMatrix() == this) m->setSetupMatrix(NULL); }
DECLARE_EXPORT void SolverMRP::solve(void *v) { // Count how many clusters we have to plan int cl = HasLevel::getNumberOfClusters() + 1; // Categorize all demands in their cluster demands_per_cluster.resize(cl); for (Demand::iterator i = Demand::begin(); i != Demand::end(); ++i) demands_per_cluster[i->getCluster()].push_back(&*i); // Delete of operationplans of the affected clusters // This deletion is not multi-threaded... But on the other hand we need to // loop through the operations only once (rather than as many times as there // are clusters) if (getErasePreviousFirst()) { if (getLogLevel()>0) logger << "Deleting previous plan" << endl; for (Operation::iterator e=Operation::begin(); e!=Operation::end(); ++e) e->deleteOperationPlans(); } // Solve in parallel threads. // When not solving in silent and autocommit mode, we only use a single // solver thread. // Otherwise we use as many worker threads as processor cores. ThreadGroup threads; if (getLogLevel()>0 || !getAutocommit()) threads.setMaxParallel(1); // Register all clusters to be solved for (int j = 0; j < cl; ++j) threads.add( SolverMRPdata::runme, new SolverMRPdata(this, j, &(demands_per_cluster[j])) ); // Run the planning command threads and wait for them to exit threads.execute(); // @todo Check the resource setups that were broken - needs to be removed for (Resource::iterator gres = Resource::begin(); gres != Resource::end(); ++gres) if (gres->getSetupMatrix()) gres->updateSetups(); }