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";
575 interfaceDir = pathName + DENOPTIMConstants.FSEP +
"interface";
907 switch (key.toUpperCase())
915 case "NUMPARALLELTASKS=":
917 if (value.length() > 0)
924 case "PARALLELIZATION=":
926 switch (value.toUpperCase())
940 case "PRECISIONLEVEL=":
942 if (value.length() > 0)
951 if (value.length() > 0)
960 if (value.length() > 0)
969 if (value.length() > 0)
976 case "RECORDMATESELECTION=":
978 if (value.length() > 0)
985 case "MONITORDUMPSTEP=":
987 if (value.length() > 0)
997 if (value.length() > 0)
999 seed = Long.parseLong(value);
1004 case "MAXTRIESPERPOPULATION=":
1006 if (value.length() > 0)
1011 case "MAXGENETICOPSATTEMPTS=":
1013 if (value.length() > 0)
1018 case "INITPOPLNFILE=":
1020 if (value.length() > 0)
1027 case "INITMOLSTOFRAGMENTFILE=":
1029 if (value.length() > 0)
1036 case "SORTBYINCREASINGFITNESS":
1042 case "NANFITNESSKILLSEXPERIMENT":
1047 case "LEVELGROWTHMULTIPLIER=":
1049 if (value.length() > 0)
1057 case "LEVELGROWTHSIGMASTEEPNESS=":
1059 if (value.length() > 0)
1067 case "LEVELGROWTHSIGMAMIDDLE=":
1069 if (value.length() > 0)
1077 case "LEVELGROWTHPROBSCHEME=":
1084 case "MOLGROWTHMULTIPLIER=":
1086 if (value.length() > 0)
1094 case "MOLGROWTHSIGMASTEEPNESS=":
1096 if (value.length() > 0)
1104 case "MOLGROWTHSIGMAMIDDLE=":
1106 if (value.length() > 0)
1114 case "MOLGROWTHPROBSCHEME=":
1121 case "CROWDMULTIPLIER=":
1123 if (value.length() > 0)
1130 case "CROWDSIGMASTEEPNESS=":
1132 if (value.length() > 0)
1139 case "CROWDSIGMAMIDDLE=":
1141 if (value.length() > 0)
1148 case "SYMMETRYPROBABILITY=":
1150 if (value.length() > 0)
1157 case "CROWDPROBSCHEME=":
1163 case "NUMGENERATIONS=":
1165 if (value.length() > 0)
1172 case "NUMCHILDREN=":
1174 if (value.length() > 0)
1181 case "CROSSOVERWEIGHT=":
1183 if (value.length() > 0)
1190 case "MUTATIONWEIGHT=":
1192 if (value.length() > 0)
1199 case "COUPLEMUTATIONTOCROSSOVER=":
1201 if (value.length() > 0)
1208 case "PARENTSSURVIVE=":
1210 if (value.length() > 0)
1217 case "EXCLUDEMUTATIONTYPE=":
1219 if (value.length() > 0)
1226 case "CONSTRUCTIONWEIGHT=":
1228 if (value.length() > 0)
1235 case "REPLACEMENTSTRATEGY=":
1237 switch (value.toUpperCase())
1251 case "POPULATIONSIZE=":
1253 if (value.length() > 0)
1262 if (value.length() > 0)
1269 case "MAXRINGSADDEDBYMUTATION=":
1271 if (value.length() > 0)
1278 case "KEEPNEWRINGSYSTEMVERTEXES":
1284 case "KEEPNEWRINGSYSTEMSCAFFOLDS":
1290 case "KEEPNEWRINGSYSTEMFITNESSTRSH=":
1292 if (value.length() > 0)
1299 case "MULTISITEMUTATIONWEIGHTS=":
1301 String[] ws = value.split(
",|\\s+");
1302 List<Double> lst =
new ArrayList<Double>();
1305 if (!w.trim().equals(
""))
1306 lst.add(Double.parseDouble(w));
1309 for (
int i=0; i<lst.size(); i++)
1316 case "XOVERSELECTIONMODE=":
1318 if (value.length() > 0)
1321 if (value.compareToIgnoreCase(
"TS") == 0)
1325 }
else if (value.compareToIgnoreCase(
"RW") == 0)
1329 }
else if (value.compareToIgnoreCase(
"SUS") == 0)
1333 }
else if (value.compareToIgnoreCase(
"RANDOM") == 0)
1339 + value +
"' cannot be interpreted as a "
1340 +
"parent selection strategy.");
1346 case "SELECTIVEPRESSURE=":
1348 if (value.length() > 0)
1356 case "NUMOFFSPRINGFROMXOVER=":
1358 if (value.length() > 0)
1363 +
"up to 2 offspring from crossover, but you "
1369 case "KEEPBESTSIBLING=":
1375 case "MUTATEDGRAPHCHECKFAILTOLERANT=":
1381 case "XOVERGRAPHCHECKFAILTOLERANT=":
1387 case "MUTATIONFAILURETOLERANT=":
1393 case "XOVERFAILURETOLERANT=":
1399 case "BUILDFAILURETOLERANT=":
1405 case "MAXXOVERSUBGRAPHSIZE=":
1407 if (value.length() > 0)
1414 case "MAXXOVERCOMPATVRTXPAIRS=":
1416 if (value.length() > 0)
1423 case "MAXXOVERENDPOINTSCOMBINATIONS=":
1425 if (value.length() > 0)
1432 case "MAXXOVERENDPOINTSPERMUTATIONS=":
1434 if (value.length() > 0)
1441 case "MAXAPMAPPINGCOMBINATIONS=":
1443 if (value.length() > 0)
1450 case "WRITEPOPULATIONTOFILE":
1457 msg =
"Keyword " + key +
" is not a known GeneticAlgorithm-"
1458 +
"related keyword. Check input files.";
1469 switch (option.toUpperCase())
1480 case "UNRESTRICTED":
1485 "Unknown growth probability scheme.");
1500 boolean success =
false;
1503 SimpleDateFormat sdf =
new SimpleDateFormat(
"yyyyMMddkkmmss");
1506 dataDir = cdataDir + DENOPTIMConstants.FSEP + str;
1507 success = denoptim.files.FileUtils.createDirectory(
dataDir);
1510 if (!denoptim.files.FileUtils.createDirectory(
interfaceDir))
1538 int nproc = Runtime.getRuntime().availableProcessors();
1564 +
"Output files associated with the current run are "
1578 error =
"Number of children must be a positive number.";
1583 error =
"Number of generations must be a positive number.";
1589 error =
"Number of convergence iterations must be a positive "
1597 error =
"Symmetric molecule probability must be between 0 and 1.";
1603 error =
"Weight of mutation must be a positive number";
1609 error =
"Weight of crossover must be a positive number";
1615 error =
"Weight of construction must be a positive number";
1623 error =
"Cannot find initial population data: " +
initPoplnFile;
1637 if (replacementStrategy < 0 || replacementStrategy > 2)
1639 error =
"Allowed values for replacementStrategy (1-2)";
1645 error =
"Cannot use both graph level or molecular size as criterion "
1646 +
"for controlling the growth of graphs. "
1647 +
"Please, use either of them.";
1665 StringBuilder sb =
new StringBuilder(1024);
1667 for (Field f : this.getClass().getDeclaredFields())
1671 sb.append(f.getName()).append(
" = ").append(
1672 f.get(
this)).append(
NL);
1677 +
" parameters. Cause: " + t);
1683 sb.append(otherCollector.getPrintedList());
1685 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()
int maxXoverEndPointsCombinations
Limit to the number of combinations of subgraph end points considered when locating crossover sites.
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 maxCompatibleVrtxPairs
Limit to the number of compatible vertex pairs to consider for crossover.
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 maxAPMappingCombinations
Limit to the number of AP-AP mapping combinations considered by denoptim.fragspace....
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 maxXoverEndPointsPermutations
Limit to the number of permutations of subgraph end points considered for each combination when locat...
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.