• 大小: 106KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: 其他
  • 标签: CRO  PSO  

资源简介

这是将CRO与PSO结合的算法思想代码,解决单目标问题

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.IO;
namespace CRO_CONSOLE_LAM
{
    public class Container
    {
     /** * The problem that this container is evaluating.*/
    private Problem problem;
    /** * The current function evaluation number of this container. */
    private int FE;
    /** * The initial population size in the container. */
    private int iniPopSize;
    
    /** * The energy buffer of this container. This variable is set with a value
     * and is updated during the course of searching. */
    private double energyBuffer;
    /** * The initial kinetic energy assigned to new molecules.*/
    private double iniKE;
    /** * The collision rate between molecules in the container.*/
    private double collRate;
    /** * The energy loss rate in an on-wall ineffective collision.*/
    private double lossRate;
    /** * The threshold for decomposition to happen.*/
    private int decThres;
    /** * The threshold for synthesis to happen. */
    private double synThres;
    /** * The perturbation strength or “Step Size“ of the neighborhood function.*/
    private double stepSize;
    /** * The data point values of this container. */
    //ArrayList population = new ArrayList();
    ArrayList population = new ArrayList();
    /** * The current global minimum of this container. This variable is updated 
     * * during the course of searching.*/
    public static double globalMin;
    public static double[] bestGlobalMols = new double[30];// in PSO
    /**
     * This function is the class constructor.
     *
     * @param problem The problem that this container is going to handle.
     */
    public Container(Problem problem) 
        {
            this.problem = problem;
            globalMin = 1E100;
        }
    /**
     * This function initialize the population of the container. It shall be
     * called only after the problem object has initialized the parameter of the
     * container and shall be called only once.
     */
    public void initPopulation() {
        FE = iniPopSize;
        for (int i = 0; i < iniPopSize; i++)
        {
            population.Add(new Molecule(problem this));
            Molecule m = (Molecule) population[i];
            update(m);
        }
       for (int i = 0; i < iniPopSize; i++) 
        {
            Molecule m = (Molecule) population[i];
            m.setKE(iniKE);
        }
    }
    /**
     * This function implements the update feature of RCCRO. Whenever a new
     * molecular structure is generated this function is called to check
     * whether there is a better molecule generated compared with the
     * best-so-far molecule.
     *
     * @param newMolecule The newly generated molecule.
     */
    private void update(Molecule newMolecule) {
        if (newMolecule.getPE() < globalMin)
        {   // Update t

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-05-23 15:01  CRO_CONSOLE_LAM\
     目录           0  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\
     文件        2605  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\Benchmark.cs
     文件         555  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F01.cs
     文件         602  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F02.cs
     文件         674  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F03.cs
     文件         592  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F04.cs
     文件         638  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F05.cs
     文件         550  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F06.cs
     文件         604  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F07.cs
     文件         588  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F08.cs
     文件         597  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F09.cs
     文件         769  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F10.cs
     文件         690  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F11.cs
     文件        1208  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F12.cs
     文件        1147  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F13.cs
     文件         981  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F14.cs
     文件         974  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F15.cs
     文件         590  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F16.cs
     文件         593  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F17.cs
     文件         774  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F18.cs
     文件        1111  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F19.cs
     文件        1332  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F20.cs
     文件        1012  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F21.cs
     文件        1044  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F22.cs
     文件        1046  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\F23.cs
     文件         371  2014-05-23 15:01  CRO_CONSOLE_LAM\BM\objective.cs
     文件        3585  2014-05-23 15:01  CRO_CONSOLE_LAM\CRO_PSO.csproj
     文件        8580  2014-05-23 15:01  CRO_CONSOLE_LAM\Container.cs
     文件        6658  2014-05-23 15:01  CRO_CONSOLE_LAM\Molecule.cs
     文件        4566  2014-05-23 15:01  CRO_CONSOLE_LAM\Problem.cs
............此处省略22个文件信息

评论

共有 条评论