System.Collections.BitArray.Clone C# (CSharp) Method

Clone() public method

public Clone ( ) : object
return object
        public object Clone()
        {
            return new BitArray(this);
        }

Usage Example

示例#1
0
        //Runs the algoritm for number of iterations
        public override void Run(Configuration config)
        {
            log = new RandomLogSpecification(data.DataFileName, config.RandomSeed, config.NumberOfRuns, config.PenaltyCoefficient);
            solution = new SolutionSpecification();

            BitArray routerswitches = new BitArray((int)data.RouterCount);
            double highestfitness = 0.0;
            BitArray best = new BitArray((int)data.RouterCount);
            for(int i = 0; i < config.NumberOfRuns; i++)
            {
                routerswitches = new BitArray((int)data.RouterCount);
                int numbertoswitch = randomgenerator.Next((int)data.RouterCount);
                for(int j = 0; j < numbertoswitch; j++)
                {
                    int switching;
                    while(routerswitches.Get(switching = randomgenerator.Next((int)data.RouterCount)) == true);
                    routerswitches.Set(switching, true);
                }

                double fitness = FitnessEvaluation(data.NetworkPaths, routerswitches, numbertoswitch, config.PenaltyCoefficient);

                if(fitness > highestfitness)
                {
                    ((RandomLogSpecification)log).AddEvaluation(i, fitness);
                    highestfitness = fitness;
                    best = (BitArray)routerswitches.Clone();
                }
            }

            solution.RoutersTurnedOff = ExtensionMethods.ConvertBitArrayToOffRouterNumbers(best, data.HostCount);
        }
All Usage Examples Of System.Collections.BitArray::Clone