20package denoptim.programs.denovo;
22import java.lang.reflect.Field;
23import java.text.SimpleDateFormat;
24import java.util.ArrayList;
27import java.util.logging.Level;
29import denoptim.constants.DENOPTIMConstants;
30import denoptim.exception.DENOPTIMException;
31import denoptim.files.FileFormat;
32import denoptim.graph.rings.RingClosureParameters;
33import denoptim.logging.Monitor;
34import denoptim.logging.StaticLogger;
35import denoptim.programs.RunTimeParameters;
36import denoptim.programs.RunTimeParameters.ParametersType;
37import denoptim.utils.MutationType;
55 private String
dataDir = System.getProperty(
"user.dir");
62 + System.getProperty(
"file.separator") +
"interface";
517 interfaceDir = pathName + DENOPTIMConstants.FSEP +
"interface";
842 switch (key.toUpperCase())
850 case "NUMPARALLELTASKS=":
852 if (value.length() > 0)
859 case "PARALLELIZATION=":
861 switch (value.toUpperCase())
875 case "PRECISIONLEVEL=":
877 if (value.length() > 0)
886 if (value.length() > 0)
895 if (value.length() > 0)
904 if (value.length() > 0)
911 case "MONITORDUMPSTEP=":
913 if (value.length() > 0)
923 if (value.length() > 0)
925 seed = Long.parseLong(value);
930 case "MAXTRIESPERPOPULATION=":
932 if (value.length() > 0)
937 case "MAXGENETICOPSATTEMPTS=":
939 if (value.length() > 0)
944 case "INITPOPLNFILE=":
946 if (value.length() > 0)
953 case "INITMOLSTOFRAGMENTFILE=":
955 if (value.length() > 0)
962 case "SORTBYINCREASINGFITNESS":
964 if (value.length() > 0)
971 case "LEVELGROWTHMULTIPLIER=":
973 if (value.length() > 0)
981 case "LEVELGROWTHSIGMASTEEPNESS=":
983 if (value.length() > 0)
991 case "LEVELGROWTHSIGMAMIDDLE=":
993 if (value.length() > 0)
1001 case "LEVELGROWTHPROBSCHEME=":
1008 case "MOLGROWTHMULTIPLIER=":
1010 if (value.length() > 0)
1018 case "MOLGROWTHSIGMASTEEPNESS=":
1020 if (value.length() > 0)
1028 case "MOLGROWTHSIGMAMIDDLE=":
1030 if (value.length() > 0)
1038 case "MOLGROWTHPROBSCHEME=":
1045 case "CROWDMULTIPLIER=":
1047 if (value.length() > 0)
1054 case "CROWDSIGMASTEEPNESS=":
1056 if (value.length() > 0)
1063 case "CROWDSIGMAMIDDLE=":
1065 if (value.length() > 0)
1072 case "SYMMETRYPROBABILITY=":
1074 if (value.length() > 0)
1081 case "CROWDPROBSCHEME=":
1087 case "NUMGENERATIONS=":
1089 if (value.length() > 0)
1096 case "NUMCHILDREN=":
1098 if (value.length() > 0)
1105 case "CROSSOVERWEIGHT=":
1107 if (value.length() > 0)
1114 case "MUTATIONWEIGHT=":
1116 if (value.length() > 0)
1123 case "COUPLEMUTATIONTOCROSSOVER=":
1125 if (value.length() > 0)
1132 case "PARENTSSURVIVE=":
1134 if (value.length() > 0)
1141 case "EXCLUDEMUTATIONTYPE=":
1143 if (value.length() > 0)
1150 case "CONSTRUCTIONWEIGHT=":
1152 if (value.length() > 0)
1159 case "REPLACEMENTSTRATEGY=":
1161 switch (value.toUpperCase())
1175 case "POPULATIONSIZE=":
1177 if (value.length() > 0)
1186 if (value.length() > 0)
1193 case "MAXRINGSADDEDBYMUTATION=":
1195 if (value.length() > 0)
1202 case "KEEPNEWRINGSYSTEMVERTEXES":
1208 case "KEEPNEWRINGSYSTEMSCAFFOLDS":
1214 case "KEEPNEWRINGSYSTEMFITNESSTRSH=":
1216 if (value.length() > 0)
1223 case "MULTISITEMUTATIONWEIGHTS=":
1225 String[] ws = value.split(
",|\\s+");
1226 List<Double> lst =
new ArrayList<Double>();
1229 if (!w.trim().equals(
""))
1230 lst.add(Double.parseDouble(w));
1233 for (
int i=0; i<lst.size(); i++)
1240 case "XOVERSELECTIONMODE=":
1242 if (value.length() > 0)
1245 if (value.compareToIgnoreCase(
"TS") == 0)
1249 }
else if (value.compareToIgnoreCase(
"RW") == 0)
1253 }
else if (value.compareToIgnoreCase(
"SUS") == 0)
1257 }
else if (value.compareToIgnoreCase(
"RANDOM") == 0)
1263 + value +
"' cannot be interpreted as a "
1264 +
"parent selection strategy.");
1270 case "NUMOFFSPRINGFROMXOVER=":
1272 if (value.length() > 0)
1277 +
"up to 2 offspring from crossover, but you "
1283 case "KEEPBESTSIBLING=":
1289 case "MUTATEDGRAPHCHECKFAILTOLERANT=":
1295 case "XOVERGRAPHCHECKFAILTOLERANT=":
1301 case "MUTATIONFAILURETOLERANT=":
1307 case "XOVERFAILURETOLERANT=":
1313 case "BUILDFAILURETOLERANT=":
1319 case "MAXXOVERSUBGRAPHSIZE=":
1321 if (value.length() > 0)
1328 case "WRITEPOPULATIONTOFILE":
1335 msg =
"Keyword " + key +
" is not a known GeneticAlgorithm-"
1336 +
"related keyword. Check input files.";
1347 switch (option.toUpperCase())
1358 case "UNRESTRICTED":
1363 "Unknown growth probability scheme.");
1378 boolean success =
false;
1381 SimpleDateFormat sdf =
new SimpleDateFormat(
"yyyyMMddkkmmss");
1384 dataDir = cdataDir + DENOPTIMConstants.FSEP + str;
1385 success = denoptim.files.FileUtils.createDirectory(
dataDir);
1388 if (!denoptim.files.FileUtils.createDirectory(
interfaceDir))
1416 int nproc = Runtime.getRuntime().availableProcessors();
1438 +
"Output files associated with the current run are "
1452 error =
"Number of children must be a positive number.";
1457 error =
"Number of generations must be a positive number.";
1463 error =
"Number of convergence iterations must be a positive "
1471 error =
"Symmetric molecule probability must be between 0 and 1.";
1477 error =
"Weight of mutation must be a positive number";
1483 error =
"Weight of crossover must be a positive number";
1489 error =
"Weight of construction must be a positive number";
1497 error =
"Cannot find initial population data: " +
initPoplnFile;
1511 if (replacementStrategy < 0 || replacementStrategy > 2)
1513 error =
"Allowed values for replacementStrategy (1-2)";
1519 error =
"Cannot use both graph level or molecular size as criterion "
1520 +
"for controlling the growth of graphs. "
1521 +
"Please, use either of them.";
1539 StringBuilder sb =
new StringBuilder(1024);
1541 for (Field f : this.getClass().getDeclaredFields())
1545 sb.append(f.getName()).append(
" = ").append(
1546 f.get(
this)).append(
NL);
1551 +
" parameters. Cause: " + t);
1557 sb.append(otherCollector.getPrintedList());
1559 return sb.toString();
General set of constants used in DENOPTIM.
static final String EOL
new line character
Parameters and setting related to handling ring closures.
void allowRingClosures(boolean value)
Logger class for DENOPTIM.
static final Logger appLogger
Collection of parameters controlling the behavior of the software.
Map< ParametersType, RunTimeParameters > otherParameters
Collection of other parameters by type.
long getRandomSeed()
Returns the seed.
boolean isMaster
Flag signaling this is the master collection of parameters.
boolean containsParameters(ParametersType type)
static boolean readYesNoTrueFalse(String s)
Reads a string searching for any common way to say either yes/true (including shorthand t/y) or no/fa...
RunTimeParameters getParameters(ParametersType type)
String paramTypeName()
Returns a string defining the type the parameters collected here.
void checkOtherParameters()
Checks any of the parameter collections contained in this instance.
final String NL
New line character.
Randomizer startRandomizer()
Starts a program specific randomizer, i.e., a tool for generating random numbers and taking random de...
void processOtherParameters()
Processes any of the parameter collections contained in this instance.
int verbosity
Verbosity level for logger.
Parameters for genetic algorithm.
boolean buildAnewFailureTolerant
Flag that enables the ignoring of construction from scratch events triggering exceptions.
int maxRingsAddedByMutation
Maximum number of rings added by a single mutation operation.
double getConstructionWeight()
int monitorDumpStep
Monitor dumps step.
double getMutationWeight()
boolean saveRingSystemsAsTemplatesScaffolds
Flag controlling the possibility of collecting cyclic graph systems that include a scaffold and save ...
int maxXOverableSubGraphSize
Limit to the size of subgraphs that are exchanged during crossover.
int xoverSelectionMode
Crossover parents selection strategy: integer code.
void interpretKeyword(String key, String value)
Processes a keyword/value pair and assign the related parameters.
boolean useMolSizeBasedProb
Flag recording the intention to use molecular size-controlled graph extension probability.
double symmetricSubProbability
The probability at which symmetric substitution occurs.
boolean mutationFailureTolerant
Flag that enables the ignoring of mutation events triggering exceptions.
int getMolGrowthProbabilityScheme()
double lvlGrowthSigmaMiddle
Parameters controlling the growth probability function of type 'SIGMA': level at which p=50% (can be ...
int getMaxGeneticOpAttempts()
int getCrowdingProbabilityScheme()
double getSaveRingSystemsFitnessThreshold()
int parallelizationScheme
Parallelization scheme: synchronous or asynchronous.
String getDataDirectory()
int maxOffsprintFromXover
Number of offspring that a single crossover operation can produce.
double getSymmetryProbability()
int lvlGrowthProbabilityScheme
Definition of the growth probability function:
int getNumberOfChildren()
double getGrowthFactorMiddleSigma()
String getInitialPopulationFile()
boolean saveRingSystemsAsTemplatesNonScaff
Flag controlling the possibility of collecting cyclic graph systems that do NOT include a scaffold an...
boolean dumpMonitor
Flag controlling if we dump monitored data or not.
boolean sortOrderDecreasing
Flag controlling how to sort the population based on the fitness.
String timeStamp
Time stamp identifying this run.
String getInitMolsToFragmentFile()
double getMolGrowthFactorMiddleSigma()
long seed
The seed value for random number generation.
String visitedGraphsFile
Pathname to the file containing the list of previously visited graph.
int maxUIDMemory
Maximum number of unique identifiers kept in memory.
static int convertProbabilityScheme(String option)
int numConvGen
Number of identical generations before convergence is reached.
String monitorFile
Pathname of file where EA monitors dumps are printed.
final String DEFUIDFILEOUTNAME
Default name of the UIDFileOut.
boolean mutatedGraphFailedEvalTolerant
Flag that enables the ignoring of mutated graphs that lead to a failure in the evaluation of graphs t...
boolean useLevelBasedProb
Flag recording the intention to use level-controlled graph extension probability.
boolean parentsSurvive
Flag defining if population members can survive multiple generations (when this variable is true) or ...
int getNumberOfConvergenceGenerations()
double[] getMultiSiteMutationWeights()
boolean getSaveRingSystemsAsTemplatesNonScaff()
int getMaxRingsAddedByMutation()
Return the value of the number of rings that we are allowed to add in a single MutationType#ADDRING m...
boolean keepBestSibling
Flag controlling if we choose the best sibling out of crossover.
double lvlGrowthSigmaSteepness
Parameters controlling the growth probability function of type 'SIGMA': steepness of the function whe...
GAParameters()
Constructor.
int getNumberOfGenerations()
String getPrintedList()
Returns the list of parameters in a string with newline characters as delimiters.
double getMolGrowthFactorSteepSigma()
double crowdingSigmaMiddle
Parameters controlling the crowding probability function of type 'SIGMA': level at which p=50% (can b...
boolean useLevelBasedProb()
String uidMemoryOnDisk
Text file used to store unique identifiers beyond the limits of the memory (see GAParameters#maxUIDMe...
int numOfChildren
Number of children (i.e., new offspring) to be produced in each generation.
String getSelectionStrategy()
void checkParameters()
Evaluate consistency of input parameters.
double[] mutliSiteMutationWeights
The weights of multi-site mutations.
double crowdingMultiplier
Parameter controlling the crowding probability function of types 'EXP_DIFF' and 'TANH'.
boolean writePopOnDisk
Flag requesting to write a SDF file that collects all the population members each time we report the ...
double saveRingSystemsFitnessThreshold
Fitness threshold for adding template to building block libraries.
boolean coupleMutationAndCrossover()
int getReplacementStrategy()
String dataDir
Pathname to the working directory for the current run.
void setPopulationSize(int size)
double mutationWeight
The relative weight at which mutation is performed.
double getGrowthFactorSteepSigma()
int numParallelTasks
Maximum number of parallel tasks.
int maxTriesPerPop
Factor controlling the maximum number of attempts to build a graph so that the maximum number of atte...
double getMolGrowthMultiplier()
double molGrowthSigmaMiddle
Parameters controlling the molGrowth probability function of type 'SIGMA': level at which p=50% (can ...
int populationSize
Size of the population.
boolean coupleMutationAndCrossover
Flag defining if we want mutation to occur on offspring that result from crossover (i....
String getVisitedGraphsFile()
boolean useMolSizeBasedProb()
double builtAnewWeight
The relative weight at which construction from scratch is performed.
double molGrowthMultiplier
Parameter controlling the molGrowth probability function of types 'EXP_DIFF' and 'TANH'.
double getCrowdingFactorSteepSigma()
List< MutationType > getExcludedMutationTypes()
double minFitnessSD
Minimal standard deviation accepted in the fitness values of the initial population.
double crowdingSigmaSteepness
Parameters controlling the crowding probability function of type 'SIGMA': steepness of the function w...
int numGenerations
Maximum number of generations to run for.
double molGrowthSigmaSteepness
Parameters controlling the molGrowth probability function of type 'SIGMA': steepness of the function ...
String uidFileOut
Pathname of the file where the individuals unique identifiers will be recorded.
int crowdingProbabilityScheme
Definition of the crowding probability function.
String initPoplnFile
Pathname of the initial population file.
void createWorkingDirectory()
Create the directory that will store the output of the GA run.
String strXoverSelectionMode
Crossover parents selection strategy: string.
String interfaceDir
Pathname to the interface directory for the current run.
double getCrowdingFactorMiddleSigma()
boolean xoverGraphFailedEvalTolerant
Flag that enables the ignoring of crossover-ed graphs that lead to a f ailure in the evaluation of gr...
boolean xoverFailureTolerant
Flag that enables the ignoring of crossover events triggering exceptions.
void processParameters()
Processes currently loaded fields.
double crossoverWeight
The relative weight at which crossover is performed.
String initMolsToFragmentFile
Pathname to the file collecting molecules to fragment to generate initial population.
double lvlGrowthMultiplier
Parameter controlling the growth probability function of types 'EXP_DIFF' and 'TANH'.
List< MutationType > excludedMutationTypes
Mutation types that are excluded everywhere.
boolean isSortOrderDecreasing()
int getGrowthProbabilityScheme()
int getParallelizationScheme()
double getGrowthMultiplier()
void setWorkingDirectory(String pathName)
int replacementStrategy
Replacement strategy: 1) replace worst individuals with new ones that are better than the worst,...
int precisionLevel
Precision for reporting the value of the fitness.
int molGrowthProbabilityScheme
Definition of the molGrowth probability function:
int maxOffsprintFromXover()
String uidFileIn
Pathname of the file with the list of individuals unique identifiers that are initially known.
int maxGeneticOpAttempts
Maximum number of attempts to perform any genetic operation (i.e., either crossover or mutation) on a...
int getSelectionStrategyType()
double getCrowdingMultiplier()
boolean keepBestSibling()
double getCrossoverWeight()
boolean getSaveRingSystemsAsTemplatesScaff()
Identifier of the type of parameters.
GA_PARAMS
Parameters pertaining the genetic algorithm.
RC_PARAMS
Parameters pertaining to ring closures in graphs.
Types of mutation defined in relation to what happens to the target vertex (i.e., the actual mutation...
ADDRING
Creates a ring-closure to add a ring.