⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evomany.java~

📁 Java遗传算法库
💻 JAVA~
字号:
/*
 * MonicaServer.java
 *
 * Created on 16 April 2001, 17:12
 */

package es.pj.circuits.control;

import es.control.*;
import es.deploy.*;
import es.evolve.*;
import es.experiment.*;
import es.*;

import es.pj.circuits.*;
import es.pj.circuits.experiment.*;
import es.pj.circuits.fpgaft.*;

import es.pj.gral.*;

import islandev.IslandsEvolutionServer;

import debug.DebugLib;

import java.util.Vector;
import java.rmi.*;
import java.io.File;

/**
 *
 * @author  Michael Garvie
 * @version 
 */
public abstract class EvoMany
{
     static Vector taskQ = new Vector();
     static Vector taskQNames = new Vector();
    
    static String logDir;
    static String logFileName;
    
    public static void main( String[] args )
    {
        DebugLib.trcLogger.isLogging = true;
        DebugLib.logFileName = logFileName = "ms-log.txt";
        logDir = args[ 0 ];
        addDLatch(  );
        
        try
        {
            IslandsEvolutionServer ms = new IslandsEvolutionServer( "MonicaServer", taskQ, taskQNames, logDir, 0.5 );
            ms.bindServer();
            //MonicaServer ms = new MonicaServer( "MonicaServer", taskQ, taskQNames, args[ 0 ], 0.5 );
        }catch( java.rmi.RemoteException e )
        {
            System.out.println( e );
        }
        
    }

    private static void addDLatch( )
    {
        String dirName = "EdgeDLatch";
        
        boolean varSized = false;
        
        // A - Genetic Algorithms Properties
         final int POP_SIZE = 32;
         final double XOVER_PROB = 0.4;
         final double MUTATION_PROB = 0.6;
         final int NUM_OF_ELITES = 2;

        // D -  Circuit Structure Properties
         final int BITS_PER_VARIABLE = varSized? 5:5;
         final int LUT_INPUTS = 2;

         final int SIMULATOR_GATE_DELAY = 0;
         final double T_SETUP = 0.45;

        // E - Experiment Properties
        Experiment experiment = new EdgeDLExperiment( T_SETUP );

        // M - Log Properties
         int DUMP_POP_EVERY = 100;
        
        // D - DEPLOYMENT set up
         //ElementDelayModel delayModel = new ConstantDelayModel( SIMULATOR_GATE_DELAY );
        ElementDelayModel delayModel = new GaussianDelayModel( 0.5, 0.5 );
        
        CircuitMapping circuitMapping;
        if( varSized )
        {
            circuitMapping = new LUTVariableSizedAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs(), BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
        }else
        {
            circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs(), BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
        }
        //SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        SimulatorSimpleCircuit circuit = new SimulatorSimpleCircuit( circuitMapping );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );

        // A - Genetic Operators Set up
        int genotypeLength;
        int lutSize = 1 << LUT_INPUTS;
        int blockSize = lutSize + LUT_INPUTS * BITS_PER_VARIABLE;
        if( varSized )
        {
            genotypeLength = blockSize * 4;
        }else
        {
            genotypeLength = ( ( 1 << BITS_PER_VARIABLE ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + LUT_INPUTS * BITS_PER_VARIABLE );
        }

        // final Genotype SEED0 = new Genotype( "RrPlOkOVTb^Q^`GBQsC7Au^cjQ", genotypeLength, 6 );
        // final Genotype[] SEEDS = { SEED0, SEED1, SEED2 };
        // final Genotype[] SEEDS = { SEED0, SEED1 };
         //final Genotype[] SEEDS = { SEED0 };
         final Genotype[] SEEDS = { };

        //GeneticOperator m = new ExactGenotypeMutator( GENOTYPE_MUT );
         GeneticOperator m = new SAGAMutator( 1, 10 );
         GeneticOperator spxo = new SinglePointXOver();        
        GeneticOperator bmin0 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize );
        GeneticOperator bmin1 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize + BITS_PER_VARIABLE );
        GeneticOperator bc = new BlockCopy ( blockSize, blockSize );
        
        GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
        double[] opsProbs = { 0.3, 0.1, 0.2, 0.2, 0.2 };
       
        Selector selector = new RankSelector(  );

        Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );

        int nrEvals = 3;
        InteractionModel sim = new StandardInteractionModel( evolver, deployment, experiment );
        InteractionModel noisyIm = new NoisyIM( sim, deployment, nrEvals);
        InteractionModel interactionModel;
        Monica monica = new Monica( noisyIm, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );        
        
        monica.setName( dirName );
        taskQ.add( monica );
        taskQNames.add( dirName );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName );
    }    

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -