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

📄 fitnessalgorithmf3.java

📁 使用java编写的关于通讯及串口编程所必需的类库
💻 JAVA
字号:
/* * FitnessAlgorithmF3.java * * Created on March 10, 2003, 2:04 PM */package com.adaptiveview.ospso.test;import com.adaptiveview.ospso.*;import com.adaptiveview.ospso.dmi.*;/**<code>Fitness = 0.0 - (x + y + (z * w))^2; dimension boundaries = [-10.0..10.0]; *Boundary Type = Constraint.WRAP.</code> * * @author  AdaptiveView.com */public class FitnessAlgorithmF3 implements IFitnessAlgorithm, DMI_AboutFitnessAlgorithms {        private int dimensions;    private Constraint dimensionConstraint;    private String problemDescription;    private String boundaryTypeName;        /** Creates a new instance of FitnessAlgorithm1 */    public FitnessAlgorithmF3() {        // Set the following according to problem in calculateFitness()        dimensions = 4;         dimensionConstraint = new Constraint(-10.0,10.0,Constraint.WRAP);        boundaryTypeName = "WRAP";        problemDescription = "(x + y + (z * w))^2 = 0.0";    }        public double calculateFitness(LocationChange location) {        double[] c = location.getCopyOfCoordinates();        double answer = 0.0;               /* Problem:      (x + y + (z * w))^2        * Data sources: x = c[0]; y = c[1]; z = c[2]; w = c[3];        */        answer += Math.pow(c[0] + c[1] + (c[2] * c[3]),2.0);        return convertToFitness(answer);    }        private double convertToFitness(double answer) {        return 0.0 - Math.abs(answer);    }     /** Returns the number of dimesnions (unknowns) in the solution space.     * @return the number of dimesnions     */    public int getDimensions() {        return dimensions;    }        /** Returns a reference to the dimension Constraint instance.     * @return the dimension Constraint     */    public Constraint getDimensionConstraint() {        return dimensionConstraint;    }        /** Returns a description of the solution space.     * @return a String describing the solution space.     */    public String toString() {        StringBuffer s = new StringBuffer();        s.append(problemDescription);        s.append(" (Dimensions=");        s.append(dimensions);        s.append("; Dimension[Minimum=");        s.append(dimensionConstraint.getMinimum());        s.append(", Maximum=");        s.append(dimensionConstraint.getMaximum());        s.append(", BoundaryType='");        s.append(boundaryTypeName);        s.append("'])");        return s.toString();    }}

⌨️ 快捷键说明

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