private void GenerateClustersFromNnc()
        {
            PenaltyCluster = new Cluster();

            if (ClustersCount >= nncClusters.Count)
            {
                Clusters = nncClusters;
            }
            else
            {
                Clusters = new List<Cluster>();

                List<Cluster> newClusters = new List<Cluster>();
                newClusters.AddRange(nncClusters);

                for (int i = 0; i != ClustersCount; i++)
                {
                    int index = TaskController.Rnd.Next(newClusters.Count);
                    Clusters.Add(newClusters[index]);
                    newClusters.RemoveAt(index);
                }

                foreach (Cluster newCluster in newClusters)
                {
                    PenaltyCluster.Merge(newCluster);
                }
            }

            foreach (Cluster cluster in Clusters)
            {
                cluster.Depot = Depot;
            }
        }
예제 #2
0
        protected override List<Node> GenerateClusters(List<Node> nodesForClusters, Node _depot)
        {
            this.Depot = _depot;

            while (nodesForClusters.Count != 0)
            {
                bool b = false;

                for (int i = 0; i != Clusters.Count; i++)
                {
                    if (nodesForClusters.Count == 0)
                        break;

                    int index = TaskController.Rnd.Next(nodesForClusters.Count);

                    if (Clusters[i].Volume + nodesForClusters[index].Volume <= Clusters[i].CapacityLimit)
                    {
                        Clusters[i].AddNode(nodesForClusters[index]);
                        nodesForClusters.RemoveAt(index);
                        b = true;
                    }
                }

                if (!b && Clusters.Count == ClustersCount)
                {
                    break;
                }

                if (!b)
                {
                    AddCluster();
                }
            }

            List<Node> remainingNodes = new List<Node>();
            remainingNodes.AddRange(nodesForClusters);

            return remainingNodes;
        }
예제 #3
0
        protected virtual List<Node> GenerateClusters(List<Node> nodesForClusters, Node _depot)
        {
            for (int i = 0; i != ClustersCount; i++)
            {
                Clusters.Add(new Cluster());
                Clusters[i].Depot = _depot;

                int nodeIndex = TaskController.Rnd.Next(nodesForClusters.Count);
                Clusters[i].AddNode(nodesForClusters[nodeIndex]);
                nodesForClusters.RemoveAt(nodeIndex);
            }

            foreach (Node node in nodesForClusters)
            {
                if (node.Type == Node.NodeType.Consumer)
                {
                    int clusterIndex = TaskController.Rnd.Next(Clusters.Count);
                    Clusters[clusterIndex].AddNode(node);
                }
            }

            List<Node> remainingNodes = new List<Node>();
            remainingNodes.AddRange(nodesForClusters);

            return remainingNodes;
        }
예제 #4
0
        private void GenerateSequence(int depotsCount, int clustersCount, int consumersCount)
        {
            List<int> orderedSequence = new List<int>();

            for (int i = 0; i != depotsCount; i++)
            {
                for (int j = 0; j != clustersCount; j++)
                {
                    orderedSequence.Add(i);
                }
            }

            for (int i = depotsCount; i != depotsCount + consumersCount; i++)
            {
                orderedSequence.Add(i);
            }

            nodesSequence = new int[depotsCount*clustersCount + consumersCount];

            for (int i = 0; i != nodesSequence.Length; i++)
            {
                int index = TaskController.Rnd.Next(orderedSequence.Count);

                nodesSequence[i] = orderedSequence[index];

                orderedSequence.RemoveAt(index);
            }
        }