The OptBase class stores variables and helper functions for global searches. More...
#include <globalsearch/optbase.h>
Public Types | |
| enum | FailActions { FA_DoNothing = 0, FA_KillIt, FA_Randomize, FA_NewOffspring } |
Public Slots | |
| virtual void | reset () |
| virtual void | startSearch ()=0 |
| virtual void | generateNewStructure () |
| virtual void | preoptimizeStructure (Structure *s) |
| void | debug (const QString &s) |
| void | warning (const QString &s) |
| void | error (const QString &s) |
| void | emitSessionStarted () |
| void | emitReadOnlySessionStarted () |
| void | emitStartingSession () |
| void | setIsStartingTrue () |
| void | setIsStartingFalse () |
| void | setReadOnlyTrue () |
| void | setReadOnlyFalse () |
| void | printBackTrace () |
| void | setQueueInterface (QueueInterface *q) |
| void | setOptimizer (Optimizer *o) |
| void | promptForBoolean (const QString &message, bool *ok=0) |
| void | promptForPassword (const QString &message, QString *newPassword, bool *ok=0) |
| void | setClipboard (const QString &text) const |
Signals | |
| void | startingSession () |
| void | sessionStarted () |
| void | readOnlySessionStarted () |
| void | queueInterfaceChanged (QueueInterface *) |
| void | optimizerChanged (Optimizer *) |
| void | debugStatement (const QString &s) |
| void | warningStatement (const QString &s) |
| void | errorStatement (const QString &s) |
| void | needBoolean (const QString &message, bool *ok) |
| void | needPassword (const QString &message, QString *newPassword, bool *ok) |
| void | refreshAllStructureInfo () |
Public Member Functions | |
| OptBase (AbstractDialog *parent) | |
| virtual | ~OptBase () |
| QString | getIDString () |
| virtual Structure * | replaceWithRandom (Structure *s, const QString &reason="") |
| virtual Structure * | replaceWithOffspring (Structure *s, const QString &reason="") |
| virtual bool | checkLimits ()=0 |
| virtual bool | checkStepOptimizedStructure (Structure *s, QString *err=NULL) |
| virtual bool | save (const QString &filename="", bool notify=false) |
| virtual bool | postSave (const QString &filename) |
| virtual bool | load (const QString &filename, const bool forceReadOnly=false) |
| virtual QString | interpretTemplate (const QString &templateString, Structure *structure) |
| virtual QString | getTemplateKeywordHelp () |
| AbstractDialog * | dialog () |
| Tracker * | tracker () |
| QueueManager * | queue () |
| QueueInterface * | queueInterface () |
| Optimizer * | optimizer () |
| SSHManager * | ssh () |
Static Public Member Functions | |
| static QList< double > | getProbabilityList (const QList< Structure * > &structures) |
Public Attributes | |
| bool | limitRunningJobs |
| Whether to impose the running job limit. | |
| uint | runningJobLimit |
| Number of concurrent jobs allowed. | |
| uint | contStructs |
| Number of continuous structures generated. | |
| int | cutoff |
| How many structures to produce before halting search. -1 for no limit. | |
| bool | testingMode |
| Whether to run benchmarking tests. | |
| uint | test_nRunsStart |
| Starting run number for benchmark. | |
| uint | test_nRunsEnd |
| Ending run number for benchmark. | |
| uint | test_nStructs |
| Number of Structures per run when benchmarking. | |
| uint | failLimit |
| FailActions | failAction |
| QString | filePath |
| Local directory to work in. | |
| QString | description |
| Terse description of current search. | |
| QString | host |
| Host name or IP address of remote PBS server. | |
| int | port |
| Port on remote PBS server used for SSH communication. | |
| QString | username |
| Username for ssh login on remote PBS server. | |
| QString | rempath |
| QMutex * | sOBMutex |
| QMutex * | stateFileMutex |
| QMutex * | backTraceMutex |
| This is locked when generating a backtrace. | |
| bool | usePreopt |
| True if a preoptimization should be used. | |
| bool | savePending |
| True if there is a save requested or in progress. | |
| bool | isStarting |
| True if a session is starting or being loaded. | |
| bool | readOnly |
| Whether readOnly mode is enabled (e.g. no connection to server). | |
Protected Member Functions | |
| void | interpretKeyword_base (QString &keyword, Structure *structure) |
| Hidden call to interpretKeyword. | |
| QString | getTemplateKeywordHelp_base () |
| Hidden call to getTemplateKeywordHelp. | |
Protected Attributes | |
| QString | m_idString |
| SSHManager * | m_ssh |
| AbstractDialog * | m_dialog |
| Tracker * | m_tracker |
| QThread * | m_queueThread |
| Thread to run the QueueManager. | |
| QueueManager * | m_queue |
| QueueInterface * | m_queueInterface |
| Optimizer * | m_optimizer |
| unsigned int | m_schemaVersion |
| Current version of save/resume schema. | |
| bool | m_isDestroying |
The OptBase class stores variables and helper functions for global searches.
OptBase is the main class in libglobalsearch. It contains the variables that define a search, as well as handling structure generation. This class ties all others together.
Definition at line 53 of file optbase.h.
Actions to take when a structure has failed optimization too many times.
| GlobalSearch::OptBase::OptBase | ( | AbstractDialog * | parent | ) | [explicit] |
Constructor
| parent | Dialog window of GUI. |
Definition at line 48 of file optbase.cpp.
References m_queueThread, needBoolean(), needPassword(), promptForBoolean(), promptForPassword(), readOnlySessionStarted(), sessionStarted(), setIsStartingFalse(), setIsStartingTrue(), and startingSession().
| GlobalSearch::OptBase::~OptBase | ( | ) | [virtual] |
Destructor
Definition at line 100 of file optbase.cpp.
References m_optimizer, m_queue, m_queueInterface, m_queueThread, and m_tracker.
| virtual bool GlobalSearch::OptBase::checkLimits | ( | ) | [pure virtual] |
Before starting an optimization, this function will check the parameters of the search to ensure that they are within a reasonable range.
| virtual bool GlobalSearch::OptBase::checkStepOptimizedStructure | ( | Structure * | s, | |
| QString * | err = NULL | |||
| ) | [inline, virtual] |
Perform any post-optimization checks that need to be performed when a structure enters the Structure::StepOptimized state.
| s | Structure to check | |
| err | If non-NULL, will be overwritten with an explaination of why the check failed. |
| void GlobalSearch::OptBase::debug | ( | const QString & | s | ) | [slot] |
Prints a debug message to the terminal and emits debugStatement
| s | The debug statement. |
Definition at line 631 of file optbase.cpp.
References debugStatement().
| void GlobalSearch::OptBase::debugStatement | ( | const QString & | s | ) | [signal] |
Emitted when debug(const QString&) is called.
| s | The debugging statement. |
Referenced by debug().
| AbstractDialog* GlobalSearch::OptBase::dialog | ( | ) | [inline] |
Definition at line 242 of file optbase.h.
References m_dialog.
Referenced by GlobalSearch::Optimizer::dialog(), promptForBoolean(), and promptForPassword().
| void GlobalSearch::OptBase::emitReadOnlySessionStarted | ( | ) | [inline, slot] |
Emits the readOnlySessionStarted signal.
Definition at line 557 of file optbase.h.
References readOnlySessionStarted().
Referenced by GlobalSearch::AbstractDialog::resumeSession_().
| void GlobalSearch::OptBase::emitSessionStarted | ( | ) | [inline, slot] |
Emits the sessionStarted signal.
Definition at line 547 of file optbase.h.
References sessionStarted().
Referenced by GlobalSearch::AbstractDialog::resumeSession_().
| void GlobalSearch::OptBase::emitStartingSession | ( | ) | [inline, slot] |
Emits the startingSession signal.
Definition at line 566 of file optbase.h.
References startingSession().
Referenced by GlobalSearch::AbstractDialog::resumeSession_().
| void GlobalSearch::OptBase::error | ( | const QString & | s | ) | [slot] |
Prints a error message to the terminal and emits errorStatement
| s | The error statement. |
Definition at line 636 of file optbase.cpp.
References errorStatement().
Referenced by GlobalSearch::Optimizer::read(), and save().
| void GlobalSearch::OptBase::errorStatement | ( | const QString & | s | ) | [signal] |
Emitted when error(const QString&) is called.
| s | The error statement. |
Referenced by error().
| virtual void GlobalSearch::OptBase::generateNewStructure | ( | ) | [inline, virtual, slot] |
Called when the QueueManager requests more Structures.
| QString GlobalSearch::OptBase::getIDString | ( | ) | [inline] |
Definition at line 91 of file optbase.h.
References m_idString.
Referenced by GlobalSearch::AbstractEditTab::loadScheme(), GlobalSearch::Optimizer::readDataFromSettings(), GlobalSearch::Optimizer::readTemplatesFromSettings(), GlobalSearch::Optimizer::readUserValuesFromSettings(), GlobalSearch::AbstractDialog::resumeSession(), GlobalSearch::AbstractEditTab::saveScheme(), GlobalSearch::AbstractDialog::updateGUI(), GlobalSearch::Optimizer::writeDataToSettings(), GlobalSearch::Optimizer::writeTemplatesToSettings(), and GlobalSearch::Optimizer::writeUserValuesToSettings().
| QList< double > GlobalSearch::OptBase::getProbabilityList | ( | const QList< Structure * > & | structures | ) | [static] |
Generate a probability list using the enthalpies of a collection of structures.
The probability is calculated by:
p_i = N * (1 - (H_i - H_min) / (H_max - H_min) )
where p_i is the probability of selecting structure i, H_i is the enthalpy of structure i, H_min and H_max are the lowest and highest enthalpies in the collection, and N is a normalization factor.
To use the probability list generated by this function, run
double r = RANDDOUBLE(); int ind; for (ind = 0; ind < probs.size(); ind++) if (r < probs.at(ind)) break;
ind will hold the chosen index.
| structures | Collection of Structure objects to use. Must be sorted by enthalpy |
Definition at line 150 of file optbase.cpp.
References GlobalSearch::Structure::getEnthalpy().
| virtual QString GlobalSearch::OptBase::getTemplateKeywordHelp | ( | ) | [inline, virtual] |
Definition at line 236 of file optbase.h.
References getTemplateKeywordHelp_base().
Referenced by GlobalSearch::AbstractEditTab::showHelp().
| QString GlobalSearch::OptBase::interpretTemplate | ( | const QString & | templateString, | |
| Structure * | structure | |||
| ) | [virtual] |
Takes a template and inserts structure specific information by replacing keywords.
| templateString | Template | |
| structure | Structure of interest |
Definition at line 343 of file optbase.cpp.
References interpretKeyword_base().
Referenced by GlobalSearch::Optimizer::getInterpretedTemplates().
| virtual bool GlobalSearch::OptBase::load | ( | const QString & | filename, | |
| const bool | forceReadOnly = false | |||
| ) | [inline, virtual] |
Load a search session from the specified filename.
| filename | State file to resume. | |
| forceReadOnly | Set to true to skip any prompts and load the session readonly |
Definition at line 213 of file optbase.h.
Referenced by GlobalSearch::AbstractDialog::resumeSession_().
| void GlobalSearch::OptBase::needBoolean | ( | const QString & | message, | |
| bool * | ok | |||
| ) | [signal] |
Prompts user with an "Yes/No" dialog
| message | Message to the user. | |
| ok | True if user accepts dialog, false if they cancel. |
Referenced by OptBase().
| void GlobalSearch::OptBase::needPassword | ( | const QString & | message, | |
| QString * | newPassword, | |||
| bool * | ok | |||
| ) | [signal] |
Request a password from the user, used for libssh authentication.
| message | Message to the user. | |
| newPassword | pointer to the QString that will hold the new password. | |
| ok | True if user accepts dialog, false if they cancel. |
Referenced by OptBase().
| Optimizer* GlobalSearch::OptBase::optimizer | ( | ) | [inline] |
Definition at line 266 of file optbase.h.
References m_optimizer.
Referenced by GlobalSearch::AbstractEditTab::appendOptStep(), GlobalSearch::AbstractEditTab::configureOptimizer(), GlobalSearch::Optimizer::getInterpretedTemplates(), GlobalSearch::AbstractEditTab::getTemplateNames(), interpretKeyword_base(), GlobalSearch::AbstractEditTab::populateOptStepList(), GlobalSearch::AbstractEditTab::removeCurrentOptStep(), GlobalSearch::AbstractEditTab::saveCurrentTemplate(), GlobalSearch::AbstractEditTab::saveScheme(), GlobalSearch::AbstractEditTab::updateEditWidget(), GlobalSearch::AbstractEditTab::updateGUI(), GlobalSearch::AbstractEditTab::updateOptimizer(), GlobalSearch::AbstractEditTab::updateUserValues(), and GlobalSearch::QueueInterface::writeInputFiles().
| void GlobalSearch::OptBase::optimizerChanged | ( | Optimizer * | ) | [signal] |
Emitted when the current Optimizer changed
Referenced by setOptimizer().
| virtual bool GlobalSearch::OptBase::postSave | ( | const QString & | filename | ) | [inline, virtual] |
| virtual void GlobalSearch::OptBase::preoptimizeStructure | ( | Structure * | s | ) | [inline, virtual, slot] |
Perform a background preoptimization on Structure s. This may not be implemented for all search types, and does nothing by default.
| s | the Structure to preoptimize. |
Definition at line 498 of file optbase.h.
Referenced by GlobalSearch::QueueManager::startPreoptimization().
| void GlobalSearch::OptBase::printBackTrace | ( | ) | [slot] |
Prints a backtrace to the terminal
Definition at line 142 of file optbase.cpp.
References backTraceMutex.
Referenced by GlobalSearch::QueueManager::startJob().
| void GlobalSearch::OptBase::promptForBoolean | ( | const QString & | message, | |
| bool * | ok = 0 | |||
| ) | [slot] |
Prompt user with a "Yes/No" dialog.
| message | Message to the user. | |
| ok | True if user accepts dialog, false if they cancel. |
Definition at line 515 of file optbase.cpp.
References dialog(), and m_idString.
Referenced by OptBase().
| void GlobalSearch::OptBase::promptForPassword | ( | const QString & | message, | |
| QString * | newPassword, | |||
| bool * | ok = 0 | |||
| ) | [slot] |
Request a password from the user, used for libssh authentication.
| message | Message to the user. | |
| newPassword | pointer to the QString that will hold the new password. | |
| ok | True if user accepts dialog, false if they cancel. |
Definition at line 507 of file optbase.cpp.
References dialog().
Referenced by OptBase().
| QueueManager* GlobalSearch::OptBase::queue | ( | ) | [inline] |
Definition at line 252 of file optbase.h.
References m_queue.
Referenced by GlobalSearch::AbstractDialog::initialize().
| QueueInterface* GlobalSearch::OptBase::queueInterface | ( | ) | [inline] |
Definition at line 259 of file optbase.h.
References m_queueInterface.
Referenced by GlobalSearch::Optimizer::checkForSuccessfulOutput(), GlobalSearch::Optimizer::checkIfOutputFileExists(), GlobalSearch::QueueManager::checkPopulation(), GlobalSearch::AbstractEditTab::configureQueueInterface(), GlobalSearch::AbstractEditTab::getTemplateNames(), GlobalSearch::Optimizer::Optimizer(), GlobalSearch::AbstractEditTab::populateOptStepList(), GlobalSearch::Optimizer::readTemplatesFromSettings(), GlobalSearch::QueueManager::startJob(), GlobalSearch::QueueManager::stopJob(), GlobalSearch::Optimizer::update(), GlobalSearch::AbstractEditTab::updateGUI(), GlobalSearch::AbstractEditTab::updateQueueInterface(), GlobalSearch::Optimizer::updateQueueInterface(), GlobalSearch::Optimizer::writeSettings(), and GlobalSearch::Optimizer::writeTemplatesToSettings().
| void GlobalSearch::OptBase::queueInterfaceChanged | ( | QueueInterface * | ) | [signal] |
Emitted when the current QueueInterface changes
Referenced by setQueueInterface().
| void GlobalSearch::OptBase::readOnlySessionStarted | ( | ) | [signal] |
Emitted when a read-only session finishes loading.
Referenced by emitReadOnlySessionStarted(), and OptBase().
| void GlobalSearch::OptBase::refreshAllStructureInfo | ( | ) | [signal] |
Emitted when a major change has occurred affecting many structures, e.g. when duplicates are set/reset. It is recommended that any user-visible structure data is rebuilt from scratch when this is called.
| virtual Structure* GlobalSearch::OptBase::replaceWithOffspring | ( | Structure * | s, | |
| const QString & | reason = "" | |||
| ) | [inline, virtual] |
Replace the Structure with a new offspring. This only makes sense if the search method uses offspring (e.g. a GA). The default implementation of this method calls replaceWithRandom().
| s | The Structure to be replaced. This pointer remains valid -- the structure it points to will be modified. | |
| reason | Reason for replacing. This will appear in the Structure::getParents() string. (Optional) |
Definition at line 119 of file optbase.h.
References replaceWithRandom().
| virtual Structure* GlobalSearch::OptBase::replaceWithRandom | ( | Structure * | s, | |
| const QString & | reason = "" | |||
| ) | [inline, virtual] |
Replace the Structure with an appropriate random Structure.
| s | The Structure to be replaced. This pointer remains valid -- the structure it points to will be modified. | |
| reason | Reason for replacing. This will appear in the Structure::getParents() string. (Optional) |
Definition at line 103 of file optbase.h.
Referenced by replaceWithOffspring().
| void GlobalSearch::OptBase::reset | ( | ) | [virtual, slot] |
Deletes all structures from m_tracker and calls m_tracker->reset() and m_queue->reset().
Definition at line 123 of file optbase.cpp.
References GlobalSearch::Tracker::deleteAllStructures(), GlobalSearch::Tracker::lockForWrite(), m_queue, m_tracker, GlobalSearch::QueueManager::reset(), GlobalSearch::Tracker::reset(), and GlobalSearch::Tracker::unlock().
| bool GlobalSearch::OptBase::save | ( | const QString & | filename = "", |
|
| bool | notify = false | |||
| ) | [virtual] |
Save the current search. If filename is omitted, default to m_filePath + "/[search name].state". Must set OptBase::savePending = true before calling.
| filename | Filename to write to. Optional. | |
| notify | Whether to display a user-visible notification |
Definition at line 224 of file optbase.cpp.
References error(), filePath, GlobalSearch::Structure::getResultsEntry(), isStarting, GlobalSearch::Tracker::list(), m_dialog, m_idString, m_schemaVersion, m_tracker, postSave(), readOnly, GlobalSearch::Tracker::rwLock(), savePending, GlobalSearch::Structure::setIndex(), GlobalSearch::Structure::sortAndRankByEnthalpy(), GlobalSearch::AbstractDialog::startProgressUpdate(), stateFileMutex, GlobalSearch::AbstractDialog::stopProgressUpdate(), GlobalSearch::AbstractDialog::updateProgressLabel(), GlobalSearch::Structure::writeSettings(), and GlobalSearch::AbstractDialog::writeSettings().
| void GlobalSearch::OptBase::sessionStarted | ( | ) | [signal] |
Emitted when a session finishes starting or loading.
Referenced by emitSessionStarted(), and OptBase().
| void GlobalSearch::OptBase::setClipboard | ( | const QString & | text | ) | const [slot] |
Set the clipboard contents to text. Also sets the global mouse selection on supported systems.
| text | Text to place on the clipboard |
Definition at line 527 of file optbase.cpp.
| void GlobalSearch::OptBase::setIsStartingFalse | ( | ) | [inline, slot] |
Sets this->isStarting to false;
Definition at line 578 of file optbase.h.
References isStarting.
Referenced by OptBase().
| void GlobalSearch::OptBase::setIsStartingTrue | ( | ) | [inline, slot] |
Sets this->isStarting to true;
Definition at line 572 of file optbase.h.
References isStarting.
Referenced by OptBase().
| void GlobalSearch::OptBase::setOptimizer | ( | Optimizer * | o | ) | [slot] |
Update the Optimizer to the one indicated
| o | New Optimizer to use. |
Definition at line 495 of file optbase.cpp.
References m_optimizer, and optimizerChanged().
| void GlobalSearch::OptBase::setQueueInterface | ( | QueueInterface * | q | ) | [slot] |
Update the QueueInterface to q.
Definition at line 501 of file optbase.cpp.
References m_queueInterface, and queueInterfaceChanged().
| void GlobalSearch::OptBase::setReadOnlyFalse | ( | ) | [inline, slot] |
Sets this->readOnly to false;
Definition at line 590 of file optbase.h.
References readOnly.
| void GlobalSearch::OptBase::setReadOnlyTrue | ( | ) | [inline, slot] |
Sets this->readOnly to true;
Definition at line 584 of file optbase.h.
References readOnly.
| SSHManager* GlobalSearch::OptBase::ssh | ( | ) | [inline] |
| void GlobalSearch::OptBase::startingSession | ( | ) | [signal] |
Emitted when a session is starting or being loaded.
Referenced by emitStartingSession(), and OptBase().
| virtual void GlobalSearch::OptBase::startSearch | ( | ) | [pure virtual, slot] |
Begin the search.
| Tracker* GlobalSearch::OptBase::tracker | ( | ) | [inline] |
Definition at line 247 of file optbase.h.
References m_tracker.
Referenced by GlobalSearch::AbstractDialog::initialize(), and GlobalSearch::AbstractDialog::resumeSession_().
| void GlobalSearch::OptBase::warning | ( | const QString & | s | ) | [slot] |
Prints a warning message to the terminal and emits warningStatement
| s | The warning message. |
Definition at line 626 of file optbase.cpp.
References warningStatement().
Referenced by GlobalSearch::Optimizer::load(), GlobalSearch::Optimizer::read(), GlobalSearch::QueueManager::startJob(), and GlobalSearch::Optimizer::update().
| void GlobalSearch::OptBase::warningStatement | ( | const QString & | s | ) | [signal] |
Emitted when warning(const QString&) is called.
| s | The warning statement. |
Referenced by warning().
What to do when a Structure exceeds failLimit
Number of times a Structure may fail
AbstractDialog* GlobalSearch::OptBase::m_dialog [protected] |
QString GlobalSearch::OptBase::m_idString [protected] |
String that uniquely identifies the derived OptBase
Definition at line 667 of file optbase.h.
Referenced by getIDString(), promptForBoolean(), and save().
Optimizer* GlobalSearch::OptBase::m_optimizer [protected] |
Cache pointer to the current optimizer
Definition at line 696 of file optbase.h.
Referenced by optimizer(), setOptimizer(), and ~OptBase().
QueueManager* GlobalSearch::OptBase::m_queue [protected] |
Cached pointer to the QueueManager
Definition at line 686 of file optbase.h.
Referenced by queue(), reset(), and ~OptBase().
QueueInterface* GlobalSearch::OptBase::m_queueInterface [protected] |
Cached pointer to the QueueInterface
Definition at line 690 of file optbase.h.
Referenced by queueInterface(), setQueueInterface(), and ~OptBase().
SSHManager* GlobalSearch::OptBase::m_ssh [protected] |
Tracker* GlobalSearch::OptBase::m_tracker [protected] |
| QString GlobalSearch::OptBase::rempath |
| QMutex* GlobalSearch::OptBase::sOBMutex |
Much of OpenBabel is not written with thread safety in mind. This mutex should be locked whenever non-static OpenBabel functions are called.
Definition at line 329 of file optbase.h.
Referenced by GlobalSearch::Optimizer::read().
1.6.3