view defical-sharp/libsemtd/ga.cs @ 1:758381a85d76 default tip

Incorrect printf format.
author Edho Prima Arief <me@myconan.net>
date Mon, 28 Jun 2010 14:52:19 +0700
parents ebed2bd0d300
children
line wrap: on
line source

/*using System;

namespace libsemtd
{
    public partial class Semtd
    {
        private void ga_LabelRemoveVer(int posVer) { this.labelVer[posVer] = 0; }
        private void ga_LabelSetVer(int posVer, int labelVer) { this.labelVer[posVer] = labelVer; }
        private double ga_ScoreAlgorithm(int start, int end, params int[] numbers)
        {
            //STANDARD DEVIATION
            double mean = 0;
            double nstdev = 0;
            int numData = end - start + 1;
            foreach (double num in numbers)
            {
                mean += num;
            }
            mean /= numData;
            for (int i = start; i <= end; i++)
            {
                nstdev += Math.Pow((numbers[i] - mean), 2);
            }
            return Math.Sqrt(nstdev / numData);
        }
        private double ga_SemtScore()
        {
            if (this.scoreCache > -1) { return scoreCache; }
            if (this.IsSemt()) { return 0; }
            int rangeDelta = this.numEdges - this.labelRangeEdge();
            int upperBound = this.labelEdgeAbsoluteMax;
            int edgeTempMax = this.labelEdgeMax;
            int edgeTempMin = this.labelEdgeMin;
            int[] edgeTempLabels = new int[upperBound + 1];
            if (rangeDelta > 0)
            {
                if ((edgeTempMax + rangeDelta) > upperBound)
                {
                    edgeTempMax = upperBound;
                    edgeTempMin -= upperBound - edgeTempMax;
                }
                else
                {
                    edgeTempMax += rangeDelta;
                }
            }
            for (int i = 0; i < upperBound; i++)
            {
                edgeTempLabels[i] = this.labelEdgesUsed[i];
            }
            this.scoreCache = ga_ScoreAlgorithm(edgeTempMin, edgeTempMax, edgeTempLabels);
            return scoreCache;
        }
        private void ga_FixLabel()
        {
            bool[] labelVerUsed = new bool[this.numVerTotal+ 1];
            bool[] verPassed = new bool[this.numVerMain + 1];
            for (int i = 0; i < this.numVerMain; i++)
            {
                if (!labelVerUsed[this.labelVer[i]])
                {
                    labelVerUsed[this.labelVer[i]] = true;
                    verPassed[i] = true;
                }
            }
            for (int i = 0; i < this.numVerMain; i++)
            {
                if (!verPassed[i])
                {
                    for (int nextLabel = 0; nextLabel < this.numVerMain; nextLabel++)
                    {
                        if (!labelVerUsed[nextLabel])
                        {
                            this.labelVer[i] = nextLabel;
                            verPassed[i] = true;
                            labelVerUsed[nextLabel] = true;
                            break;
                        }
                    }
                }
            }
        }
        private void ga_SwapLabel()
        {
            Random random = new Random();
            int verA, verB, labelVerTemp;
            verA = random.Next(this.numVerMain);
            verB = verA;
            while (verA == verB)
            {
                verB = random.Next(1, this.numVerMain);
            }
            labelVerTemp = this.labelVer[verA];
            this.labelSetVer(verA, this.labelVer[verB]);
            this.labelSetVer(verB, labelVerTemp);
        }
        private bool ga_IsSemt()
        {
            int[] labelVerTemp = new int[this.numVerMain];
            for(int i=0;i<this.numVerMain;i++)
                labelVerTemp[i] = this.labelVer[i];
            labelReset();
            for (int i = 0; i < this.numVerMain; i++)
                labelSetVer(i, labelVerTemp[i]);
            return isSemt();
        }
    }
}*/