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); }
public Population(int size, SolverInstance instance) { Size = size; Instance = instance; Results = new Result[size]; }
public CanSolver(SolverInstance instance) { Instance = instance; }
public Result(SolverInstance instance, int[,,] x, float[,,] y) { Instance = instance; X = x; Y = y; }