GlobalSearch::OptBase Class Reference

The OptBase class stores variables and helper functions for global searches. More...

#include <globalsearch/optbase.h>

List of all members.

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 StructurereplaceWithRandom (Structure *s, const QString &reason="")
virtual StructurereplaceWithOffspring (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 ()
AbstractDialogdialog ()
Trackertracker ()
QueueManagerqueue ()
QueueInterfacequeueInterface ()
Optimizeroptimizer ()
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
AbstractDialogm_dialog
Trackerm_tracker
QThread * m_queueThread
 Thread to run the QueueManager.
QueueManagerm_queue
QueueInterfacem_queueInterface
Optimizerm_optimizer
unsigned int m_schemaVersion
 Current version of save/resume schema.
bool m_isDestroying

Detailed Description

The OptBase class stores variables and helper functions for global searches.

Author:
David C. Lonie

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.


Member Enumeration Documentation

Actions to take when a structure has failed optimization too many times.

See also:
OptBase::failAction
OptBase::failLimit
Enumerator:
FA_DoNothing 

Do nothing; keep submitting for optimization.

FA_KillIt 

Kill the structure.

FA_Randomize 

Replace the failing structure with a new random one.

FA_NewOffspring 

Replace with a new offspring structure.

Definition at line 77 of file optbase.h.


Constructor & Destructor Documentation

GlobalSearch::OptBase::OptBase ( AbstractDialog parent  )  [explicit]
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.


Member Function Documentation

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.

Returns:
True if the search parameters are valid, false otherwise.
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.

Parameters:
s Structure to check
err If non-NULL, will be overwritten with an explaination of why the check failed.
Returns:
True if structure passes, false otherwise.

Definition at line 140 of file optbase.h.

void GlobalSearch::OptBase::debug ( const QString &  s  )  [slot]

Prints a debug message to the terminal and emits debugStatement

Parameters:
s The debug statement.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

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.

Parameters:
s The debugging statement.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

Referenced by debug().

AbstractDialog* GlobalSearch::OptBase::dialog (  )  [inline]
Returns:
A pointer to the main dialog..

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.

See also:
sessionStarted
emitSessionStarted
readOnlySessionStarted
startingSession
emitStartingSession

Definition at line 557 of file optbase.h.

References readOnlySessionStarted().

Referenced by GlobalSearch::AbstractDialog::resumeSession_().

void GlobalSearch::OptBase::emitSessionStarted (  )  [inline, slot]
void GlobalSearch::OptBase::emitStartingSession (  )  [inline, slot]

Emits the startingSession signal.

See also:
sessionStarted
emitSessionStarted
startingSession
emitStartingSession

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

Parameters:
s The error statement.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

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.

Parameters:
s The error statement.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

Referenced by error().

virtual void GlobalSearch::OptBase::generateNewStructure (  )  [inline, virtual, slot]

Called when the QueueManager requests more Structures.

See also:
QueueManager

Definition at line 491 of file optbase.h.

QString GlobalSearch::OptBase::getIDString (  )  [inline]
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.

Parameters:
structures Collection of Structure objects to use. Must be sorted by enthalpy
See also:
Structure::sortByEnthalpy()
Note:
IMPORTANT: structures must contain one more structure than needed -- the last structure in the list will be removed from the probability list! (e.g. return list has size (structure.size()-1)).
Returns:

Definition at line 150 of file optbase.cpp.

References GlobalSearch::Structure::getEnthalpy().

virtual QString GlobalSearch::OptBase::getTemplateKeywordHelp (  )  [inline, virtual]
Returns:
A QString defining all known keywords.

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.

Parameters:
templateString Template
structure Structure of interest
Returns:
Interpreted template with structure information included
See also:
getTemplateKeywordHelp
getTemplateKeywordHelp_base
interpretTemplate_base

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.

Parameters:
filename State file to resume.
forceReadOnly Set to true to skip any prompts and load the session readonly
Returns:
True is successful, false otherwise.

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

Parameters:
message Message to the user.
ok True if user accepts dialog, false if they cancel.
See also:
promptForBoolean

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.

Parameters:
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.
See also:
promptForPassword

Referenced by OptBase().

Optimizer* GlobalSearch::OptBase::optimizer (  )  [inline]
void GlobalSearch::OptBase::optimizerChanged ( Optimizer  )  [signal]

Emitted when the current Optimizer changed

See also:
setOptimizer
optimizer

Referenced by setOptimizer().

virtual bool GlobalSearch::OptBase::postSave ( const QString &  filename  )  [inline, virtual]

Override with any saving operations that derived classes need.

Definition at line 198 of file optbase.h.

Referenced by save().

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.

Parameters:
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.

Parameters:
message Message to the user.
ok True if user accepts dialog, false if they cancel.
See also:
needBoolean

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.

Parameters:
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.
See also:
needPassword

Definition at line 507 of file optbase.cpp.

References dialog().

Referenced by OptBase().

QueueManager* GlobalSearch::OptBase::queue (  )  [inline]
Returns:
A pointer to the associated QueueManager.

Definition at line 252 of file optbase.h.

References m_queue.

Referenced by GlobalSearch::AbstractDialog::initialize().

QueueInterface* GlobalSearch::OptBase::queueInterface (  )  [inline]
void GlobalSearch::OptBase::queueInterfaceChanged ( QueueInterface  )  [signal]

Emitted when the current QueueInterface changes

See also:
setQueueInterface
queueInterface

Referenced by setQueueInterface().

void GlobalSearch::OptBase::readOnlySessionStarted (  )  [signal]
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().

Parameters:
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)
Returns:
The pointer to the structure (same as s).

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.

