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";
552 interfaceDir = pathName + DENOPTIMConstants.FSEP +
"interface";
884 switch (key.toUpperCase())
892 case "NUMPARALLELTASKS=":
894 if (value.length() > 0)
901 case "PARALLELIZATION=":
903 switch (value.toUpperCase())
917 case "PRECISIONLEVEL=":
919 if (value.length() > 0)
928 if (value.length() > 0)
937 if (value.length() > 0)
946 if (value.length() > 0)
953 case "RECORDMATESELECTION=":
955 if (value.length() > 0)
962 case "MONITORDUMPSTEP=":
964 if (value.length() > 0)
974 if (value.length() > 0)
976 seed = Long.parseLong(value);
981 case "MAXTRIESPERPOPULATION=":
983 if (value.length() > 0)
988 case "MAXGENETICOPSATTEMPTS=":
990 if (value.length() > 0)
995 case "INITPOPLNFILE=":
997 if (value.length() > 0)
1004 case "INITMOLSTOFRAGMENTFILE=":
1006 if (value.length() > 0)
1013 case "SORTBYINCREASINGFITNESS":
1019 case "NANFITNESSKILLSEXPERIMENT":
1024 case "LEVELGROWTHMULTIPLIER=":
1026 if (value.length() > 0)
1034 case "LEVELGROWTHSIGMASTEEPNESS=":
1036 if (value.length() > 0)
1044 case "LEVELGROWTHSIGMAMIDDLE=":
1046 if (value.length() > 0)
1054 case "LEVELGROWTHPROBSCHEME=":
1061 case "MOLGROWTHMULTIPLIER=":
1063 if (value.length() > 0)
1071 case "MOLGROWTHSIGMASTEEPNESS=":
1073 if (value.length() > 0)
1081 case "MOLGROWTHSIGMAMIDDLE=":
1083 if (value.length() > 0)
1091 case "MOLGROWTHPROBSCHEME=":
1098 case "CROWDMULTIPLIER=":
1100 if (value.length() > 0)
1107 case "CROWDSIGMASTEEPNESS=":
1109 if (value.length() > 0)
1116 case "CROWDSIGMAMIDDLE=":
1118 if (value.length() > 0)
1125 case "SYMMETRYPROBABILITY=":
1127 if (value.length() > 0)
1134 case "CROWDPROBSCHEME=":
1140 case "NUMGENERATIONS=":
1142 if (value.length() > 0)
1149 case "NUMCHILDREN=":
1151 if (value.length() > 0)
1158 case "CROSSOVERWEIGHT=":
1160 if (value.length() > 0)
1167 case "MUTATIONWEIGHT=":
1169 if (value.length() > 0)
1176 case "COUPLEMUTATIONTOCROSSOVER=":
1178 if (value.length() > 0)
1185 case "PARENTSSURVIVE=":
1187 if (value.length() > 0)
1194 case "EXCLUDEMUTATIONTYPE=":
1196 if (value.length() > 0)
1203 case "CONSTRUCTIONWEIGHT=":
1205 if (value.length() > 0)
1212 case "REPLACEMENTSTRATEGY=":
1214 switch (value.toUpperCase())
1228 case "POPULATIONSIZE=":
1230 if (value.length() > 0)
1239 if (value.length() > 0)
1246 case "MAXRINGSADDEDBYMUTATION=":
1248 if (value.length() > 0)
1255 case "KEEPNEWRINGSYSTEMVERTEXES":
1261 case "KEEPNEWRINGSYSTEMSCAFFOLDS":
1267 case "KEEPNEWRINGSYSTEMFITNESSTRSH=":
1269 if (value.length() > 0)
1276 case "MULTISITEMUTATIONWEIGHTS=":
1278 String[] ws = value.split(
",|\\s+");
1279 List<Double> lst =
new ArrayList<Double>();
1282 if (!w.trim().equals(
""))
1283 lst.add(Double.parseDouble(w));
1286 for (
int i=0; i<lst.size(); i++)
1293 case "XOVERSELECTIONMODE=":
1295 if (value.length() > 0)
1298 if (value.compareToIgnoreCase(
"TS") == 0)
1302 }
else if (value.compareToIgnoreCase(
"RW") == 0)
1306 }
else if (value.compareToIgnoreCase(
"SUS") == 0)
1310 }
else if (value.compareToIgnoreCase(
"RANDOM") == 0)
1316 + value +
"' cannot be interpreted as a "
1317 +
"parent selection strategy.");
1323 case "SELECTIVEPRESSURE=":
1325 if (value.length() > 0)
1333 case "NUMOFFSPRINGFROMXOVER=":
1335 if (value.length() > 0)
1340 +
"up to 2 offspring from crossover, but you "
1346 case "KEEPBESTSIBLING=":
1352 case "MUTATEDGRAPHCHECKFAILTOLERANT=":
1358 case "XOVERGRAPHCHECKFAILTOLERANT=":
1364 case "MUTATIONFAILURETOLERANT=":
1370 case "XOVERFAILURETOLERANT=":
1376 case "BUILDFAILURETOLERANT=":
1382 case "MAXXOVERSUBGRAPHSIZE=":
1384 if (value.length() > 0)
1391 case "WRITEPOPULATIONTOFILE":
1398 msg =
"Keyword " + key +
" is not a known GeneticAlgorithm-"
1399 +
"related keyword. Check input files.";
1410 switch (option.toUpperCase())
1421 case "UNRESTRICTED":
1426 "Unknown growth probability scheme.");
1441 boolean success =
false;
1444 SimpleDateFormat sdf =
new SimpleDateFormat(
"yyyyMMddkkmmss");
1447 dataDir = cdataDir + DENOPTIMConstants.FSEP + str;
1448 success = denoptim.files.FileUtils.createDirectory(
dataDir);
1451 if (!denoptim.files.FileUtils.createDirectory(
interfaceDir))
1479 int nproc = Runtime.getRuntime().availableProcessors();
1505 +
"Output files associated with the current run are "
1519 error =
"Number of children must be a positive number.";
1524 error =
"Number of generations must be a positive number.";
1530 error =
"Number of convergence iterations must be a positive "
1538 error =
"Symmetric molecule probability must be between 0 and 1.";
1544 error =
"Weight of mutation must be a positive number";
1550 error =
"Weight of crossover must be a positive number";
1556 error =
"Weight of construction must be a positive number";
1564 error =
"Cannot find initial population data: " +
initPoplnFile;
1578 if (replacementStrategy < 0 || replacementStrategy > 2)
1580 error =
"Allowed values for replacementStrategy (1-2)";
1586 error =
"Cannot use both graph level or molecular size as criterion "
1587 +
"for controlling the growth of graphs. "
1588 +
"Please, use either of them.";
1606 StringBuilder sb =
new StringBuilder(1024);
1608 for (Field f : this.getClass().getDeclaredFields())
1612 sb.append(f.getName()).append(
" = ").append(
1613 f.get(
this)).append(
NL);
1618 +
" parameters. Cause: " + t);
1624 sb.append(otherCollector.getPrintedList());
1626 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.