/// <summary> /// Manages the probabilistic simulation of Tenants requesting spaces /// </summary> /// <param name="request"></param> protected override void RequestSpace(PPSpaceRequest request) { var requestArea = request.Population * request.Tenant.AreaPerIndInferred; //Request area assuming the area the tenant prefers per individual var availableSpaces = _spaces.Where(s => !s.Occupied && !s.IsSpare); if (availableSpaces.Count() > 0) { PPSpace bestSuited = availableSpaces.MaxBy(s => s.Area); foreach (var space in availableSpaces) { var spaceArea = space.Area; if (spaceArea >= requestArea && spaceArea < bestSuited.Area) { bestSuited = space; } } bestSuited.OccupySpace(request); //string newMessage = $"Assinged {bestSuited.Name} to {request.Tenant.Name} at {_hour.ToString("D2")}:00 for {request.ActivityName}"; string newMessage = $"Assinged to {request.Tenant.Name}"; _spacesMessages[bestSuited] = newMessage; //AddDisplayMessage(newMessage); } else { //AddDisplayMessage("No available space found"); } }
void RequestSpace(PPSpaceRequest request) { var requestArea = request.Population * 8; //This considers that 1 person requires 8 voxels (~1m²) var availableSpaces = _spaces.Where(s => !s.Occupied && !s.IsSpare); PPSpace bestSuited = availableSpaces.MaxBy(s => s.Area); foreach (var space in availableSpaces) { var spaceArea = space.Area; if (spaceArea >= requestArea && spaceArea < bestSuited.Area) { bestSuited = space; } } bestSuited.OccupySpace(request); print($"Assinged {bestSuited.Name} to {request.Tenant.Name} at {_dateTimeNow}"); }
/// <summary> /// Attempts to assign a space to a request made by a Tenant /// </summary> /// <param name="request">The Request object</param> void RequestSpace(PPSpaceRequest request) { var requestArea = request.Population * request.Tenant.AreaPerIndInferred; //Request area assuming the area the tenant prefers per individual var availableSpaces = _spaces.Where(s => !s.Occupied && !s.IsSpare); PPSpace bestSuited = availableSpaces.MaxBy(s => s.VoxelCount); foreach (var space in availableSpaces) { var spaceArea = space.Area; if (spaceArea >= requestArea && spaceArea < bestSuited.VoxelCount) { bestSuited = space; } } bestSuited.OccupySpace(request); _activityLog = $"Assinged {bestSuited.Name} to {request.Tenant.Name} at {_dateTimeNow}"; }
/// <summary> /// Manages the probabilistic simulation of Tenants requesting spaces /// </summary> /// <param name="request"></param> protected override void RequestSpace(PPSpaceRequest request) { var requestArea = request.Population * request.Tenant.AreaPerIndInferred; //Request area assuming the area the tenant prefers per individual var availableSpaces = _spaces.Where(s => !s.Occupied && !s.IsSpare); if (availableSpaces.Count() > 0) { PPSpace bestSuited = availableSpaces.MaxBy(s => s.Area); foreach (var space in availableSpaces) { var spaceArea = space.Area; if (spaceArea >= requestArea && spaceArea < bestSuited.Area) { bestSuited = space; } } bestSuited.OccupySpace(request); string newMessage = $"Assinged to {request.Tenant.Name}"; _spacesMessages[bestSuited] = newMessage; } }