Package ec.util

Examples of ec.util.Parameter


        return prefixField;
        }
    public void loadParameters()
        {
        numGensField.setText(console.parameters.getStringWithDefault(
                new Parameter(EvolutionState.P_GENERATIONS),null,"1"));
        quitOnRunCompleteCheckbox.setSelected(console.parameters.getBoolean(new Parameter(EvolutionState.P_QUITONRUNCOMPLETE),null,true));
        evalThreadsField.setText(console.parameters.getStringWithDefault(new Parameter(Evolve.P_EVALTHREADS),null,"1"));
        breedThreadsField.setText(console.parameters.getStringWithDefault(new Parameter(Evolve.P_BREEDTHREADS),null,"1"));
        checkpointCheckBox.setSelected(console.parameters.getBoolean(new Parameter(EvolutionState.P_CHECKPOINT),null,false));
        checkpointModuloField.setText(console.parameters.getStringWithDefault(new Parameter(EvolutionState.P_CHECKPOINTMODULO),null,"10"));
        prefixField.setText(console.parameters.getStringWithDefault(new Parameter(EvolutionState.P_CHECKPOINTPREFIX),null,"gc"));
        numJobsField.setText("1");
        jobFilePrefixField.setText(console.parameters.getStringWithDefault(new Parameter(P_JOBFILEPREFIX),null,""));
       
        resizeSeedTable();
        }
View Full Code Here


            // numJobs * numThreads seeds are read.  If there are not enough seeds,
            // print a warning and generate the remaining necessary.
            int numJobs = 0;
            try { numJobs = Integer.parseInt(numJobsField.getText()); }
            catch(NumberFormatException e) { }
            int evalThreads = getThreadCount(console.parameters.getString(new Parameter(Evolve.P_EVALTHREADS),null));
            int breedThreads = getThreadCount(console.parameters.getString(new Parameter(Evolve.P_BREEDTHREADS),null));
            int numThreads = Math.max(evalThreads, breedThreads);
       
            // Read seeds for threads first
            // TODO Make this more robust (i.e. ensure we're reading integers).
            int job = 0;
View Full Code Here

                {
                public void keyPressed(java.awt.event.KeyEvent e)
                    {   
                    if (e.getKeyCode() == KeyEvent.VK_ENTER)
                        {
                        console.parameters.set(new Parameter(P_JOBFILEPREFIX), ((JTextField)e.getSource()).getText());
                        }
                    else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                        {
                        ((JTextField)e.getSource()).setText(console.parameters.getStringWithDefault(new Parameter(P_JOBFILEPREFIX),null,""));
                        }
                    }
                });
            }
        return jobFilePrefixField;
