public OptimizationAlgorithm(IDeveloperRepository developerRepository, ITicketRepository ticketRepository)
 {
     Developers = developerRepository.GetDevelopers();
     Tickets = ticketRepository.GetTickets();
     CostCalculator = new Cost(Developers, Tickets);
     Domain = GetDomain();
 }
示例#2
0
        public void SetUp()
        {
            var fakeData = new FakeData();
            _tickets = fakeData.GetTickets();
            _developers = fakeData.GetDevelopers();

            _cost = new Cost(_developers, _tickets);
        }
示例#3
0
        public List<int> GetSolution(List<List<int>> domain, Cost costCalculator)
        {
            int bestCost = int.MaxValue;
            List<int> bestSolution = new List<int>();
            var random = new Random();

            for(int i = 0; i < 1000; i++)
            {
                var randomSolution = GetRandomSolution(domain, random);

                int cost = costCalculator.Calculate(randomSolution);
                if (cost < bestCost)
                {
                    bestCost = cost;
                    bestSolution = randomSolution;

                    if (cost == 0)
                        return bestSolution;
                }

            }

            return bestSolution;
        }