Parameters:
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)
Returns:
The pointer to the structure (same as s).

Definition at line 103 of file optbase.h.

Referenced by replaceWithOffspring().

void GlobalSearch::OptBase::reset (  )  [virtual, slot]
bool GlobalSearch::OptBase::save ( const QString &  filename = "",
bool  notify = false 
) [virtual]
void GlobalSearch::OptBase::sessionStarted (  )  [signal]
void GlobalSearch::OptBase::setClipboard ( const QString &  text  )  const [slot]

Set the clipboard contents to text. Also sets the global mouse selection on supported systems.

Parameters:
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;

See also:
setIsStartingTrue

Definition at line 578 of file optbase.h.

References isStarting.

Referenced by OptBase().

void GlobalSearch::OptBase::setIsStartingTrue (  )  [inline, slot]

Sets this->isStarting to true;

See also:
setIsStartingFalse

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

Parameters:
o New Optimizer to use.
See also:
optimizerChanged
optimizer

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.

See also:
queueInterfaceChanged
queueInterface

Definition at line 501 of file optbase.cpp.

References m_queueInterface, and queueInterfaceChanged().

void GlobalSearch::OptBase::setReadOnlyFalse (  )  [inline, slot]

Sets this->readOnly to false;

See also:
setReadOnlyTrue

Definition at line 590 of file optbase.h.

References readOnly.

void GlobalSearch::OptBase::setReadOnlyTrue (  )  [inline, slot]

Sets this->readOnly to true;

See also:
setReadOnlyFalse

Definition at line 584 of file optbase.h.

References readOnly.

SSHManager* GlobalSearch::OptBase::ssh (  )  [inline]
Returns:
A pointer to the SSHManager instance.

Definition at line 271 of file optbase.h.

References m_ssh.

void GlobalSearch::OptBase::startingSession (  )  [signal]
virtual void GlobalSearch::OptBase::startSearch (  )  [pure virtual, slot]

Begin the search.

Tracker* GlobalSearch::OptBase::tracker (  )  [inline]
Returns:
A pointer to the main Structure Tracker.

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

Parameters:
s The warning message.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

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.

Parameters:
s The warning statement.
See also:
debug
debugStatement
warning
warningStatement
error
errorStatement

Referenced by warning().


Member Data Documentation

What to do when a Structure exceeds failLimit

See also:
OptBase::FailActions
OptBase::failLimit

Definition at line 305 of file optbase.h.

Number of times a Structure may fail

See also:
OptBase::failAction
OptBase::FailActions

Definition at line 300 of file optbase.h.

Cached pointer to the Dialog window

See also:
tracker

Definition at line 675 of file optbase.h.

Referenced by dialog(), and save().

QString GlobalSearch::OptBase::m_idString [protected]

String that uniquely identifies the derived OptBase

See also:
getIDString

Definition at line 667 of file optbase.h.

Referenced by getIDString(), promptForBoolean(), and save().

Cache pointer to the current optimizer

See also:
optimizerChanged
optimizer
setOptimizer

Definition at line 696 of file optbase.h.

Referenced by optimizer(), setOptimizer(), and ~OptBase().

Cached pointer to the QueueManager

See also:
queue

Definition at line 686 of file optbase.h.

Referenced by queue(), reset(), and ~OptBase().

Cached pointer to the QueueInterface

See also:
queueInterface

Definition at line 690 of file optbase.h.

Referenced by queueInterface(), setQueueInterface(), and ~OptBase().

SSHManager* GlobalSearch::OptBase::m_ssh [protected]

Cached pointer to the SSHManager

See also:
ssh

Definition at line 671 of file optbase.h.

Referenced by ssh().

Cached pointer to the main Tracker

See also:
tracker

Definition at line 679 of file optbase.h.

Referenced by reset(), save(), tracker(), and ~OptBase().

Path on remote server to store files during and after optimization

Definition at line 324 of file optbase.h.

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().

This should be locked whenever the state file (resume file) is being written

Definition at line 333 of file optbase.h.

Referenced by save().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator
Generated on Mon Jul 16 14:40:04 2012 for GlobalSearch by  doxygen 1.6.3