本文整理汇总了Java中org.jgap.InvalidConfigurationException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidConfigurationException.printStackTrace方法的具体用法?Java InvalidConfigurationException.printStackTrace怎么用?Java InvalidConfigurationException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgap.InvalidConfigurationException
的用法示例。
在下文中一共展示了InvalidConfigurationException.printStackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: learn
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
@Override
protected MLResults learn(AMapping trainingData) {
try {
setUp(trainingData);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
logger.error(e.getMessage());
return null;
}
turn++;
fitness.addToReference(extractPositiveMatches(trainingData));
fitness.fillCachesIncrementally(trainingData);
Integer nGen = (Integer) getParameter(GENERATIONS);
for (int gen = 1; gen <= nGen; gen++) {
gp.evolve();
bestSolutions.add(determineFittest(gp, gen));
}
MLResults result = createSupervisedResult();
return result;
}
示例2: clone
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
@Override
public Object clone() {
try {
return new StringPreprocessingCommand(this.getGPConfiguration(), this.getReturnType(), function, getSubReturnType(), is_mutable);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return this;
}
}
示例3: clone
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
public CommandGene clone() {
try {
return new NumberPropertyPair(config, getReturnType(), getSubReturnType(), mutateable, pairIndex);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return this;
}
}
示例4: clone
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
public CommandGene clone() {
try {
return new DatePropertyPair(config, getReturnType(), getSubReturnType(), mutateable, pairIndex);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return this;
}
}
示例5: clone
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
public CommandGene clone() {
try {
StringPropertyPair newPair = new StringPropertyPair(config, getReturnType(), getSubReturnType(), mutateable, pairIndex);
return newPair;
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return this;
}
}
示例6: clone
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
public CommandGene clone() {
try {
PointSetPropertyPair newPair = new PointSetPropertyPair(config, getReturnType(), getSubReturnType(), mutateable, pairIndex);
return newPair;
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return this;
}
}
示例7: optimize
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
@Override
public void optimize (final IRunExecutable run)
{
Configuration config = new DefaultConfiguration ();
config.setPreservFittestIndividual (true);
try
{
config.setFitnessFunction (new FitnessFunction ()
{
private static final long serialVersionUID = 1L;
private Double m_fBias = null;
@Override
protected double evaluate (IChromosome chromosome)
{
StringBuilder sbResult = new StringBuilder ();
double fResult = run.execute (MetaHeuristicOptimizer.getParametersFromChromosome (chromosome), sbResult, checkBounds ());
chromosome.setApplicationData (sbResult.toString ());
// JGAP maximizes the fitness function, and only positive results are allowed
//return Math.exp (-fResult / 1e8);
//if (m_fBias == null)
// m_fBias = fResult * 10;
//return m_fBias - fResult;
if (m_fBias == null && fResult != Double.MAX_VALUE && fResult != 0)
m_fBias = fResult;
if (m_fBias == null)
return Math.exp (-fResult);
return Math.exp (-fResult / m_fBias);
}
});
// create the chromosome
Gene[] rgSampleGenes = new Gene[run.getParametersCount ()];
for (int i = 0; i < run.getParametersCount (); i++)
rgSampleGenes[i] = new IntegerGene (config, run.getParameterLowerBounds ()[i], run.getParameterUpperBounds ()[i]);
config.setSampleChromosome (new Chromosome (config, rgSampleGenes));
config.setPopulationSize (POPULATION_SIZE);
// create population and evolve it
Genotype population = Genotype.randomInitialGenotype (config);
for (int i = 0; i < MAX_EVOLUTIONS; i++)
{
population.evolve ();
LOGGER.info (population.getFittestChromosome ());
}
setResult (population.getFittestChromosome ());
}
catch (InvalidConfigurationException e)
{
e.printStackTrace ();
}
}
示例8: findOneSequence
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
private Operand findOneSequence ()
{
try
{
// create population and evolve it
IChromosome[] rgChromosomes = new IChromosome[m_listInputOperands.size ()];
int nIdx = 0;
for (Operand op : m_listInputOperands)
{
Gene[] rgGenes = new Gene[m_nElementsCount];
for (int i = 0; i < m_nElementsCount; i++)
{
rgGenes[i] = new IntegerGene (m_config, 0, 2 * m_nElementsCount - 1);
rgGenes[i].setAllele (op.getElements ()[i]);
}
rgChromosomes[nIdx] = new Chromosome (m_config, rgGenes);
rgChromosomes[nIdx].setApplicationData (op);
nIdx++;
}
// evolve the population
Population population = new Population (m_config, rgChromosomes);
Genotype genotype = new Genotype (m_config, population);
for (int i = 0; i < MAX_EVOLUTIONS; i++)
{
genotype.evolve ();
//LOGGER.info (genotype.getFittestChromosome ());
}
IChromosome chromFittest = genotype.getFittestChromosome ();
LOGGER.info (chromFittest);
Operand opRes = (Operand) chromFittest.getApplicationData ();
opRes.m_rgElements = new int[m_nElementsCount];
for (int i = 0; i < m_nElementsCount; i++)
opRes.m_rgElements[i] = (Integer) chromFittest.getGene (i).getAllele ();
return opRes;
}
catch (InvalidConfigurationException e)
{
e.printStackTrace ();
}
return null;
}
示例9: main
import org.jgap.InvalidConfigurationException; //导入方法依赖的package包/类
public static void main( String[] args ) {
// Configure genetic algorithm
PropertiesStore conf = GeneticSynth.getDefaults();
// Take arguments from commandline
String targetWav = "";
int midiNote = -1;
String outputDirectory = "";
for ( String arg : args ) {
String[] split = arg.split( "=", 2 );
// Two essential parameters
if ( split[0].equals( "target" ) ) {
targetWav = split[1];
} else if ( split[0].equals( "midinote" ) ) {
midiNote = Integer.parseInt( split[1] );
} else if ( split[0].equals( "output" ) ) {
outputDirectory = split[1];
} else {
// Store in conf!
PropertiesStore.ConstraintType type = conf.getPropertyType( split[0] );
if ( type != null ) {
switch ( type ) {
case INT:
conf.setProperty( split[0], Integer.parseInt( split[1] ) );
break;
case FLOAT:
conf.setProperty( split[0], Float.parseFloat( split[1] ) );
break;
default:
break;
}
}
}
}
// Error if necessary parameters not specified.
if ( midiNote == -1 ) {
System.err.println( "No midi note specified!" );
System.exit( -1 );
} else if ( targetWav.equals( "" ) ) {
System.err.println( "No target wav file specified!" );
System.exit( -1 );
} else if ( outputDirectory.equals( "" ) ) {
System.err.println( "No output directory specified - no output will be stored!" );
}
// Load wav file
float[] wavBuffer = MonoWaveformManipulator.readWav( targetWav );
if ( wavBuffer == null ) {
System.err.println( "Cannot read wav file" );
System.exit( -1 );
}
// Create genetic algorithm
GeneticSynth gSynth = null;
try {
gSynth = new GeneticSynth( conf, wavBuffer, midiNote, outputDirectory );
gSynth.init();
} catch ( InvalidConfigurationException e1 ) {
e1.printStackTrace();
System.exit( -1 );
}
// Run run run!
gSynth.run();
// Save best individual for inspection
gSynth.saveBestWavAndConf( "./" );
}