Ejemplo n.º 1
0
 public void ScenarioTearDown(IIteration context)
 {
     // ScenarioTearDown gets executed once for each thread instance
     // which is about to be stopped (due to ending test or thread being stopped by threading strategy)
     //
     // Exceptions here are not handled and breaks the test!
 }
        static void Main(string[] args)
        {
            PersonnelAggregate personnelAggregate = new PersonnelAggregate();

            personnelAggregate.Add(new Personnel {
                PersonnelId = 1, PersonnelName = "Tuğba", PersonelLastName = "ÖLÇER"
            });
            personnelAggregate.Add(new Personnel {
                PersonnelId = 2, PersonnelName = "Fatih", PersonelLastName = "SARAL"
            });
            personnelAggregate.Add(new Personnel {
                PersonnelId = 3, PersonnelName = "Pınar", PersonelLastName = "SAVCI"
            });
            personnelAggregate.Add(new Personnel {
                PersonnelId = 4, PersonnelName = "Yasemin", PersonelLastName = "ÖZTÜRK"
            });

            IIteration iteration = personnelAggregate.CreateIterator();

            while (iteration.HasItem())
            {
                Console.WriteLine($"ID : {iteration.CurrentItem().PersonnelId} \n" +
                                  $"Personnel Name : {iteration.CurrentItem().PersonnelName} \n" +
                                  $"Personnel LastName : {iteration.CurrentItem().PersonelLastName} \n***************************");
                iteration.NextItem();
            }

            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public void ScenarioSetup(IIteration context)
        {
            // ScenarioSetup() gets executed once for each created instance
            //
            // Exceptions here are not handled and breaks the test!

            Console.WriteLine($"Created Thread {context.ThreadId}");
        }
Ejemplo n.º 4
0
        public void ExecuteScenario(IIteration context)
        {
            int sleepMs = Random.Next(500, 3000);

            context.UserData = sleepMs;

            Thread.Sleep(sleepMs);
        }
        public IIteration DoIteration(IIteration prevIter)
        {
            it = (HJIteration)prevIter;
            double f = ip.GetFuncValue(it.arrX);

            while (it.arrE == null)
            {
                f = ip.GetFuncValue(it.arrX);
                double[] arrENext, arrXNext;
                double   fNext = Research(it.arrX, out arrENext, out arrXNext);
                if (Math.Abs(fNext - f) < ip.fEpsilon)
                {
                    for (int i = 0; i < it.arrXDelta.Length; i++)
                    {
                        it.arrXDelta[i] /= 2;
                    }
                    for (int i = 0; i < it.arrXDelta.Length; i++)
                    {
                        if (it.arrXDelta[i] < ip.xEpsilon)
                        {
                            it.CalcResult(ip);
                            return(null);
                        }
                    }
                }
                else
                {
                    it.arrE = arrENext;
                }
            }
            double[] arrXSmp = new double[it.arrX.Length];
            for (int i = 0; i < arrXSmp.Length; i++)
            {
                arrXSmp[i] = it.arrX[i] + it.arrE[i] * it.mult;
            }
            double fSmp = ip.GetFuncValue(arrXSmp);

            if (Math.Abs(fSmp - f) < ip.fEpsilon || fSmp > f)
            {
                it.fRes = f;
                return(new HJIteration(it.arrX, it.arrXDelta, null, 1));
            }
            double[]    arrXRes, arrERes;
            double      fRes = Research(arrXSmp, out arrERes, out arrXRes);
            HJIteration itNext;

            if (Math.Abs(fRes - f) < ip.fEpsilon)
            {
                it.fRes = f;
                itNext  = new HJIteration(it.arrX, it.arrXDelta, null, 1);
            }
            else
            {
                it.fRes = fSmp;
                itNext  = new HJIteration(arrXSmp, it.arrXDelta, it.arrE, it.mult + 1);
            }
            return(itNext);
        }
Ejemplo n.º 6
0
        public void IterationSetup(IIteration context)
        {
            // IterationSetup is executed before each ExecuteScenario call

            if (Random.Next(100) % 50 == 0)
            {
                throw new Exception("2% error chance for testing");
            }
        }
Ejemplo n.º 7
0
        public void IterationTearDown(IIteration context)
        {
            // IterationTearDown is executed each time after ExecuteScenario iteration is finished.
            // It is also executed even when IterationSetup or ExecuteScenario fails

            if (Random.Next(100) % 25 == 0)
            {
                throw new Exception("4% error chance for testing");
            }
        }
Ejemplo n.º 8
0
        public void ExecuteScenario(IIteration context)
        {
            // ExecuteScenario defines single iteration for load test scenario
            // It is called after each successful IterationSetup call.
            // Execution time is measured only for this function
            // You can use testContext.Checkpoint() function to mark points,
            // where time should be measured

            Thread.Sleep(Random.Next(1500));

            if (Random.Next(100) % 10 == 0)
            {
                throw new Exception("10% error chance for testing");
            }
        }
Ejemplo n.º 9
0
 public void ExecuteScenario(IIteration context)
 {
     //Console.WriteLine(context.Timer.Value.ToString("g"));
     Thread.Sleep(300);
 }
Ejemplo n.º 10
0
 public void IterationSetup(IIteration context)
 {
 }
Ejemplo n.º 11
0
 public void Deconstruct(out IIteration iteration, out IAccumulatedChangeSet changeSet, out ISet <Object> derivedObjects)
 {
     changeSet      = this.Iteration.ChangeSet;
     iteration      = this.Iteration;
     derivedObjects = this.Iteration.Cycle.Derivation.DerivedObjects;
 }
Ejemplo n.º 12
0
 public ObjectOnPreDerive WithIteration(IIteration iteration)
 {
     this.Iteration = iteration;
     return(this);
 }
 public SwarmAdaptationIteration()
 {
     AdaptationStrategy = new DoNothingAdaptation();
     DetectionStrategy  = new AlwaysTrueDetection();
     Delegate           = new SynchronousIteration();
 }
Ejemplo n.º 14
0
 public void ScenarioSetup(IIteration context)
 {
     Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}] Scenario Setup");
 }
