Пример #1
0
        public override void Run()
        {
            double currentEnergy = Box.CalculateEnergy();

            for (int i = 0; i < Cycles; i++)
            {
                for (int j = 0; j < MovesPerCycle; j++)
                {
                    SimulationObject mcObject = Box.GetRandomObject();
                    SimulationMove   move     = mcObject.GetRandomMove();
                    move.ApplyMove(Box, mcObject);
                }

                double newEnergy = Box.CalculateEnergy();
                if (IsMoveAcceptable(currentEnergy, newEnergy))
                {
                    Box.AcceptAllMoves();
                    currentEnergy = newEnergy;
                    Console.WriteLine(currentEnergy);
                }
                else
                {
                    Box.RejectAllMoves();
                }
            }
        }
Пример #2
0
        protected override void RunInternal()
        {
            double previousEnergy = Box.CalculateEnergy();

            for (int i = 0; i < Cycles; i++)
            {
                _currentCycle = i;

                for (int j = 0; j < MovesPerCycle; j++)
                {
                    SimulationObject mcObject = Box.GetRandomObject();
                    SimulationMove   moveType = mcObject.GetRandomMove();
                    moveType.ApplyMove(Box, mcObject);
                }

                var energy = Box.CalculateEnergy();
                if (IsMoveAcceptable(previousEnergy, energy))
                {
                    previousEnergy = energy;
                    Box.AcceptAllMoves();
                    OnChanged();
                }
                else
                {
                    Box.RejectAllMoves();
                }

                OnProgress();
            }
        }