Esempio n. 1
0
 /// <summary>
 /// Očekává ze nenastane vyjimka, výsledek vypíše
 /// </summary>
 /// <param name="funkce">funkce vracejici double ktera bere dva parametry</param>
 /// <param name="N">int, pocet prvku pole</param>
 /// <param name="pole">List<double></param>
 void ExpectNoThrow(Function4 funkce, int N, List <double> pole)
 {
     try
     {
         funkce(N, pole);
         richTextBox1.AppendText("\r\nNoThrow zadane parametry:" + N + " pole");
     }
     catch
     {
         chyby++;
         richTextBox1.AppendText("\r\nChybaNoThrow zadane parametry:" + N + " pole");
     }
 }
        public async Task Run_CosmosDbReturnsEmptyCollectionOfDocuments_Return404NotFound()
        {
            //arrange
            var docs = new List <IntermediaryServiceDocument>();

            //act
            var actionResult = await Function4.Run(_mockHttpRequest.Object, docs, _mockLogger);

            //assert
            Assert.IsTrue(_mockLogger.GetLogs().Where(m => m.Contains(UserFriendlyMessages.DocumentNotFound)).Count() == 1);
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundObjectResult));
            StringAssert.Contains(((NotFoundObjectResult)actionResult).Value.ToString(), UserFriendlyMessages.DocumentNotFound);
        }
Esempio n. 3
0
 public int[] ProcessData2(Function4 f, int x, int[] array)
 {
     int[] res = new int[array.Length / 3];
     int i = 0;
     var list = new List<int>();
     foreach (int value in array)
     {
         list.Add(value);
         if(list.Count == 3)
         {
             int first = list[0];
             res[i++] = f(list[0],list[1],list[2], x);
             list.Clear();
         }
     }
     return res;
 }
Esempio n. 4
0
        public int[] ProcessData2(Function4 f, int x, int[] array)
        {
            int[] res  = new int[array.Length / 3];
            int   i    = 0;
            var   list = new List <int>();

            foreach (int value in array)
            {
                list.Add(value);
                if (list.Count == 3)
                {
                    int first = list[0];
                    res[i++] = f(list[0], list[1], list[2], x);
                    list.Clear();
                }
            }
            return(res);
        }
        public async Task GenerateSchedule()
        {
            var periodTimeslots = (await PeriodTimeslotRepository.GetEntityListAsync())
                                  .Select(x => PeriodTimeslotConverter.Convert(x)).ToList();

            var classrooms = (await ClassroomRepository.GetEntityListAsync())
                             .Select(x => ClassroomConverter.Convert(x)).ToList();

            var teachingUnits = (await TeachingUnitRepository.GetEntityListAsync())
                                .Select(x => TeachingUnitConverter.Convert(x)).ToList();

            var generation = new GeneticScheduleGeneration(10, teachingUnits.Count);

            generation.GlobalGA.IterationCompleted += async() =>
            {
                var bestChromosome = generation.GlobalGA.ChromosomePool.First();

                await HubContext.Clients.All.SendAsync("SendScheduleInfo", new ScheduleInfo()
                {
                    MaxValue     = bestChromosome.Value,
                    AverageValue = generation.GlobalGA.Pool.Average(x => x.Value),
                    AverageAge   = generation.GlobalGA.Pool.Average(x => x.Age),
                    Evaluations  =
                    {
                        Function1.Count(bestChromosome.Schedule),
                        Function3.Count(bestChromosome.Schedule),
                        Function4.Count(bestChromosome.Schedule),
                        Function5.Count(bestChromosome.Schedule),
                        Function6.Count(bestChromosome.Schedule),
                        Function7.Count(bestChromosome.Schedule)
                    }
                });
            };

            var schedules = generation.Run(classrooms, periodTimeslots, teachingUnits);

            await ScheduleCellRepository.Clear();

            await ScheduleCellRepository.AddRangeAsync(schedules.First().ScheduleCells.Select(x => ScheduleCellConverter.Convert(x)));

            var gridResponse = await GetScheduleGridPrivate();

            await HubContext.Clients.All.SendAsync("GenerateScheduleCompleted", gridResponse);
        }
        public async Task Run_DocumentFound_Return200OKSuccessWithDocument()
        {
            //arrange
            var documentId = Guid.NewGuid().ToString();
            List <IntermediaryServiceDocument> docs = new List <IntermediaryServiceDocument>()
            {
                new IntermediaryServiceDocument()
                {
                    id = documentId
                }
            };

            //act
            var actionResult = await Function4.Run(_mockHttpRequest.Object, docs, _mockLogger);

            //assert
            Assert.IsInstanceOfType(actionResult, typeof(OkObjectResult));
            Assert.IsTrue(string.Equals(documentId, ((IntermediaryServiceDocument)((OkObjectResult)actionResult).Value).id));
        }