View Full Code Here

    public void setup(final EvolutionState state, final Parameter base)
        {
        super.setup(state, base);
        String wp = state.parameters.getStringWithDefault(base.push(P_WHICH_PROBLEM), null, "");
        int i, j, k;
        Parameter p = new Parameter(Initializer.P_POP);
        int genomeSize = state.parameters.getInt(p.push(Population.P_SUBPOP).push("0").push(Subpopulation.P_SPECIES).push(P_GENOME_SIZE), null, 1);
        String noiseStr = state.parameters.getString(base.push(P_NOISE), null);
        for (i = 0; i < noiseTypes.length; i++)
            if (noiseStr.equals(noiseTypes[i]))
                noise = i;
               
View Full Code Here

                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < noiseTypes.length; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case ELLIPSOIDAL:// f2
                /*
                 * separable ellipsoid with monotone transformation with noiseless
                 * condition 1e6 and noisy condition 1e4
                 */
                fAdd = fOpt;
                if (noise == NONE)
                    {
                    condition = 1e6;
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = genome[i] - xOpt[i];
                        }
                    }
                else
                    {
                    condition = 1e4;
                    fAdd = fOpt;

                    /* BOUNDARY HANDLING */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmp = Math.abs(genome[i]) - 5.;
                        if (tmp > 0.)
                            {
                            fPen += tmp * tmp;
                            }
                        }
                    fAdd += 100. * fPen;

                    /* TRANSFORMATION IN SEARCH SPACE */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = 0.;
                        for (j = 0; j < genomeSize; j++)
                            {
                            tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                            }
                        }
                    }

                monotoneTFosc(tmx);
                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    value += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
                    }

                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       

            case RASTRIGIN:// f3
                /* Rastrigin with monotone transformation separable "condition" 10 */
                condition = 10;
                beta = 0.2;
                fAdd = fOpt;
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = genome[i] - xOpt[i];
                    }
                monotoneTFosc(tmx);
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = ((double) i) / ((double) (genomeSize - 1));
                    if (tmx[i] > 0)
                        tmx[i] = Math.pow(tmx[i], 1 + beta * tmp * Math.sqrt(tmx[i]));
                    tmx[i] = Math.pow(Math.sqrt(condition), tmp) * tmx[i];
                    }
                /* COMPUTATION core */
                tmp = 0;
                tmp2 = 0;
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp += Math.cos(2 * Math.PI * tmx[i]);
                    tmp2 += tmx[i] * tmx[i];
                    }
                value = 10 * (genomeSize - tmp) + tmp2;
                value += fAdd;

                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case BUCHE_RASTRIGIN:// f4
                /* skew Rastrigin-Bueche, condition 10, skew-"condition" 100 */
                condition = 10.0;
                alpha = 100;
                fAdd = fOpt;
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.;
                    if (tmp > 0.)
                        fPen += tmp * tmp;
                    }
                fPen *= 1e2;
                fAdd += fPen;

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = genome[i] - xOpt[i];
                    }

                monotoneTFosc(tmx);
                for (i = 0; i < genomeSize; i++)
                    {
                    if (i % 2 == 0 && tmx[i] > 0)
                        tmx[i] = Math.sqrt(alpha) * tmx[i];
                    tmx[i] = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
                    }
                /* COMPUTATION core */
                tmp = 0.0;
                tmp2 = 0.0;
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp += Math.cos(2 * Math.PI * tmx[i]);
                    tmp2 += tmx[i] * tmx[i];
                    }
                value = 10 * (genomeSize - tmp) + tmp2;
                value += fAdd;

                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case LINEAR_SLOPE:// f5
                /* linear slope */
                alpha = 100;
                fAdd = fOpt;
                /* BOUNDARY HANDLING */
                /* move "too" good coordinates back into domain */
                for (i = 0; i < genomeSize; i++)
                    {
                    if ((xOpt[i] == 5.) && (genome[i] > 5))
                        tmx[i] = 5.;
                    else if ((xOpt[i] == -5.) && (genome[i] < -5))
                        tmx[i] = -5.;
                    else
                        tmx[i] = genome[i];
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    if (xOpt[i] > 0)
                        {
                        value -= Math.pow(Math.sqrt(alpha), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
                        }
                    else
                        {
                        value += Math.pow(Math.sqrt(alpha), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
                        }
                    }
                value += fAdd;

                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case ATTRACTIVE_SECTOR:// f6
                /* attractive sector function */
                alpha = 100.0;
                fAdd = fOpt;

                /* BOUNDARY HANDLING */
                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {

                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += linearTF[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    if (tmx[i] * xOpt[i] > 0)
                        tmx[i] *= alpha;
                    value += tmx[i] * tmx[i];
                    }

                /* monotoneTFosc... */
                if (value > 0)
                    {
                    value = Math.pow(Math.exp(Math.log(value) / 0.1 + 0.49 * (Math.sin(Math.log(value) / 0.1) + Math.sin(0.79 * Math.log(value) / 0.1))), 0.1);
                    }
                else if (value < 0)
                    {
                    value = -Math.pow(Math.exp(Math.log(-value) / 0.1 + 0.49 * (Math.sin(0.55 * Math.log(-value) / 0.1) + Math.sin(0.31 * Math.log(-value) / 0.1))), 0.1);
                    }
                value = Math.pow(value, 0.9);
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case STEP_ELLIPSOIDAL:// f7
                /* step-ellipsoid, condition 100 */
                condition = 100.0;
                alpha = 10.0;
                fAdd = fOpt;
                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.0;
                    if (tmp > 0.0)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                if (noise == NONE)
                    fAdd += fPen;
                else
                    fAdd += 100. * fPen;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {

                    tmpvect[i] = 0.0;
                    tmp = Math.sqrt(Math.pow(condition / 10., ((double) i) / ((double) (genomeSize - 1))));
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += tmp * rot2[i][j] * (genome[j] - xOpt[j]);
                        }

                    }
                x1 = tmpvect[0];

                for (i = 0; i < genomeSize; i++)
                    {
                    if (Math.abs(tmpvect[i]) > 0.5)
                        tmpvect[i] = Math.round(tmpvect[i]);
                    else
                        tmpvect[i] = Math.round(alpha * tmpvect[i]) / alpha;
                    }

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * tmpvect[j];
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    value += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
                    }
                value = 0.1 * Math.max(1e-4 * Math.abs(x1), value);
                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case ROSENBROCK:// f8
                /* Rosenbrock, non-rotated */
                fAdd = fOpt;
                if (noise == NONE)
                    {
                    /* TRANSFORMATION IN SEARCH SPACE */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = scales * (genome[i] - xOpt[i]) + 1;
                        }
                    }
                else
                    {
                    /* BOUNDARY HANDLING */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmp = Math.abs(genome[i]) - 5.;
                        if (tmp > 0.)
                            {
                            fPen += tmp * tmp;
                            }
                        }
                    fAdd += 100.0 * fPen;
                    /* TRANSFORMATION IN SEARCH SPACE */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = scales * (genome[i] - 0.75 * xOpt[i]) + 1;
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = (tmx[i] * tmx[i] - tmx[i + 1]);
                    value += tmp * tmp;
                    }
                value *= 1e2;
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = (tmx[i] - 1.);
                    value += tmp * tmp;
                    }

                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    case GAUSSIAN_MODERATE:
                        value = fGauss(value, 0.01, state.random[threadnum]);
                        break;
                    case UNIFORM_MODERATE:
                        value = fUniform(value, 0.01 * (0.49 + 1. / genomeSize), 0.01, state.random[threadnum]);
                        break;
                    case CAUCHY_MODERATE:
                        value = fCauchy(value, 0.01, 0.05, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < noiseTypes.length; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }                      
                       
                value += fAdd;

                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;

                       
                       
                       
            case ROSENBROCK_ROTATED:// f9
                /* Rosenbrock, rotated */
                fAdd = fOpt;

                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.5;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += linearTF[i][j] * genome[j];
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = (tmx[i] * tmx[i] - tmx[i + 1]);
                    value += tmp * tmp;
                    }
                value *= 1e2;
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = (tmx[i] - 1.);
                    value += tmp * tmp;
                    }

                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case ELLIPSOIDAL_2:// f10
                /* ellipsoid with monotone transformation, condition 1e6 */
                condition = 1e6;

                fAdd = fOpt;
                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                monotoneTFosc(tmx);
                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    fAdd += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
                    }
                value = fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case DISCUS:// f11
                        /* DISCUS (tablet) with monotone transformation, condition 1e6 */
                condition = 1e6;
                fAdd = fOpt;
                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                monotoneTFosc(tmx);

                /* COMPUTATION core */
                value = condition * tmx[0] * tmx[0];
                for (i = 1; i < genomeSize; i++)
                    {
                    value += tmx[i] * tmx[i];
                    }
                value += fAdd; /* without noise */
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case BENT_CIGAR:// f12
                /* bent cigar with asymmetric space distortion, condition 1e6 */
                condition = 1e6;
                beta = 0.5;
                fAdd = fOpt;
                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    if (tmpvect[i] > 0)
                        {
                        tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
                        }
                    }

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * tmpvect[j];
                        }
                    }

                /* COMPUTATION core */
                value = tmx[0] * tmx[0];
                for (i = 1; i < genomeSize; i++)
                    {
                    value += condition * tmx[i] * tmx[i];
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case SHARP_RIDGE:// f13
                /* sharp ridge */
                condition = 10.0;
                alpha = 100.0;

                fAdd = fOpt;
                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += linearTF[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                /* COMPUTATION core */
                for (i = 1; i < genomeSize; i++)
                    {
                    value += tmx[i] * tmx[i];
                    }
                value = alpha * Math.sqrt(value);
                value += tmx[0] * tmx[0];
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case DIFFERENT_POWERS:// f14
                /* sum of different powers, between x^2 and x^6 */
                alpha = 4.0;
                fAdd = fOpt;
                if (noise != NONE)
                    {
                    /* BOUNDARY HANDLING */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmp = Math.abs(genome[i]) - 5.;
                        if (tmp > 0.)
                            {
                            fPen += tmp * tmp;
                            }
                        }
                    fAdd += 100. * fPen;
                    }

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    value += Math.pow(Math.abs(tmx[i]), 2. + alpha * ((double) i) / ((double) (genomeSize - 1)));
                    }
                value = Math.sqrt(value);
                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case RASTRIGIN_2:// f15
                /* Rastrigin with asymmetric non-linear distortion, "condition" 10 */
                condition = 10.0;
                beta = 0.2;
                tmp = tmp2 = 0;

                fAdd = fOpt;
                /* BOUNDARY HANDLING */

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                monotoneTFosc(tmpvect);
                for (i = 0; i < genomeSize; i++)
                    {
                    if (tmpvect[i] > 0)
                        tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
                    }
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += linearTF[i][j] * tmpvect[j];
                        }
                    }
                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp += Math.cos(2. * Math.PI * tmx[i]);
                    tmp2 += tmx[i] * tmx[i];
                    }
                value = 10. * ((double) genomeSize - tmp) + tmp2;
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case WEIERSTRASS:// f16
                /* Weierstrass, condition 100 */
                condition = 100.0;
                fPen = 0;

                fAdd = fOpt;

                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.;
                    if (tmp > 0.)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                fAdd += 10. / (double) genomeSize * fPen;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    }

                monotoneTFosc(tmpvect);
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += linearTF[i][j] * tmpvect[j];
                        }
                    }
                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = 0.0;
                    for (j = 0; j < 12; j++)
                        {
                        tmp += Math.cos(2 * Math.PI * (tmx[i] + 0.5) * bK[j]) * aK[j];
                        }
                    value += tmp;
                    }
                value = 10. * Math.pow(value / (double) genomeSize - f0, 3.);
                value += fAdd;
                ;

                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case SCHAFFERS_F7:// f17
                /*
                 * Schaffers F7 with asymmetric non-linear transformation, condition
                 * 10
                 */
                condition = 10.0;
                beta = 0.5;
                fAdd = fOpt;

                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.;
                    if (tmp > 0.)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                fAdd += 10. * fPen;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    if (tmpvect[i] > 0)
                        tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
                    }

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    tmp = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += tmp * rot2[i][j] * tmpvect[j];
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = tmx[i] * tmx[i] + tmx[i + 1] * tmx[i + 1];
                    value += Math.pow(tmp, 0.25) * (Math.pow(Math.sin(50 * Math.pow(tmp, 0.1)), 2.0) + 1.0);
                    }
                value = Math.pow(value / (double) (genomeSize - 1), 2.);
                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case SCHAFFERS_F7_2:// f18
                /*
                 * Schaffers F7 with asymmetric non-linear transformation, condition
                 * 1000
                 */
                condition = 1e3;
                beta = 0.5;
                fPen = 0.0;
                fAdd = fOpt;
                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.;
                    if (tmp > 0.)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                fAdd += 10. * fPen;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
                        }
                    if (tmpvect[i] > 0)
                        tmpvect[i] = Math.pow(tmpvect[i], 1. + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
                    }

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    tmp = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += tmp * rot2[i][j] * tmpvect[j];
                        }
                    }

                /* COMPUTATION core */
                for (i = 0; i < genomeSize - 1; i++)
                    {
                    tmp = tmx[i] * tmx[i] + tmx[i + 1] * tmx[i + 1];
                    value += Math.pow(tmp, 0.25) * (Math.pow(Math.sin(50. * Math.pow(tmp, 0.1)), 2.) + 1.);
                    }
                value = Math.pow(value / (double) (genomeSize - 1), 2.);
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case GRIEWANK_ROSENBROCK:// f19
                /* F8f2 sum of Griewank-Rosenbrock 2-D blocks */
                fAdd = fOpt;
                if (noise == NONE)
                    {
                    /* TRANSFORMATION IN SEARCH SPACE */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = 0.5;
                        for (j = 0; j < genomeSize; j++)
                            {
                            tmx[i] += linearTF[i][j] * genome[j];
                            }
                        }
                    /* COMPUTATION core */
                    for (i = 0; i < genomeSize - 1; i++)
                        {
                        tmp2 = tmx[i] * tmx[i] - tmx[i + 1];
                        f2 = 100. * tmp2 * tmp2;
                        tmp2 = 1 - tmx[i];
                        f2 += tmp2 * tmp2;
                        tmp += f2 / 4000. - Math.cos(f2);
                        }
                    value = 10. + 10. * tmp / (double) (genomeSize - 1);
                    }
                else
                    {
                    /* BOUNDARY HANDLING */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmp = Math.abs(genome[i]) - 5.0;
                        if (tmp > 0.0)
                            {
                            fPen += tmp * tmp;
                            }
                        }
                    fAdd += 100.0 * fPen;

                    /* TRANSFORMATION IN SEARCH SPACE */
                    for (i = 0; i < genomeSize; i++)
                        {
                        tmx[i] = 0.5;
                        for (j = 0; j < genomeSize; j++)
                            {
                            tmx[i] += scales * rotation[i][j] * genome[j];
                            }
                        }
                    /* COMPUTATION core */
                    tmp = 0.;
                    for (i = 0; i < genomeSize - 1; i++)
                        {
                        f2 = 100. * (tmx[i] * tmx[i] - tmx[i + 1]) * (tmx[i] * tmx[i] - tmx[i + 1]) + (1 - tmx[i]) * (1 - tmx[i]);
                        tmp += f2 / 4000. - Math.cos(f2);
                        }
                    value = 1. + 1. * tmp / (double) (genomeSize - 1);
                    }
                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case SCHWEFEL:// f20
                /* Schwefel with tridiagonal variable transformation */
                condition = 10.0;
                fPen = 0.0;
                fAdd = fOpt;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmpvect[i] = 2. * genome[i];
                    if (xOpt[i] < 0.)
                        tmpvect[i] *= -1.;
                    }

                tmx[0] = tmpvect[0];
                for (i = 1; i < genomeSize; i++)
                    {
                    tmx[i] = tmpvect[i] + 0.25 * (tmpvect[i - 1] - 2. * Math.abs(xOpt[i - 1]));
                    }

                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] -= 2 * Math.abs(xOpt[i]);
                    tmx[i] *= Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
                    tmx[i] = 100. * (tmx[i] + 2 * Math.abs(xOpt[i]));
                    }

                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(tmx[i]) - 500.0;
                    if (tmp > 0.)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                fAdd += 0.01 * fPen;

                /* COMPUTATION core */
                for (i = 0; i < genomeSize; i++)
                    {
                    value += tmx[i] * Math.sin(Math.sqrt(Math.abs(tmx[i])));
                    }
                value = 0.01 * ((418.9828872724339) - value / (double) genomeSize);
                value += fAdd;/* without noise */
                fit = (-value);
                ((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
            break;
                       
                       
                       
            case GALLAGHER_GAUSSIAN_101ME:// f21
                /*
                 * Gallagher with 101 Gaussian peaks, condition up to 1000, one
                 * global rotation
                 */
                a = 0.1;
                fac = -0.5 / (double) genomeSize;
                fAdd = fOpt;

                /* BOUNDARY HANDLING */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmp = Math.abs(genome[i]) - 5.;
                    if (tmp > 0.)
                        {
                        fPen += tmp * tmp;
                        }
                    }
                if (noise == NONE)
                    fAdd += fPen;
                else
                    fAdd += 100. * fPen;

                /* TRANSFORMATION IN SEARCH SPACE */
                for (i = 0; i < genomeSize; i++)
                    {
                    tmx[i] = 0.0;
                    for (j = 0; j < genomeSize; j++)
                        {
                        tmx[i] += rotation[i][j] * genome[j];
                        }
                    }

                /* COMPUTATION core */
                if (noise == NONE)
                    for (i = 0; i < NHIGHPEAKS21; i++)
                        {
                        tmp2 = 0.0;
                        for (j = 0; j < genomeSize; j++)
                            {
                            tmp = (tmx[j] - xLocal[j][i]);
                            tmp2 += arrScales[i][j] * tmp * tmp;
                            }
                        tmp2 = peakvalues[i] * Math.exp(fac * tmp2);
                        f = Math.max(f, tmp2);
                        }
                else
                    /* COMPUTATION core */
                    for (i = 0; i < NHIGHPEAKS21; i++)
                        {
                        tmp2 = 0.;
                        for (j = 0; j < genomeSize; j++)
                            {
                            tmp2 += arrScales[i][j] * (tmx[j] - xLocal[j][i]) * (tmx[j] - xLocal[j][i]);
                            }
                        tmp2 = peakvalues[i] * Math.exp(fac * tmp2);
                        f = Math.max(f, tmp2);
                        }

                f = 10.0 - f;
                /* monotoneTFosc */
                if (f > 0)
                    {
                    value = Math.log(f) / a;
                    value = Math.pow(Math.exp(value + 0.49 * (Math.sin(value) + Math.sin(0.79 * value))), a);
                    }
                else if (f < 0)
                    {
                    value = Math.log(-f) / a;
                    value = -Math.pow(Math.exp(value + 0.49 * (Math.sin(0.55 * value) + Math.sin(0.31 * value))), a);
                    }
                else
                    value = f;

                value *= value;
                switch (noise)
                    {
                    case NONE:
                        break;
                    case GAUSSIAN:
                        value = fGauss(value, 1.0, state.random[threadnum]);
                        break;
                    case UNIFORM:
                        value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
                        break;
                    case CAUCHY:
                        value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
                        break;
                    default:
                        String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
                        for (i = 0; i < 4; i++)
                            outputStr += noiseTypes[i] + "\n";
                        state.output.fatal(outputStr, new Parameter(P_NOISE));
                        break;
                    }
                value += fAdd;
                ; /* without noise */

 
View Full Code Here

        if (individualsList == null)
            {
            individualsList = new JList();
            individualsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
            int size = -1;
            if (console.parameters.exists(new Parameter("pop.subpop."+subPopNum+".size"),null))
                {
                size = console.parameters.getInt(new Parameter("pop.subpop."+subPopNum+".size"),null);
                }
            else if (console.parameters.exists(new Parameter("pop.default-subpop"), null));
                    {
                    int defaultsub = console.parameters.getInt(new Parameter("pop.default-subpop"), null);
                    if (defaultsub >= 0)
                        {
                        size = console.parameters.getInt(new Parameter("pop.subpop." + defaultsub + ".size"), null);
                        }
                    }
            DefaultListModel model = new DefaultListModel();
            for (int i = 0; i < size; ++i)
                {
View Full Code Here

    public void setup(EvolutionState state, Parameter base)
        {
        super.setup(state, base); // unnecessary really

        Parameter def = defaultBase();
        int numFitnesses;

        numFitnesses = state.parameters.getInt(base.push(P_NUMOBJECTIVES), def.push(P_NUMOBJECTIVES), 0);
        if (numFitnesses <= 0)
            state.output.fatal("The number of objectives must be an integer >= 1.", base.push(P_NUMOBJECTIVES), def.push(P_NUMOBJECTIVES));

        objectives = new double[numFitnesses];
        maxObjective = new double[numFitnesses];
        minObjective = new double[numFitnesses];
        maximize = new boolean[numFitnesses];
               
        for (int i = 0; i < numFitnesses; i++)
            {
            // load default globals
            minObjective[i] = state.parameters.getDoubleWithDefault(base.push(P_MINOBJECTIVES), def.push(P_MINOBJECTIVES), 0.0);
            maxObjective[i] = state.parameters.getDoubleWithDefault(base.push(P_MAXOBJECTIVES), def.push(P_MAXOBJECTIVES), 1.0);
            maximize[i] = state.parameters.getBoolean(base.push(P_MAXIMIZE), def.push(P_MAXIMIZE), true);

            // load specifics if any
            minObjective[i] = state.parameters.getDoubleWithDefault(base.push(P_MINOBJECTIVES).push("" + i), def.push(P_MINOBJECTIVES).push("" + i), minObjective[i]);
            maxObjective[i] = state.parameters.getDoubleWithDefault(base.push(P_MAXOBJECTIVES).push("" + i), def.push(P_MAXOBJECTIVES).push("" + i), maxObjective[i]);
            maximize[i] = state.parameters.getBoolean(base.push(P_MAXIMIZE).push("" + i), def.push(P_MAXIMIZE).push("" + i), maximize[i]);
           
            // test for validity
            if (minObjective[i] >= maxObjective[i])
                state.output.error("For objective " + i + "the min fitness must be strictly less than the max fitness.");
            }
View Full Code Here

    public static final String P_MULTI = "multi";

    /** Returns the default base. */
    public static final Parameter base()
        {
        return new Parameter(P_MULTI);
        }
View Full Code Here

    public static final String P_RULE = "rule";

    /** Returns the default base. */
    public static final Parameter base()
        {
        return new Parameter(P_RULE);
        }
View Full Code Here

    public static final String P_SELECT = "select";

    /** Returns the default base. */
    public static final Parameter base()
        {
        return new Parameter(P_SELECT);
        }
View Full Code Here

TOP

Related Classes of ec.util.Parameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.