Beispiel #1
0
        private bool TryPlaceServer(int row, Server server, PoolDetails minPool, ProblemInput input, ProblemOutput output)
        {
            for (int i = 0; i < input.RowSize - server.Size + 1; i++)
            {
                bool canPlace = true;
                for (int j = 0; j < server.Size; j++)
                {
                    canPlace &= !input.Slots[row, i + j];
                }

                if (canPlace)
                {
                    server.Row = row;
                    minPool.AddServerToPool(server);
                    server.SlotInRow = i;
                    output.Servers.Add(server);
                    for (int j = 0; j < server.Size; j++)
                    {
                        input.Slots[row, i + j] = true;
                    }

                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        private static List <Row> GetRows(ProblemInput input, PoolDetails poolToImprove)
        {
            List <Row> rows = new List <Row>();

            for (int i = 0; i < input.NumOfRows; i++)
            {
                rows.Add(new Row(i)
                {
                    Capacity = poolToImprove.RowsCapacity[i]
                });
            }

            return(rows);
        }