Ejemplo n.º 1
0
        public static Result CreateRandomInstance(SolverInstance instance)
        {
            var newX = new int[instance.MCount, instance.NCount + 1, instance.SCount + 1];
            var newY = new float[instance.MCount, instance.NCount + 1, instance.SCount + 1];

            var freeSpaceOnServersLookup = new Dictionary <int, uint>();

            foreach (var s in instance.S)
            {
                freeSpaceOnServersLookup.Add(s, instance.B_s[s]);
            }

            // For each object random server to upload on
            // only if the server has capacity left
            foreach (var n in instance.N)
            {
                while (true)
                {
                    var randomServer = Random.Next(1, instance.SCount + 1);

                    if (freeSpaceOnServersLookup[randomServer] >= instance.b_n[n])
                    {
                        freeSpaceOnServersLookup[randomServer] -= instance.b_n[n];

                        foreach (var m in instance.M)
                        {
                            var minY = instance.y_mn_min[m, n];
                            var maxY = instance.y_mn_max[m, n];

                            newX[m, n, randomServer] = 1;
                            newY[m, n, randomServer] = GetRandomNumber(minY, maxY);
                        }

                        break;
                    }
                }
            }

            var potentialResult = new Result(instance, newX, newY);

            potentialResult.CalculateFitness();

            return(potentialResult);
        }
Ejemplo n.º 2
0
 public Population(int size, SolverInstance instance)
 {
     Size     = size;
     Instance = instance;
     Results  = new Result[size];
 }
Ejemplo n.º 3
0
 public CanSolver(SolverInstance instance)
 {
     Instance = instance;
 }
Ejemplo n.º 4
0
 public Result(SolverInstance instance, int[,,] x, float[,,] y)
 {
     Instance = instance;
     X        = x;
     Y        = y;
 }