Java tutorial
/* * Copyright (C) 2012 Grupo Integrado de Ingeniera (<a href="www.gii.udc.es">www.gii.udc.es</a>) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package es.udc.gii.common.eaf.stoptest.cma; import es.udc.gii.common.eaf.algorithm.CMAEvolutionaryAlgorithm; import es.udc.gii.common.eaf.algorithm.EvolutionaryAlgorithm; import es.udc.gii.common.eaf.stoptest.SimpleStopTest; import org.apache.commons.configuration.Configuration; /** * * @author Grupo Integrado de Ingeniera (<a * href="www.gii.udc.es">www.gii.udc.es</a>) */ public class CMAXMeanStuckStopTest extends SimpleStopTest { @Override public boolean isReach(EvolutionaryAlgorithm algorithm) { CMAEvolutionaryAlgorithm cma = (CMAEvolutionaryAlgorithm) algorithm; int N = cma.getPopulation().getIndividual(0).getDimension(); /* Test whether one component of xmean is stuck */ for (int iKoo = 0; iKoo < N; ++iKoo) { if (cma.getxMean()[iKoo] == cma.getxMean()[iKoo] + 0.2 * cma.getSigma() * Math.sqrt(cma.getC()[iKoo][iKoo])) { return true; } } /* for iKoo */ return false; } @Override public void configure(Configuration conf) { //Do nothing } }