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.utils.MutationType;
54 private String
dataDir = System.getProperty(
"user.dir");
61 + System.getProperty(
"file.separator") +
"interface";
551 interfaceDir = pathName + DENOPTIMConstants.FSEP +
"interface";
883 switch (key.toUpperCase())
891 case "NUMPARALLELTASKS=":
893 if (value.length() > 0)
900 case "PARALLELIZATION=":
902 switch (value.toUpperCase())
916 case "PRECISIONLEVEL=":
918 if (value.length() > 0)
927 if (value.length() > 0)
936 if (value.length() > 0)
945 if (value.length() > 0)
952 case "RECORDMATESELECTION=":
954 if (value.length() > 0)
961 case "MONITORDUMPSTEP=":
963 if (value.length() > 0)
973 if (value.length() > 0)
975 seed = Long.parseLong(value);
980 case "MAXTRIESPERPOPULATION=":
982 if (value.length() > 0)
987 case "MAXGENETICOPSATTEMPTS=":
989 if (value.length() > 0)
994 case "INITPOPLNFILE=":
996 if (value.length() > 0)
1003 case "INITMOLSTOFRAGMENTFILE=":
1005 if (value.length() > 0)
1012 case "SORTBYINCREASINGFITNESS":
1018 case "NANFITNESSKILLSEXPERIMENT":
1023 case "LEVELGROWTHMULTIPLIER=":
1025 if (value.length() > 0)
1033 case "LEVELGROWTHSIGMASTEEPNESS=":
1035 if (value.length() > 0)
1043 case "LEVELGROWTHSIGMAMIDDLE=":
1045 if (value.length() > 0)
1053 case "LEVELGROWTHPROBSCHEME=":
1060 case "MOLGROWTHMULTIPLIER=":
1062 if (value.length() > 0)
1070 case "MOLGROWTHSIGMASTEEPNESS=":
1072 if (value.length() > 0)
1080 case "MOLGROWTHSIGMAMIDDLE=":
1082 if (value.length() > 0)
1090 case "MOLGROWTHPROBSCHEME=":
1097 case "CROWDMULTIPLIER=":
1099 if (value.length() > 0)
1106 case "CROWDSIGMASTEEPNESS=":
1108 if (value.length() > 0)
1115 case "CROWDSIGMAMIDDLE=":
1117 if (value.length() > 0)
1124 case "SYMMETRYPROBABILITY=":
1126 if (value.length() > 0)
1133 case "CROWDPROBSCHEME=":
1139 case "NUMGENERATIONS=":
1141 if (value.length() > 0)
1148 case "NUMCHILDREN=":
1150 if (value.length() > 0)
1157 case "CROSSOVERWEIGHT=":
1159 if (value.length() > 0)
1166 case "MUTATIONWEIGHT=":
1168 if (value.length() > 0)
1175 case "COUPLEMUTATIONTOCROSSOVER=":
1177 if (value.length() > 0)
1184 case "PARENTSSURVIVE=":
1186 if (value.length() > 0)
1193 case "EXCLUDEMUTATIONTYPE=":
1195 if (value.length() > 0)
1202 case "CONSTRUCTIONWEIGHT=":
1204 if (value.length() > 0)
1211 case "REPLACEMENTSTRATEGY=":
1213 switch (value.toUpperCase())
1227 case "POPULATIONSIZE=":
1229 if (value.length() > 0)
1238 if (value.length() > 0)
1245 case "MAXRINGSADDEDBYMUTATION=":
1247 if (value.length() > 0)
1254 case "KEEPNEWRINGSYSTEMVERTEXES":
1260 case "KEEPNEWRINGSYSTEMSCAFFOLDS":
1266 case "KEEPNEWRINGSYSTEMFITNESSTRSH=":
1268 if (value.length() > 0)
1275 case "MULTISITEMUTATIONWEIGHTS=":
1277 String[] ws = value.split(
",|\\s+");
1278 List<Double> lst =
new ArrayList<Double>();
1281 if (!w.trim().equals(
""))
1282 lst.add(Double.parseDouble(w));
1285 for (
int i=0; i<lst.size(); i++)
1292 case "XOVERSELECTIONMODE=":
1294 if (value.length() > 0)
1297 if (value.compareToIgnoreCase(
"TS") == 0)
1301 }
else if (value.compareToIgnoreCase(
"RW") == 0)
1305 }
else if (value.compareToIgnoreCase(
"SUS") == 0)
1309 }
else if (value.compareToIgnoreCase(
"RANDOM") == 0)
1315 + value +
"' cannot be interpreted as a "
1316 +
"parent selection strategy.");
1322 case "SELECTIVEPRESSURE=":
1324 if (value.length() > 0)
1332 case "NUMOFFSPRINGFROMXOVER=":
1334 if (value.length() > 0)
1339 +
"up to 2 offspring from crossover, but you "
1345 case "KEEPBESTSIBLING=":
1351 case "MUTATEDGRAPHCHECKFAILTOLERANT=":
1357 case "XOVERGRAPHCHECKFAILTOLERANT=":
1363 case "MUTATIONFAILURETOLERANT=":
1369 case "XOVERFAILURETOLERANT=":
1375 case "BUILDFAILURETOLERANT=":
1381 case "MAXXOVERSUBGRAPHSIZE=":
1383 if (value.length() > 0)
1390 case "WRITEPOPULATIONTOFILE":
1397 msg =
"Keyword " + key +
" is not a known GeneticAlgorithm-"
1398 +
"related keyword. Check input files.";
1409 switch (option.toUpperCase())
1420 case "UNRESTRICTED":
1425 "Unknown growth probability scheme.");
1440 boolean success =
false;
1443 SimpleDateFormat sdf =
new SimpleDateFormat(
"yyyyMMddkkmmss");
1446 dataDir = cdataDir + DENOPTIMConstants.FSEP + str;
1447 success = denoptim.files.FileUtils.createDirectory(
dataDir);
1450 if (!denoptim.files.FileUtils.createDirectory(
interfaceDir))
1478 int nproc = Runtime.getRuntime().availableProcessors();
1504 +
"Output files associated with the current run are "
1518 error =
"Number of children must be a positive number.";
1523 error =
"Number of generations must be a positive number.";
1529 error =
"Number of convergence iterations must be a positive "
1537 error =
"Symmetric molecule probability must be between 0 and 1.";
1543 error =
"Weight of mutation must be a positive number";
1549 error =
"Weight of crossover must be a positive number";
1555 error =
"Weight of construction must be a positive number";
1563 error =
"Cannot find initial population data: " +
initPoplnFile;
1577 if (replacementStrategy < 0 || replacementStrategy > 2)
1579 error =
"Allowed values for replacementStrategy (1-2)";
1585 error =
"Cannot use both graph level or molecular size as criterion "
1586 +
"for controlling the growth of graphs. "
1587 +
"Please, use either of them.";
1605 StringBuilder sb =
new StringBuilder(1024);
1607 for (Field f : this.getClass().getDeclaredFields())
1611 sb.append(f.getName()).append(
" = ").append(
1612 f.get(
this)).append(
NL);
1617 +
" parameters. Cause: " + t);
1623 sb.append(otherCollector.getPrintedList());
1625 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 ...
boolean isNanFitnessKillsExperiment()
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.
boolean recordMateSelection
Flag defining whether we record which mates are selected or not.
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 nanFitnessKillsExperiment
Flag controlling whether we allow NaN fitness to kill design experiments.
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.
int selectivePressure
Intensity for selecting high fitness parents.
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()
boolean recordMateSelection()
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()
int getSelectivePressure()
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...
ADDFUSEDRING
Adds a subgraph that introduced a fused ring.
ADDRING
Creates a ring-closure to add a ring.