Ejemplo n.º 15
0
 public virtual void IterationTearDown(IIteration context)
 {
 }
Ejemplo n.º 16
0
 public virtual void IterationSetup(IIteration context)
 {
 }
Ejemplo n.º 17
0
 public void ExecuteScenario(IIteration context)
 {
     //Thread.Sleep(200);
 }
Ejemplo n.º 18
0
 public void ExecuteScenario(IIteration context)
 {
 }
Ejemplo n.º 19
0
 public void ScenarioTearDown(IIteration context)
 {
     Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Scenario End");
 }
Ejemplo n.º 20
0
 public void ExecuteScenario(IIteration context)
 {
     Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Execute");
     Thread.Sleep(1000);
 }
Ejemplo n.º 21
0
        public void IterationSetup(IIteration context)
        {
            context.UserData = _data;

            Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Iteration Setup");
        }
Ejemplo n.º 22
0
 public void IterationSetup(IIteration context)
 {
     //BatchResults.TryAdd(context.ThreadIterationId, new Batch[ThreadCount]);
 }
Ejemplo n.º 23
0
 public virtual void ScenarioSetup(IIteration context)
 {
 }
Ejemplo n.º 24
0
 public void ExecuteScenario(IIteration context)
 {
     Thread.Sleep(_sleepTime);
 }
Ejemplo n.º 25
0
 public abstract void ExecuteScenario(IIteration context);
Ejemplo n.º 26
0
 public void ScenarioTearDown(IIteration context)
 {
     // "ScenarioTearDown Executes once LoadTest execution is over
     //"Exceptions here are not handled!
 }
Ejemplo n.º 27
0
 public virtual void ScenarioTearDown(IIteration context)
 {
 }
Ejemplo n.º 28
0
 public void ScenarioTearDown(IIteration context)
 {
     // One time cleanup for each instance/thread
 }
Ejemplo n.º 29
0
 public void ScenarioSetup(IIteration context)
 {
     // ScenarioSetup Executes on thread creation
     // Exceptions here are not handled!
 }
        public IIteration DoIteration(IIteration prevIter)
        {
            it = (NMIteration)prevIter;
            for (int i = 0; i < it.matrX.Length; i++)
            {
                if (it.matrX[i].Length + 1 != it.matrX.Length)
                {
                    throw new Exception();
                }
            }
            int n = it.matrX[0].Length;

            it.arrF = new double[n + 1];
            for (int i = 0; i < n + 1; i++)
            {
                it.arrF[i] = ip.GetFuncValue(it.matrX[i]);
            }
            it.fg = it.fh = float.MinValue;
            it.fl = float.MaxValue;
            for (int i = 0; i < n + 1; i++)
            {
                if (it.arrF[i] > it.fh)
                {
                    it.fh = it.arrF[i];
                    it.h  = i;
                }
                if (it.arrF[i] > it.fg && it.arrF[i] < it.fh)
                {
                    it.fg = it.arrF[i];
                    it.g  = i;
                }
                if (it.arrF[i] < it.fl)
                {
                    it.fl = it.arrF[i];
                    it.l  = i;
                }
            }

            // центр
            it.arrX0 = new double[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n + 1; j++)
                {
                    if (j == it.h)
                    {
                        continue;
                    }
                    it.arrX0[i] += it.matrX[j][i];
                }
                it.arrX0[i] /= n;
            }
            it.f0 = ip.GetFuncValue(it.arrX0);

            // отражение
            it.arrXr = new double[n];
            for (int i = 0; i < n; i++)
            {
                it.arrXr[i] = (1 + ip.alpha) * it.arrX0[i] - ip.alpha * it.matrX[it.h][i];
            }
            it.fr = ip.GetFuncValue(it.arrXr);

            if (it.fr < it.fl)
            {
                // растяжение
                it.arrXe = new double[n];
                for (int i = 0; i < n; i++)
                {
                    it.arrXe[i] = ip.gamma * it.arrXr[i] + (1 - ip.gamma) * it.arrX0[i];
                }
                it.fe = ip.GetFuncValue(it.arrXe);

                if (it.fe < it.fl)
                {
                    it.matrX[it.h] = (double[])it.arrXe.Clone();
                    it.CalcResult(ip);
                    if (!CheckIsDone())
                    {
                        return(new NMIteration(it.matrX));
                    }
                    else
                    {
                        return(null);
                    }
                }

                it.matrX[it.h] = (double[])it.arrXr.Clone();
                it.CalcResult(ip);
                if (!CheckIsDone())
                {
                    return(new NMIteration(it.matrX));
                }
                else
                {
                    return(null);
                }
            }

            if (it.fr <= it.fg)
            {
                it.matrX[it.h] = (double[])it.arrXr.Clone();
                it.CalcResult(ip);
                if (!CheckIsDone())
                {
                    return(new NMIteration(it.matrX));
                }
                else
                {
                    return(null);
                }
            }

            if (it.fr <= it.fh)
            {
                it.matrX[it.h] = (double[])it.arrXr.Clone();
            }

            // сжатие
            it.arrXc = new double[n];
            for (int i = 0; i < it.arrXc.Length; i++)
            {
                it.arrXc[i] = ip.beta * it.matrX[it.h][i] + (1 - ip.beta) * it.arrX0[i];
            }
            it.fc = ip.GetFuncValue(it.arrXc);

            if (it.fc > it.fh)
            {
                for (int i = 0; i < n + 1; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        it.matrX[i][j] = 0.5 * (it.matrX[i][j] + it.matrX[it.l][j]);
                    }
                }
                it.CalcResult(ip);
                if (!CheckIsDone())
                {
                    return(new NMIteration(it.matrX));
                }
                else
                {
                    return(null);
                }
            }

            it.matrX[it.h] = (double[])it.arrXc.Clone();
            it.CalcResult(ip);
            if (!CheckIsDone())
            {
                return(new NMIteration(it.matrX));
            }
            else
            {
                return(null);
            }
        }