Esempio n. 7
0
 /// <summary>
 /// After a delay, Function f will be called with parameters p1, p2, p3, p4.
 /// </summary>
 /// <param name="owner">Mono object that will own the coroutine</param>
 /// <param name="f">Callback function</param>
 /// <param name="p1">Parameter 1</param>
 /// <param name="p2">Parameter 2</param>
 /// <param name="p3">Parameter 3</param>
 /// <param name="p3">Parameter 4</param>
 /// <param name="delay">A delay in seconds</param>
 public static void Start <P1, P2, P3, P4>(MonoBehaviour owner, Function4 <P1, P2, P3, P4> f, P1 p1, P2 p2, P3 p3, P4 p4, float delay)
 {
     owner.StartCoroutine(CallbackCoroutine(f, p1, p2, p3, p4, delay));
 }
Esempio n. 8
0
    private static IEnumerator CallbackCoroutine <P1, P2, P3, P4>(Function4 <P1, P2, P3, P4> f, P1 p1, P2 p2, P3 p3, P4 p4, float delay)
    {
        yield return(new WaitForSeconds(delay));

        f(p1, p2, p3, p4);
    }
        // 간편 기능4 버튼
        private void Function4_Click(object sender, RoutedEventArgs e)
        {
            Function4 function4 = new Function4();

            function4.Show();
        }
Esempio n. 10
0
        static async Task Main(string[] args)
        {
            var connectionOptions = new ConnectionOptions(ConnectionString);

            var periodTimeslotRepository = new MsSqlPeriodTimeslotRepository(connectionOptions);
            var classroomRepository      = new MsSqlClassroomRepository(connectionOptions);
            var teachingUnitRepository   = new MsSqlTeachingUnitRepository(connectionOptions);
            var scheduleCellRepository   = new MsSqlScheduleCellRepository(connectionOptions);

            var periodTimeslots = (await periodTimeslotRepository.GetEntityListAsync())
                                  .Select(x => PeriodTimeslotConverter.Convert(x)).ToList();

            var classrooms = (await classroomRepository.GetEntityListAsync())
                             .Select(x => ClassroomConverter.Convert(x)).ToList();

            var teachingUnits = (await teachingUnitRepository.GetEntityListAsync())
                                .Select(x => TeachingUnitConverter.Convert(x)).ToList();

            var generation = new GeneticScheduleGeneration(10, teachingUnits.Count);
            var schedules  = generation.Run(classrooms, periodTimeslots, teachingUnits);

            var i    = 1;
            var sum  = 0;
            var sum2 = 0;
            var sum3 = 0;
            var sum4 = 0;
            var sum5 = 0;
            var sum6 = 0;

            schedules.ForEach(x =>
            {
                var f  = Function1.Count(x);
                var f2 = Function3.Count(x);
                var f3 = Function4.Count(x);
                var f4 = Function5.Count(x);
                var f5 = Function6.Count(x);
                var f6 = Function7.Count(x);
                sum   += f;
                sum2  += f2;
                sum3  += f3;
                sum4  += f4;
                sum5  += f5;
                sum6  += f6;
                Console.WriteLine($"Расписание {i++}");
                Console.WriteLine($"Количество неутренних лекций: {f}");
                Console.WriteLine($"Количество избыточных мест: {f2}");
                Console.WriteLine($"Количество превышений пар в день для преподавателей: {f3}");
                Console.WriteLine($"Количество окон для преподавателей: {f4}");
                Console.WriteLine($"Количество превышений пар в день для студентов: {f5}");
                Console.WriteLine($"Количество окон для студентов: {f6}");
                Console.WriteLine($"Оценка расписания: {EvaluationCalculation.Calculate(x)}");
                Console.WriteLine($"-------------------------------------");
            });

            Console.WriteLine($"Всего ошибок (Лекции): {sum}");
            Console.WriteLine($"Всего ошибок (Избыточные места): {sum2}");
            Console.WriteLine($"Всего ошибок (Количество превышений пар в день для преподавателей): {sum3}");
            Console.WriteLine($"Всего ошибок (Количество окон для преподавателей): {sum4}");
            Console.WriteLine($"Всего ошибок (Количество превышений пар в день для студентов): {sum5}");
            Console.WriteLine($"Всего ошибок (Количество окон для студентов): {sum6}");

            await scheduleCellRepository.Clear();

            await scheduleCellRepository.AddRangeAsync(schedules.First().ScheduleCells.Select(x => ScheduleCellConverter.Convert(x)));

            Console.ReadKey();
        }