Commit 363e5706 authored by mvalle's avatar mvalle
Browse files

Added immediate check on the optimizer code.

Corrected help line for the -m option
For the global optimizer set the timeout to 24 hours


git-svn-id: https://svn.vital-it.ch/svn/hp2c/trunk/Codeml_Variants/Fastcodeml@5926 95c5a404-1f88-0410-a6b0-c3f062b6f34a
parent c96c93c7
......@@ -872,6 +872,24 @@ double BranchSiteModelAltHyp::combineSiteLikelihoods(void)
return lnl;
}
void BranchSiteModel::verifyOptimizerAlgo(unsigned int aOptimizationAlgo)
{
switch(aOptimizationAlgo)
{
case OPTIM_LD_MING2:
case OPTIM_LD_LBFGS:
case OPTIM_LD_VAR1:
case OPTIM_LD_VAR2:
case OPTIM_LD_SLSQP:
case OPTIM_LN_BOBYQA:
case OPTIM_MLSL_LDS:
return;
default:
throw FastCodeMLFatal("Invalid optimization algorithm identifier on the command line.");
}
}
/// Adapter class to pass the routine to the optimizer.
///
......@@ -1119,8 +1137,8 @@ double BranchSiteModel::maximizeLikelihood(size_t aFgBranch, bool aStopIfBigger,
case OPTIM_MLSL_LDS:
opt.reset(new nlopt::opt(nlopt::G_MLSL_LDS, mNumTimes+mNumVariables));
{
// For global optimization put a timeout of one hour
opt->set_maxtime(60*60);
// For global optimization put a timeout of one day
opt->set_maxtime(24*60*60);
// This algorithm requires a local optimizer, add it
nlopt::opt local_opt(nlopt::LN_BOBYQA, mNumTimes+mNumVariables);
......
......@@ -193,6 +193,14 @@ public:
///
void getScales(std::vector<double>& aScales) const {aScales.resize(2); aScales[0] = mBgScale; aScales[1] = mFgScale;}
/// Verify if the code entered on command line is valid.
///
/// @param[in] aOptimizationAlgo The code set on the command line.
///
/// @exception FastCodeMLFatal IInvalid optimization algorithm identifier on the command line.
///
static void verifyOptimizerAlgo(unsigned int aOptimizationAlgo);
protected:
/// Compute the four site proportions from the two values in the optimization variables
///
......
......@@ -181,7 +181,7 @@ void CmdLine::parseCmdLine(int aCnt, char **aVal)
{ OPT_ONE_HYP_ONLY, "--only-hyp", SO_REQ_SEP, "" },
{ OPT_INIT_H0_FROM_H1, "-i1", SO_NONE, "Start H0 optimization from H1 results" },
{ OPT_INIT_H0_FROM_H1, "--init-from-h1", SO_NONE, "" },
{ OPT_OPTIM_ALGO, "-m", SO_REQ_SEP, "Optimizer algorithm (0:LBFGS, 1:VAR1, 2:VAR2, 3:SLSQP, 11:BOBYQA, 22:FromCodeML) (default: 0)" },
{ OPT_OPTIM_ALGO, "-m", SO_REQ_SEP, "Optimizer algorithm (0:LBFGS, 1:VAR1, 2:VAR2, 3:SLSQP, 11:BOBYQA, 22:FromCodeML, 99:MLSL_LDS) (default: 0)" },
{ OPT_OPTIM_ALGO, "--maximizer", SO_REQ_SEP, "" },
{ OPT_DELTA_VAL, "-sd", SO_REQ_SEP, "Delta used in gradient computation (default: 1.49e-8)" },
{ OPT_DELTA_VAL, "--small-diff", SO_REQ_SEP, "" },
......
......@@ -184,6 +184,9 @@ int main(int aRgc, char **aRgv)
#endif
srand(cmd.mSeed);
// Verify the optimizer algorithm selected on the command line
if(!cmd.mNoMaximization) BranchSiteModel::verifyOptimizerAlgo(cmd.mOptimizationAlgo);
// Start a timer (to measure serial part over parallel one)
Timer timer;
if(cmd.mVerboseLevel >= VERBOSE_INFO_OUTPUT) timer.start();
......@@ -575,7 +578,7 @@ Usage:
Start H0 optimization from H1 results
-m --maximizer (required argument)
Optimizer algorithm (0:LBFGS, 1:VAR1, 2:VAR2, 3:SLSQP, 11:BOBYQA, 22:FromCodeML) (default: 0)
Optimizer algorithm (0:LBFGS, 1:VAR1, 2:VAR2, 3:SLSQP, 11:BOBYQA, 22:FromCodeML, 99:MLSL_LDS) (default: 0)
-sd --small-diff (required argument)
Delta used in gradient computation (default: 1.49e-8)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment